feat: auth flow
This commit is contained in:
+23
-21
@@ -1,27 +1,29 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { P, H1 } from '@/components/ui/typography';
|
||||
import { useEffect } from "react";
|
||||
import { useAuthStore } from "@/stores/auth-store";
|
||||
import { LoginPage } from "@/features/auth/login-page";
|
||||
import { HomePage } from "@/pages/home-page";
|
||||
|
||||
const App = () => {
|
||||
useEffect(
|
||||
() => {
|
||||
console.log('loaded');
|
||||
},
|
||||
[]
|
||||
);
|
||||
const [state, updateState] = useState(1);
|
||||
const status = useAuthStore((s) => s.status);
|
||||
const restoreSession = useAuthStore((s) => s.restoreSession);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<H1>Hello World!</H1>
|
||||
<P>Welcome to your Electron application.</P>
|
||||
<P>What is the purpose of this app</P>
|
||||
<Button onClick={() => {
|
||||
console.log(state);
|
||||
updateState(state + 1);
|
||||
}}>Click me</Button>
|
||||
</div>
|
||||
);
|
||||
useEffect(() => {
|
||||
restoreSession();
|
||||
}, [restoreSession]);
|
||||
|
||||
if (status === "idle" || status === "restoring") {
|
||||
return (
|
||||
<div className="flex min-h-screen items-center justify-center">
|
||||
<p className="text-muted-foreground text-sm">Loading...</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (status === "authenticated") {
|
||||
return <HomePage />;
|
||||
}
|
||||
|
||||
return <LoginPage />;
|
||||
};
|
||||
|
||||
export default App;
|
||||
|
||||
Reference in New Issue
Block a user