From f725ea5b156c1da3d77595c5372064e4354d8977 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Tue, 7 Mar 2023 22:21:50 +0530 Subject: [PATCH] fix: edit module mutation error (#394) --- apps/app/components/modules/modal.tsx | 15 ++++++--------- .../components/modules/select/select-status.tsx | 1 + .../app/components/modules/single-module-card.tsx | 14 ++++++-------- apps/app/components/ui/custom-search-select.tsx | 2 +- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/apps/app/components/modules/modal.tsx b/apps/app/components/modules/modal.tsx index 7acf81339..fcbd3f531 100644 --- a/apps/app/components/modules/modal.tsx +++ b/apps/app/components/modules/modal.tsx @@ -76,15 +76,12 @@ export const CreateUpdateModuleModal: React.FC = ({ isOpen, setIsOpen, da .then((res) => { mutate( MODULE_LIST(projectId as string), - (prevData) => { - const newData = prevData?.map((item) => { - if (item.id === res.id) { - return res; - } - return item; - }); - return newData; - }, + (prevData) => + prevData?.map((p) => { + if (p.id === res.id) return { ...p, ...payload }; + + return p; + }), false ); handleClose(); diff --git a/apps/app/components/modules/select/select-status.tsx b/apps/app/components/modules/select/select-status.tsx index 4b9ce65bb..f0723eb27 100644 --- a/apps/app/components/modules/select/select-status.tsx +++ b/apps/app/components/modules/select/select-status.tsx @@ -43,6 +43,7 @@ export const ModuleStatusSelect: React.FC = ({ control, error }) => ( } onChange={onChange} + noChevron > {MODULE_STATUS.map((status) => ( diff --git a/apps/app/components/modules/single-module-card.tsx b/apps/app/components/modules/single-module-card.tsx index c8b179ae5..eeb2628cb 100644 --- a/apps/app/components/modules/single-module-card.tsx +++ b/apps/app/components/modules/single-module-card.tsx @@ -175,9 +175,7 @@ export const SingleModuleCard: React.FC = ({ module, handleEditModule })
- + {truncateText(module.name, 75)} @@ -186,19 +184,19 @@ export const SingleModuleCard: React.FC = ({ module, handleEditModule })
- Start : + Start: {renderShortDateWithYearFormat(startDate)}
-
+
- End : + End: {renderShortDateWithYearFormat(endDate)}
- Lead : + Lead:
{module.lead_detail ? (
@@ -221,7 +219,7 @@ export const SingleModuleCard: React.FC = ({ module, handleEditModule })
- Members + Members:
{module.members_detail && module.members_detail.length > 0 ? ( diff --git a/apps/app/components/ui/custom-search-select.tsx b/apps/app/components/ui/custom-search-select.tsx index 8121405eb..a8b685642 100644 --- a/apps/app/components/ui/custom-search-select.tsx +++ b/apps/app/components/ui/custom-search-select.tsx @@ -29,7 +29,7 @@ type CustomSearchSelectProps = { export const CustomSearchSelect = ({ label, textAlignment, - height = "sm", + height = "md", value, onChange, options,