update tab nhật ký (Lọc, Ngôn ngữ,...)

This commit is contained in:
2025-12-07 20:23:10 +07:00
parent 0672f8adf9
commit e405a0bcfa
17 changed files with 851 additions and 332 deletions

31
state/use-tripslist.ts Normal file
View File

@@ -0,0 +1,31 @@
import { queryTripsList } from "@/controller/TripController";
import { create } from "zustand";
type TripsListState = {
tripsList: Model.TripsListResponse | null;
getTripsList: (body: Model.TripListBody) => Promise<void>;
error: string | null;
loading?: boolean;
};
export const useTripsList = create<TripsListState>((set) => ({
tripsList: null,
getTripsList: async (body: Model.TripListBody) => {
set({ loading: true, error: null });
try {
const response = await queryTripsList(body);
console.log("Trip fetching API: ", response.data.trips?.length);
set({ tripsList: response.data ?? [], loading: false });
} catch (error) {
console.error("Error when fetch things: ", error);
set({
error: "Failed to fetch things data",
loading: false,
tripsList: null,
});
}
},
error: null,
loading: false,
}));