added adding and editing of availabilities

This commit is contained in:
z1glr
2025-01-18 13:25:12 +00:00
parent e37310b774
commit e17c9db90c
24 changed files with 737 additions and 163 deletions

View File

@@ -18,33 +18,28 @@ export default function Main({ children }: { children: React.ReactNode }) {
const router = useRouter();
const pathname = usePathname();
const user = zustand((state) => state.user);
useEffect(() => {
void (async () => {
let loggedIn = false;
if (zustand.getState().user === null) {
const welcomeResult = await apiCall<{
userName: string;
loggedIn: boolean;
}>("GET", "welcome");
const welcomeResult = await apiCall<{
userName: string;
loggedIn: boolean;
}>("GET", "welcome");
if (welcomeResult.ok) {
try {
const response = await welcomeResult.json();
if (welcomeResult.ok) {
try {
const response = await welcomeResult.json();
if (response.userName !== undefined && response.userName !== "") {
zustand.getState().reset({ user: response });
if (response.userName !== undefined && response.userName !== "") {
zustand.getState().reset({ user: response });
loggedIn = true;
}
} catch {}
} else {
zustand.getState().reset();
}
loggedIn = true;
}
} catch {}
} else {
loggedIn = true;
zustand.getState().reset();
}
if (pathname === "/login") {
@@ -62,7 +57,7 @@ export default function Main({ children }: { children: React.ReactNode }) {
}
}
})();
}, [pathname, router, user]);
}, [pathname, router]);
switch (auth) {
case AuthState.Loading: