fix: edit module mutation error (#394)

This commit is contained in:
Aaryan Khandelwal 2023-03-07 22:21:50 +05:30 committed by GitHub
parent cf94b92be2
commit f725ea5b15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 18 deletions

View File

@ -76,15 +76,12 @@ export const CreateUpdateModuleModal: React.FC<Props> = ({ isOpen, setIsOpen, da
.then((res) => { .then((res) => {
mutate<IModule[]>( mutate<IModule[]>(
MODULE_LIST(projectId as string), MODULE_LIST(projectId as string),
(prevData) => { (prevData) =>
const newData = prevData?.map((item) => { prevData?.map((p) => {
if (item.id === res.id) { if (p.id === res.id) return { ...p, ...payload };
return res;
} return p;
return item; }),
});
return newData;
},
false false
); );
handleClose(); handleClose();

View File

@ -43,6 +43,7 @@ export const ModuleStatusSelect: React.FC<Props> = ({ control, error }) => (
</div> </div>
} }
onChange={onChange} onChange={onChange}
noChevron
> >
{MODULE_STATUS.map((status) => ( {MODULE_STATUS.map((status) => (
<CustomSelect.Option key={status.value} value={status.value}> <CustomSelect.Option key={status.value} value={status.value}>

View File

@ -175,9 +175,7 @@ export const SingleModuleCard: React.FC<Props> = ({ module, handleEditModule })
<div className="flex h-full w-full flex-col items-start justify-between gap-6 p-5"> <div className="flex h-full w-full flex-col items-start justify-between gap-6 p-5">
<div className="flex w-full flex-col gap-5"> <div className="flex w-full flex-col gap-5">
<Tooltip tooltipContent={module.name} position="top-left"> <Tooltip tooltipContent={module.name} position="top-left">
<span <span className="break-all text-xl font-semibold text-black">
className="break-all text-xl font-semibold text-black"
>
<Link href={`/${workspaceSlug}/projects/${module.project}/modules/${module.id}`}> <Link href={`/${workspaceSlug}/projects/${module.project}/modules/${module.id}`}>
<a className="w-full">{truncateText(module.name, 75)}</a> <a className="w-full">{truncateText(module.name, 75)}</a>
</Link> </Link>
@ -186,19 +184,19 @@ export const SingleModuleCard: React.FC<Props> = ({ module, handleEditModule })
<div className="flex items-center gap-4"> <div className="flex items-center gap-4">
<div className="flex items-start gap-1 "> <div className="flex items-start gap-1 ">
<CalendarDaysIcon className="h-4 w-4 text-gray-900" /> <CalendarDaysIcon className="h-4 w-4 text-gray-900" />
<span className="text-gray-400">Start :</span> <span className="text-gray-400">Start:</span>
<span>{renderShortDateWithYearFormat(startDate)}</span> <span>{renderShortDateWithYearFormat(startDate)}</span>
</div> </div>
<div className="flex items-start gap-1 "> <div className="flex items-start gap-1">
<CalendarDaysIcon className="h-4 w-4 text-gray-900" /> <CalendarDaysIcon className="h-4 w-4 text-gray-900" />
<span className="text-gray-400">End :</span> <span className="text-gray-400">End:</span>
<span>{renderShortDateWithYearFormat(endDate)}</span> <span>{renderShortDateWithYearFormat(endDate)}</span>
</div> </div>
</div> </div>
<div className="flex items-center gap-6"> <div className="flex items-center gap-6">
<div className="flex items-center gap-1.5"> <div className="flex items-center gap-1.5">
<UserCircleIcon className="h-5 w-5 text-gray-400" /> <UserCircleIcon className="h-5 w-5 text-gray-400" />
<span>Lead : </span> <span>Lead:</span>
<div> <div>
{module.lead_detail ? ( {module.lead_detail ? (
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
@ -221,7 +219,7 @@ export const SingleModuleCard: React.FC<Props> = ({ module, handleEditModule })
</div> </div>
<div className="flex items-center gap-1.5"> <div className="flex items-center gap-1.5">
<UserGroupIcon className="h-5 w-5 text-gray-400" /> <UserGroupIcon className="h-5 w-5 text-gray-400" />
<span>Members</span> <span>Members:</span>
<div className="flex items-center gap-1 text-xs"> <div className="flex items-center gap-1 text-xs">
{module.members_detail && module.members_detail.length > 0 ? ( {module.members_detail && module.members_detail.length > 0 ? (
<AssigneesList users={module.members_detail} length={3} /> <AssigneesList users={module.members_detail} length={3} />

View File

@ -29,7 +29,7 @@ type CustomSearchSelectProps = {
export const CustomSearchSelect = ({ export const CustomSearchSelect = ({
label, label,
textAlignment, textAlignment,
height = "sm", height = "md",
value, value,
onChange, onChange,
options, options,