Correction build APK Android
- Fix: Configuration Docker pour éviter l'écrasement de node_modules - Fix: Script build-apk.sh installe correctement les dépendances dev - Fix: Adaptation du code pour export statique (Suspense, useSearchParams) - Fix: Correction type Accordion
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect, useMemo } from "react";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { config } from "@/lib/config";
|
||||
|
||||
export interface ClientData {
|
||||
@ -28,12 +27,28 @@ function loadFromStorage(): ClientData | null {
|
||||
}
|
||||
|
||||
export function useClientData() {
|
||||
const searchParams = useSearchParams();
|
||||
// Utiliser window.location pour l'export statique (compatible)
|
||||
const [token, setToken] = useState<string | null>(null);
|
||||
// Charger immédiatement depuis localStorage pour éviter le délai
|
||||
const [clientData, setClientData] = useState<ClientData | null>(() => loadFromStorage());
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
// Récupérer le token depuis l'URL (compatible export statique)
|
||||
if (typeof window !== "undefined") {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
setToken(urlParams.get("token"));
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (token === null && typeof window !== "undefined") {
|
||||
// Attendre que le token soit récupéré
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
setToken(urlParams.get("token"));
|
||||
return;
|
||||
}
|
||||
|
||||
const loadClientData = async () => {
|
||||
// 1. Charger d'abord depuis localStorage pour un affichage immédiat
|
||||
const storedData = loadFromStorage();
|
||||
@ -43,7 +58,6 @@ export function useClientData() {
|
||||
}
|
||||
|
||||
// 2. Vérifier s'il y a un token dans l'URL
|
||||
const token = searchParams.get("token");
|
||||
|
||||
if (token) {
|
||||
try {
|
||||
@ -82,7 +96,7 @@ export function useClientData() {
|
||||
};
|
||||
|
||||
loadClientData();
|
||||
}, [searchParams]);
|
||||
}, [token]);
|
||||
|
||||
// Retourner les données client ou les valeurs par défaut
|
||||
return useMemo(() => ({
|
||||
|
||||
Reference in New Issue
Block a user