Skip to content

Commit 3569336

Browse files
committed
fix: page 404 + redirection login/profil après sauvegarde
1 parent 2a0dfd4 commit 3569336

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

src/App.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useEffect, lazy, Suspense } from "react";
2-
import { BrowserRouter, Routes, Route } from "react-router-dom";
2+
import { BrowserRouter, Routes, Route, Link } from "react-router-dom";
3+
import { MapPin } from "lucide-react";
34
import { AppLayout } from "@/components/layout/app-layout";
45
import { Spinner } from "@/components/ui/spinner";
56
import { AppErrorBoundary } from "@/components/error/app-error-boundary";
@@ -129,6 +130,26 @@ function LoadingFallback() {
129130
);
130131
}
131132

133+
function NotFoundPage() {
134+
return (
135+
<div className="mx-auto flex max-w-md flex-col items-center gap-4 px-4 pb-24 pt-16 text-center">
136+
<div className="flex h-16 w-16 items-center justify-center rounded-2xl border border-white/10 bg-white/5">
137+
<MapPin className="h-7 w-7 text-muted-foreground/40" />
138+
</div>
139+
<h1 className="text-xl font-bold text-foreground">Page introuvable</h1>
140+
<p className="text-sm text-muted-foreground">
141+
Cette adresse n'existe pas ou a été déplacée.
142+
</p>
143+
<Link
144+
to="/"
145+
className="mt-2 rounded-xl border border-white/10 bg-white/5 px-4 py-2 text-sm font-medium text-foreground hover:bg-white/8 transition-colors"
146+
>
147+
Retour à l'accueil
148+
</Link>
149+
</div>
150+
);
151+
}
152+
132153
export default function App() {
133154
const { initialize, isLoading, authError } = useAuthStore();
134155

@@ -219,6 +240,7 @@ export default function App() {
219240
<Route path="/auth/callback" element={<AuthCallbackPage />} />
220241
<Route path="/login" element={<LoginPage />} />
221242
<Route path="/onboarding" element={<OnboardingPage />} />
243+
<Route path="*" element={<NotFoundPage />} />
222244
</Route>
223245
</Routes>
224246
</Suspense>

src/pages/profile-edit-page.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export function ProfileEditPage() {
116116

117117
useEffect(() => {
118118
if (!user && profileLoaded) {
119-
navigate("/");
119+
navigate("/login", { replace: true });
120120
return;
121121
}
122122
if (profile) {
@@ -161,7 +161,9 @@ export function ProfileEditPage() {
161161
github_url: data.github_url ?? "",
162162
});
163163
toast.success("Profil mis à jour avec succès");
164-
await fetchProfile(user.id);
164+
const refreshed = await fetchProfile(user.id);
165+
if (refreshed) setProfile(refreshed);
166+
navigate(`/contributeurs/${username}`);
165167
} catch (error) {
166168
const message =
167169
error instanceof Error ? error.message : "Erreur lors de la sauvegarde du profil";

0 commit comments

Comments
 (0)