feat: connect pengaduan-layanan-publik to live database

New API Endpoint:
- GET /api/complaint/trends - Fetch complaint trends for last 7 months

Component Updates:
- Removed hardcoded trenData array (7 months mock data)
- Removed hardcoded ideInovatif array (2 mock ideas)
- Added API calls to /api/complaint/trends and /api/complaint/innovation-ideas
- Added loading states for trend chart and innovation ideas
- Added empty states for both sections
- Connected LineChart to real complaint data
- Connected Innovation Ideas list to real InnovationIdea model

Features Added:
- Real-time complaint trend visualization
- Real innovation ideas from database
- Proper TypeScript typing for API responses
- Loading skeletons during data fetch
- Empty state messages when no data

Files changed:
- src/api/complaint.ts: Added /trends endpoint
- src/components/pengaduan-layanan-publik.tsx: Connected to APIs
- generated/api.ts: Regenerated types

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
2026-03-27 16:26:24 +08:00
parent 097f9f34cc
commit 0736df8523
4 changed files with 397 additions and 105 deletions

View File

@@ -2561,6 +2561,157 @@
"summary": "Get recent complaints"
}
},
"/api/complaint/trends": {
"get": {
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "object",
"required": [
"month",
"month_num",
"count"
],
"properties": {
"month": {
"type": "string"
},
"month_num": {
"type": "number"
},
"count": {
"type": "number"
}
}
}
}
},
"required": [
"data"
]
}
},
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "object",
"required": [
"month",
"month_num",
"count"
],
"properties": {
"month": {
"type": "string"
},
"month_num": {
"type": "number"
},
"count": {
"type": "number"
}
}
}
}
},
"required": [
"data"
]
}
},
"text/plain": {
"schema": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "object",
"required": [
"month",
"month_num",
"count"
],
"properties": {
"month": {
"type": "string"
},
"month_num": {
"type": "number"
},
"count": {
"type": "number"
}
}
}
}
},
"required": [
"data"
]
}
}
}
},
"500": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
},
"required": [
"error"
]
}
},
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
},
"required": [
"error"
]
}
},
"text/plain": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
},
"required": [
"error"
]
}
}
}
}
},
"operationId": "getApiComplaintTrends",
"summary": "Get complaint trends for last 7 months"
}
},
"/api/complaint/service-stats": {
"get": {
"responses": {