import { useOnChange } from "@prismicio/editor-support/React"; import { Box, Dialog, DialogActionButton, DialogActions, DialogCancelButton, DialogContent, DialogHeader, Form, ScrollArea, Select, SelectItem, Text, } from "@prismicio/editor-ui"; import { type FC, useState } from "react"; import styles from "./ConvertLegacySliceButton.module.css"; import { DialogProps } from "./types"; export const ConvertLegacySliceMergeWithIdenticalDialog: FC = ({ isOpen, close, onSubmit, isLoading, identicalSlices, }) => { const defaultPath = identicalSlices[0]?.path ?? ""; const [path, setPath] = useState(defaultPath); const [error, setError] = useState(); useOnChange(isOpen, () => { if (!isOpen) { setPath(defaultPath); setError(undefined); } }); function handleValueChange(value: string) { setPath(value); if (!value) setError("Cannot be empty."); } function handleSubmit() { if (Boolean(error)) { return; } const [libraryID, sliceID, variationID] = path.split("::"); onSubmit({ libraryID, sliceID, variationID }); } return ( !open && close()} size={{ width: 448, height: "auto" }} >
If you have multiple identical slices, you can merge them. All of your content will be remapped to the target slice. Choose a slice that you would like to merge this into. Merge
); };