import { jsx, jsxs } from "react/jsx-runtime"; import { C as Combobox } from "./combobox-BpeE9nB5.js"; import { I as InputError } from "./input-error-D1JIzedA.js"; import { L as LoadingButton } from "./loading-button-CCIxhJrY.js"; import { T as TagInput } from "./tag-input-D5O17wz6.js"; import { C as Card } from "./card-B-gBwpxd.js"; import { I as Input } from "./input-BsvJqbcd.js"; import { L as Label } from "./label-0rIIfpX0.js"; import { T as Textarea } from "./textarea-Z0d4V-ti.js"; import { D as DashboardLayout } from "./layout-Cf9mPjOS.js"; import { o as onHandleChange } from "./inertia-BtwbgBI3.js"; import { useForm } from "@inertiajs/react"; import "./button-CdJZJLGw.js"; import "react"; import "@radix-ui/react-slot"; import "class-variance-authority"; import "./utils-DLCPGU0v.js"; import "clsx"; import "tailwind-merge"; import "cmdk"; import "lucide-react"; import "./popover-Cv6Hz_y0.js"; import "@radix-ui/react-popover"; import "@yaireo/tagify"; import "@radix-ui/react-label"; import "./sidebar-C1tqSfnl.js"; import "./separator-CSqU-rrB.js"; import "@radix-ui/react-separator"; import "./sheet-BOQ-e9_C.js"; import "@radix-ui/react-dialog"; import "./tooltip-BYKuzaoQ.js"; import "@radix-ui/react-tooltip"; import "./main-BKBelQb-.js"; import "next-themes"; import "sonner"; import "./appearance-BJIqrZL5.js"; import "./dropdown-menu-msun3TP8.js"; import "@radix-ui/react-dropdown-menu"; import "./language-mewnB-2r.js"; import "./notification-Bg6IzWOo.js"; import "date-fns"; import "./scroll-area-CDdrLubh.js"; import "@radix-ui/react-scroll-area"; import "./app-logo-DWyi5bLn.js"; import "./accordion-cIAfVfPq.js"; import "@radix-ui/react-accordion"; import "./route-DlE7FdTW.js"; import "./avatar-C8iCpF5R.js"; import "@radix-ui/react-avatar"; import "./use-lang-44ndmTOc.js"; const CreateUpdate = ({ instructor, users, translate }) => { const initialOptions = (instructor == null ? void 0 : instructor.skills) ? typeof instructor.skills === "string" ? JSON.parse(instructor.skills) : instructor.skills : []; const { dashboard, input, button } = translate; const { data, setData, post, processing, errors, reset } = useForm({ user_id: "", designation: (instructor == null ? void 0 : instructor.designation) || "", skills: initialOptions, biography: (instructor == null ? void 0 : instructor.biography) || "", resume: null }); const handleSubmit = (e) => { e.preventDefault(); if (instructor) { post(route("become-instructor.update", { id: instructor.id })); } else { post(route("become-instructor.store"), { onSuccess: () => { reset(); } }); } }; const transformedUsers = users.map((user) => ({ value: user.id.toString(), label: user.name })); return /* @__PURE__ */ jsx(Card, { className: "p-4 sm:p-6", children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "relative space-y-4", children: [ /* @__PURE__ */ jsxs("div", { children: [ /* @__PURE__ */ jsxs(Label, { children: [ dashboard.course_instructor, " *" ] }), /* @__PURE__ */ jsx(Combobox, { data: transformedUsers, placeholder: input.select, onSelect: (selected) => setData("user_id", selected.value) }), /* @__PURE__ */ jsx(InputError, { message: errors.user_id }) ] }), /* @__PURE__ */ jsxs("div", { children: [ /* @__PURE__ */ jsx(Label, { children: input.designation }), /* @__PURE__ */ jsx(Input, { type: "text", name: "designation", onChange: (e) => onHandleChange(e, setData), placeholder: input.designation_placeholder }), /* @__PURE__ */ jsx(InputError, { message: errors.designation }) ] }), /* @__PURE__ */ jsxs("div", { children: [ /* @__PURE__ */ jsx(Label, { children: input.resume }), /* @__PURE__ */ jsx(Input, { readOnly: true, type: "file", name: "resume", onChange: (e) => onHandleChange(e, setData) }), /* @__PURE__ */ jsx(InputError, { message: errors.resume }) ] }), /* @__PURE__ */ jsxs("div", { children: [ /* @__PURE__ */ jsx(Label, { children: input.skills }), /* @__PURE__ */ jsx(TagInput, { defaultTags: data.skills, placeholder: input.skills, onChange: (values) => setData("skills", values) }) ] }), /* @__PURE__ */ jsxs("div", { className: "pb-3", children: [ /* @__PURE__ */ jsx(Label, { children: input.biography }), /* @__PURE__ */ jsx( Textarea, { rows: 5, required: true, name: "biography", value: data.biography, onChange: (e) => onHandleChange(e, setData), placeholder: input.biography_placeholder } ), /* @__PURE__ */ jsx(InputError, { message: errors.biography }) ] }), /* @__PURE__ */ jsx(LoadingButton, { loading: processing, className: "mt-2", children: instructor ? button.update : button.submit }) ] }) }); }; CreateUpdate.layout = (page) => /* @__PURE__ */ jsx(DashboardLayout, { children: page }); export { CreateUpdate as default };