mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 13:21:46 +00:00
fix(offline): route reservations, budget, files, and FilesPage loads through repo layer
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user