diff --git a/ui/src/App.tsx b/ui/src/App.tsx index 3bc3436..617f710 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -8,6 +8,7 @@ import { LandingPage } from "./pages/landing"; import { ProtectedRoute } from "./components/ProtectedRoute"; import { TabloPage } from "./pages/tablo"; import { SessionProvider } from "./contexts/SessionContext"; +import { GoogleSigninPage } from "./pages/google-signin"; export const App = () => { return ( @@ -29,14 +30,7 @@ export const App = () => { } /> - - - - } - /> + } /> } /> } /> } /> diff --git a/ui/src/ui-library/header.tsx b/ui/src/components/header.tsx similarity index 90% rename from ui/src/ui-library/header.tsx rename to ui/src/components/header.tsx index 317c7e5..cabc45e 100644 --- a/ui/src/ui-library/header.tsx +++ b/ui/src/components/header.tsx @@ -1,16 +1,11 @@ -import { Button } from "./button"; -import { Switch } from "./switch"; +import { Button } from "../ui-library/button"; +import { Switch } from "../ui-library/switch"; import { twMerge } from "tailwind-merge"; import logo from "../assets/icon.jpg"; -import { useState } from "react"; -import { ConnectionForm } from "./connection-form"; -import { SignUpForm } from "./signup-form"; import { Link, useNavigate } from "react-router-dom"; import { useTheme } from "../contexts/ThemeContext"; export function Header() { - const [showConnectionForm, setShowConnectionForm] = useState(false); - const [showSignUpForm, setShowSignUpForm] = useState(false); const navigate = useNavigate(); const { theme, setTheme } = useTheme(); @@ -127,12 +122,6 @@ export function Header() { - {showConnectionForm && ( - setShowConnectionForm(false)} /> - )} - {showSignUpForm && ( - setShowSignUpForm(false)} /> - )} ); } diff --git a/ui/src/hooks/auth.ts b/ui/src/hooks/auth.ts index 3eceb4c..91e8b23 100644 --- a/ui/src/hooks/auth.ts +++ b/ui/src/hooks/auth.ts @@ -1,4 +1,4 @@ -import { useMutation, useQuery } from "@tanstack/react-query"; +import { useMutation } from "@tanstack/react-query"; import { useNavigate } from "react-router-dom"; import { useState } from "react"; import { match } from "ts-pattern"; @@ -8,7 +8,6 @@ import { Session, createClient, } from "@supabase/supabase-js"; -import { queryClient } from "../lib/api"; export type User = SupabaseUser & { user_metadata: { @@ -139,7 +138,7 @@ export function useLoginGoogle() { const { data, error } = await supabase.auth.signInWithOAuth({ provider: "google", options: { - redirectTo: "http://localhost:5173/", + redirectTo: "http://localhost:5173/login-with-google", }, }); if (error) throw error; @@ -149,32 +148,11 @@ export function useLoginGoogle() { return { loginWithGoogle: mutate }; } -export function useGetCurrentUser() { - const { data: user } = useQuery({ - queryKey: ["currentUser"], - queryFn: async () => { - const { data } = await supabase.auth.getSession(); - if (!data.session) { - throw new Error("No session found"); - } - return data.session?.user; - }, - retryDelay: 1000, - refetchInterval: 1000 * 60 * 10, - }); - return { user: user as User | null }; -} export function useLogout() { - const navigate = useNavigate(); return useMutation({ mutationFn: async () => { const { error } = await supabase.auth.signOut(); if (error) throw error; }, - onSuccess: () => { - console.log("logout"); - queryClient.invalidateQueries({ queryKey: ["currentUser"] }); - navigate("/login"); - }, }); } diff --git a/ui/src/pages/google-signin.tsx b/ui/src/pages/google-signin.tsx new file mode 100644 index 0000000..49980c4 --- /dev/null +++ b/ui/src/pages/google-signin.tsx @@ -0,0 +1,12 @@ +import { useEffect } from "react"; +import { useNavigate } from "react-router-dom"; + +export const GoogleSigninPage = () => { + const navigate = useNavigate(); + useEffect(() => { + setTimeout(() => { + navigate("/"); + }, 100); + }, [navigate]); + return <>; +}; diff --git a/ui/src/pages/landing.tsx b/ui/src/pages/landing.tsx index b0b65f9..75e43f4 100644 --- a/ui/src/pages/landing.tsx +++ b/ui/src/pages/landing.tsx @@ -1,8 +1,8 @@ import { Button } from "../ui-library/button"; -import { Header } from "../ui-library/header"; import { twMerge } from "tailwind-merge"; import logo from "../assets/icon.jpg"; +import { Header } from "../components/header"; export const LandingPage = () => { return ( diff --git a/ui/src/pages/tablo.tsx b/ui/src/pages/tablo.tsx index af8f56a..f26a19c 100644 --- a/ui/src/pages/tablo.tsx +++ b/ui/src/pages/tablo.tsx @@ -1,18 +1,18 @@ import { SignOutButton } from "../components/SignOutButton"; import { useSession } from "../contexts/SessionContext"; +import { Header } from "../components/header"; export const TabloPage = () => { const { session } = useSession(); return (
-
-
-

- Tablo -

- -
-
+
+
+

+ Tablo +

+ +
diff --git a/ui/src/ui-library/connection-form.tsx b/ui/src/ui-library/connection-form.tsx deleted file mode 100644 index 79c5ef2..0000000 --- a/ui/src/ui-library/connection-form.tsx +++ /dev/null @@ -1,137 +0,0 @@ -import { Button } from "./button"; -import { twMerge } from "tailwind-merge"; -import { useState } from "react"; - -interface ConnectionFormProps { - onClose: () => void; -} - -export function ConnectionForm({ onClose }: ConnectionFormProps) { - const [email, setEmail] = useState(""); - const [password, setPassword] = useState(""); - - const handleSubmit = (e: React.FormEvent) => { - e.preventDefault(); - // TODO: Implement connection logic - console.log("Connection attempt with:", { email, password }); - }; - - return ( -
-
-
-

- Connexion -

- -
- -
-
- - setEmail(e.target.value)} - className={twMerge( - "w-full px-4 py-2 rounded-lg border border-slate-300 dark:border-slate-600", - "bg-white dark:bg-slate-700 text-slate-900 dark:text-white", - "focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent" - )} - required - /> -
- -
- - setPassword(e.target.value)} - className={twMerge( - "w-full px-4 py-2 rounded-lg border border-slate-300 dark:border-slate-600", - "bg-white dark:bg-slate-700 text-slate-900 dark:text-white", - "focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent" - )} - required - /> -
- -
- - - Mot de passe oublié ? - -
- - -
- -
-

- Pas encore de compte ?{" "} - - S'inscrire - -

-
-
-
- ); -} diff --git a/ui/src/ui-library/signup-form.tsx b/ui/src/ui-library/signup-form.tsx deleted file mode 100644 index 78e6d00..0000000 --- a/ui/src/ui-library/signup-form.tsx +++ /dev/null @@ -1,242 +0,0 @@ -import { Button } from "./button"; -import { twMerge } from "tailwind-merge"; -import { useState } from "react"; - -interface SignUpFormProps { - onClose: () => void; -} - -export function SignUpForm({ onClose }: SignUpFormProps) { - const [formData, setFormData] = useState({ - firstName: "", - lastName: "", - email: "", - password: "", - confirmPassword: "", - company: "", - }); - - const handleSubmit = (e: React.FormEvent) => { - e.preventDefault(); - // TODO: Implement sign up logic - console.log("Sign up attempt with:", formData); - }; - - const handleChange = (e: React.ChangeEvent) => { - const { name, value } = e.target; - setFormData((prev) => ({ ...prev, [name]: value })); - }; - - return ( -
-
-
-

- Créer un compte -

- -
- -
-
-
- - -
-
- - -
-
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- - -
- -
-

- Déjà un compte ?{" "} - - Se connecter - -

-
-
-
- ); -}