fixed order, image carousel
This commit is contained in:
@@ -14,8 +14,8 @@ interface LoginCredentials {
|
||||
|
||||
interface RegisterData {
|
||||
phone_number: string;
|
||||
name?: string;
|
||||
email?: string;
|
||||
name: string;
|
||||
address: string;
|
||||
}
|
||||
|
||||
interface VerifyTokenData {
|
||||
@@ -52,31 +52,31 @@ function extractToken(data: AuthResponse): string {
|
||||
|
||||
function handleAuthError(error: unknown): AuthError {
|
||||
if (error instanceof AxiosError) {
|
||||
if (error.code === 'ECONNABORTED') {
|
||||
if (error.code === "ECONNABORTED") {
|
||||
return {
|
||||
message: "Request timeout - server not responding",
|
||||
code: "TIMEOUT",
|
||||
statusCode: 408
|
||||
statusCode: 408,
|
||||
};
|
||||
}
|
||||
if (error.response) {
|
||||
return {
|
||||
message: error.response.data?.message || "Authentication failed",
|
||||
code: error.response.data?.code || "AUTH_ERROR",
|
||||
statusCode: error.response.status
|
||||
statusCode: error.response.status,
|
||||
};
|
||||
}
|
||||
if (error.request) {
|
||||
return {
|
||||
message: "Network error - cannot reach server",
|
||||
code: "NETWORK_ERROR",
|
||||
statusCode: 0
|
||||
statusCode: 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
return {
|
||||
message: error instanceof Error ? error.message : "Unknown error occurred",
|
||||
code: "UNKNOWN_ERROR"
|
||||
code: "UNKNOWN_ERROR",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -106,8 +106,8 @@ export function useGetGuestToken() {
|
||||
{},
|
||||
{
|
||||
signal: controller.signal,
|
||||
timeout: 10000
|
||||
}
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
clearTimeout(timeoutId);
|
||||
return extractToken(response.data);
|
||||
@@ -123,7 +123,7 @@ export function useGetGuestToken() {
|
||||
console.error("[Guest Token] Failed:", {
|
||||
message: error.message,
|
||||
code: error.code,
|
||||
statusCode: error.statusCode
|
||||
statusCode: error.statusCode,
|
||||
});
|
||||
},
|
||||
retry: (failureCount, error) => {
|
||||
@@ -147,7 +147,7 @@ export function useLogin() {
|
||||
const response = await apiClient.post<AuthResponse>(
|
||||
"/auth/login",
|
||||
credentials,
|
||||
{ timeout: 15000 }
|
||||
{ timeout: 15000 },
|
||||
);
|
||||
return extractToken(response.data);
|
||||
},
|
||||
@@ -172,7 +172,7 @@ export function useRegister() {
|
||||
const response = await apiClient.post<AuthResponse>(
|
||||
"/auth/register",
|
||||
userData,
|
||||
{ timeout: 15000 }
|
||||
{ timeout: 15000 },
|
||||
);
|
||||
return extractToken(response.data);
|
||||
},
|
||||
@@ -197,7 +197,7 @@ export function useVerifyToken() {
|
||||
const response = await apiClient.post<AuthResponse>(
|
||||
"/auth/verify",
|
||||
verifyData,
|
||||
{ timeout: 15000 }
|
||||
{ timeout: 15000 },
|
||||
);
|
||||
return extractToken(response.data);
|
||||
},
|
||||
@@ -222,7 +222,9 @@ export function useLogout() {
|
||||
try {
|
||||
await apiClient.post("/auth/logout", {}, { timeout: 5000 });
|
||||
} catch (error) {
|
||||
console.warn("[Logout] Server call failed, clearing local state anyway");
|
||||
console.warn(
|
||||
"[Logout] Server call failed, clearing local state anyway",
|
||||
);
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
@@ -234,4 +236,4 @@ export function useLogout() {
|
||||
queryClient.clear();
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user