changes after second dev test

fixed full name issue, refresh issue on reservation and user/admin login issue
This commit is contained in:
belviskhoremk
2026-05-27 23:04:32 +00:00
parent 209ac114b0
commit 53365b9dbf
7 changed files with 60 additions and 27 deletions

View File

@@ -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) => {

View File

@@ -13,6 +13,7 @@ interface AuthContextType {
login: (email: string, password: string) => Promise<UserProfile>;
register: (email: string, password: string, name: string) => Promise<UserProfile | null>;
logout: () => void;
refreshUser: () => Promise<void>;
}
const AuthContext = createContext<AuthContextType | undefined>(undefined);
@@ -50,6 +51,11 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
setUser(null);
};
const refreshUser = async () => {
const profile = await authApi.getMe();
setUser(profile);
};
return (
<AuthContext.Provider
value={{
@@ -59,6 +65,7 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
login,
register,
logout,
refreshUser,
}}
>
{children}

View File

@@ -89,6 +89,7 @@ const translations: Record<string, Record<Language, string>> = {
"auth.forgot_send": { fr: "Envoyer le lien", de: "Link senden", en: "Send link" },
"auth.forgot_sent": { fr: "Email envoyé ! Vérifiez votre boîte mail.", de: "E-Mail gesendet! Prüfen Sie Ihren Posteingang.", en: "Email sent! Check your inbox." },
"auth.back_to_login": { fr: "Retour à la connexion", de: "Zurück zur Anmeldung", en: "Back to login" },
"auth.admin_not_allowed": { fr: "Les administrateurs doivent utiliser l'espace admin", de: "Administratoren müssen den Admin-Bereich verwenden", en: "Administrators must use the admin login" },
// ── Booking (public page) ────────────────────────────────────────────────────
"booking.select_service": { fr: "Choisir un service", de: "Service wählen", en: "Select service" },