import { useState } from "react"; import { PlusIcon } from "@heroicons/react/solid"; import { EditorType, IconType } from "@/types/editor"; import { Empty } from "@/components/empty"; import { IconSelected } from "./icon-selected"; import { FormattedMessage, useIntl } from "react-intl"; export const Icons = ({ editor, onChange, onStep, }: { editor: EditorType; onChange: (e: EditorType) => void; onStep: (step: number, multiple?: boolean) => void; }) => { const [opened, setOpened] = useState(0); const intl = useIntl(); const handleChange = (index: number, icon: any) => { const newIcons = [...editor.icons]; newIcons[index] = icon; onChange({ ...editor, icons: newIcons, }); }; const handleDeleteIcon = (index: number) => { const newIcons = [...editor.icons]; newIcons.splice(index, 1); onChange({ ...editor, icons: newIcons, }); }; const handleChangeOrder = (index: number, value: number) => { const newIcons = [...editor.icons]; const [removed] = newIcons.splice(index, 1); newIcons.splice(value, 0, removed); onChange({ ...editor, icons: newIcons, }); }; return (

{editor?.icons?.length > 0 ? ( <>
onStep(0, true)} >

{editor?.icons?.map((icon: IconType, k) => { return ( ); })} ) : ( onStep(0)} /> )}
); };