From 4bb353193000d17e4eb9d4f5ff60f20ac36881ef Mon Sep 17 00:00:00 2001 From: "jason.lam" Date: Tue, 6 May 2025 11:54:31 +0800 Subject: [PATCH] [editable search result] update custom render params --- .../RoughScheduleSetting/RoughScheduleSetting.tsx | 14 ++++++++++++++ .../SearchResults/EditableSearchResults.tsx | 11 ++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/components/RoughScheduleSetting/RoughScheduleSetting.tsx b/src/components/RoughScheduleSetting/RoughScheduleSetting.tsx index bb26b76..4e2d908 100644 --- a/src/components/RoughScheduleSetting/RoughScheduleSetting.tsx +++ b/src/components/RoughScheduleSetting/RoughScheduleSetting.tsx @@ -108,6 +108,20 @@ const RSSOverview: React.FC = ({ items }) => { label: t("Exclude Date"), type: 'multi-select', options: dayOptions, + renderCell: (item: ItemsResult) => { + console.log("[debug] render item", item) + const selectedValues = item.excludeDate as number[] ?? []; // Assuming excludeDate is an array of numbers + const selectedLabels = dayOptions + .filter(option => selectedValues.includes(option.value)) + .map(option => option.label) + .join(", "); // Join labels into a string + + return ( + handleEditClick(item.id as number)}> + {selectedLabels || "None"} {/* Display "None" if no days are selected */} + + ); + }, }, // { // name: "action", diff --git a/src/components/SearchResults/EditableSearchResults.tsx b/src/components/SearchResults/EditableSearchResults.tsx index f3a5e8a..07a7d8f 100644 --- a/src/components/SearchResults/EditableSearchResults.tsx +++ b/src/components/SearchResults/EditableSearchResults.tsx @@ -26,6 +26,7 @@ interface BaseColumn { label: string; type: string; options: T[]; + renderCell? : (T) => void; } interface ColumnWithAction extends BaseColumn { @@ -148,6 +149,7 @@ function EditableSearchResults({ case 'input': return ( handleInputChange(item.id as number, columnName, e.target.value)} @@ -167,9 +169,12 @@ function EditableSearchResults({ } })() ) : ( - handleEditClick(item.id as number)}> - {item[columnName] as string} - + column.renderCell ? + column.renderCell(item) + : + handleEditClick(item.id as number)}> + {item[columnName] as string} + )} );