1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6831],{13742:(e,t,l)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/blog/edit",function(){return l(20585)}])},20585:(e,t,l)=>{"use strict";l.r(t),l.d(t,{__N_SSP:()=>v,default:()=>w});var a=l(37876),r=l(69473),s=l(76361),d=l(14232),o=l(48655),i=l(13758),n=l(8829),c=l(76987),m=l(65613),u=l(89099),b=l(81908),p=l(90992),x=l(48230),h=l.n(x),g=l(26250),v=!0;function w(e){let{data:t,categories:l}=e,x=(0,u.useRouter)(),v=(0,u.useRouter)().locale,w=(0,d.useRef)(null),[_,j]=(0,d.useState)(""),[f,y]=(0,d.useState)(""),[N,k]=(0,d.useState)(!1),[A,S]=(0,d.useState)(!1),T=async e=>{try{let t=await fetch("/api/admin/blog_update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await t.json()}catch(e){console.error("Error updating blog:",e)}},E=async(e,t)=>{S(!0);let l="";switch(t){case"prod":l="https://www.fieldbee.com";break;case"dev":l="https://dev-fieldbee.vercel.app";break;case"test":l="http://localhost:3000"}try{let t="/api/admin/blog_deploy?directory=".concat("en"!==v?"/"+v:"","/blog/").concat(e,"&destination=").concat(l),a=await fetch(t);return await a.json()}catch(e){throw console.error("Error:",e.message),e}};return(0,a.jsxs)(r.A,{children:[(0,a.jsx)("form",{className:"pt-10 pb-10 bg-white text-black rounded-xl",id:"form",onSubmit:e=>(e=>{e.preventDefault();let l={},a=e.target,r=a.querySelectorAll("input"),s=a.querySelectorAll("select"),d=a.querySelectorAll("textarea"),o=document.getElementById("preview_block_image");r.forEach(e=>{""!==e.name&&(l[e.name]=e.value)}),l.content=w.current.getContent(),l.title=l.preview_block_title,l.share_links=null,l.preview_block_link=l.blog_id,l.lang_code=x.query.lang,l.category_id=s[0].value,l.preview_block_content=d[1].value,l.preview_block_image=o.textContent,l.id=parseInt(l.id),l.preview_mode=parseInt(l.preview_mode),T(((e,l)=>{let a={};for(let r in t)e[r]!==l[r]&&(a[r]=e[r]);return a.id=l.id,a})(l,t)).then(e=>{j(e.message),y(e.success),k(!0);let t=setTimeout(()=>{k(!1)},3e3);return()=>{clearTimeout(t)}})})(e),method:"POST",children:(0,a.jsxs)(s.xA,{children:[(0,a.jsx)(o.A,{value:t.id,className:"hidden",name:"id"}),(0,a.jsx)(o.A,{value:t.created_at,className:"hidden",name:"created_at"}),(0,a.jsx)(o.A,{value:t.updated_at,className:"hidden",name:"updated_at"}),(0,a.jsxs)("div",{className:"mb-10",children:[(0,a.jsxs)("div",{className:"mb-6 text-center",children:[(0,a.jsx)(o.A,{value:t.preview_block_date,className:"uppercase mb-2 font-semibold text-sm text-light-3 text-center",name:"preview_block_date"}),(0,a.jsx)(o.A,{value:t.preview_block_title,className:"mx-auto text-3xl font-bold w-full block text-black text-center h-full",name:"preview_block_title"})]}),(0,a.jsx)(n.A,{className:"post-img",image:t.preview_block_image})]}),(0,a.jsxs)(s.fI,{children:[(0,a.jsxs)(s.fv,{xs:3,lg:3,className:"hidden lg:block",children:[(0,a.jsx)("div",{className:"block bg-admin-grey animate-pulse w-full h-10 rounded mb-5"}),[0,1,2,3,4].map(e=>(0,a.jsx)("div",{className:"block bg-admin-grey animate-pulse w-full h-10 rounded mb-2"},e))]}),(0,a.jsxs)(s.fv,{xs:12,lg:6,className:"post-content",children:[(0,a.jsxs)("div",{className:"flex flex-row items-center gap-2 !m-0 border border-regal-red rounded-xl p-3",children:[(0,a.jsx)(g.tr_,{className:"w-16 h-16 text-regal-red"}),(0,a.jsx)("span",{className:"text-regal-red leading-5 text-justify",children:"After uploading the image, please wait a couple of seconds before saving while the image is uploaded to the server"})]}),(0,a.jsx)(i.A,{initialValue:t.content,editorRef:w}),(0,a.jsx)("div",{className:"h-px mt-10 mb-6 bg-grey border-0"}),(0,a.jsx)("table",{children:(0,a.jsxs)("tbody",{children:[(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"w-52 border border-grey p-2",children:"Blog id:"}),(0,a.jsx)("td",{className:"border border-grey p-2",children:(0,a.jsx)(o.A,{className:"w-full",readOnly:!0,value:t.blog_id,name:"blog_id"})})]}),(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"w-52 border border-grey p-2",children:"Category:"}),(0,a.jsx)("td",{className:"border border-grey py-2 !px-1.5",children:(0,a.jsx)("select",{className:"focus:outline-0",defaultValue:t.category_id,name:"category_id",id:"category",children:l.map((e,t)=>(0,a.jsx)("option",{value:e.id,children:e.category_name},t))})})]}),(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"w-52 border border-grey p-2",children:"Preview button title:"}),(0,a.jsx)("td",{className:"border border-grey p-2",children:(0,a.jsx)(o.A,{className:"w-full",value:t.preview_block_btn_title,name:"preview_block_btn_title"})})]}),(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"w-52 border border-grey p-2",children:"Preview content:"}),(0,a.jsx)("td",{className:"border border-grey p-2",children:(0,a.jsx)(o.A,{className:"w-full",textarea:!0,value:t.preview_block_content,name:"preview_block_content",attributes:{maxLength:225}})})]}),(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"w-52 border border-grey p-2",children:"Editor mode:"}),(0,a.jsx)("td",{className:"border border-grey p-2",children:(0,a.jsx)(c.A,{status:t.preview_mode,name:"preview_mode"})})]})]})}),(0,a.jsxs)("div",{className:"flex flex-row justify-between",children:[(0,a.jsx)(m.Ay,{size:m.wd.small,className:"mt-10 w-fit",id:"formSubmit",children:"Save"}),A?(0,a.jsx)(p.A,{className:"!mt-10 !mb-0 !w-[172px] flex justify-center"}):(0,a.jsx)("button",{type:"button",className:"mt-10 w-fit button-lead bg-regal-yellow text-black button rounded-full font-semibold uppercase transition duration-150 ease-out hover:ease-in px-8 py-2 text-sm",onClick:()=>E(t.blog_id,"dev").then(e=>{j(e.revalidated?"Deployed on dev":"Problem with deploying on dev"),y(e.revalidated),k(!0),S(!1);let t=setTimeout(()=>{k(!1)},3e3);return()=>{clearTimeout(t)}}),children:"Deploy [dev]"}),(0,a.jsx)(h(),{href:"https://dev-fieldbee.vercel.app".concat("en"!==v?"/"+v:"","/blog/").concat(t.blog_id),target:"_blank",className:"mt-10 w-fit button-lead bg-regal-yellow text-black button rounded-full font-semibold uppercase transition duration-150 ease-out hover:ease-in px-8 py-2 text-sm hover:!text-black",children:"Preview [dev]"}),A?(0,a.jsx)(p.A,{className:"!mt-10 !mb-0 !w-[172px] flex justify-center"}):(0,a.jsx)("button",{type:"button",className:"mt-10 w-fit button-lead bg-regal-yellow text-black button rounded-full font-semibold uppercase transition duration-150 ease-out hover:ease-in px-8 py-2 text-sm",onClick:()=>E(t.blog_id,"prod").then(e=>{j(e.revalidated?"Deployed on prod":"Problem with deploying on prod"),y(e.revalidated),k(!0),S(!1);let t=setTimeout(()=>{k(!1)},3e3);return()=>{clearTimeout(t)}}),children:"Deploy [prod]"})]})]}),(0,a.jsxs)(s.fv,{xs:3,lg:3,className:"hidden lg:block",children:[(0,a.jsxs)("div",{className:"mb-6",children:[(0,a.jsx)("div",{className:"block bg-admin-grey animate-pulse w-full h-10 rounded mb-5"}),[0,1,2].map(e=>(0,a.jsx)("div",{className:"block bg-admin-grey animate-pulse w-full h-40 rounded-2xl mb-2"},e))]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"block bg-admin-grey animate-pulse w-full h-10 rounded mb-5"}),(0,a.jsx)("div",{className:"flex flex-wrap justify-between grid-cols-2",children:l.map((e,t)=>(0,a.jsx)("div",{className:"block bg-admin-grey animate-pulse w-[49%] h-10 rounded-2xl mb-2"},t))})]})]})]})]})}),N&&(0,a.jsx)(b.A,{message:_,status:f,visible:N})]})}}},e=>{e.O(0,[3845,4188,8752,4176,8827,7374,9904,9823,636,6593,8792],()=>e(e.s=13742)),_N_E=e.O()}]);
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.