MVP frontend+backend

This commit is contained in:
2026-06-14 09:58:30 +02:00
parent d9539f23cc
commit 772d853e37
56 changed files with 5099 additions and 207 deletions
+6 -7
View File
@@ -11,17 +11,17 @@ interface UsePlannedDaysResult {
remove: (id: string) => Promise<void>
}
export function usePlannedDays(workspaceId: string | null, childId?: string): UsePlannedDaysResult {
export function usePlannedDays(childId?: string): UsePlannedDaysResult {
const [data, setData] = useState<PlannedLeaveDay[] | null>(null)
const [isLoading, setIsLoading] = useState(false)
const [error, setError] = useState<string | null>(null)
const fetch = useCallback(async () => {
if (!workspaceId || !childId) return
if (!childId) return
setIsLoading(true)
setError(null)
try {
const response = await api.getPlannedDays(workspaceId, childId)
const response = await api.getPlannedDays(childId)
setData(response)
} catch (err) {
setError(err instanceof Error ? err.message : 'Failed to fetch planned days')
@@ -29,19 +29,18 @@ export function usePlannedDays(workspaceId: string | null, childId?: string): Us
} finally {
setIsLoading(false)
}
}, [workspaceId, childId])
}, [childId])
const add = useCallback(
async (date: string, childId: string, leaveType: string) => {
if (!workspaceId) throw new Error('Workspace not selected')
const result = await api.createPlannedDay(workspaceId, childId, {
const result = await api.createPlannedDay(childId, {
date,
leaveType,
})
await fetch()
return result
},
[workspaceId, fetch]
[fetch]
)
const remove = useCallback(