import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useState } from 'react';
import { Button, Input, Modal, ModalBody, ModalFooter, ModalTitle, useToast, Textarea } from '@vertesia/ui/core';
export function CreateOrUpdateTypeModal({ title, isOpen, onClose, okLabel, initialPayload }) {
    const toast = useToast();
    const [name, setName] = useState(initialPayload?.name);
    const [description, setDescription] = useState(initialPayload?.description);
    const [strictMode, setStrictMode] = useState(initialPayload?.strict_mode ?? false);
    const onSave = () => {
        if (!name) {
            toast({
                status: 'error',
                title: 'Name is required',
                duration: 5000
            });
            return;
        }
        const payload = { name, description, strict_mode: strictMode };
        onClose(payload).then(() => onClose());
        setName(undefined);
        setDescription(undefined);
        setStrictMode(false);
    };
    return (_jsxs(Modal, { isOpen: isOpen, onClose: () => onClose(), children: [_jsx(ModalTitle, { children: title }), _jsx(ModalBody, { className: "pt-0", children: _jsxs("div", { className: 'h-full flex flex-col gap-4 content-between', children: [_jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-muted", children: "Name" }), _jsx(Input, { value: name, onChange: setName })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-muted", children: "Description" }), _jsx(Textarea, { value: description, onChange: e => setDescription(e.target.value) })] })] }) }), _jsx(ModalFooter, { children: _jsxs("div", { className: 'flex justify-end gap-4', children: [_jsx(Button, { variant: "secondary", onClick: () => onClose(), children: "Cancel" }), _jsx(Button, { variant: "primary", onClick: () => onSave(), children: okLabel })] }) })] }));
}
//# sourceMappingURL=CreateOrUpdateTypeModal.js.map