From 0dd336aec80318b08d21ff19516f644e4d63649a Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal Date: Wed, 6 Sep 2023 12:25:34 +0530 Subject: [PATCH 1/2] fix: don't render invalid dated issues --- .../gantt-chart/helpers/block-structure.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/web/components/gantt-chart/helpers/block-structure.tsx b/web/components/gantt-chart/helpers/block-structure.tsx index ab2475bdd..ea51c3b12 100644 --- a/web/components/gantt-chart/helpers/block-structure.tsx +++ b/web/components/gantt-chart/helpers/block-structure.tsx @@ -4,11 +4,13 @@ import { IGanttBlock } from "components/gantt-chart"; export const renderIssueBlocksStructure = (blocks: IIssue[]): IGanttBlock[] => blocks && blocks.length > 0 - ? blocks.map((block) => ({ - data: block, - id: block.id, - sort_order: block.sort_order, - start_date: new Date(block.start_date ?? ""), - target_date: new Date(block.target_date ?? ""), - })) + ? blocks + .filter((b) => new Date(b?.start_date ?? "") <= new Date(b?.target_date ?? "")) + .map((block) => ({ + data: block, + id: block.id, + sort_order: block.sort_order, + start_date: new Date(block.start_date ?? ""), + target_date: new Date(block.target_date ?? ""), + })) : []; From c5612ee7a37afb6b5daa26bbbbe3d17f741df290 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal Date: Wed, 6 Sep 2023 12:26:51 +0530 Subject: [PATCH 2/2] fix: don't render invalid dated cycles and modules --- web/components/cycles/gantt-chart/cycles-list-layout.tsx | 4 +++- web/components/modules/gantt-chart/modules-list-layout.tsx | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/web/components/cycles/gantt-chart/cycles-list-layout.tsx b/web/components/cycles/gantt-chart/cycles-list-layout.tsx index 9614ea447..41e7a5444 100644 --- a/web/components/cycles/gantt-chart/cycles-list-layout.tsx +++ b/web/components/cycles/gantt-chart/cycles-list-layout.tsx @@ -63,7 +63,9 @@ export const CyclesListGanttChartView: FC = ({ cycles, mutateCycles }) => const blockFormat = (blocks: ICycle[]) => blocks && blocks.length > 0 ? blocks - .filter((b) => b.start_date && b.end_date) + .filter( + (b) => b.start_date && b.end_date && new Date(b.start_date) <= new Date(b.end_date) + ) .map((block) => ({ data: block, id: block.id, diff --git a/web/components/modules/gantt-chart/modules-list-layout.tsx b/web/components/modules/gantt-chart/modules-list-layout.tsx index 08465ffa9..b8ebd0185 100644 --- a/web/components/modules/gantt-chart/modules-list-layout.tsx +++ b/web/components/modules/gantt-chart/modules-list-layout.tsx @@ -69,7 +69,10 @@ export const ModulesListGanttChartView: FC = ({ modules, mutateModules }) const blockFormat = (blocks: IModule[]) => blocks && blocks.length > 0 ? blocks - .filter((b) => b.start_date && b.target_date) + .filter( + (b) => + b.start_date && b.target_date && new Date(b.start_date) <= new Date(b.target_date) + ) .map((block) => ({ data: block, id: block.id,