base con autenticacion, registro, modulo encuestas

This commit is contained in:
2025-06-16 12:02:22 -04:00
commit 475e0754df
411 changed files with 26265 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
import { z } from 'zod';
// Definir esquema de validación con Zod para el formulario
export const formSchema = z.object({
username: z
.string()
.min(5, { message: 'Usuario debe tener minimo 5 caracteres' }),
password: z
.string()
.min(6, { message: 'La contraseña debe tener al menos 6 caracteres' }),
});
export type UserFormValue = z.infer<typeof formSchema>;
// Esquema para el rol
const rolSchema = z.object({
id: z.number(),
rol: z.string(),
});
// Esquema para el usuario
const userSchema = z.object({
id: z.number(),
username: z.string(),
fullname: z.string(),
email: z.string().email(),
rol: z.array(rolSchema),
});
// Esquema para los tokens
export const tokensSchema = z.object({
access_token: z.string(),
access_expire_in: z.number(),
refresh_token: z.string(),
refresh_expire_in: z.number(),
});
// Esquema final para la respuesta del backend
export const loginResponseSchema = z.object({
message: z.string(),
user: userSchema,
tokens: tokensSchema,
});
// Tipo TypeScript basado en el esquema de Zod
export type LoginResponse = z.infer<typeof loginResponseSchema>;

View File

@@ -0,0 +1,14 @@
import { z } from 'zod';
import { tokensSchema } from './login';
// Esquema para el refresh token
export const refreshTokenSchema = z.object({
token: z.string(),
});
export type RefreshTokenValue = z.infer<typeof refreshTokenSchema>;
// Esquema final para la respuesta del backend
export const RefreshTokenResponseSchema = z.object({
tokens: tokensSchema,
});

View File

@@ -0,0 +1,35 @@
import { z } from 'zod';
// Definir esquema de validación con Zod para el formulario
export const createUser = z.object({
username: z.string().min(5, { message: "Debe de tener 5 o más caracteres" }),
password: z.string().min(8, { message: "Debe de tener 8 o más caracteres" }),
email: z.string().email({ message: "Correo no válido" }),
fullname: z.string(),
phone: z.string(),
state: z.number(),
municipality: z.number(),
parish: z.number(),
confirmPassword: z.string(),
})
.refine((data) => data.password === data.confirmPassword, {
message: 'La contraseña no coincide',
path: ['confirmPassword'],
})
export type createUserValue = z.infer<typeof createUser>;
export const user = z.object({
id: z.number().optional(),
username: z.string(),
email: z.string(),
fullname: z.string(),
phone: z.string().nullable(),
isActive: z.boolean(),
role: z.string()
});
export const UsersMutate = z.object({
message: z.string(),
data: user,
})