import { jsxs, jsx } from "react/jsx-runtime"; import { I as InputError } from "./input-error-D1JIzedA.js"; import { L as LoadingButton } from "./loading-button-CCIxhJrY.js"; import { B as Button } from "./button-CdJZJLGw.js"; import { D as Dialog, a as DialogTrigger, b as DialogContent, c as DialogHeader, d as DialogTitle, e as DialogFooter, f as DialogClose } from "./dialog-DGP_3dPQ.js"; import { I as Input } from "./input-BsvJqbcd.js"; import { L as Label } from "./label-0rIIfpX0.js"; import { o as onHandleChange } from "./inertia-BtwbgBI3.js"; import { usePage, useForm } from "@inertiajs/react"; import { SquarePen } from "lucide-react"; import { useState } from "react"; import { Editor } from "richtor"; /* empty css */ import "./utils-DLCPGU0v.js"; import "clsx"; import "tailwind-merge"; import "@radix-ui/react-slot"; import "class-variance-authority"; import "@radix-ui/react-dialog"; import "@radix-ui/react-label"; const ForumEdit = ({ url, forum }) => { const [open, setOpen] = useState(false); const { props } = usePage(); const { translate } = props; const { button, input, frontend } = translate; const { data, setData, put, errors, processing, reset } = useForm({ url, title: forum.title, description: forum.description }); const handleSubmit = (e) => { e.preventDefault(); put(route("course-forums.update", forum.id), { onSuccess: () => { reset(); setOpen(false); } }); }; return /* @__PURE__ */ jsxs(Dialog, { open, onOpenChange: setOpen, children: [ /* @__PURE__ */ jsx(DialogTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "ghost", className: "w-full cursor-pointer justify-start px-2", children: [ /* @__PURE__ */ jsx(SquarePen, { className: "h-4 w-4" }), /* @__PURE__ */ jsx("span", { children: button.edit }) ] }) }), /* @__PURE__ */ jsxs(DialogContent, { children: [ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: frontend.edit_forum_question }) }), /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "space-y-4 p-0.5", children: [ /* @__PURE__ */ jsxs("div", { children: [ /* @__PURE__ */ jsx(Label, { children: input.question_title }), /* @__PURE__ */ jsx( Input, { required: true, type: "text", name: "title", value: data.title, placeholder: input.question_title_placeholder, onChange: (e) => onHandleChange(e, setData) } ), /* @__PURE__ */ jsx(InputError, { message: errors.title }) ] }), /* @__PURE__ */ jsxs("div", { children: [ /* @__PURE__ */ jsx(Label, { children: input.description }), /* @__PURE__ */ jsx( Editor, { ssr: true, output: "html", placeholder: { paragraph: input.content_placeholder, imageCaption: input.image_caption_placeholder }, contentMinHeight: 260, contentMaxHeight: 600, initialContent: data.description, onContentChange: (value) => setData("description", value) } ), /* @__PURE__ */ jsx(InputError, { message: errors.description }) ] }), /* @__PURE__ */ jsxs(DialogFooter, { children: [ /* @__PURE__ */ jsx(LoadingButton, { loading: processing, children: button.update }), /* @__PURE__ */ jsx(DialogClose, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "outline", children: button.cancel }) }) ] }) ] }) ] }) ] }); }; export { ForumEdit as default };