Fix calendar style
This commit is contained in:
@@ -7,7 +7,8 @@ interface UsePlannedDaysResult {
|
||||
isLoading: boolean
|
||||
error: string | null
|
||||
refresh: () => Promise<void>
|
||||
add: (date: string, childId: string, leaveType: string) => Promise<PlannedLeaveDay>
|
||||
add: (payload: api.CreatePlannedDayPayload) => Promise<PlannedLeaveDay>
|
||||
update: (id: string, payload: api.UpdatePlannedDayPayload) => Promise<PlannedLeaveDay>
|
||||
remove: (id: string) => Promise<void>
|
||||
}
|
||||
|
||||
@@ -32,15 +33,21 @@ export function usePlannedDays(childId?: string): UsePlannedDaysResult {
|
||||
}, [childId])
|
||||
|
||||
const add = useCallback(
|
||||
async (date: string, childId: string, leaveType: string) => {
|
||||
const result = await api.createPlannedDay(childId, {
|
||||
date,
|
||||
leaveType,
|
||||
})
|
||||
async (payload: api.CreatePlannedDayPayload) => {
|
||||
const result = await api.createPlannedDay(payload)
|
||||
await fetch()
|
||||
return result
|
||||
},
|
||||
[fetch]
|
||||
[fetch],
|
||||
)
|
||||
|
||||
const update = useCallback(
|
||||
async (id: string, payload: api.UpdatePlannedDayPayload) => {
|
||||
const result = await api.updatePlannedDay(id, payload)
|
||||
await fetch()
|
||||
return result
|
||||
},
|
||||
[fetch],
|
||||
)
|
||||
|
||||
const remove = useCallback(
|
||||
@@ -48,12 +55,12 @@ export function usePlannedDays(childId?: string): UsePlannedDaysResult {
|
||||
await api.deletePlannedDay(id)
|
||||
await fetch()
|
||||
},
|
||||
[fetch]
|
||||
[fetch],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
fetch()
|
||||
}, [fetch])
|
||||
|
||||
return { data, isLoading, error, refresh: fetch, add, remove }
|
||||
return { data, isLoading, error, refresh: fetch, add, update, remove }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user