corregido errores de compilacion para next en web
This commit is contained in:
@@ -2,7 +2,36 @@
|
||||
import { safeFetchApi } from '@/lib';
|
||||
import { loginResponseSchema, UserFormValue } from '../schemas/login';
|
||||
|
||||
export const SignInAction = async (payload: UserFormValue) => {
|
||||
|
||||
|
||||
|
||||
type LoginActionSuccess = {
|
||||
message: string;
|
||||
user: {
|
||||
email: string;
|
||||
username: string;
|
||||
id: number;
|
||||
rol: Array<{ id: number; rol: string }>;
|
||||
fullname: string;
|
||||
};
|
||||
tokens: {
|
||||
access_token: string;
|
||||
access_expire_in: number;
|
||||
refresh_token: string;
|
||||
refresh_expire_in: number;
|
||||
};
|
||||
}
|
||||
|
||||
type LoginActionError = {
|
||||
type: 'API_ERROR' | 'VALIDATION_ERROR' | 'UNKNOWN_ERROR'; // **Asegúrate de que el tipo de `type` sea este aquí**
|
||||
message: string;
|
||||
details?: any;
|
||||
};
|
||||
|
||||
// Si SignInAction también puede devolver null, asegúralo en su tipo de retorno
|
||||
type LoginActionResult = LoginActionSuccess | LoginActionError | null;
|
||||
|
||||
export const SignInAction = async (payload: UserFormValue): Promise<LoginActionResult> => {
|
||||
const [error, data] = await safeFetchApi(
|
||||
loginResponseSchema,
|
||||
'/auth/sign-in',
|
||||
@@ -10,7 +39,11 @@ export const SignInAction = async (payload: UserFormValue) => {
|
||||
payload,
|
||||
);
|
||||
if (error) {
|
||||
return error;
|
||||
return {
|
||||
type: error.type as 'API_ERROR' | 'VALIDATION_ERROR' | 'UNKNOWN_ERROR',
|
||||
message: error.message,
|
||||
details: error.details
|
||||
};
|
||||
} else {
|
||||
return data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user