From 85d72c831d9f63a118d35d594487e4e6aea90f04 Mon Sep 17 00:00:00 2001 From: jubnl Date: Tue, 14 Apr 2026 23:40:49 +0200 Subject: [PATCH] fix(offline): route reservations, budget, files, and FilesPage loads through repo layer --- client/src/pages/FilesPage.tsx | 7 ++++--- client/src/store/slices/budgetSlice.ts | 3 ++- client/src/store/slices/filesSlice.ts | 3 ++- client/src/store/slices/reservationsSlice.ts | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/client/src/pages/FilesPage.tsx b/client/src/pages/FilesPage.tsx index 2a6c4eac..cb48d5e1 100644 --- a/client/src/pages/FilesPage.tsx +++ b/client/src/pages/FilesPage.tsx @@ -1,7 +1,8 @@ import React, { useEffect, useState } from 'react' import { useParams, useNavigate, Link } from 'react-router-dom' import { useTripStore } from '../store/tripStore' -import { tripsApi, placesApi } from '../api/client' +import { tripRepo } from '../repo/tripRepo' +import { placeRepo } from '../repo/placeRepo' import Navbar from '../components/Layout/Navbar' import FileManager from '../components/Files/FileManager' import { ArrowLeft } from 'lucide-react' @@ -27,8 +28,8 @@ export default function FilesPage(): React.ReactElement { setIsLoading(true) try { const [tripData, placesData] = await Promise.all([ - tripsApi.get(tripId), - placesApi.list(tripId), + tripRepo.get(tripId), + placeRepo.list(tripId), ]) setTrip(tripData.trip) setPlaces(placesData.places) diff --git a/client/src/store/slices/budgetSlice.ts b/client/src/store/slices/budgetSlice.ts index 04e58fda..9f63bc45 100644 --- a/client/src/store/slices/budgetSlice.ts +++ b/client/src/store/slices/budgetSlice.ts @@ -1,4 +1,5 @@ import { budgetApi } from '../../api/client' +import { budgetRepo } from '../../repo/budgetRepo' import type { StoreApi } from 'zustand' import type { TripStoreState } from '../tripStore' import type { BudgetItem, BudgetMember } from '../../types' @@ -21,7 +22,7 @@ export interface BudgetSlice { export const createBudgetSlice = (set: SetState, get: GetState): BudgetSlice => ({ loadBudgetItems: async (tripId) => { try { - const data = await budgetApi.list(tripId) + const data = await budgetRepo.list(tripId) set({ budgetItems: data.items }) } catch (err: unknown) { console.error('Failed to load budget items:', err) diff --git a/client/src/store/slices/filesSlice.ts b/client/src/store/slices/filesSlice.ts index 07ed0deb..13617515 100644 --- a/client/src/store/slices/filesSlice.ts +++ b/client/src/store/slices/filesSlice.ts @@ -1,4 +1,5 @@ import { filesApi } from '../../api/client' +import { fileRepo } from '../../repo/fileRepo' import type { StoreApi } from 'zustand' import type { TripStoreState } from '../tripStore' import type { TripFile } from '../../types' @@ -16,7 +17,7 @@ export interface FilesSlice { export const createFilesSlice = (set: SetState, get: GetState): FilesSlice => ({ loadFiles: async (tripId) => { try { - const data = await filesApi.list(tripId) + const data = await fileRepo.list(tripId) set({ files: data.files }) } catch (err: unknown) { console.error('Failed to load files:', err) diff --git a/client/src/store/slices/reservationsSlice.ts b/client/src/store/slices/reservationsSlice.ts index 536d4cb1..c020a593 100644 --- a/client/src/store/slices/reservationsSlice.ts +++ b/client/src/store/slices/reservationsSlice.ts @@ -1,4 +1,5 @@ import { reservationsApi } from '../../api/client' +import { reservationRepo } from '../../repo/reservationRepo' import type { StoreApi } from 'zustand' import type { TripStoreState } from '../tripStore' import type { Reservation } from '../../types' @@ -18,7 +19,7 @@ export interface ReservationsSlice { export const createReservationsSlice = (set: SetState, get: GetState): ReservationsSlice => ({ loadReservations: async (tripId) => { try { - const data = await reservationsApi.list(tripId) + const data = await reservationRepo.list(tripId) set({ reservations: data.reservations }) } catch (err: unknown) { console.error('Failed to load reservations:', err)