From 6d23fc491232f692bcd39bd87729768420174936 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Tue, 26 Nov 2024 07:49:34 +0200 Subject: [PATCH] add coderabit suggetions --- .../lib/features/project/create-project-modal.tsx | 13 +++++++++++-- apps/web/locales/en.json | 2 +- apps/web/locales/es.json | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/web/lib/features/project/create-project-modal.tsx b/apps/web/lib/features/project/create-project-modal.tsx index 2440362e3..fd32a2c65 100644 --- a/apps/web/lib/features/project/create-project-modal.tsx +++ b/apps/web/lib/features/project/create-project-modal.tsx @@ -2,7 +2,7 @@ import { useOrganizationProjects } from '@/app/hooks'; import { IProject } from '@/app/interfaces'; import { Button, Card, InputField, Modal, Text } from 'lib/components'; import { useTranslations } from 'next-intl'; -import { useCallback, useState } from 'react'; +import { useCallback, useEffect, useState } from 'react'; interface ICreateProjectModalProps { open: boolean; @@ -24,15 +24,24 @@ export function CreateProjectModal(props: ICreateProjectModalProps) { const { createOrganizationProject, createOrganizationProjectLoading } = useOrganizationProjects(); const [name, setName] = useState(''); + // Cleanup + useEffect(() => { + return () => { + setName(''); + }; + }, []); + const handleCreateProject = useCallback(async () => { try { + if (name.trim() === '') { + return; + } const data = await createOrganizationProject({ name }); if (data) { onSuccess?.(data); } - setName(''); closeModal(); } catch (error) { console.error(error); diff --git a/apps/web/locales/en.json b/apps/web/locales/en.json index e50e358c8..f9b336cb5 100644 --- a/apps/web/locales/en.json +++ b/apps/web/locales/en.json @@ -268,7 +268,7 @@ "CLEAR_FILTER": "Clear Filter", "CLEAR": "Clear", "APPLY_FILTER": "Apply Filter", - "CREATE_NEW": "Crear nuevo" + "CREATE_NEW": "Create New" }, "hotkeys": { "HELP": "Help", diff --git a/apps/web/locales/es.json b/apps/web/locales/es.json index 2d44197b4..48a1fb500 100644 --- a/apps/web/locales/es.json +++ b/apps/web/locales/es.json @@ -268,7 +268,7 @@ "CLEAR_FILTER": "Borrar filtro", "CLEAR": "Borrar", "APPLY_FILTER": "Aplicar filtro", - "CREATE_NEW": "Create New" + "CREATE_NEW": "Crear nuevo" }, "hotkeys": { "HELP": "Ayuda",