fix(SW-216): Fixes after PR
This commit is contained in:
@@ -14,9 +14,9 @@ import Table from "@/components/TempDesignSystem/Table"
|
|||||||
|
|
||||||
import styles from "./table.module.css"
|
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 { columns, rows, totalWidth } = data
|
||||||
const initialPageSize = 5
|
const initialPageSize = 5
|
||||||
const [pageSize, setPageSize] = useState(initialPageSize)
|
const [pageSize, setPageSize] = useState(initialPageSize)
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ export default function ScrollWrapper({
|
|||||||
className,
|
className,
|
||||||
children,
|
children,
|
||||||
}: ScrollWrapperProps) {
|
}: ScrollWrapperProps) {
|
||||||
const { containerRef, showLeftShadow, showRightShadow } = useScrollShadows()
|
const { containerRef, showLeftShadow, showRightShadow } =
|
||||||
|
useScrollShadows<HTMLDivElement>()
|
||||||
|
|
||||||
const classNames = useMemo(() => {
|
const classNames = useMemo(() => {
|
||||||
const cls = [styles.scrollWrapper, className]
|
const cls = [styles.scrollWrapper, className]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useEffect, useRef, useState } from "react"
|
import { useEffect, useRef, useState } from "react"
|
||||||
|
|
||||||
const useScrollShadows = () => {
|
export default function useScrollShadows<T extends HTMLElement>() {
|
||||||
const containerRef = useRef<HTMLDivElement | null>(null)
|
const containerRef = useRef<T>(null)
|
||||||
const [showLeftShadow, setShowLeftShadow] = useState<boolean>(false)
|
const [showLeftShadow, setShowLeftShadow] = useState<boolean>(false)
|
||||||
const [showRightShadow, setShowRightShadow] = useState<boolean>(false)
|
const [showRightShadow, setShowRightShadow] = useState<boolean>(false)
|
||||||
|
|
||||||
@@ -32,5 +32,3 @@ const useScrollShadows = () => {
|
|||||||
|
|
||||||
return { containerRef, showLeftShadow, showRightShadow }
|
return { containerRef, showLeftShadow, showRightShadow }
|
||||||
}
|
}
|
||||||
|
|
||||||
export default useScrollShadows
|
|
||||||
|
|||||||
@@ -38,13 +38,12 @@ export const tableSchema = z.object({
|
|||||||
width: data.column_widths[idx] || 0,
|
width: data.column_widths[idx] || 0,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const rows = data.table.tableState.data.map((rowData) => {
|
const rows = data.table.tableState.data.map((rowData) =>
|
||||||
const transformedRow: Record<string, string> = {}
|
columns.reduce<Record<string, string>>((transformedRow, column) => {
|
||||||
columns.forEach((header) => {
|
transformedRow[column.id] = rowData[column.id] || ""
|
||||||
transformedRow[header.id] = rowData[header.id] || ""
|
return transformedRow
|
||||||
})
|
}, {})
|
||||||
return transformedRow
|
)
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
columns,
|
columns,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { TableData } from "@/types/trpc/routers/contentstack/blocks"
|
import type { TableData } from "@/types/trpc/routers/contentstack/blocks"
|
||||||
|
|
||||||
export interface TableProps {
|
export interface TableBlockProps {
|
||||||
data: TableData
|
data: TableData
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user