From 873fb31bfe0c3a58c1445e8905b33a794b0a8e1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez?= Date: Thu, 1 Feb 2024 14:07:34 +0100 Subject: [PATCH] fixes updating description of a project --- app/layout/project/sidebar/header/title/index.tsx | 6 ++++-- app/layout/project/sidebar/project/header/index.tsx | 10 ++++------ app/layout/project/sidebar/scenario/header/index.tsx | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/layout/project/sidebar/header/title/index.tsx b/app/layout/project/sidebar/header/title/index.tsx index 45f07b409a..71e5e00e75 100644 --- a/app/layout/project/sidebar/header/title/index.tsx +++ b/app/layout/project/sidebar/header/title/index.tsx @@ -26,7 +26,9 @@ const EditableTitle = ({ title: string; description?: string; className?: HTMLAttributes['className']; - onEditTitle: (newName: string) => void; + onEditTitle: ( + newName: Parameters>['onSubmit']>[0] + ) => void; }): JSX.Element => { const { query } = useRouter(); const { pid } = query as { pid: string }; @@ -40,7 +42,7 @@ const EditableTitle = ({ const handleSubmit = useCallback( (data: Parameters>['onSubmit']>[0]) => { titleInputRef.current?.blur(); - onEditTitle(data.name); + onEditTitle(data); setEditting(false); }, [onEditTitle, titleInputRef] diff --git a/app/layout/project/sidebar/project/header/index.tsx b/app/layout/project/sidebar/project/header/index.tsx index 074c1f2920..07d9aac102 100644 --- a/app/layout/project/sidebar/project/header/index.tsx +++ b/app/layout/project/sidebar/project/header/index.tsx @@ -25,14 +25,12 @@ const InventoryProjectHeader = (): JSX.Element => { }, }); - const onEditProjectName = useCallback( - (newName: Parameters['onEditTitle']>[0]) => { + const onEditInfo = useCallback( + (data: Parameters['onEditTitle']>[0]) => { saveProjectMutation.mutate( { id: pid, - data: { - name: newName, - }, + data, }, { onSuccess: async () => { @@ -47,7 +45,7 @@ const InventoryProjectHeader = (): JSX.Element => { return (
- + <Title title={name} description={description} onEditTitle={onEditInfo} /> <div className="mt-4 flex items-center space-x-5"> <Contributors /> <ProjectButton /> diff --git a/app/layout/project/sidebar/scenario/header/index.tsx b/app/layout/project/sidebar/scenario/header/index.tsx index 9837026327..f35bf0697d 100644 --- a/app/layout/project/sidebar/scenario/header/index.tsx +++ b/app/layout/project/sidebar/scenario/header/index.tsx @@ -20,11 +20,11 @@ export const ScenarioHeader = (): JSX.Element => { const { name, description } = scenarioQuery.data; const onEditScenarioName = useCallback( - (newName: Parameters<ComponentProps<typeof Title>['onEditTitle']>[0]) => { + (data: Parameters<ComponentProps<typeof Title>['onEditTitle']>[0]) => { saveScenarioMutation.mutate({ id: sid, data: { - name: newName, + name: data.name, }, }); },