mirror of
http://88.130.71.182:3000/BlitTech/badoHair_fe.git
synced 2026-06-13 08:58:31 +00:00
changes after second dev test
fixed full name issue, refresh issue on reservation and user/admin login issue
This commit is contained in:
@@ -44,7 +44,7 @@ interface AdminContextType {
|
||||
deleteProduct: (id: string) => Promise<void>;
|
||||
reservations: Reservation[];
|
||||
reservationsLoading: boolean;
|
||||
refreshReservations: () => Promise<void>;
|
||||
refreshReservations: (silent?: boolean) => Promise<void>;
|
||||
updateReservationStatus: (id: string, status: "confirmed" | "cancelled") => Promise<void>;
|
||||
deleteReservation: (id: string) => Promise<void>;
|
||||
}
|
||||
@@ -69,14 +69,14 @@ export const AdminProvider = ({ children }: { children: ReactNode }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const refreshReservations = async () => {
|
||||
const refreshReservations = async (silent = false) => {
|
||||
if (!isAdmin) return;
|
||||
setReservationsLoading(true);
|
||||
if (!silent) setReservationsLoading(true);
|
||||
try {
|
||||
const res = await bookingsApi.adminListBookings();
|
||||
setReservations(res.data.map(toReservation));
|
||||
} finally {
|
||||
setReservationsLoading(false);
|
||||
if (!silent) setReservationsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -108,12 +108,11 @@ export const AdminProvider = ({ children }: { children: ReactNode }) => {
|
||||
|
||||
const updateReservationStatus = async (id: string, status: "confirmed" | "cancelled") => {
|
||||
await bookingsApi.adminUpdateBookingStatus(id, status);
|
||||
// Optimistic update for immediate feedback
|
||||
setReservations((prev) =>
|
||||
prev.map((r) => (r.id === id ? { ...r, status } : r))
|
||||
);
|
||||
// Refresh from server to ensure consistency
|
||||
refreshReservations();
|
||||
// Sync with server silently — no loading flash
|
||||
refreshReservations(true);
|
||||
};
|
||||
|
||||
const deleteReservation = async (id: string) => {
|
||||
|
||||
Reference in New Issue
Block a user