import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
import { Icon, Modal } from "@powerhousedao/design-system";
import { memo, useCallback } from "react";
import { twMerge } from "tailwind-merge";
import { tableLabels } from "../constants/names.js";
import { useTableForm } from "../hooks/useTableForm.js";
import { ModalFormInputs } from "./modal-form-inputs.js";
export const RWACreateItemModal = memo(function RWACreateItemModal(props) {
    const { tableName, open, onOpenChange } = props;
    const { reset, submit, formInputs: { inputs, additionalInputs }, } = useTableForm({
        operation: "create",
        tableName,
    });
    const tableLabel = tableLabels[tableName];
    const handleCancel = useCallback(() => {
        reset();
        onOpenChange(false);
    }, [onOpenChange, reset]);
    const handleSubmit = useCallback(async () => {
        try {
            await submit();
            onOpenChange(false);
        }
        catch (error) {
            console.error(error);
        }
    }, [onOpenChange, submit]);
    const buttonStyles = "min-h-[48px] min-w-[142px] text-base font-semibold py-3 px-6 rounded-xl outline-none active:opacity-75 hover:scale-105 transform transition-all";
    return (_jsx(Modal, { contentProps: {
            className: "rounded-3xl",
        }, onOpenChange: onOpenChange, open: open, overlayProps: {
            className: "top-10",
        }, children: _jsxs("div", { className: "w-[400px] p-6 text-slate-300", children: [_jsxs("div", { className: "mb-6 flex justify-between", children: [_jsxs("h1", { className: "text-xl font-bold", children: ["Create ", tableLabel] }), _jsx("button", { className: "flex size-8 items-center justify-center rounded-md bg-gray-100 text-gray-500 outline-none hover:text-gray-900", onClick: handleCancel, tabIndex: -1, children: _jsx(Icon, { name: "XmarkLight", size: 24 }) })] }), _jsx(ModalFormInputs, { inputs: inputs }), additionalInputs, _jsxs("div", { className: "mt-8 flex justify-between gap-3", children: [_jsx("button", { className: twMerge(buttonStyles, "flex-1 bg-slate-50 text-slate-800"), onClick: handleCancel, children: "Cancel" }), _jsx("button", { className: twMerge(buttonStyles, "flex-1 bg-gray-800 text-gray-50"), onClick: handleSubmit, children: "Save" })] })] }) }));
});
//# sourceMappingURL=create-item-modal.js.map