import { CustomType } from "@prismicio/types-internal/lib/customtypes"; import { CustomTypeFormat } from "@slicemachine/manager"; import { useState } from "react"; import { MdOutlineDelete } from "react-icons/md"; import { Close, Flex, Heading, Text, useThemeUI } from "theme-ui"; import { deleteCustomType } from "@/features/customTypes/actions/deleteCustomType"; import { CUSTOM_TYPES_MESSAGES } from "@/features/customTypes/customTypesMessages"; import { Button } from "@/legacy/components/Button"; import { Card } from "@/legacy/components/Card"; import SliceMachineModal from "@/legacy/components/SliceMachineModal"; import useSliceMachineActions from "@/modules/useSliceMachineActions"; type DeleteCTModalProps = { customType: CustomType; format: CustomTypeFormat; onClose: (didDelete?: boolean) => void; onDeleteCustomTypeSuccess: () => void; }; export const DeleteCustomTypeModal: React.FunctionComponent< DeleteCTModalProps > = ({ customType, format, onClose, onDeleteCustomTypeSuccess }) => { const customTypesMessages = CUSTOM_TYPES_MESSAGES[format]; const [isDeleting, setIsDeleting] = useState(false); const { deleteCustomTypeSuccess } = useSliceMachineActions(); const onConfirm = async () => { setIsDeleting(true); await deleteCustomType({ customType, onSuccess: () => deleteCustomTypeSuccess(customType.id), }); onDeleteCustomTypeSuccess(); }; const { theme } = useThemeUI(); return ( onClose()} > `1px solid ${String(t.colors?.borders)}`, }} > Delete{" "} {customTypesMessages.name({ start: false, plural: false })} onClose()} /> } Footer={() => ( `1px solid ${String(t.colors?.darkBorders)}`, backgroundColor: "gray", }} >