From b303398cd4484628278815e4a229935990c3ebdf Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 22 Dec 2025 14:24:53 -0600 Subject: [PATCH] Se agrega ruta de login --- src/components/auth/ExternalLoginForm.tsx | 35 +++++++++++++++++++++++ src/components/auth/InternalLoginForm.tsx | 35 +++++++++++++++++++++++ src/components/auth/LoginCard.tsx | 27 +++++++++++++++++ src/components/auth/LoginTabs.tsx | 28 ++++++++++++++++++ src/components/ui/Input.tsx | 28 ++++++++++++++++++ src/components/ui/SubmitButton.tsx | 15 ++++++++++ src/routeTree.gen.ts | 24 ++++++++++++++-- src/routes/login.tsx | 14 +++++++++ 8 files changed, 203 insertions(+), 3 deletions(-) create mode 100644 src/components/auth/ExternalLoginForm.tsx create mode 100644 src/components/auth/InternalLoginForm.tsx create mode 100644 src/components/auth/LoginCard.tsx create mode 100644 src/components/auth/LoginTabs.tsx create mode 100644 src/components/ui/Input.tsx create mode 100644 src/components/ui/SubmitButton.tsx create mode 100644 src/routes/login.tsx diff --git a/src/components/auth/ExternalLoginForm.tsx b/src/components/auth/ExternalLoginForm.tsx new file mode 100644 index 0000000..0e55acf --- /dev/null +++ b/src/components/auth/ExternalLoginForm.tsx @@ -0,0 +1,35 @@ +import { useState } from 'react' +//import { supabase } from '@/lib/supabase' +import { Input } from '../ui/Input' +import { SubmitButton } from '../ui/SubmitButton' + +export function ExternalLoginForm() { + const [email, setEmail] = useState('') + const [password, setPassword] = useState('') + + const submit = async () => { + /*await supabase.auth.signInWithPassword({ + email, + password, + })*/ + } + + return ( +
{ + e.preventDefault() + submit() + }} + > + + + + + ) +} diff --git a/src/components/auth/InternalLoginForm.tsx b/src/components/auth/InternalLoginForm.tsx new file mode 100644 index 0000000..b2a7f70 --- /dev/null +++ b/src/components/auth/InternalLoginForm.tsx @@ -0,0 +1,35 @@ +import { useState } from 'react' +//import { supabase } from '@/lib/supabase' +import { Input } from '../ui/Input' +import { SubmitButton } from '../ui/SubmitButton' + +export function InternalLoginForm() { + const [clave, setClave] = useState('') + const [password, setPassword] = useState('') + + const submit = async () => { + /*await supabase.auth.signInWithPassword({ + email: `${clave}@ulsa.mx`, + password, + })*/ + } + + return ( +
{ + e.preventDefault() + submit() + }} + > + + + + + ) +} diff --git a/src/components/auth/LoginCard.tsx b/src/components/auth/LoginCard.tsx new file mode 100644 index 0000000..107dbef --- /dev/null +++ b/src/components/auth/LoginCard.tsx @@ -0,0 +1,27 @@ +import { useState } from 'react' +import { LoginTabs } from './LoginTabs.tsx' +import { InternalLoginForm } from './InternalLoginForm.tsx' +import { ExternalLoginForm } from './ExternalLoginForm.tsx' + +export function LoginCard() { + const [type, setType] = useState<'internal' | 'external'>('internal') + + return ( +
+

+ Iniciar sesión +

+

+ Accede al Sistema de Planes de Estudio +

+ + + + {type === 'internal' ? ( + + ) : ( + + )} +
+ ) +} diff --git a/src/components/auth/LoginTabs.tsx b/src/components/auth/LoginTabs.tsx new file mode 100644 index 0000000..1b8a9f1 --- /dev/null +++ b/src/components/auth/LoginTabs.tsx @@ -0,0 +1,28 @@ +interface Props { + value: 'internal' | 'external' + onChange: (v: 'internal' | 'external') => void +} + +export function LoginTabs({ value, onChange }: Props) { + return ( +
+ {[ + { key: 'internal', label: 'Interno' }, + { key: 'external', label: 'Externo' }, + ].map(tab => ( + + ))} +
+ ) +} diff --git a/src/components/ui/Input.tsx b/src/components/ui/Input.tsx new file mode 100644 index 0000000..17ceefa --- /dev/null +++ b/src/components/ui/Input.tsx @@ -0,0 +1,28 @@ +interface InputProps { + label: string + value: string + onChange: (value: string) => void + type?: string +} + +export function Input({ + label, + value, + onChange, + type = 'text', +}: InputProps) { + return ( +
+ + onChange(e.target.value)} + className="w-full rounded-lg border border-gray-300 px-3 py-2 + focus:outline-none focus:ring-2 focus:ring-[#7b0f1d]" + /> +
+ ) +} diff --git a/src/components/ui/SubmitButton.tsx b/src/components/ui/SubmitButton.tsx new file mode 100644 index 0000000..805b8b4 --- /dev/null +++ b/src/components/ui/SubmitButton.tsx @@ -0,0 +1,15 @@ +interface Props { + text?: string +} + +export function SubmitButton({ text = 'Iniciar sesión' }: Props) { + return ( + + ) +} diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.ts index cd2c3d8..e686f94 100644 --- a/src/routeTree.gen.ts +++ b/src/routeTree.gen.ts @@ -9,10 +9,16 @@ // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. import { Route as rootRouteImport } from './routes/__root' +import { Route as LoginRouteImport } from './routes/login' import { Route as DashboardRouteImport } from './routes/dashboard' import { Route as IndexRouteImport } from './routes/index' import { Route as DemoTanstackQueryRouteImport } from './routes/demo/tanstack-query' +const LoginRoute = LoginRouteImport.update({ + id: '/login', + path: '/login', + getParentRoute: () => rootRouteImport, +} as any) const DashboardRoute = DashboardRouteImport.update({ id: '/dashboard', path: '/dashboard', @@ -32,35 +38,46 @@ const DemoTanstackQueryRoute = DemoTanstackQueryRouteImport.update({ export interface FileRoutesByFullPath { '/': typeof IndexRoute '/dashboard': typeof DashboardRoute + '/login': typeof LoginRoute '/demo/tanstack-query': typeof DemoTanstackQueryRoute } export interface FileRoutesByTo { '/': typeof IndexRoute '/dashboard': typeof DashboardRoute + '/login': typeof LoginRoute '/demo/tanstack-query': typeof DemoTanstackQueryRoute } export interface FileRoutesById { __root__: typeof rootRouteImport '/': typeof IndexRoute '/dashboard': typeof DashboardRoute + '/login': typeof LoginRoute '/demo/tanstack-query': typeof DemoTanstackQueryRoute } export interface FileRouteTypes { fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/dashboard' | '/demo/tanstack-query' + fullPaths: '/' | '/dashboard' | '/login' | '/demo/tanstack-query' fileRoutesByTo: FileRoutesByTo - to: '/' | '/dashboard' | '/demo/tanstack-query' - id: '__root__' | '/' | '/dashboard' | '/demo/tanstack-query' + to: '/' | '/dashboard' | '/login' | '/demo/tanstack-query' + id: '__root__' | '/' | '/dashboard' | '/login' | '/demo/tanstack-query' fileRoutesById: FileRoutesById } export interface RootRouteChildren { IndexRoute: typeof IndexRoute DashboardRoute: typeof DashboardRoute + LoginRoute: typeof LoginRoute DemoTanstackQueryRoute: typeof DemoTanstackQueryRoute } declare module '@tanstack/react-router' { interface FileRoutesByPath { + '/login': { + id: '/login' + path: '/login' + fullPath: '/login' + preLoaderRoute: typeof LoginRouteImport + parentRoute: typeof rootRouteImport + } '/dashboard': { id: '/dashboard' path: '/dashboard' @@ -88,6 +105,7 @@ declare module '@tanstack/react-router' { const rootRouteChildren: RootRouteChildren = { IndexRoute: IndexRoute, DashboardRoute: DashboardRoute, + LoginRoute: LoginRoute, DemoTanstackQueryRoute: DemoTanstackQueryRoute, } export const routeTree = rootRouteImport diff --git a/src/routes/login.tsx b/src/routes/login.tsx new file mode 100644 index 0000000..aad87c1 --- /dev/null +++ b/src/routes/login.tsx @@ -0,0 +1,14 @@ +import { createFileRoute } from '@tanstack/react-router' +import { LoginCard } from '@/components/auth/LoginCard' + +export const Route = createFileRoute('/login')({ + component: LoginPage, +}) + +function LoginPage() { + return ( +
+ +
+ ) +}