Sfoglia il codice sorgente

update

bomUpdateTest
CANCERYS\kw093 4 ore fa
parent
commit
54536d4e79
2 ha cambiato i file con 14 aggiunte e 5 eliminazioni
  1. +10
    -3
      src/app/(main)/axios/AxiosProvider.tsx
  2. +4
    -2
      src/app/global.css

+ 10
- 3
src/app/(main)/axios/AxiosProvider.tsx Vedi File

@@ -19,9 +19,13 @@ const TokenContext = createContext<{
setAccessToken: () => {},
});

/** True after client hydrate and accessToken is available (safe to call authed APIs). */
const AuthReadyContext = createContext(false);

export const AxiosProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const [accessToken, setAccessToken] = useState<string | null>(null);
const [isHydrated, setIsHydrated] = useState(false);
const isAuthReady = isHydrated && Boolean(accessToken);

// Hydrate token only on client
useEffect(() => {
@@ -103,12 +107,15 @@ export const AxiosProvider: React.FC<{ children: React.ReactNode }> = ({ childre
return (
<AxiosContext.Provider value={axiosInstance}>
<TokenContext.Provider value={{ setAccessToken: handleSetAccessToken }}>
{/* Render children immediately – they will just not have the token for 1-2ms */}
{children}
<AuthReadyContext.Provider value={isAuthReady}>
{/* Render children immediately – they will just not have the token for 1-2ms */}
{children}
</AuthReadyContext.Provider>
</TokenContext.Provider>
</AxiosContext.Provider>
);
};

export const useAxios = () => useContext(AxiosContext);
export const useToken = () => useContext(TokenContext);
export const useToken = () => useContext(TokenContext);
export const useAuthReady = () => useContext(AuthReadyContext);

+ 4
- 2
src/app/global.css Vedi File

@@ -41,8 +41,10 @@ html:has([data-po-workbench-layout]) body {

/* Tablet/mobile: stable layout when virtual keyboard opens */
html {
/* Prefer dynamic viewport height so layout can adapt to keyboard (if browser resizes) */
height: 100%;
/* min-height (not height) so the document can grow with content;
fixed height: 100% locked the box to the viewport and exposed white below long pages. */
min-height: 100%;
min-height: 100dvh;
/* Base font size: slightly larger for readability */
font-size: 16px;
}


Caricamento…
Annulla
Salva