import {
  DatePickerButton
} from "./chunk-ZPHOW4LP.js";
import {
  Form
} from "./chunk-BGPMDQGB.js";
import {
  TextField
} from "./chunk-5KDNSBO5.js";
import {
  TextArea
} from "./chunk-3F45OPXG.js";
import {
  Card
} from "./chunk-HEDMSFPW.js";
import {
  Button
} from "./chunk-AFPH32MF.js";
import {
  Flex
} from "./chunk-25HMMI7R.js";
import {
  __spreadValues
} from "./chunk-2NMEKWO5.js";

// src/app/platform/goal-manage-card-edit.tsx
import { useCallback, useState } from "react";
import { format } from "date-fns";
import { jsx, jsxs } from "react/jsx-runtime";
var initialValues = {
  goal: "",
  effect: "",
  huddle: "",
  dueDate: void 0
};
var dummyFn = () => {
};
function GoalManageCardEdit(props) {
  const { defaultValues, errors } = props;
  const [values, setValues] = useState(defaultValues || initialValues);
  const onChange = useCallback(
    (v) => {
      var _a;
      setValues((prev) => __spreadValues(__spreadValues({}, prev), v));
      (_a = props.onChange) == null ? void 0 : _a.call(props, v);
    },
    [props]
  );
  const onClickInit = useCallback(() => {
    var _a;
    setValues(initialValues);
    (_a = props.onChange) == null ? void 0 : _a.call(props, defaultValues || initialValues);
  }, [defaultValues, props]);
  const onClickSubmit = useCallback(() => {
    var _a;
    (_a = props.onSubmit) == null ? void 0 : _a.call(props, values);
  }, [props, values]);
  return /* @__PURE__ */ jsx(Card, { style: { width: "100%" }, children: /* @__PURE__ */ jsxs(Form.Root, { onSubmit: dummyFn, children: [
    /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "5", children: [
      /* @__PURE__ */ jsxs(Form.Field, { name: "title", children: [
        /* @__PURE__ */ jsx(Form.Label, { children: "\uC774\uBC88 \uCF54\uCE6D\uC758 \uBAA9\uD45C\uB294 \uC544\uB798\uC640 \uAC19\uC2B5\uB2C8\uB2E4" }),
        /* @__PURE__ */ jsx(
          TextField.Root,
          {
            error: Boolean(errors == null ? void 0 : errors.goal),
            onChange: (e) => {
              onChange({ goal: e.target.value });
            },
            placeholder: "\uC774\uBC88 \uCF54\uCE6D \uACFC\uC815\uC758 \uBAA9\uD45C\uB97C \uD55C \uBB38\uC7A5\uC73C\uB85C \uC801\uC5B4\uC8FC\uC138\uC694",
            value: values.goal
          }
        ),
        /* @__PURE__ */ jsx(Form.Message, { forceMatch: Boolean(errors == null ? void 0 : errors.goal), children: errors == null ? void 0 : errors.goal })
      ] }),
      /* @__PURE__ */ jsxs(Form.Field, { name: "effect", children: [
        /* @__PURE__ */ jsx(Form.Label, { children: "\uAE30\uB300\uD6A8\uACFC" }),
        /* @__PURE__ */ jsx(
          TextArea,
          {
            error: Boolean(errors == null ? void 0 : errors.effect),
            onChange: (e) => {
              onChange({ effect: e.target.value });
            },
            placeholder: "\uC608\uC2DC : \uD300\uC6D0\uB4E4\uACFC \uB354 \uCE5C\uBC00\uD574\uC9C0\uACE0, \uD300\uC6D0\uB4E4\uC5D0 \uB300\uD55C \uC774\uD574\uB3C4\uAC00 \uC313\uC774\uBA70 \uB354 \uD6A8\uC728\uC801\uC778 \uC778\uC7AC\uAD00\uB9AC\uB97C \uC704\uD55C \uAD00\uACC4\uD615\uC131\uC774 \uAC00\uB2A5\uD574\uC9D1\uB2C8\uB2E4.",
            resize: "vertical",
            value: values.effect
          }
        ),
        /* @__PURE__ */ jsx(Form.Message, { forceMatch: Boolean(errors == null ? void 0 : errors.effect), children: errors == null ? void 0 : errors.effect })
      ] }),
      /* @__PURE__ */ jsxs(Form.Field, { name: "huddle", children: [
        /* @__PURE__ */ jsx(Form.Label, { children: "\uBC29\uD574\uC694\uC18C" }),
        /* @__PURE__ */ jsx(
          TextArea,
          {
            error: Boolean(errors == null ? void 0 : errors.huddle),
            onChange: (e) => {
              onChange({ huddle: e.target.value });
            },
            placeholder: `- \uAC11\uC790\uAE30 \uC7A1\uD788\uB294 \uBBF8\uD305\uB4E4
- MZ \uC138\uB300\uC640\uC758 \uC790\uC5F0\uC2A4\uB7FD\uC9C0 \uC54A\uC740 \uC18C\uD1B5
- \uB300\uD654\uC5D0\uC11C \uCC38\uC744\uC131 \uBD80\uC871`,
            resize: "vertical",
            value: values.huddle
          }
        ),
        /* @__PURE__ */ jsx(Form.Message, { forceMatch: Boolean(errors == null ? void 0 : errors.huddle), children: errors == null ? void 0 : errors.huddle })
      ] }),
      /* @__PURE__ */ jsxs(Form.Field, { name: "dueDate", children: [
        /* @__PURE__ */ jsx(Form.Label, { children: "\uBAA9\uD45C \uB2EC\uC131 \uAE30\uD55C\uC740 \uB2E4\uC74C\uACFC \uAC19\uC2B5\uB2C8\uB2E4" }),
        /* @__PURE__ */ jsx(
          DatePickerButton,
          {
            format: (v) => format(v, "yyyy\uB144 MM\uC6D4 dd\uC77C"),
            onChange: (date) => {
              date && onChange({ dueDate: date });
            },
            placeholder: "YYYY\uB144 MM\uC6D4 DD\uC77C",
            selected: values.dueDate
          }
        ),
        /* @__PURE__ */ jsx(Form.Message, { forceMatch: Boolean(errors == null ? void 0 : errors.dueDate), children: errors == null ? void 0 : errors.dueDate })
      ] })
    ] }),
    /* @__PURE__ */ jsxs(Flex, { gap: "3", justify: "end", width: "100%", children: [
      /* @__PURE__ */ jsx(
        Button,
        {
          color: "gray",
          onClick: onClickInit,
          size: "small",
          type: "button",
          variant: "outline",
          children: "\uCD08\uAE30\uD654\uD558\uAE30"
        }
      ),
      /* @__PURE__ */ jsx(Button, { onClick: onClickSubmit, size: "small", type: "button", children: "\uC800\uC7A5\uD558\uAE30" })
    ] })
  ] }) });
}

export {
  GoalManageCardEdit
};
//# sourceMappingURL=chunk-X3GWEPOR.js.map