Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mejores mensajes de error en el signup #38

Merged
merged 7 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.fixAll": "explicit"
}
},
"standard.enable": false
}
6 changes: 5 additions & 1 deletion src/components/signup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BadRequestError } from "@/types/badRequestError.schema";
import { useSetAtom } from "jotai";
import { sendSignUpAtom } from "./client";
import { useState } from "react";
import { useEffect, useState } from "react";
import { Alert } from "../alert";
import { useRouter } from "next/router";
import { Button } from "../button";
Expand All @@ -11,6 +11,10 @@ export default function SignUp(): JSX.Element {
const sendSignUp = useSetAtom(sendSignUpAtom);
const router = useRouter();

useEffect(() => {
console.log(error);
}, [error]);
Janque marked this conversation as resolved.
Show resolved Hide resolved

async function handleSubmit(
event: React.FormEvent<HTMLFormElement>,
): Promise<void> {
Expand Down
6 changes: 4 additions & 2 deletions src/pages/api/user/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function createUserHandler(
if (password.length < 8) {
return res
.status(400)
.json({ message: "password length should be more than 8 characters" });
.json({ message: "La contraseña debe tener al menos 8 caractéres" });
Janque marked this conversation as resolved.
Show resolved Hide resolved
}
try {
const user = await prisma.userAuth.create({
Expand All @@ -52,7 +52,9 @@ async function createUserHandler(
} catch (e) {
if (e instanceof Prisma.PrismaClientKnownRequestError) {
if (e.code === "P2002") {
return res.status(400).json({ message: e.message });
Janque marked this conversation as resolved.
Show resolved Hide resolved
return res
.status(400)
.json({ message: "Ya existe una cuenta con ese email." });
}
return res.status(400).json({ message: e.message });
}
Expand Down
Loading
Loading