1import{G as W,r as m,j as i,S as X}from"./app-Ha4X7SlF.js";import{A as Y}from"./AuthenticatedLayout-BZKUhDrh.js";import{I as o}from"./InputError-Do4kQPnM.js";import{I as n}from"./InputLabel-D410np7F.js";import{P as Z}from"./PrimaryButton-Bjn3n3t2.js";import{T as h}from"./TextInput-YH4SiJD7.js";import{Q as T}from"./index-C9bVzuNG.js";/* empty css */import{M as $}from"./MediaModal-DTWNCtfU.js";import ee from"./MediaPreview-D7BGVdAv.js";import{h as ie,a as k,b as se,c as te,v as le}from"./helpers-C3Ubf4D0.js";import{T as u,S as re,D as v}from"./constants-gejEprHZ.js";import"./transition-DszwGdUG.js";import"./Sidebar-BmBFQuN7.js";import"./SvgSwitcher-DH9r9e5c.js";import"./ToastNotification-BhTNdAie.js";import"./_baseIsEqual-CXvocJ9U.js";import"./index-BCTjt6el.js";import"./index-DFCUUP5-.js";import"./moment-C5S46NFB.js";function Ce({auth:q,medias:x,announcement:a}){const w=window.location.origin,{data:t,setData:r,put:y,processing:S,errors:d,setError:s}=W({id:a.id,title:a.title,slug:a.slug,description:a.description,short_description:a.short_description,status:a.status,publish_at:new Date(a.publish_at).toISOString().slice(0,10)||new Date().toISOString().slice(0,10),badge_text:a.badge_text,badge_text_hi:a.badge_text_hi,link:a.link,type:a.type,media_id:a.media_id,title_hi:a.title_hi,short_description_hi:a.short_description_hi,description_hi:a.description_hi}),[ae,C]=m.useState(""),[de,g]=m.useState(!1);m.useEffect(()=>{C(window.location.origin+"/"+t.slug),a.status==1&&(g(!0),r("publish_at",new Date(a.publish_at).toISOString().slice(0,10)))},[t.slug]);const F=e=>{if(e){s("title","");const l=e.slice(0,u);k(l)&&(r(c=>({...c,title:l})),s("slug",""))}else s("title","The title field is required."),r(l=>({...l,title:e,slug:e}))},D=e=>{if(e){s("badge_text","");const l=e.slice(0,u);k(l)&&r("badge_text",e)}else s("badge_text","The Badge Text field is required."),r("badge_text","")},I=e=>{if(e){s("badge_text_hi","");const l=e.slice(0,u);se(l)&&r("badge_text_hi",e)}else s("badge_text_hi","The badge text hindi field is required."),r("badge_text_hi","")},E=e=>{if(e){if(s("title",""),e.length<=90){const l=e.slice(0,60);r(c=>({...c,title:e,slug:te(l)})),s("slug","")}}else s("title","The title field is required."),r(l=>({...l,title:e,slug:e}))},H=e=>{if(e){s("title_hi","");const l=e.slice(0,u);l&&r(c=>({...c,title_hi:l}))}else s("title_hi","The title in hindi field is required."),r(l=>({...l,title_hi:e}))},V=e=>{if(e){const l=e.slice(0,re);le(l)&&(s("slug",""),r("slug",l))}else s("slug","The slug field is required."),r("slug",e)},B=e=>{e?e.length<=120&&(s("short_description",""),r("short_description",e)):(s("short_description","The short description field is required."),r("short_description",e))},L=e=>{e?e.length<=120&&(s("short_description_hi",""),r("short_description_hi",e)):(s("short_description_hi","The short description in hindi field is required."),r("short_description_hi",e))},O=(e,l)=>{e?l.slice(0,v)!==t.description&&(s("description",""),r("description",e)):(s("description","The description field is required."),r("description",e))},M=(e,l)=>{e?l.slice(0,v)!==t.description&&(s("description_hi",""),r("description_hi",e)):(s("description_hi","The description in hindi field is required."),r("description_hi",e))},A=e=>{if(e===1){g(!0);const l=new Date().toISOString().split("T")[0];t.publish_at=l}else g(!1),t.publish_at="";r("status",e)},P=e=>{e?(s("link",""),r("link",e)):(s("link",""),r("link",""))},G=e=>{e&&(s("type",""),r("type",e))},U=()=>{let e=!0;return t.title?t.title.length<3&&(e=!1,s("title","The title field minimum length should be more than 3 characters.")):(e=!1,s("title","The title field is required.")),t.slug?t.slug.length<2&&(e=!1,s("slug","The slug field minimum length should be more than 2 characters.")):(e=!1,s("slug","The slug field is required.")),t.short_description?t.short_description.length<3&&(e=!1,s("short_description","The short description field minimum length should be more than 3 characters.")):(e=!1,s("short_description","The short description field is required.")),t.description?t.description.length<3&&(e=!1,s("description","The description field minimum length should be more than 3 characters.")):(e=!1,s("description","The description field is required.")),t.media_id||(s("media_id","The featured image is required."),e=!1),t.title_hi?t.title_hi.length<3&&(e=!1,s("title_hi","The title in hindi field minimum length should be more than 3 characters.")):(e=!1,s("title_hi","The title in hindi field is required.")),t.description_hi?t.description_hi.length<3&&(e=!1,s("description_hi","The description in hindi field minimum length should be more than 3 characters.")):(e=!1,s("description_hi","The description in hindi field is required.")),t.short_description_hi?t.short_description_hi.length<3&&(e=!1,s("short_description_hi","The short description in hindi field minimum length should be more than 3 characters.")):(e=!1,s("short_description_hi","The short description in hindi field is required.")),t.type||(e=!1,s("type","The link type Field is required")),t.badge_text||(e=!1,s("badge_text","The Badge Text Field is required")),t.badge_text_hi||(e=!1,s("badge_text_hi","The Badge Text Hindi Field is required")),t.link||(e=!1,s("link","The Link Field is required")),e},[z,_]=m.useState(!1),Q=e=>{e.preventDefault(),t.status==0&&(t.publish_at=""),U()&&y(route("announcements.update",a.id),{onFinish:()=>{r({id:"",title:"",slug:"",description:"",short_description:"",status:0,badge_text_hi:"",publish_at:new Date().toISOString().slice(0,10),badge_text:"",link:"",type:"",media_id:"",title_hi:"",short_description_hi:"",description_hi:""})}})},R=()=>{_(!0)},b=()=>{_(!1)},j={toolbar:[["bold","italic","underline","strike"],["blockquote","code-block"],["link","image","video","formula"],[{header:1},{header:2}],[{list:"ordered"},{list:"bullet"},{list:"check"}],[{script:"sub"},{script:"super"}],[{indent:"-1"},{indent:"+1"}],[{direction:"rtl"}],[{size:["small",!1,"large","huge"]}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{font:[]}],[{align:[]}],["clean"]]},N=["header","font","size","bold","italic","underline","align","strike","script","blockquote","background","list","bullet","indent","link","image","color","code-block"],[oe,J]=m.useState(null),K=e=>{var l;J(e),r("media_id",(l=e[0])==null?void 0:l.id),s("media_id",""),b()};return i.jsxs(Y,{user:q.user,header:i.jsx("h2",{className:"font-semibold text-xl text-gray-800 leading-tight",children:"Edit Announcement"}),children:[i.jsx(X,{title:"Edit Announcement"}),i.jsx("div",{className:"py-4",children:i.jsxs("div",{className:"max-w-8xl mx-auto px-6 lg:px-8 space-y-5",children:[i.jsx("div",{className:"py-1",children:i.jsx("div",{className:"flex justify-between items-center",children:i.jsx("h3",{className:"text-lg font-semibold",children:"Edit Announcement "})})}),i.jsxs("div",{className:"flex",children:[i.jsxs("div",{className:"p-4 sm:p-8 bg-white shadow sm:rounded-lg w-2/3",children:[i.jsxs("div",{className:"flex gap-4",children:[i.jsxs("div",{className:"w-1/2",children:[i.jsx(n,{htmlFor:"title",value:"Title",className:"req-star"}),i.jsx(h,{id:"title",name:"title",value:t.title,className:"mt-1 block w-full focus:border-black rounded-sm bg-gray-100",autoComplete:"title",isFocused:!0,onChange:e=>F(e.target.value),onBlur:e=>E(e.target.value),required:!0}),i.jsx(o,{message:d.title,className:"mt-2"})]}),i.jsxs("div",{className:"w-1/2",children:[i.jsx(n,{htmlFor:"title_hi",value:"Title in Hindi",className:"req-star"}),i.jsx(h,{id:"title_hi",name:"title_hi",value:t.title_hi,className:"mt-1 block w-full focus:border-black rounded-sm bg-gray-100",autoComplete:"titleHindi",onChange:e=>H(e.target.value),required:!0}),i.jsx(o,{message:d.title_hi,className:"mt-2"})]})]}),i.jsxs("div",{className:"mt-4",children:[i.jsx(n,{htmlFor:"slug",value:"Slug",className:"req-star"}),i.jsx(h,{id:"slug",name:"slug",value:t.slug,className:"mt-1 block w-full focus:border-black rounded-sm bg-gray-100",autoComplete:"slug",onChange:e=>V(e.target.value),required:!0}),i.jsx(o,{message:d.slug,className:"mt-2"})]}),i.jsxs("div",{className:"flex gap-4",children:[i.jsxs("div",{className:"mt-4 w-1/2",children:[i.jsx(n,{htmlFor:"short_description",value:"Short Description",className:"req-star"}),i.jsx(h,{id:"short_description",name:"short_description",value:t.short_description,className:"mt-1 block w-full focus:border-black rounded-sm bg-gray-100",onChange:e=>B(e.target.value),required:!0}),i.jsx(o,{message:d.short_description,className:"mt-2"})]}),i.jsxs("div",{className:"mt-4 w-1/2",children:[i.jsx(n,{htmlFor:"short_description_hi",value:"Short Description in hindi",className:"req-star"}),i.jsx(h,{id:"short_description_hi",name:"short_description_hi",value:t.short_description_hi,className:"mt-1 block w-full focus:border-black rounded-sm bg-gray-100",onChange:e=>L(e.target.value),required:!0}),i.jsx(o,{message:d.short_description_hi,className:"mt-2"})]})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"mt-4",children:[i.jsx(n,{htmlFor:"description",value:"Description",className:"mb-1 req-star"}),i.jsx(T,{value:t.description,onChange:(e,l,c,p)=>{const f=p.getText().trim();O(e,f)},modules:j,formats:N,theme:"snow",placeholder:"Compose your description here...",style:{minHeight:"200px"}})]}),i.jsx("div",{style:{marginTop:"20px"},children:i.jsx(o,{message:d.description,className:"mt-2"})}),i.jsxs("div",{className:"mt-4",children:[i.jsx(n,{htmlFor:"description_hi",value:"Description in Hindi",className:"mb-1 req-star"}),i.jsx(T,{value:t.description_hi,onChange:(e,l,c,p)=>{const f=p.getText().trim();M(e,f)},modules:j,formats:N,theme:"snow",placeholder:"Compose your description here...",style:{minHeight:"200px"}})]}),i.jsx("div",{style:{marginTop:"20px"},children:i.jsx(o,{message:d.description_hi,className:"mt-2"})})]})]}),i.jsxs("div",{className:"ml-5 w-1/3",children:[i.jsxs("div",{className:"w-full p-4 sm:p-8 bg-white shadow sm:rounded-lg",children:[i.jsxs("div",{className:"mb-4",children:[i.jsx(n,{htmlFor:"Status",value:"Status :",className:"req-star"}),i.jsxs("select",{className:"border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 rounded-md shadow-sm mt-1 block w-full focus:border-black rounded-sm bg-gray-100",value:t.status,onChange:e=>A(Number(e.target.value)),children:[i.jsx("option",{value:0,children:"Draft"}),i.jsx("option",{value:1,children:"Publish"})]}),i.jsx(o,{message:d.status,className:"mt-2"})]}),i.jsx("form",{onSubmit:Q,className:"my-2",children:i.jsx("div",{className:"flex items-center justify-end mt-4",children:i.jsx(Z,{className:"ms-4 bgTheme",disabled:S,children:"Update Announcement"})})})]}),i.jsxs("div",{className:"mt-5 w-full p-4 sm:p-8 bg-white shadow sm:rounded-lg",children:[i.jsx("h3",{className:"req-star",children:"Featured Images"}),i.jsx("button",{onClick:R,className:"text-blue-500 text-sm underline",children:"Upload Featured Images"}),i.jsx($,{imageOnly:!0,isOpen:z,onClose:b,onFileSelect:K,medias:x}),t.media_id&&x.filter(e=>e.id==t.media_id).map((e,l)=>i.jsx(ee,{item:{file_path:e.file_path,file_name:e.file_name,format:e.format||"",title:""},baseUrl:w,handleDocumentClick:ie,componentType:0})),i.jsx(o,{message:d.media_id,className:"mt-2"})]}),i.jsxs("div",{className:"w-full mt-5 p-4 sm:p-8 bg-white shadow sm:rounded-lg",children:[i.jsxs("div",{className:"mb-4",children:[i.jsx(n,{htmlFor:"badge_text",className:"req-star",value:"Badge Text"}),i.jsx(h,{id:"badge_text",name:"badge_text",value:t.badge_text,className:"mt-1 block w-full focus:border-black rounded-sm bg-gray-100",onChange:e=>D(e.target.value),required:!0}),i.jsx(o,{message:d.badge_text,className:"mt-2"})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx(n,{htmlFor:"badge_text_hi",className:"req-star",value:"Badge Text Hindi"}),i.jsx(h,{id:"badge_text_hi",name:"badge_text_hi",value:t.badge_text_hi,className:"mt-1 block w-full focus:border-black rounded-sm bg-gray-100",onChange:e=>I(e.target.value),required:!0}),i.jsx(o,{message:d.badge_text_hi,className:"mt-2"})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx(n,{htmlFor:"link",className:"req-star",value:"Link"}),i.jsx(h,{id:"link",name:"link",value:t.link,className:"mt-1 block w-full focus:border-black rounded-sm bg-gray-100",onChange:e=>P(e.target.value),required:!0}),i.jsx(o,{message:d.link,className:"mt-2"})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx(n,{htmlFor:"type",value:"Link Type",className:"req-star"}),i.jsxs("select",{className:"border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 rounded-md shadow-sm mt-1 block w-full focus:border-black rounded-sm bg-gray-100",value:t.type,onCh
1ange:e=>G(e.target.value),children:[i.jsx("option",{value:"",children:"select"}),i.jsx("option",{value:"internal",children:"internal"}),i.jsx("option",{value:"external",children:"external"})]}),i.jsx(o,{message:d.type,className:"mt-2"})]})]})]})]})]})})]})}export{Ce as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.