Fix login redirect — access result.data.token/user
Login/register pages now correctly unwrap API response {data: {token, user}}.
Cleaned up leftover apiFetch code.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10,9 +10,10 @@ export const metadata: Metadata = {
|
||||
manifest: "/manifest.json",
|
||||
appleWebApp: {
|
||||
capable: true,
|
||||
statusBarStyle: "default",
|
||||
statusBarStyle: "black-translucent",
|
||||
title: "Task Team",
|
||||
},
|
||||
other: { "mobile-web-app-capable": "yes" },
|
||||
};
|
||||
|
||||
export const viewport: Viewport = {
|
||||
|
||||
@@ -23,7 +23,7 @@ export default function LoginPage() {
|
||||
setError("");
|
||||
try {
|
||||
const result = await login({ email: email.trim() });
|
||||
setAuth(result.token, result.user);
|
||||
setAuth(result.data.token, result.data.user);
|
||||
router.push("/tasks");
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "Chyba prihlaseni");
|
||||
|
||||
@@ -29,7 +29,7 @@ export default function RegisterPage() {
|
||||
name: name.trim(),
|
||||
phone: phone.trim() || undefined,
|
||||
});
|
||||
setAuth(result.token, result.user);
|
||||
setAuth(result.data.token, result.data.user);
|
||||
router.push("/tasks");
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "Chyba registrace");
|
||||
|
||||
@@ -36,14 +36,14 @@ async function apiFetch<T>(path: string, opts: ApiOptions = {}): Promise<T> {
|
||||
|
||||
// Auth
|
||||
export function register(data: { email: string; name: string; phone?: string }) {
|
||||
return apiFetch<{ token: string; user: User }>("/api/v1/auth/register", {
|
||||
return apiFetch<{ data: { token: string; user: User } }>("/api/v1/auth/register", {
|
||||
method: "POST",
|
||||
body: data,
|
||||
});
|
||||
}
|
||||
|
||||
export function login(data: { email: string; password?: string }) {
|
||||
return apiFetch<{ token: string; user: User }>("/api/v1/auth/login", {
|
||||
return apiFetch<{ data: { token: string; user: User } }>("/api/v1/auth/login", {
|
||||
method: "POST",
|
||||
body: data,
|
||||
});
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 0 B After Width: | Height: | Size: 983 B |
Binary file not shown.
|
Before Width: | Height: | Size: 0 B After Width: | Height: | Size: 2.9 KiB |
@@ -1,17 +1 @@
|
||||
{
|
||||
"name": "Task Team",
|
||||
"short_name": "Tasks",
|
||||
"description": "Správa úkolů pro tým",
|
||||
"start_url": "/tasks",
|
||||
"display": "standalone",
|
||||
"background_color": "#0a0a0a",
|
||||
"theme_color": "#3B82F6",
|
||||
"orientation": "portrait-primary",
|
||||
"icons": [
|
||||
{"src": "/icon-192.png", "sizes": "192x192", "type": "image/png"},
|
||||
{"src": "/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any maskable"}
|
||||
],
|
||||
"categories": ["productivity", "utilities"],
|
||||
"lang": "cs",
|
||||
"dir": "ltr"
|
||||
}
|
||||
{"name":"Task Team","short_name":"Tasks","start_url":"/","display":"standalone","background_color":"#0A0A0F","theme_color":"#1D4ED8","icons":[{"src":"/icon-192.png","sizes":"192x192","type":"image/png","purpose":"any maskable"},{"src":"/icon-512.png","sizes":"512x512","type":"image/png","purpose":"any maskable"}]}
|
||||
|
||||
Reference in New Issue
Block a user