From 1bf7f8bc6911ad2ebdf996416b46f306a4be1f63 Mon Sep 17 00:00:00 2001 From: johnnadeluy Date: Wed, 18 Dec 2024 11:10:24 +0100 Subject: [PATCH] Destructure props and remove unused props --- .../resources/lib/types/partTypes/table.ts | 2 - src/main/resources/react4xp/table/Table.tsx | 70 ++++++++++++------- src/main/resources/site/parts/table/table.ts | 7 +- 3 files changed, 45 insertions(+), 34 deletions(-) diff --git a/src/main/resources/lib/types/partTypes/table.ts b/src/main/resources/lib/types/partTypes/table.ts index 694fed456..2ce90a082 100644 --- a/src/main/resources/lib/types/partTypes/table.ts +++ b/src/main/resources/lib/types/partTypes/table.ts @@ -6,7 +6,6 @@ export interface TableProps { downloadTableLabel: string downloadTableTitle: object downloadTableOptions: DropdownItems - displayName: string table: Partial & { language: string | undefined } @@ -14,7 +13,6 @@ export interface TableProps { standardSymbol: TableStandardSymbolLink | undefined sources: SourceList sourceLabel: string - iconUrl: string showPreviewDraft: boolean paramShowDraft: boolean draftExist: boolean | undefined diff --git a/src/main/resources/react4xp/table/Table.tsx b/src/main/resources/react4xp/table/Table.tsx index d57f1ab33..264149d60 100644 --- a/src/main/resources/react4xp/table/Table.tsx +++ b/src/main/resources/react4xp/table/Table.tsx @@ -24,12 +24,30 @@ declare global { } function Table(props: TableProps) { - const { useNewTableExport, table } = props - - const [currentTable, setCurrentTable] = useState(props.paramShowDraft && props.draftExist ? props.tableDraft : table) - const [fetchUnPublished, setFetchUnPublished] = useState(props.paramShowDraft) - const showPreviewToggle = - props.showPreviewDraft && (!props.pageTypeStatistic || (props.paramShowDraft && props.pageTypeStatistic)) + const { + downloadTableLabel, + downloadTableTitle, + downloadTableOptions, + table, + tableDraft, + standardSymbol, + sources, + sourceLabel, + showPreviewDraft, + paramShowDraft, + draftExist, + pageTypeStatistic, + sourceListTables, + sourceTableLabel, + statBankWebUrl, + hiddenTitle, + checkIsOverflowing, + useNewTableExport, + } = props + + const [currentTable, setCurrentTable] = useState(paramShowDraft && draftExist ? tableDraft : table) + const [fetchUnPublished, setFetchUnPublished] = useState(paramShowDraft) + const showPreviewToggle = showPreviewDraft && (!pageTypeStatistic || (paramShowDraft && pageTypeStatistic)) const tableWrapperRef = useRef(null) const tableRef = useRef(null) @@ -58,7 +76,7 @@ function Table(props: TableProps) { } function addDownloadTableDropdown(mobile: boolean) { - if (props.downloadTableLabel && props.downloadTableTitle && props.downloadTableOptions) { + if (downloadTableLabel && downloadTableTitle && downloadTableOptions) { const downloadTable = (item: { id: string }) => { if (item.id === 'downloadTableAsCSV') downloadTableAsCSV() if (item.id === 'downloadTableAsXLSX') downloadTableAsExcel() @@ -67,9 +85,9 @@ function Table(props: TableProps) { return (
@@ -137,7 +155,7 @@ function Table(props: TableProps) { className={tableClass} caption={addCaption()} dataNoteRefs={currentTable.caption?.noterefs} - checkIsOverflowing={props.checkIsOverflowing} + checkIsOverflowing={checkIsOverflowing} > {currentTable.thead?.map((t, index) => ( @@ -336,10 +354,10 @@ function Table(props: TableProps) { } function addStandardSymbols() { - if (props.standardSymbol && props.standardSymbol.href && props.standardSymbol.text) { + if (standardSymbol && standardSymbol.href && standardSymbol.text) { return ( - - {props.standardSymbol.text} + + {standardSymbol.text} ) } @@ -347,7 +365,7 @@ function Table(props: TableProps) { } function addPreviewButton() { - if (showPreviewToggle && !props.pageTypeStatistic) { + if (showPreviewToggle && !pageTypeStatistic) { return (