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,27 @@
'use server';
import { safeFetchApi } from '@/lib/fetch.api';
import { createUserValue, UsersMutate } from '../schemas/register';
export const registerUserAction = async (payload: createUserValue) => {
const { confirmPassword, ...payloadWithoutId } = payload;
const [error, data] = await safeFetchApi(
UsersMutate,
'/auth/sing-up',
'POST',
payloadWithoutId,
);
if (error) {
// console.error(error);
if (error.message === 'Username already exists') {
throw new Error('Ese usuario ya existe');
}
if (error.message === 'Email already exists') {
throw new Error('Ese correo ya está en uso');
}
throw new Error('Error al crear el usuario');
}
return payloadWithoutId;
};