feat: daily report

This commit is contained in:
efrilm
2025-08-11 02:12:19 +07:00
parent b648349ebd
commit 3440aaa764
11 changed files with 676 additions and 10 deletions
+25 -3
View File
@@ -1,6 +1,6 @@
import { useQuery } from "@tanstack/react-query"
import { Outlets } from "../../types/services/outlet"
import { api } from "../api"
import { useQuery } from '@tanstack/react-query'
import { Outlet, Outlets } from '../../types/services/outlet'
import { api } from '../api'
interface OutletsQueryParams {
page?: number
@@ -31,6 +31,28 @@ export function useOutlets(params: OutletsQueryParams = {}) {
const res = await api.get(`/outlets/list?${queryParams.toString()}`)
return res.data.data
}
})
}
export function useOutletById() {
const user = (() => {
try {
return JSON.parse(localStorage.getItem('user') || '{}')
} catch {
return {}
}
})()
const outletId = user?.outlet_id // atau sesuai struktur data user
return useQuery<Outlet>({
queryKey: ['outlet', outletId],
queryFn: async () => {
if (!outletId) throw new Error('Outlet ID not found in localStorage')
const res = await api.get(`/outlets/detail/${outletId}`)
return res.data.data
},
enabled: !!outletId // query hanya jalan kalau ada outletId
})
}