import NoteModal from "../../../../plus/noteModal/index.js";
import React, { useState } from "react";
import { Button } from "antd";
import { locales } from "@pisell/utils";
import Edit05 from "@pisell/icon/es/Edit05";
import "./index.less";
//#region src/components/booking/notes/addNote/index.tsx
const AddNote = ({ value, onChange, title, placeholder }) => {
	const [modalOpen, setModalOpen] = useState(false);
	const handleOpenModal = () => {
		setModalOpen(true);
	};
	const handleConfirm = (newValue) => {
		onChange === null || onChange === void 0 || onChange(newValue);
		setModalOpen(false);
	};
	const handleDelete = () => {
		onChange === null || onChange === void 0 || onChange("");
		setModalOpen(false);
	};
	const handleCancel = () => {
		setModalOpen(false);
	};
	return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode__booking-notes" }, /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode__booking-notes-label" }, title), /* @__PURE__ */ React.createElement("div", {
		className: "pisell-lowcode__booking-notes-input-area",
		style: { marginTop: title ? 8 : 0 },
		onClick: handleOpenModal
	}, value ? /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode__booking-notes-content" }, value) : /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode__booking-notes-placeholder" }, placeholder || locales.getText("pisell2.text.add-order-notes")), /* @__PURE__ */ React.createElement(Button, {
		type: "text",
		icon: /* @__PURE__ */ React.createElement(Edit05, null),
		size: "small",
		className: "pisell-lowcode__booking-notes-edit-btn",
		onClick: (e) => {
			e.stopPropagation();
			handleOpenModal();
		}
	}))), /* @__PURE__ */ React.createElement(NoteModal, {
		open: modalOpen,
		title: title || locales.getText("pisell2.text.add-order-notes"),
		value,
		onConfirm: handleConfirm,
		onDelete: handleDelete,
		onCancel: handleCancel
	}));
};
//#endregion
export { AddNote as default };
