initial commit, boilerplate stuff

This commit is contained in:
khannurien
2026-03-15 17:15:46 +00:00
commit 6207a7549f
52 changed files with 4400 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
import { createContext } from "react";
import { type AuthResponse } from "../model.ts";
export interface AuthContextValue {
authResponse: AuthResponse | null;
setAuthResponse: (authResponse: AuthResponse | null) => void;
}
export const AuthContext = createContext<AuthContextValue>({
authResponse: null,
setAuthResponse: () => {},
});

View File

@@ -0,0 +1,21 @@
import { ReactNode, useState } from "react";
import { AuthContext, type AuthContextValue } from "./AuthContext.ts";
import { type AuthResponse } from "../model.ts";
export function AuthProvider({ children }: { children: ReactNode }) {
const [authResponse, setAuthResponse] = useState<AuthResponse | null>(() => {
const stored = localStorage.getItem("authResponse");
return stored ? JSON.parse(stored) : null;
});
const value: AuthContextValue = { authResponse, setAuthResponse };
return (
<AuthContext.Provider value={value}>
{children}
</AuthContext.Provider>
);
}