refactor(04): calculate stat

This commit is contained in:
puriphatt 2024-09-04 14:45:53 +07:00
parent f03eb722b5
commit d8a6b346ab
2 changed files with 41 additions and 8 deletions

View file

@ -413,8 +413,18 @@ const useProductServiceStore = defineStore('api-product-service', () => {
}
// Service
async function fetchStatsService() {
const res = await api.get('/service/stats');
async function fetchStatsService(opts?: { productGroupId?: string }) {
const params = new URLSearchParams();
for (const [k, v] of Object.entries(opts || {})) {
v !== undefined && params.append(k, v.toString());
}
const query = params.toString();
const res = await api.get(
`/service/stats${(params && '?'.concat(query)) || ''}`,
);
if (!res) return false;