fix(client): work through the findings from the coverage pass

214 items came out of writing the tests. Real defects are corrected, dead code
is removed rather than covered, and the tests that pinned the old behaviour
move with them.

Also drops two agent coverage scratch files that slipped into the coverage PR
and adds the ignore rule that keeps them out.
This commit is contained in:
Maurice
2026-07-29 11:57:24 +02:00
committed by Maurice
parent a4bf815d24
commit 72a82b3c44
425 changed files with 3155 additions and 1968 deletions
+94 -1
View File
@@ -1,4 +1,4 @@
// FE-STORE-COLLECTION-001 to FE-STORE-COLLECTION-055
// FE-STORE-COLLECTION-001 to FE-STORE-COLLECTION-062
//
// The store owns the optimistic updates (status, labels, reorder, bulk delete) and the
// reload chains that follow every mutation, so the API layer is mocked here and the
@@ -310,6 +310,8 @@ describe('collectionStore — list CRUD', () => {
activeId: 1,
places: [buildPlace()],
members: [{ user_id: 5, username: 'bob', status: 'accepted' }],
labels: [{ id: 3, collection_id: 1, name: 'Food' }],
labelFilter: [3],
})
await store().deleteCollection(1)
@@ -318,6 +320,9 @@ describe('collectionStore — list CRUD', () => {
expect(store().activeId).toBeNull()
expect(store().places).toEqual([])
expect(store().members).toEqual([])
// Labels belong to the deleted list, so they go with it.
expect(store().labels).toEqual([])
expect(store().labelFilter).toEqual([])
expect(collectionsApi.list).toHaveBeenCalled()
})
@@ -464,6 +469,31 @@ describe('collectionStore — place mutations', () => {
expect(collectionsApi.deleteMany).toHaveBeenCalledWith([10, 11])
})
it('FE-STORE-COLLECTION-056: deletePlace() puts the row back when the server refuses', async () => {
useCollectionStore.setState({ places: [buildPlace({ id: 10 }), buildPlace({ id: 11 })] })
vi.mocked(collectionsApi.deletePlace).mockRejectedValue(new Error('nope'))
await expect(store().deletePlace(10)).rejects.toThrow('nope')
expect(store().places.map(p => p.id)).toEqual([10, 11])
expect(collectionsApi.list).not.toHaveBeenCalled()
})
it('FE-STORE-COLLECTION-057: deleteMany() restores the rows and the selection on failure', async () => {
useCollectionStore.setState({
places: [buildPlace({ id: 10 }), buildPlace({ id: 11 })],
selectedIds: [10],
selectMode: true,
})
vi.mocked(collectionsApi.deleteMany).mockRejectedValue(new Error('nope'))
await expect(store().deleteMany([10])).rejects.toThrow('nope')
expect(store().places.map(p => p.id)).toEqual([10, 11])
expect(store().selectedIds).toEqual([10])
expect(store().selectMode).toBe(true)
})
it('FE-STORE-COLLECTION-031: copyToTrip() forwards the payload and returns the dedup report', async () => {
vi.mocked(collectionsApi.copyToTrip).mockResolvedValue({ copied: 1, skipped: [{ id: 11, name: 'Shibuya' }] })
@@ -500,6 +530,28 @@ describe('collectionStore — place mutations', () => {
expect(collectionsApi.get).not.toHaveBeenCalled()
})
it('FE-STORE-COLLECTION-058: moveToList() only drops the places that actually moved', async () => {
useCollectionStore.setState({
activeId: 1,
places: [buildPlace({ id: 10 }), buildPlace({ id: 11 }), buildPlace({ id: 12 })],
selectedIds: [10, 11],
selectMode: true,
})
vi.mocked(collectionsApi.get).mockResolvedValue(
detail({ places: [buildPlace({ id: 11 }), buildPlace({ id: 12 })] }),
)
vi.mocked(collectionsApi.updatePlace)
.mockResolvedValueOnce(buildPlace({ id: 10 }))
.mockRejectedValueOnce(new Error('nope'))
await expect(store().moveToList([10, 11], 2)).rejects.toThrow('nope')
// The list is refreshed either way, so the open list matches the server again.
expect(collectionsApi.get).toHaveBeenCalledWith(1)
expect(store().places.map(p => p.id)).toEqual([11, 12])
expect(store().selectedIds).toEqual([])
})
it('FE-STORE-COLLECTION-034: duplicateToList() re-saves each place into the target list', async () => {
const source = buildPlace({
id: 10,
@@ -672,6 +724,42 @@ describe('collectionStore — labels', () => {
expect(collectionsApi.unassignLabels).toHaveBeenCalledWith([3], [10])
expect(collectionsApi.assignLabels).not.toHaveBeenCalled()
})
it('FE-STORE-COLLECTION-059: updateLabel() undoes the recolor when the server refuses', async () => {
useCollectionStore.setState({ activeId: 1, labels: [{ id: 3, collection_id: 1, name: 'Food', color: '#ef4444' }] })
vi.mocked(collectionsApi.updateLabel).mockRejectedValue(new Error('nope'))
await expect(store().updateLabel(3, { color: '#22c55e' })).rejects.toThrow('nope')
expect(store().labels[0]!.color).toBe('#ef4444')
expect(collectionsApi.get).not.toHaveBeenCalled()
})
it('FE-STORE-COLLECTION-060: deleteLabel() restores the label, its filter and its assignments', async () => {
useCollectionStore.setState({
activeId: 1,
labels: [{ id: 3, collection_id: 1, name: 'Food' }],
labelFilter: [3],
places: [buildPlace({ id: 10, label_ids: [3] })],
})
vi.mocked(collectionsApi.deleteLabel).mockRejectedValue(new Error('nope'))
await expect(store().deleteLabel(3)).rejects.toThrow('nope')
expect(store().labels.map(l => l.id)).toEqual([3])
expect(store().labelFilter).toEqual([3])
expect(store().places[0]!.label_ids).toEqual([3])
})
it('FE-STORE-COLLECTION-061: assignLabels() rolls the chips back on failure', async () => {
useCollectionStore.setState({ activeId: 1, places: [buildPlace({ id: 10, label_ids: [] })] })
vi.mocked(collectionsApi.assignLabels).mockRejectedValue(new Error('nope'))
await expect(store().assignLabels([3], [10])).rejects.toThrow('nope')
expect(store().places[0]!.label_ids).toEqual([])
expect(collectionsApi.get).not.toHaveBeenCalled()
})
})
describe('collectionStore — members and invitations', () => {
@@ -748,6 +836,8 @@ describe('collectionStore — members and invitations', () => {
activeId: 1,
places: [buildPlace()],
members: [{ user_id: 5, username: 'bob', status: 'accepted' }],
labels: [{ id: 3, collection_id: 1, name: 'Food' }],
labelFilter: [3],
})
vi.mocked(collectionsApi.list).mockResolvedValue(listResponse({ collections: [] }))
@@ -757,6 +847,9 @@ describe('collectionStore — members and invitations', () => {
expect(store().activeId).toBeNull()
expect(store().places).toEqual([])
expect(store().members).toEqual([])
// Labels belong to the list we just left.
expect(store().labels).toEqual([])
expect(store().labelFilter).toEqual([])
expect(store().collections).toEqual([])
})
+66 -17
View File
@@ -208,7 +208,8 @@ export const useCollectionStore = create<CollectionState>((set, get) => ({
deleteCollection: async (id: number) => {
await collectionsApi.remove(id)
if (get().activeId === id) set({ activeId: null, places: [], members: [] })
// Labels are per-list, so they have to go with the list they belonged to.
if (get().activeId === id) set({ activeId: null, places: [], members: [], labels: [], labelFilter: [] })
await get().loadAll()
},
@@ -253,15 +254,30 @@ export const useCollectionStore = create<CollectionState>((set, get) => ({
},
deletePlace: async (placeId: number) => {
set({ places: get().places.filter(p => p.id !== placeId) })
await collectionsApi.deletePlace(placeId)
// optimistic; put the row back if the server refuses, then let the caller toast
const prev = get().places
set({ places: prev.filter(p => p.id !== placeId) })
try {
await collectionsApi.deletePlace(placeId)
} catch (err) {
set({ places: prev })
throw err
}
await get().loadAll()
},
deleteMany: async (ids: number[]) => {
const idSet = new Set(ids)
set({ places: get().places.filter(p => !idSet.has(p.id)), selectedIds: [], selectMode: false })
await collectionsApi.deleteMany(ids)
const prev = get().places
const prevSelected = get().selectedIds
const prevSelectMode = get().selectMode
set({ places: prev.filter(p => !idSet.has(p.id)), selectedIds: [], selectMode: false })
try {
await collectionsApi.deleteMany(ids)
} catch (err) {
set({ places: prev, selectedIds: prevSelected, selectMode: prevSelectMode })
throw err
}
await get().loadAll()
},
@@ -273,12 +289,26 @@ export const useCollectionStore = create<CollectionState>((set, get) => ({
// Move the selected places into another list (re-point collection_id). They
// leave the current list, so drop them locally + refresh.
moveToList: async (placeIds: number[], targetId: number) => {
for (const id of placeIds) await collectionsApi.updatePlace(id, { collection_id: targetId })
const idSet = new Set(placeIds)
// The fan-out can fail halfway through, so drop only the places that really
// moved and refresh either way — otherwise the open list keeps showing rows
// that already belong to the target.
const moved: number[] = []
let failure: unknown = null
for (const id of placeIds) {
try {
await collectionsApi.updatePlace(id, { collection_id: targetId })
moved.push(id)
} catch (err) {
failure = err
break
}
}
const idSet = new Set(moved)
set({ places: get().places.filter(p => !idSet.has(p.id)), selectedIds: [], selectMode: false })
await get().loadAll()
const active = get().activeId
if (typeof active === 'number') await get().loadCollection(active)
if (failure) throw failure
},
// Duplicate the selected places into another list (re-save each place's data).
@@ -322,20 +352,32 @@ export const useCollectionStore = create<CollectionState>((set, get) => ({
updateLabel: async (labelId: number, body: CollectionLabelUpdateRequest) => {
// optimistic recolor/rename
set({ labels: get().labels.map(l => (l.id === labelId ? { ...l, ...body } : l)) })
await collectionsApi.updateLabel(labelId, body)
const prevLabels = get().labels
set({ labels: prevLabels.map(l => (l.id === labelId ? { ...l, ...body } : l)) })
try {
await collectionsApi.updateLabel(labelId, body)
} catch (err) {
set({ labels: prevLabels })
throw err
}
const active = get().activeId
if (typeof active === 'number') await get().loadCollection(active)
},
deleteLabel: async (labelId: number) => {
// optimistic: drop the label + its assignments + any active filter on it
const prev = { labels: get().labels, labelFilter: get().labelFilter, places: get().places }
set({
labels: get().labels.filter(l => l.id !== labelId),
labelFilter: get().labelFilter.filter(id => id !== labelId),
places: get().places.map(p => ({ ...p, label_ids: (p.label_ids ?? []).filter(id => id !== labelId) })),
labels: prev.labels.filter(l => l.id !== labelId),
labelFilter: prev.labelFilter.filter(id => id !== labelId),
places: prev.places.map(p => ({ ...p, label_ids: (p.label_ids ?? []).filter(id => id !== labelId) })),
})
await collectionsApi.deleteLabel(labelId)
try {
await collectionsApi.deleteLabel(labelId)
} catch (err) {
set(prev)
throw err
}
const active = get().activeId
if (typeof active === 'number') await get().loadCollection(active)
},
@@ -343,8 +385,9 @@ export const useCollectionStore = create<CollectionState>((set, get) => ({
assignLabels: async (labelIds: number[], placeIds: number[], remove = false) => {
const idSet = new Set(placeIds)
// optimistic per-place label_ids update
const prevPlaces = get().places
set({
places: get().places.map(p => {
places: prevPlaces.map(p => {
if (!idSet.has(p.id)) return p
const current = new Set(p.label_ids ?? [])
if (remove) labelIds.forEach(id => current.delete(id))
@@ -352,8 +395,13 @@ export const useCollectionStore = create<CollectionState>((set, get) => ({
return { ...p, label_ids: [...current] }
}),
})
if (remove) await collectionsApi.unassignLabels(labelIds, placeIds)
else await collectionsApi.assignLabels(labelIds, placeIds)
try {
if (remove) await collectionsApi.unassignLabels(labelIds, placeIds)
else await collectionsApi.assignLabels(labelIds, placeIds)
} catch (err) {
set({ places: prevPlaces })
throw err
}
const active = get().activeId
if (typeof active === 'number') await get().loadCollection(active)
},
@@ -390,7 +438,8 @@ export const useCollectionStore = create<CollectionState>((set, get) => ({
leave: async (collectionId: number) => {
await collectionsApi.leave(collectionId)
if (get().activeId === collectionId) set({ activeId: null, places: [], members: [] })
// Labels are per-list, so they have to go with the list we just left.
if (get().activeId === collectionId) set({ activeId: null, places: [], members: [], labels: [], labelFilter: [] })
await get().loadAll()
},
+1 -1
View File
@@ -349,5 +349,5 @@ export const useJourneyStore = create<JourneyState>((set, get) => ({
})
},
clear: () => set({ journeys: [], current: null, loading: false }),
clear: () => set({ journeys: [], current: null, loading: false, notFound: false }),
}))
@@ -264,4 +264,23 @@ describe('budgetSlice', () => {
expect(useTripStore.getState().budgetItems.map(i => i.id)).toEqual([1, 2]);
expect(addToast).toHaveBeenCalledWith('Reorder rejected', 'error', undefined);
});
it('FE-STORE-BUDGET-017: a reorder whose reload also fails still notifies instead of rejecting', async () => {
const a = buildBudgetItem({ id: 1, trip_id: 1 });
const b = buildBudgetItem({ id: 2, trip_id: 1 });
seedStore(useTripStore, { budgetItems: [a, b] });
// Offline: the reorder and the recovery read both fail. The caller fires
// this without awaiting, so nothing may escape as a rejection.
server.use(
http.put('/api/trips/1/budget/reorder/items', () => HttpResponse.error()),
http.put('/api/trips/1/budget/reorder/categories', () => HttpResponse.error()),
http.get('/api/trips/1/budget', () => HttpResponse.error())
);
await expect(useTripStore.getState().reorderBudgetItems(1, [2, 1])).resolves.toBeUndefined();
await expect(useTripStore.getState().reorderBudgetCategories(1, ['Transport'])).resolves.toBeUndefined();
expect(addToast).toHaveBeenCalledTimes(2);
});
});
+18 -10
View File
@@ -95,10 +95,12 @@ export const createBudgetSlice = (set: SetState, get: GetState): BudgetSlice =>
// Optimistic: reorder locally
set(state => {
const byId = new Map(state.budgetItems.map(i => [i.id, i]))
const reordered = orderedIds.map((id, idx): BudgetItem | null => {
const item = byId.get(id)
return item ? { ...item, sort_order: idx } : null
}).filter((i): i is BudgetItem => i !== null)
// Drop unknown ids before reindexing, otherwise a stale id leaves a gap
// in the local sort_order sequence.
const reordered = orderedIds
.map(id => byId.get(id))
.filter((i): i is BudgetItem => i !== undefined)
.map((item, idx): BudgetItem => ({ ...item, sort_order: idx }))
// Keep items not in orderedIds at the end
const remaining = state.budgetItems.filter(i => !orderedIds.includes(i.id))
return { budgetItems: [...reordered, ...remaining] }
@@ -107,9 +109,12 @@ export const createBudgetSlice = (set: SetState, get: GetState): BudgetSlice =>
await budgetApi.reorderItems(tripId, orderedIds)
} catch (err: unknown) {
// Reload on failure to restore the server's ordering, and tell the user
// their reorder didn't stick (the caller fires this without awaiting).
const data = await budgetApi.list(tripId)
set({ budgetItems: data.items })
// their reorder didn't stick (the caller fires this without awaiting, so
// a failing reload must not escape as an unhandled rejection).
try {
const data = await budgetApi.list(tripId)
set({ budgetItems: data.items })
} catch { /* offline too — the next successful load restores the order */ }
notify(getApiErrorMessage(err, 'Error reordering budget items'), 'error')
}
},
@@ -137,9 +142,12 @@ export const createBudgetSlice = (set: SetState, get: GetState): BudgetSlice =>
await budgetApi.reorderCategories(tripId, orderedCategories)
} catch (err: unknown) {
// Reload on failure to restore the server's ordering, and tell the user
// their reorder didn't stick (the caller fires this without awaiting).
const data = await budgetApi.list(tripId)
set({ budgetItems: data.items })
// their reorder didn't stick (the caller fires this without awaiting, so
// a failing reload must not escape as an unhandled rejection).
try {
const data = await budgetApi.list(tripId)
set({ budgetItems: data.items })
} catch { /* offline too — the next successful load restores the order */ }
notify(getApiErrorMessage(err, 'Error reordering budget items'), 'error')
}
},
+2 -1
View File
@@ -165,7 +165,7 @@ describe('daysSlice', () => {
expect(useTripStore.getState().days.map(d => d.id)).toEqual([1, 5]);
});
it('FE-TSLICE-DAYS-008: restores the day list and throws when the insert fails', async () => {
it('FE-TSLICE-DAYS-008: leaves the day list untouched and throws when the insert fails', async () => {
seedStore(useTripStore, { days: datedDays() });
server.use(
http.post('/api/trips/1/days', () =>
@@ -174,6 +174,7 @@ describe('daysSlice', () => {
);
await expect(useTripStore.getState().insertDay(1, 2)).rejects.toThrow('Trip is locked');
// The insert never writes optimistically, so a failure needs no rollback.
expect(useTripStore.getState().days.map(d => d.id)).toEqual([1, 2, 3]);
});
});
-2
View File
@@ -44,14 +44,12 @@ export const createDaysSlice = (set: SetState, get: GetState): DaysSlice => ({
// Insert a new empty day at a 1-based position (omit to append). On a dated
// trip this extends the trip by one day and re-pins dates server-side.
insertDay: async (tripId, position) => {
const prevDays = get().days
try {
const result = await daysApi.create(tripId, { position })
await get().refreshDays(tripId)
await get().loadReservations(tripId)
return result.day
} catch (err: unknown) {
set({ days: prevDays })
throw new Error(getApiErrorMessage(err, 'Error adding day'))
}
},
+3 -3
View File
@@ -263,9 +263,9 @@ describe('packingSlice', () => {
const items = useTripStore.getState().packingItems;
expect(items.map(i => i.id)).toEqual([2, 1, 3]);
// sort_order is reindexed against the requested positions, so the slot the
// unknown id occupied leaves a gap until the server's order comes back.
expect(items.map(i => i.sort_order)).toEqual([0, 2, 2]);
// The unknown id is dropped before reindexing, so the reordered items get a
// gapless sequence; the unlisted item keeps its own sort_order.
expect(items.map(i => i.sort_order)).toEqual([0, 1, 2]);
});
it('FE-STORE-PACKING-013: togglePackingItem rolls the checkbox back and notifies on failure', async () => {
+5 -2
View File
@@ -80,11 +80,14 @@ export const createPackingSlice = (set: SetState, get: GetState): PackingSlice =
const prev = get().packingItems
// Optimistic reorder: rebuild the array in the requested order, reindexing
// sort_order; any items not in orderedIds keep their place at the end.
// Unknown ids are dropped first so a stale id can't leave a gap in the
// local sort_order sequence.
set(state => {
const byId = new Map(state.packingItems.map(i => [i.id, i]))
const reordered = orderedIds
.map((id, idx): PackingItem | null => { const item = byId.get(id); return item ? { ...item, sort_order: idx } : null })
.filter((i): i is PackingItem => i !== null)
.map(id => byId.get(id))
.filter((i): i is PackingItem => i !== undefined)
.map((item, idx): PackingItem => ({ ...item, sort_order: idx }))
const remaining = state.packingItems.filter(i => !orderedIds.includes(i.id))
return { packingItems: [...reordered, ...remaining] }
})
+1 -1
View File
@@ -126,7 +126,7 @@ export const createPlacesSlice = (set: SetState, get: GetState): PlacesSlice =>
let changed = false
for (const [dayId, items] of Object.entries(state.assignments)) {
if (items.some((a: Assignment) => a.place?.id != null && idSet.has(a.place.id))) {
updatedAssignments[dayId] = items.filter((a: Assignment) => !idSet.has(a.place?.id!))
updatedAssignments[dayId] = items.filter((a: Assignment) => a.place?.id == null || !idSet.has(a.place.id))
changed = true
}
}
+10 -6
View File
@@ -266,9 +266,11 @@ export const STATE_APPLIERS: Partial<Record<TrekWsTripEventName, StateApplier>>
}
},
'assignment:reordered': (payload, state) => {
// No ids means no order to apply — dropping through would wipe the day.
if (!payload.orderedIds) return {}
const dayKey = String(payload.dayId)
const currentItems = state.assignments[dayKey] || []
const orderedIds: number[] = (payload.orderedIds as number[] | undefined) || []
const orderedIds = payload.orderedIds as number[]
const reordered = orderedIds.map((id, idx) => {
const item = currentItems.find(a => a.id === id)
return item ? { ...item, order_index: idx } : null
@@ -396,12 +398,14 @@ export const STATE_APPLIERS: Partial<Record<TrekWsTripEventName, StateApplier>>
if (payload.orderedIds) {
const orderedIds = payload.orderedIds as number[]
const byId = new Map(state.budgetItems.map(i => [i.id, i]))
const reordered = orderedIds.map((id, idx): BudgetItem | null => {
const item = byId.get(id)
return item ? { ...item, sort_order: idx } : null
}).filter((i): i is BudgetItem => i !== null)
const reordered = orderedIds
.map(id => byId.get(id))
.filter((i): i is BudgetItem => i !== undefined)
const remaining = state.budgetItems.filter(i => !orderedIds.includes(i.id))
return { budgetItems: [...reordered, ...remaining] }
// A partial orderedIds list leaves the untouched items behind, so index
// the whole array — otherwise sort_order and array position disagree and
// anything that re-sorts by sort_order undoes the reorder.
return { budgetItems: [...reordered, ...remaining].map((item, idx) => ({ ...item, sort_order: idx })) }
}
if (payload.orderedCategories) {
const orderedCategories = payload.orderedCategories as string[]
+3 -3
View File
@@ -113,9 +113,9 @@ describe('todoSlice', () => {
const items = useTripStore.getState().todoItems;
expect(items.map(i => i.id)).toEqual([2, 1, 3]);
// sort_order is reindexed against the requested positions, so the slot the
// unknown id occupied leaves a gap until the server's order comes back.
expect(items.map(i => i.sort_order)).toEqual([0, 2, 2]);
// The unknown id is dropped before reindexing, so the reordered todos get a
// gapless sequence; the unlisted todo keeps its own sort_order.
expect(items.map(i => i.sort_order)).toEqual([0, 1, 2]);
});
it('FE-STORE-TODO-004: toggleTodoItem rolls the checkbox back and notifies on failure', async () => {
+5 -2
View File
@@ -73,11 +73,14 @@ export const createTodoSlice = (set: SetState, get: GetState): TodoSlice => ({
reorderTodoItems: async (tripId, orderedIds) => {
const prev = get().todoItems
// Unknown ids are dropped before reindexing so a stale id can't leave a gap
// in the local sort_order sequence.
set(state => {
const byId = new Map(state.todoItems.map(i => [i.id, i]))
const reordered = orderedIds
.map((id, idx): TodoItem | null => { const item = byId.get(id); return item ? { ...item, sort_order: idx } : null })
.filter((i): i is TodoItem => i !== null)
.map(id => byId.get(id))
.filter((i): i is TodoItem => i !== undefined)
.map((item, idx): TodoItem => ({ ...item, sort_order: idx }))
const remaining = state.todoItems.filter(i => !orderedIds.includes(i.id))
return { todoItems: [...reordered, ...remaining] }
})
-6
View File
@@ -72,7 +72,6 @@ interface VacayApi {
declineInvite: (planId: number) => Promise<unknown>
cancelInvite: (userId: number) => Promise<unknown>
dissolve: () => Promise<unknown>
availableUsers: () => Promise<{ users: VacayUser[] }>
getYears: () => Promise<VacayYearsResponse>
addYear: (year: number) => Promise<VacayYearsResponse>
removeYear: (year: number) => Promise<VacayYearsResponse>
@@ -81,7 +80,6 @@ interface VacayApi {
toggleCompanyHoliday: (date: string) => Promise<unknown>
getStats: (year: number) => Promise<VacayStatsResponse>
updateStats: (year: number, days: number, targetUserId?: number) => Promise<unknown>
getCountries: () => Promise<{ countries: string[] }>
getHolidays: (year: number, country: string) => Promise<VacayHolidayRaw[]>
getSchoolHolidays: (year: number, country: string, subdivision?: string | null, group?: string | null) => Promise<VacaySchoolHolidayRaw[]>
addHolidayCalendar: (data: { region: string; color?: string; label?: string | null; type?: 'public_holiday' | 'school_holiday' }) => Promise<{ calendar: VacayHolidayCalendar }>
@@ -91,7 +89,6 @@ interface VacayApi {
share: (userId: number) => Promise<unknown>
removeShare: (shareId: number) => Promise<unknown>
updateShare: (shareId: number, hidden: boolean) => Promise<unknown>
shareAvailableUsers: () => Promise<{ users: VacayUser[] }>
getSharedCalendars: (year: number) => Promise<{ calendars: SharedVacayCalendar[] }>
getYearSettings: () => Promise<{ settings: VacayYearSettings }>
updateYearSettings: (data: VacayYearSettingsRequest) => Promise<{ settings: VacayYearSettings }>
@@ -106,7 +103,6 @@ const api: VacayApi = {
declineInvite: (planId) => ax.post('/addons/vacay/invite/decline', { plan_id: planId } satisfies VacayInviteActionRequest).then((r: AxiosResponse) => r.data),
cancelInvite: (userId) => ax.post('/addons/vacay/invite/cancel', { user_id: userId }).then((r: AxiosResponse) => r.data),
dissolve: () => ax.post('/addons/vacay/dissolve').then((r: AxiosResponse) => r.data),
availableUsers: () => ax.get('/addons/vacay/available-users').then((r: AxiosResponse) => r.data),
getYears: () => ax.get('/addons/vacay/years').then((r: AxiosResponse) => r.data),
addYear: (year) => ax.post('/addons/vacay/years', { year } satisfies VacayAddYearRequest).then((r: AxiosResponse) => r.data),
removeYear: (year) => ax.delete(`/addons/vacay/years/${year}`).then((r: AxiosResponse) => r.data),
@@ -115,7 +111,6 @@ const api: VacayApi = {
toggleCompanyHoliday: (date) => ax.post('/addons/vacay/entries/company-holiday', { date } satisfies VacayCompanyHolidayRequest).then((r: AxiosResponse) => r.data),
getStats: (year) => ax.get(`/addons/vacay/stats/${year}`).then((r: AxiosResponse) => r.data),
updateStats: (year, days, targetUserId) => ax.put(`/addons/vacay/stats/${year}`, { vacation_days: days, target_user_id: targetUserId } satisfies VacayUpdateStatsRequest).then((r: AxiosResponse) => r.data),
getCountries: () => ax.get('/addons/vacay/holidays/countries').then((r: AxiosResponse) => r.data),
getHolidays: (year, country) => ax.get(`/addons/vacay/holidays/${year}/${country}`).then((r: AxiosResponse) => r.data),
getSchoolHolidays: (year, country, subdivision, group) => {
const params = new URLSearchParams()
@@ -130,7 +125,6 @@ const api: VacayApi = {
share: (userId) => ax.post('/addons/vacay/shares', { user_id: userId } satisfies VacayShareRequest).then((r: AxiosResponse) => r.data),
removeShare: (shareId) => ax.delete(`/addons/vacay/shares/${shareId}`).then((r: AxiosResponse) => r.data),
updateShare: (shareId, hidden) => ax.put(`/addons/vacay/shares/${shareId}`, { hidden } satisfies VacayShareUpdateRequest).then((r: AxiosResponse) => r.data),
shareAvailableUsers: () => ax.get('/addons/vacay/shares/available-users').then((r: AxiosResponse) => r.data),
getSharedCalendars: (year) => ax.get(`/addons/vacay/shares/calendars/${year}`).then((r: AxiosResponse) => r.data),
getYearSettings: () => ax.get('/addons/vacay/year-settings').then((r: AxiosResponse) => r.data),
updateYearSettings: (data) => ax.put('/addons/vacay/year-settings', data satisfies VacayYearSettingsRequest).then((r: AxiosResponse) => r.data),