"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import * as React from "react";
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from "@open-mercato/ui/primitives/dialog";
import { useT } from "@open-mercato/shared/lib/i18n/context";
import { TaskForm } from "./TaskForm.js";
function TaskDialog({ open, mode, onOpenChange, initialValues, onSubmit, isSubmitting, contextMessage, useCanonicalInteractions = false }) {
  const t = useT();
  const dialogTitle = mode === "edit" ? t("customers.people.detail.tasks.dialog.editTitle", "Edit task") : t("customers.people.detail.tasks.dialog.createTitle", "Add task");
  const handleCancel = React.useCallback(() => {
    onOpenChange(false);
  }, [onOpenChange]);
  const handleSubmit = React.useCallback(
    async (payload) => {
      await onSubmit(payload);
      onOpenChange(false);
    },
    [onOpenChange, onSubmit]
  );
  return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-2xl", children: [
    /* @__PURE__ */ jsxs(DialogHeader, { children: [
      /* @__PURE__ */ jsx(DialogTitle, { children: dialogTitle }),
      contextMessage ? /* @__PURE__ */ jsx(DialogDescription, { children: contextMessage }) : null
    ] }),
    /* @__PURE__ */ jsx(
      TaskForm,
      {
        mode,
        initialValues,
        onSubmit: handleSubmit,
        onCancel: handleCancel,
        isSubmitting,
        useCanonicalInteractions
      }
    )
  ] }) });
}
export {
  TaskDialog
};
//# sourceMappingURL=TaskDialog.js.map
