add new pages
This commit is contained in:
@@ -8,6 +8,8 @@ import {
|
|||||||
export default [
|
export default [
|
||||||
layout('routes/layout.tsx', [
|
layout('routes/layout.tsx', [
|
||||||
index('routes/index.tsx'),
|
index('routes/index.tsx'),
|
||||||
|
route('/signup', 'routes/signup.tsx'),
|
||||||
|
route('/forgot', 'routes/forgot.tsx'),
|
||||||
route('/deny', 'routes/deny.tsx')
|
route('/deny', 'routes/deny.tsx')
|
||||||
]),
|
]),
|
||||||
route('/authorize', 'routes/authorize.ts'),
|
route('/authorize', 'routes/authorize.ts'),
|
||||||
|
|||||||
110
id.saladeaula.digital/client/app/routes/forgot.tsx
Normal file
110
id.saladeaula.digital/client/app/routes/forgot.tsx
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
import type { Route } from './+types'
|
||||||
|
|
||||||
|
import { Link } from 'react-router'
|
||||||
|
|
||||||
|
import logo from '@/components/logo.svg'
|
||||||
|
import { Button } from '@/components/ui/button'
|
||||||
|
import {
|
||||||
|
Form,
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormItem,
|
||||||
|
FormLabel,
|
||||||
|
FormMessage
|
||||||
|
} from '@/components/ui/form'
|
||||||
|
import { Input } from '@/components/ui/input'
|
||||||
|
import { isValidCPF } from '@brazilian-utils/brazilian-utils'
|
||||||
|
import { zodResolver } from '@hookform/resolvers/zod'
|
||||||
|
import { useForm } from 'react-hook-form'
|
||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
const schema = z.object({
|
||||||
|
username: z
|
||||||
|
.string()
|
||||||
|
.nonempty('Digite um Email ou CPF')
|
||||||
|
.refine((val) => {
|
||||||
|
const onlyDigits = val.replace(/\D/g, '')
|
||||||
|
|
||||||
|
return onlyDigits.length === 11
|
||||||
|
? isValidCPF(val)
|
||||||
|
: z.string().email().safeParse(val).success
|
||||||
|
}, 'Deve ser um Email ou CPF válido')
|
||||||
|
})
|
||||||
|
|
||||||
|
type Schema = z.infer<typeof schema>
|
||||||
|
|
||||||
|
export function meta({}: Route.MetaArgs) {
|
||||||
|
return [{ title: 'Redefinir senha · EDUSEG®' }]
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Forgot({}: Route.ComponentProps) {
|
||||||
|
const form = useForm({
|
||||||
|
resolver: zodResolver(schema)
|
||||||
|
})
|
||||||
|
const { control, handleSubmit, formState } = form
|
||||||
|
|
||||||
|
const onSubmit = async (data: Schema) => {
|
||||||
|
console.log(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="w-full max-w-xs grid gap-6">
|
||||||
|
<div className="flex justify-center">
|
||||||
|
<div className="border border-white/15 bg-white/5 px-2.5 py-3 rounded-xl">
|
||||||
|
<img src={logo} alt="EDUSEG®" className="block size-12" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="text-center space-y-1.5">
|
||||||
|
<h1 className="text-2xl font-semibold font-display text-balance">
|
||||||
|
Redefinir senha
|
||||||
|
</h1>
|
||||||
|
<p className="text-white/50 text-sm">
|
||||||
|
Digite seu email e lhe enviaremos um email com as instruções para
|
||||||
|
redefinir sua senha.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Form {...form}>
|
||||||
|
<form onSubmit={handleSubmit(onSubmit)} className="grid gap-6">
|
||||||
|
<FormField
|
||||||
|
control={control}
|
||||||
|
name="username"
|
||||||
|
defaultValue=""
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Email ou CPF</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
autoFocus={true}
|
||||||
|
placeholder="seu@email.com"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
className="w-full bg-lime-400 cursor-pointer"
|
||||||
|
disabled={formState.isSubmitting}
|
||||||
|
>
|
||||||
|
Enviar instruções
|
||||||
|
</Button>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
|
|
||||||
|
<p className="text-white/50 text-xs text-center">
|
||||||
|
Lembrou da senha?{' '}
|
||||||
|
<Link to="/" className="underline hover:no-underline">
|
||||||
|
Faça login
|
||||||
|
</Link>
|
||||||
|
.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -13,21 +13,20 @@ import { zodResolver } from '@hookform/resolvers/zod'
|
|||||||
import { Loader2Icon } from 'lucide-react'
|
import { Loader2Icon } from 'lucide-react'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { useForm } from 'react-hook-form'
|
import { useForm } from 'react-hook-form'
|
||||||
import { redirect, useFetcher } from 'react-router'
|
import { Link, redirect, useFetcher } from 'react-router'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
import logo from '@/components/logo.svg'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { Checkbox } from '@/components/ui/checkbox'
|
import { Checkbox } from '@/components/ui/checkbox'
|
||||||
import { Input } from '@/components/ui/input'
|
import { Input } from '@/components/ui/input'
|
||||||
import { Label } from '@/components/ui/label'
|
import { Label } from '@/components/ui/label'
|
||||||
import * as httpStatus from '@/lib/http-status'
|
import * as httpStatus from '@/lib/http-status'
|
||||||
|
|
||||||
import logo from '@/components/logo.svg'
|
|
||||||
|
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
username: z
|
username: z
|
||||||
.string()
|
.string()
|
||||||
.nonempty('Digite um Email ou CPF')
|
.nonempty('Digite seu Email ou CPF')
|
||||||
.refine((val) => {
|
.refine((val) => {
|
||||||
const onlyDigits = val.replace(/\D/g, '')
|
const onlyDigits = val.replace(/\D/g, '')
|
||||||
|
|
||||||
@@ -35,7 +34,7 @@ const schema = z.object({
|
|||||||
? isValidCPF(val)
|
? isValidCPF(val)
|
||||||
: z.string().email().safeParse(val).success
|
: z.string().email().safeParse(val).success
|
||||||
}, 'Deve ser um Email ou CPF válido'),
|
}, 'Deve ser um Email ou CPF válido'),
|
||||||
password: z.string().nonempty('Digite uma senha')
|
password: z.string().nonempty('Digite sua senha')
|
||||||
})
|
})
|
||||||
|
|
||||||
type Schema = z.infer<typeof schema>
|
type Schema = z.infer<typeof schema>
|
||||||
@@ -46,7 +45,6 @@ export function meta({}: Route.MetaArgs) {
|
|||||||
|
|
||||||
export async function loader({ request }: Route.ActionArgs) {
|
export async function loader({ request }: Route.ActionArgs) {
|
||||||
const url = new URL(request.url)
|
const url = new URL(request.url)
|
||||||
|
|
||||||
if (!url.searchParams.has('client_id')) {
|
if (!url.searchParams.has('client_id')) {
|
||||||
return redirect('//scorm.eduseg.workers.dev/')
|
return redirect('//scorm.eduseg.workers.dev/')
|
||||||
}
|
}
|
||||||
@@ -92,8 +90,7 @@ export default function Index({}: Route.ComponentProps) {
|
|||||||
const fetcher = useFetcher()
|
const fetcher = useFetcher()
|
||||||
|
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
resolver: zodResolver(schema),
|
resolver: zodResolver(schema)
|
||||||
defaultValues: { username: '', password: '' }
|
|
||||||
})
|
})
|
||||||
const { control, handleSubmit, formState, setError } = form
|
const { control, handleSubmit, formState, setError } = form
|
||||||
|
|
||||||
@@ -130,77 +127,88 @@ export default function Index({}: Route.ComponentProps) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form onSubmit={handleSubmit(onSubmit)}>
|
<form onSubmit={handleSubmit(onSubmit)} className="grid gap-6">
|
||||||
<div className="grid gap-6">
|
<div className="text-center space-y-1.5">
|
||||||
<div className="text-center space-y-1.5">
|
<h1 className="text-2xl font-semibold font-display text-balance">
|
||||||
<h1 className="text-2xl font-semibold font-display text-balance">
|
|
||||||
Faça login
|
|
||||||
</h1>
|
|
||||||
<p className="text-white/50 text-sm">
|
|
||||||
Não tem uma conta?{' '}
|
|
||||||
<a href="#" className="font-medium text-white">
|
|
||||||
Cadastre-se
|
|
||||||
</a>
|
|
||||||
.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={control}
|
|
||||||
name="username"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>Email ou CPF</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input autoFocus={true} {...field} />
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={control}
|
|
||||||
name="password"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<div className="flex">
|
|
||||||
<FormLabel>Senha</FormLabel>
|
|
||||||
<a
|
|
||||||
href="#"
|
|
||||||
tabIndex={-1}
|
|
||||||
className="ml-auto text-sm underline-offset-4 hover:underline"
|
|
||||||
>
|
|
||||||
Esqueceu sua senha?
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<FormControl>
|
|
||||||
<Input type={show ? 'text' : 'password'} {...field} />
|
|
||||||
</FormControl>
|
|
||||||
<div className="flex items-center gap-3">
|
|
||||||
<Checkbox
|
|
||||||
id="showPassword"
|
|
||||||
onClick={() => setShow((x) => !x)}
|
|
||||||
tabIndex={-1}
|
|
||||||
/>
|
|
||||||
<Label htmlFor="showPassword">Mostrar senha</Label>
|
|
||||||
</div>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
className="w-full bg-lime-400 cursor-pointer"
|
|
||||||
disabled={formState.isSubmitting}
|
|
||||||
>
|
|
||||||
{formState.isSubmitting && (
|
|
||||||
<Loader2Icon className="animate-spin" />
|
|
||||||
)}
|
|
||||||
Entrar
|
Entrar
|
||||||
</Button>
|
</h1>
|
||||||
|
<p className="text-white/50 text-sm">
|
||||||
|
Não tem uma senha?{' '}
|
||||||
|
<Link
|
||||||
|
to="/signup"
|
||||||
|
className="font-medium text-white hover:underline"
|
||||||
|
>
|
||||||
|
Criar senha
|
||||||
|
</Link>
|
||||||
|
.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
control={control}
|
||||||
|
name="username"
|
||||||
|
defaultValue=""
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Email ou CPF</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
autoFocus={true}
|
||||||
|
placeholder="seu@email.com"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
control={control}
|
||||||
|
name="password"
|
||||||
|
defaultValue=""
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<div className="flex">
|
||||||
|
<FormLabel>Senha</FormLabel>
|
||||||
|
<Link
|
||||||
|
to="/forgot"
|
||||||
|
tabIndex={-1}
|
||||||
|
className="ml-auto text-sm underline-offset-4 hover:underline"
|
||||||
|
>
|
||||||
|
Esqueceu sua senha?
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
type={show ? 'text' : 'password'}
|
||||||
|
placeholder="••••••••"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<Checkbox
|
||||||
|
id="showPassword"
|
||||||
|
onClick={() => setShow((x) => !x)}
|
||||||
|
tabIndex={-1}
|
||||||
|
/>
|
||||||
|
<Label htmlFor="showPassword">Mostrar senha</Label>
|
||||||
|
</div>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
className="w-full bg-lime-400 cursor-pointer"
|
||||||
|
disabled={formState.isSubmitting}
|
||||||
|
>
|
||||||
|
{formState.isSubmitting && (
|
||||||
|
<Loader2Icon className="animate-spin" />
|
||||||
|
)}
|
||||||
|
Entrar
|
||||||
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
|
|||||||
170
id.saladeaula.digital/client/app/routes/signup.tsx
Normal file
170
id.saladeaula.digital/client/app/routes/signup.tsx
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
import type { Route } from './+types'
|
||||||
|
|
||||||
|
import { useState } from 'react'
|
||||||
|
import { Link } from 'react-router'
|
||||||
|
|
||||||
|
import logo from '@/components/logo.svg'
|
||||||
|
import { Button } from '@/components/ui/button'
|
||||||
|
import { Checkbox } from '@/components/ui/checkbox'
|
||||||
|
import {
|
||||||
|
Form,
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormItem,
|
||||||
|
FormLabel,
|
||||||
|
FormMessage
|
||||||
|
} from '@/components/ui/form'
|
||||||
|
import { Input } from '@/components/ui/input'
|
||||||
|
import { Label } from '@/components/ui/label'
|
||||||
|
import { isValidCPF } from '@brazilian-utils/brazilian-utils'
|
||||||
|
import { zodResolver } from '@hookform/resolvers/zod'
|
||||||
|
import { useForm } from 'react-hook-form'
|
||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
const schema = z.object({
|
||||||
|
name: z.string().nonempty('Digite seu nome'),
|
||||||
|
email: z.email('Digite seu email'),
|
||||||
|
password: z.string().nonempty('Digite sua senha'),
|
||||||
|
cpf: z
|
||||||
|
.string()
|
||||||
|
.nonempty('Digite seu CPF')
|
||||||
|
.refine(isValidCPF, 'Deve ser um CPF válido')
|
||||||
|
})
|
||||||
|
|
||||||
|
type Schema = z.infer<typeof schema>
|
||||||
|
|
||||||
|
export function meta({}: Route.MetaArgs) {
|
||||||
|
return [{ title: 'Criar conta · EDUSEG®' }]
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Signup({}: Route.ComponentProps) {
|
||||||
|
const [show, setShow] = useState(false)
|
||||||
|
const form = useForm({
|
||||||
|
resolver: zodResolver(schema)
|
||||||
|
})
|
||||||
|
const { control, handleSubmit, formState } = form
|
||||||
|
|
||||||
|
const onSubmit = async (data: Schema) => {
|
||||||
|
console.log(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="w-full max-w-xs grid gap-6">
|
||||||
|
<div className="flex justify-center">
|
||||||
|
<div className="border border-white/15 bg-white/5 px-2.5 py-3 rounded-xl">
|
||||||
|
<img src={logo} alt="EDUSEG®" className="block size-12" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="text-center space-y-1.5">
|
||||||
|
<h1 className="text-2xl font-semibold font-display text-balance">
|
||||||
|
Criar conta
|
||||||
|
</h1>
|
||||||
|
<p className="text-white/50 text-sm">
|
||||||
|
Já tem uma conta?{' '}
|
||||||
|
<Link to="/" className="font-medium text-white hover:underline">
|
||||||
|
Faça login
|
||||||
|
</Link>
|
||||||
|
.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Form {...form}>
|
||||||
|
<form onSubmit={handleSubmit(onSubmit)} className="grid gap-6">
|
||||||
|
<FormField
|
||||||
|
control={control}
|
||||||
|
name="name"
|
||||||
|
defaultValue=""
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Nome</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input autoFocus={true} placeholder="Seu nome" {...field} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
control={control}
|
||||||
|
name="email"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Email</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input placeholder="seu@email.com" {...field} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
control={control}
|
||||||
|
name="cpf"
|
||||||
|
defaultValue=""
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>CPF</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input placeholder="___.___.___-__" {...field} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
control={control}
|
||||||
|
name="password"
|
||||||
|
defaultValue=""
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Senha</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
type={show ? 'text' : 'password'}
|
||||||
|
placeholder="••••••••"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<Checkbox
|
||||||
|
id="showPassword"
|
||||||
|
onClick={() => setShow((x) => !x)}
|
||||||
|
tabIndex={-1}
|
||||||
|
/>
|
||||||
|
<Label htmlFor="showPassword">Mostrar senha</Label>
|
||||||
|
</div>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
className="w-full bg-lime-400 cursor-pointer"
|
||||||
|
disabled={formState.isSubmitting}
|
||||||
|
>
|
||||||
|
Criar conta
|
||||||
|
</Button>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
|
|
||||||
|
<p className="text-white/50 text-xs text-center">
|
||||||
|
Ao fazer login, você concorda com nossa{' '}
|
||||||
|
<a
|
||||||
|
href="//eduseg.com.br/politica"
|
||||||
|
target="_blank"
|
||||||
|
className="underline hover:no-underline"
|
||||||
|
>
|
||||||
|
política de privacidade
|
||||||
|
</a>
|
||||||
|
.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user