import{jsxs as t,jsx as e}from"react/jsx-runtime";import{R as x}from"./rich-text-editor-BK3mvong.js";import{B as s}from"./button-BvFBRYHq.js";import{C as y,b as C,c as b,a as S}from"./card-Zg0WOx-j.js";import{I as u}from"./input-qMvM9qch.js";import{L as a}from"./label-DMnntKPk.js";import{S as I,a as F,b as P,c as j,f as c}from"./select-DfhewM4T.js";import{A as R}from"./layout-CssQHtfO.js";import{useForm as k,Head as A,router as d}from"@inertiajs/react";import{ArrowLeft as D}from"lucide-react";import{useRef as L,useState as T}from"react";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"./utils-CMbmcP35.js";import"clsx";import"tailwind-merge";import"./popover-SprfKcRl.js";import"@radix-ui/react-popover";import"./dialog-BfGkTFdF.js";import"@radix-ui/react-dialog";import"@radix-ui/react-slot";import"class-variance-authority";import"@radix-ui/react-label";import"@radix-ui/react-select";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-tooltip";import"@radix-ui/react-avatar";import"../app.js";/* empty css     */import"axios";import"sonner";import"react-dom/client";import"./toaster-DuLpwsc2.js";const B=[{title:"Admin",href:"/admin"},{title:"News",href:"/admin/news"},{title:"Create",href:"/admin/news/create"}];function De(){const g=L(null),[p,f]=T(null),{data:n,setData:o,post:N,processing:h,errors:r}=k({title:"",category:"patch",image:null,content:"",is_active:!0}),v=i=>{i.preventDefault(),N(route("admin.news.store"),{forceFormData:!0,onSuccess:()=>{d.visit(route("admin.news.index"))}})},w=i=>{const l=i.target.files?.[0];if(l){o("image",l);const m=new FileReader;m.onloadend=()=>{f(m.result)},m.readAsDataURL(l)}};return t(R,{breadcrumbs:B,children:[e(A,{title:"Create News"}),e("div",{className:"container py-6",children:t(y,{children:[e(C,{children:t("div",{className:"flex items-center justify-between",children:[e(b,{children:"Create News"}),t(s,{variant:"outline",onClick:()=>d.visit(route("admin.news.index")),children:[e(D,{className:"h-4 w-4"}),e("span",{className:"ml-2 hidden md:inline",children:"Back"})]})]})}),e(S,{children:t("form",{onSubmit:v,className:"space-y-6",children:[t("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2",children:[t("div",{className:"space-y-2 md:col-span-2",children:[t(a,{htmlFor:"title",children:["Title ",e("span",{className:"text-red-500",children:"*"})]}),e(u,{id:"title",value:n.title,onChange:i=>o("title",i.target.value),placeholder:"Enter news title",required:!0,className:r.title?"border-red-500":""}),r.title&&e("p",{className:"text-sm text-red-500",children:r.title})]}),t("div",{className:"space-y-2",children:[t(a,{htmlFor:"category",children:["Category ",e("span",{className:"text-red-500",children:"*"})]}),t(I,{value:n.category,onValueChange:i=>o("category",i),children:[e(F,{id:"category",children:e(P,{})}),t(j,{children:[e(c,{value:"patch",children:"Patch"}),e(c,{value:"download",children:"Download"}),e(c,{value:"promo",children:"Promo"})]})]}),r.category&&e("p",{className:"text-sm text-red-500",children:r.category})]}),t("div",{className:"space-y-2",children:[e(a,{htmlFor:"image",children:"Upload Image"}),e(u,{id:"image",ref:g,type:"file",accept:"image/*",onChange:w,className:r.image?"border-red-500":""}),r.image&&e("p",{className:"text-sm text-red-500",children:r.image})]}),p&&t("div",{className:"space-y-2 md:col-span-2",children:[e(a,{children:"Image Preview"}),e("div",{className:"bg-muted/30 rounded-lg border-2 p-4 backdrop-blur-sm",children:e("div",{className:"bg-background/50 flex items-center justify-center rounded-lg p-4",children:e("img",{src:p,alt:"Preview",className:"h-auto max-h-96 w-auto max-w-full rounded object-contain shadow-lg"})})})]})]}),t("div",{className:"space-y-2",children:[t(a,{htmlFor:"content",children:["Content ",e("span",{className:"text-red-500",children:"*"})]}),e(x,{content:n.content,onChange:i=>o("content",i),placeholder:"Start writing your news content..."}),r.content&&e("p",{className:"text-sm text-red-500",children:r.content})]}),t("div",{className:"flex justify-end gap-4 border-t pt-4",children:[e(s,{type:"button",variant:"outline",onClick:()=>d.visit(route("admin.news.index")),children:"Cancel"}),e(s,{type:"submit",disabled:h,children:h?"Creating...":"Create News"})]})]})})]})})]})}export{De as default};
