import{jsxs as o,jsx as p}from"react/jsx-runtime";import{B as m}from"./button-BvFBRYHq.js";import{C as l,b as u,c as f,a as h}from"./card-Zg0WOx-j.js";import{A as _}from"./layout-CssQHtfO.js";import{useForm as y,Head as g,router as r}from"@inertiajs/react";import{ArrowLeft as v}from"lucide-react";import"./badge-CFi7bqqA.js";import"clsx";import"react";import"./alert-dialog-xorwy8s8.js";import{NewsForm as N}from"./NewsForm-Br9Mssui.js";import"@radix-ui/react-slot";import"class-variance-authority";import"./utils-CMbmcP35.js";import"tailwind-merge";import"./app-sidebar-header-BX2s-HO_.js";import"@radix-ui/react-collapsible";import"./dropdown-menu-BP80qPHw.js";import"@radix-ui/react-dropdown-menu";import"./app-logo-icon-beRg1XGs.js";import"./fonts-CqawFh47.js";import"@radix-ui/react-dialog";import"@radix-ui/react-tooltip";import"@radix-ui/react-avatar";import"../app.js";/* empty css     */import"axios";import"sonner";import"react-dom/client";import"./toaster-DuLpwsc2.js";import"@radix-ui/react-alert-dialog";import"./label-DMnntKPk.js";import"@radix-ui/react-label";import"./input-qMvM9qch.js";import"./select-DfhewM4T.js";import"@radix-ui/react-select";import"./rich-text-editor-BK3mvong.js";import"@tiptap/react";import"@tiptap/starter-kit";import"@tiptap/extension-text-align";import"@tiptap/extension-link";import"@tiptap/extension-color";import"@tiptap/extension-text-style";import"@tiptap/extension-highlight";import"@tiptap/extension-table";import"@tiptap/extension-table-row";import"@tiptap/extension-table-cell";import"@tiptap/extension-table-header";import"@tiptap/core";import"./separator-BDLxzoJ8.js";import"@radix-ui/react-separator";import"./popover-SprfKcRl.js";import"@radix-ui/react-popover";import"./dialog-BfGkTFdF.js";import"./constants-B4vUcFwO.js";const b=[{title:"Admin",href:"/admin"},{title:"News",href:"/admin/news"},{title:"Edit",href:"#"}];function Ct({news:t}){const{data:i,setData:n,post:w,processing:a,errors:d}=y({title:t.title,category:t.category,image:null,content:t.content,is_active:t.is_active,show_as_popup:t.show_as_popup??!1,popup_delay:t.popup_delay??1e3,popup_frequency:t.popup_frequency??"once"}),s=c=>{c.preventDefault();const e=new FormData;e.append("_method","PUT"),e.append("title",i.title),e.append("category",i.category),e.append("content",i.content),e.append("is_active",i.is_active?"1":"0"),e.append("show_as_popup",i.show_as_popup?"1":"0"),e.append("popup_delay",i.popup_delay.toString()),e.append("popup_frequency",i.popup_frequency),i.image&&e.append("image",i.image),r.post(route("admin.news.update",t.id),e,{onSuccess:()=>{r.visit(route("admin.news.index"))}})};return o(_,{breadcrumbs:b,children:[p(g,{title:`Edit: ${t.title}`}),p("div",{className:"container py-6",children:o(l,{children:[p(u,{children:o("div",{className:"flex items-center justify-between",children:[p(f,{children:"Edit News"}),o(m,{variant:"outline",onClick:()=>r.visit(route("admin.news.index")),children:[p(v,{className:"h-4 w-4"}),p("span",{className:"ml-2 hidden md:inline",children:"Back"})]})]})}),p(h,{children:o("form",{onSubmit:s,className:"space-y-6",children:[p(N,{data:i,setData:n,errors:d,existingImage:t.image}),o("div",{className:"flex justify-end gap-4 border-t pt-4",children:[p(m,{type:"button",variant:"outline",onClick:()=>r.visit(route("admin.news.index")),children:"Cancel"}),p(m,{type:"submit",disabled:a,children:a?"Updating...":"Update News"})]})]})})]})})]})}export{Ct as default};
