From bcbffad32d1d535e85d7ea052f558afe89428afb Mon Sep 17 00:00:00 2001 From: QkoSad Date: Sat, 28 Sep 2024 20:16:02 +0300 Subject: [PATCH] fixed website breaking the server --- client/src/TODO.txt | 5 ----- client/src/components/profile-forms/ProfileForm.tsx | 4 ++-- server/routers/api/profile.ts | 1 + 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/client/src/TODO.txt b/client/src/TODO.txt index deaad65..8b13789 100644 --- a/client/src/TODO.txt +++ b/client/src/TODO.txt @@ -1,6 +1 @@ -1. When creating profile in the Profile form need to be added validation for the -email because if the email is not email it gets sent to the server and crashes -Fix all the form data apis, formData -Extract the inpudate component from addeducation -maybe fix that addeducation diff --git a/client/src/components/profile-forms/ProfileForm.tsx b/client/src/components/profile-forms/ProfileForm.tsx index 7bda2d2..4b92abe 100755 --- a/client/src/components/profile-forms/ProfileForm.tsx +++ b/client/src/components/profile-forms/ProfileForm.tsx @@ -93,7 +93,7 @@ const ProfileForm = () => { const onSubmit = async (e: React.FormEvent) => { const editing = profile ? true : false; e.preventDefault(); - const form = new FormData(); + const form = new FormData(e.currentTarget); const status = form.get("status") as string; if (facebook?.length > 100) { dispatch(createAlert("Facebook link is longer 100 characters", "danger")); @@ -113,7 +113,7 @@ const ProfileForm = () => { dispatch(createAlert("Skills is required", "danger")); } else if (status?.length === 0) { dispatch(createAlert("Status is required", "danger")); - } else if (location?.length === 0) { + } else if (location?.length > 100) { dispatch(createAlert("Location is longer 100 characters", "danger")); } else if (githubusername?.length > 50) { dispatch( diff --git a/server/routers/api/profile.ts b/server/routers/api/profile.ts index 88fd535..baa04b0 100755 --- a/server/routers/api/profile.ts +++ b/server/routers/api/profile.ts @@ -47,6 +47,7 @@ router.post( auth, check("status", "Status is required").notEmpty(), check("skills", "Skills is required").notEmpty(), + check("website", "Not a valid website").isURL(), async (req, res) => { const errors = validationResult(req); if (!errors.isEmpty()) {