import { Button, Icon, Image, Table, TableBody, TableCell, TableHead, TableRow, Text, theme, } from "@prismicio/editor-ui"; import { type CustomType } from "@prismicio/types-internal/lib/customtypes"; import { type CustomTypeFormat } from "@slicemachine/manager"; import { useRouter } from "next/router"; import { type FC } from "react"; import { BlankSlate, BlankSlateActions, BlankSlateContent, BlankSlateDescription, BlankSlateImage, BlankSlateTitle, } from "@/components/BlankSlate"; import { CUSTOM_TYPES_MESSAGES } from "@/features/customTypes/customTypesMessages"; import { ReusableIcon } from "@/icons/ReusableIcon"; import { SingleIcon } from "@/icons/SingleIcon"; import { CUSTOM_TYPES_CONFIG } from "../customTypesConfig"; import { EditDropdown } from "../EditDropdown"; import { useCustomTypes } from "../useCustomTypes"; import { useCustomTypesAutoRevalidation } from "./useCustomTypesAutoRevalidation"; type CustomTypesTableProps = { format: CustomTypeFormat; isCreatingCustomType: boolean; openCreateCustomTypeModal: () => void; }; export const CustomTypesTable: FC = ({ format, isCreatingCustomType, openCreateCustomTypeModal, }) => { const router = useRouter(); const { customTypes, updateCustomTypes } = useCustomTypes(format); const sortedCustomTypes = customTypes.sort( (customType1: CustomType, customType2: CustomType) => { return customType1.id.localeCompare(customType2.id); }, ); const customTypesConfig = CUSTOM_TYPES_CONFIG[format]; const customTypesMessages = CUSTOM_TYPES_MESSAGES[format]; useCustomTypesAutoRevalidation(customTypes, format, updateCustomTypes); if (sortedCustomTypes.length === 0) { return ( {customTypesMessages.name({ start: true, plural: true })} {customTypesMessages.blankSlateDescription} ); } // The wrapping `
` prevents `` from growing vertically. return (
Label API ID Limit {sortedCustomTypes.map((customType: CustomType) => { const { repeatable, label, id } = customType; return ( { void router.push( CUSTOM_TYPES_CONFIG[format].getBuilderPagePathname(id), ); }} > {repeatable ? ( ) : ( )} {label} {id} {repeatable ? "Reusable" : "Single"} ); })}
); };