diff --git a/components/Blocks/Table/index.tsx b/components/Blocks/Table/index.tsx index 1a84cae17..cb41f674e 100644 --- a/components/Blocks/Table/index.tsx +++ b/components/Blocks/Table/index.tsx @@ -14,9 +14,9 @@ import Table from "@/components/TempDesignSystem/Table" import styles from "./table.module.css" -import type { TableProps } from "@/types/components/blocks/table" +import type { TableBlockProps } from "@/types/components/blocks/table" -export default function TableBlock({ data }: TableProps) { +export default function TableBlock({ data }: TableBlockProps) { const { columns, rows, totalWidth } = data const initialPageSize = 5 const [pageSize, setPageSize] = useState(initialPageSize) diff --git a/components/TempDesignSystem/ScrollWrapper/index.tsx b/components/TempDesignSystem/ScrollWrapper/index.tsx index 1eb341f90..15b4bf845 100644 --- a/components/TempDesignSystem/ScrollWrapper/index.tsx +++ b/components/TempDesignSystem/ScrollWrapper/index.tsx @@ -12,7 +12,8 @@ export default function ScrollWrapper({ className, children, }: ScrollWrapperProps) { - const { containerRef, showLeftShadow, showRightShadow } = useScrollShadows() + const { containerRef, showLeftShadow, showRightShadow } = + useScrollShadows() const classNames = useMemo(() => { const cls = [styles.scrollWrapper, className] diff --git a/hooks/useScrollShadows.ts b/hooks/useScrollShadows.ts index 7073d110e..3fde382f1 100644 --- a/hooks/useScrollShadows.ts +++ b/hooks/useScrollShadows.ts @@ -1,7 +1,7 @@ import { useEffect, useRef, useState } from "react" -const useScrollShadows = () => { - const containerRef = useRef(null) +export default function useScrollShadows() { + const containerRef = useRef(null) const [showLeftShadow, setShowLeftShadow] = useState(false) const [showRightShadow, setShowRightShadow] = useState(false) @@ -32,5 +32,3 @@ const useScrollShadows = () => { return { containerRef, showLeftShadow, showRightShadow } } - -export default useScrollShadows diff --git a/server/routers/contentstack/schemas/blocks/table.ts b/server/routers/contentstack/schemas/blocks/table.ts index 5109d487b..fc694d71f 100644 --- a/server/routers/contentstack/schemas/blocks/table.ts +++ b/server/routers/contentstack/schemas/blocks/table.ts @@ -38,13 +38,12 @@ export const tableSchema = z.object({ width: data.column_widths[idx] || 0, })) - const rows = data.table.tableState.data.map((rowData) => { - const transformedRow: Record = {} - columns.forEach((header) => { - transformedRow[header.id] = rowData[header.id] || "" - }) - return transformedRow - }) + const rows = data.table.tableState.data.map((rowData) => + columns.reduce>((transformedRow, column) => { + transformedRow[column.id] = rowData[column.id] || "" + return transformedRow + }, {}) + ) return { columns, diff --git a/types/components/blocks/table.ts b/types/components/blocks/table.ts index ee7d961d0..9438f7d43 100644 --- a/types/components/blocks/table.ts +++ b/types/components/blocks/table.ts @@ -1,5 +1,5 @@ import type { TableData } from "@/types/trpc/routers/contentstack/blocks" -export interface TableProps { +export interface TableBlockProps { data: TableData }