lms/public/build/assets/blog-form-CZo4wnrU.js
2025-12-15 12:26:23 +01:00

2 lines
4.2 KiB
JavaScript

import{u as D,r as u,b as E,j as e,F as V,bd as M,L as P,bP as O}from"./vendor-BKmmeuxg.js";import{C as R}from"./combobox-Byd5-E0j.js";import{I as l}from"./input-error-LaPr_4wd.js";import{B as x}from"./button-BpNwv2aE.js";import{C as p,a as j,c as b,d as _,b as f}from"./card-D9_SJYq6.js";import{I as d}from"./input-DM0goJrn.js";import{L as n}from"./label-HmIcv5Yx.js";import{S as q,a as z,b as A,c as G,d as J}from"./select-CD9o3HN1.js";import{o as v}from"./inertia-SZXqLvQm.js";import{k as K}from"./richtor-CRcM6Du2.js";import"./utils-DxSsnXxD.js";import"./popover-B4kBsMuI.js";import"./index-WW_1X1qx.js";const le=()=>{const{props:y}=D(),{auth:C,blog:s,categories:c,statuses:w,translate:k}=y,{dashboard:t,input:m,button:N}=k,[S,F]=u.useState((s==null?void 0:s.banner)||"/assets/images/blank-image.jpg"),[I,L]=u.useState((s==null?void 0:s.thumbnail)||"/assets/images/blank-image.jpg"),{data:o,setData:r,post:g,processing:B,errors:i}=E({title:s?s.title:"",slug:s?s.slug:"",description:s?s.description:"",keywords:s&&s.keywords||"",status:s?s.status:"draft",thumbnail:null,banner:null,user_id:s?s.user_id:C.user.id,blog_category_id:s?s.blog_category_id:""}),H=a=>{a.preventDefault(),g(s?route("blogs.update",s.id):route("blogs.store"))},T=c==null?void 0:c.map(a=>({label:a.name,value:a.id}));return e.jsxs("form",{onSubmit:H,className:"space-y-6",children:[e.jsxs(p,{children:[e.jsxs(j,{children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(V,{className:"h-5 w-5"}),t.blog_information]}),e.jsx(_,{children:t.provide_blog_details})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(n,{htmlFor:"title",children:t.title_80_char}),e.jsx(d,{id:"title",value:o.title,onChange:a=>r("title",a.target.value),placeholder:t.enter_blog_title,maxLength:80}),e.jsx(l,{message:i.title})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{children:[e.jsxs(n,{htmlFor:"blog_category_id",children:[m.category," *"]}),e.jsx(R,{defaultValue:o.blog_category_id,data:T||[],placeholder:t.select_category,onSelect:a=>r("blog_category_id",a.value)}),e.jsx(l,{message:i.blog_category_id})]}),e.jsxs("div",{children:[e.jsxs(n,{htmlFor:"status",children:[m.status," *"]}),e.jsxs(q,{value:o.status,onValueChange:a=>r("status",a),children:[e.jsx(z,{children:e.jsx(A,{})}),e.jsx(G,{children:Object.entries(w).map(([a,h])=>e.jsx(J,{value:a,children:h},a))})]}),e.jsx(l,{message:i.status})]})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"keywords",children:t.keywords_80_char}),e.jsx(d,{id:"keywords",value:o.keywords,onChange:a=>r("keywords",a.target.value),placeholder:t.enter_your_keywords,maxLength:80}),e.jsx(l,{message:i.keywords})]}),e.jsxs("div",{children:[e.jsxs(n,{htmlFor:"description",children:[m.description," *"]}),e.jsx(K,{ssr:!0,output:"html",placeholder:{paragraph:t.write_blog_content_here,imageCaption:t.type_caption_optional},contentMinHeight:256,contentMaxHeight:640,initialContent:o.description,onContentChange:a=>r(h=>({...h,description:a}))}),e.jsx(l,{message:i.description})]})]})]}),e.jsxs(p,{children:[e.jsxs(j,{children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(M,{className:"h-5 w-5"}),t.media_files]}),e.jsx(_,{children:t.upload_banner_thumbnail_desc})]}),e.jsxs(f,{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(n,{htmlFor:"banner",children:t.blog_banner}),e.jsx(d,{id:"banner",type:"file",accept:"image/*",name:"banner",onChange:a=>v(a,r,F)}),e.jsx(l,{message:i.banner}),e.jsx("div",{className:"border-border mt-3 overflow-hidden rounded-lg border-2 border-dashed",children:e.jsx("img",{src:S,alt:""})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"thumbnail",children:t.blog_thumbnail}),e.jsx(d,{id:"thumbnail",type:"file",accept:"image/*",name:"thumbnail",onChange:a=>v(a,r,L)}),e.jsx(l,{message:i.thumbnail}),e.jsx("div",{className:"border-border mt-3 overflow-hidden rounded-lg border-2 border-dashed",children:e.jsx("img",{src:I,alt:""})})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-4",children:[e.jsx(x,{type:"button",variant:"outline",asChild:!0,children:e.jsx(P,{href:route("blogs.index"),children:N.cancel})}),e.jsxs(x,{type:"submit",disabled:B,children:[e.jsx(O,{className:"mr-2 h-4 w-4"}),s?t.update_blog:t.add_blog]})]})]})};export{le as default};