PageSourceSearch

https://thenewyou.vercel.app/_next/static/chunks/pages/admin/blog-d8480fa5b26c8869.js

js thenewyou.vercel.app collected 2026-10-03 07:53:15 UTC 15,017 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7084],{55802:function(e,t,r){!function(e){e.defineLocale("th",{months:"มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม".split("_"),monthsShort:"ม.ค._ก.พ._มี.ค._เม.ย._พ.ค._มิ.ย._ก.ค._ส.ค._ก.ย._ต.ค._พ.ย._ธ.ค.".split("_"),monthsParseExact:!0,weekdays:"อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์".split("_"),weekdaysShort:"อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์".split("_"),weekdaysMin:"อา._จ._อ._พ._พฤ._ศ._ส.".split("_"),weekdaysParseExact:!0,longDateFormat:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY เวลา H:mm",LLLL:"วันddddที่ D MMMM YYYY เวลา H:mm"},meridiemParse:/ก่อนเที่ยง|หลังเที่ยง/,isPM:function(e){return"หลังเที่ยง"===e},meridiem:function(e,t,r){return e<12?"ก่อนเที่ยง":"หลังเที่ยง"},calendar:{sameDay:"[วันนี้ เวลา] LT",nextDay:"[พรุ่งนี้ เวลา] LT",nextWeek:"dddd[หน้า เวลา] LT",lastDay:"[เมื่อวานนี้ เวลา] LT",lastWeek:"[วัน]dddd[ที่แล้ว เวลา] LT",sameElse:"L"},relativeTime:{future:"อีก %s",past:"%sที่แล้ว",s:"ไม่กี่วินาที",ss:"%d วินาที",m:"1 นาที",mm:"%d นาที",h:"1 ชั่วโมง",hh:"%d ชั่วโมง",d:"1 วัน",dd:"%d วัน",w:"1 สัปดาห์",ww:"%d สัปดาห์",M:"1 เดือน",MM:"%d เดือน",y:"1 ปี",yy:"%d ปี"}})}(r(95093))},86754:(e,t,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/blog",function(){return r(74884)}])},77441:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var a=r(74848),l=r(96540),s=r(47719),n=r(16047),d=r(28394);function o(e){let{data:t,code:r,setCode:o,documentId:i,isNewCode:c,lastNumber:u}=e,[g,h]=(0,l.useState)(null),{lang:m}=(0,s.A)(),{getById:p}=(0,n.A)("numbering");(0,l.useEffect)(()=>{(async()=>{c?h(await (0,d.q)(i,u)):h(await (0,d.q)(i,t.id))})()},[]);let x=()=>({docEntry:(null==t?void 0:t.start_number)+(null==t?void 0:t.last_number)-1,code:g});return(0,l.useEffect)(()=>{g&&o(x)},[g]),(0,a.jsx)("div",{id:"code",name:"code",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white",children:g})}},74884:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>P});var a=r(74848),l=r(96540),s=r(16047),n=r(47719),d=r(33816),o=r(76835),i=r(84061),c=r(61409),u=r(95179),g=r(78465),h=r.n(g),m=r(33013),p=r(29965),x=r.n(p),b=r(78885),f=r(60373),y=r(63330),w=r(63972),v=r(15950),_=r(47091),j=r(93004);r(77441),r(28394);var k=r(79219),N=r(71884),C=r(14953),S=r.n(C),L=r(41195);let A=S()(()=>Promise.all([r.e(8758),r.e(7998),r.e(8872),r.e(7150),r.e(4973)]).then(r.bind(r,24973)),{loadableGenerated:{webpack:()=>[24973]},ssr:!1});function M(e){var t,r,s,d,o;let{onClose:i,blog:u,isNewBlog:g}=e,{t:h,lang:p}=(0,n.A)(),{data:C}=(0,m.useSession)(),S=null==C?void 0:null===(t=C.user)||void 0===t?void 0:t.userId,[M,Y]=(0,l.useState)({name:{th:"",en:""},description:{th:"",en:""},group:"",subgroup:""}),[D,E]=(0,l.useState)(!1),[T,P]=(0,l.useState)(null),[R,H]=(0,l.useState)([]),[O,z]=(0,l.useState)(null),[B,F]=(0,l.useState)(null);(0,l.useEffect)(()=>{u?(Y({name:u.name||{th:"",en:""},description:u.description||{th:"",en:""},group:u.group||"",subgroup:u.subgroup||""}),P(u.cover||null),H(u.tags||[]),F(u.content)):g&&H([])},[u]);let q=()=>{Y({name:{th:"",en:""},description:{th:"",en:""},group:"",subgroup:""}),H([]),z(null),P(null),i()},I=e=>{P(e[0])},G=()=>{(0,w.W)(T.file_id),P(null)},W=e=>
1("string"==typeof e?e:(null==e?void 0:e.en)||(null==e?void 0:e.th)||"").trim().toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-"),U=async e=>{e.preventDefault(),E(!0);try{let e=(0,L.Ak)(15),t={name:{th:M.name.th,en:M.name.en},description:{th:M.description.th,en:M.description.en},cover:T||null,group:M.group,subgroup:M.subgroup,tags:R,content:B,active:!0,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:"",updated_by:"",slug:W(M.name.en)},r=(0,N.H9)(k.db,"blogs",u?u.id:e.toString());await (0,N.x7)(r),g?(t.id=e,t.created_by=S,await (0,N.BN)((0,N.H9)(k.db,"blogs",t.id),t),c.oR.success(p.add_blog_success)):(t.updated_at=new Date().toISOString(),t.updated_by=S,await (0,N.mZ)(r,t),c.oR.success(p.update_blog_success)),q()}catch(e){console.error("Error saving blog:",e),c.oR.error(p.error_occured)}finally{E(!1)}};return D?(0,a.jsx)(_.A,{}):(0,a.jsx)("div",{className:"bg-white dark:bg-gray-800 w-full h-full rounded-lg shadow-lg",children:(0,a.jsxs)("div",{className:"flex flex-col w-full h-full",children:[(0,a.jsxs)("div",{className:"flex flex-row px-4 py-2 items-center justify-between bg-orange-500 w-full",children:[(0,a.jsx)("h1",{className:"text-2xl font-semibold text-white",children:u?p.edit_blog:p.create_blog}),(0,a.jsx)(f.A,{title:p.close,placement:"bottom",children:(0,a.jsx)("button",{type:"button",className:"text-white bg-transparent hover:bg-orange-300 hover:text-gray-900 rounded-lg text-sm w-8 h-8 inline-flex justify-center items-center",onClick:i,children:(0,a.jsx)(b.$8F,{size:22})})})]}),(0,a.jsxs)("div",{className:"flex flex-col p-4 gap-2",children:[(0,a.jsx)("div",{className:"grid grid-cols-1 gap-2 lg:grid-cols-2",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-900 dark:text-gray-300",children:p.image}),T&&(0,a.jsxs)("div",{className:"relative w-full h-[200px] rounded-lg",children:[(0,a.jsx)(x(),{src:null==T?void 0:T.url,alt:"mockup",width:500,height:500,className:"w-full h-full object-cover rounded-lg",priority:!0}),(0,a.jsx)("div",{className:"absolute top-0 right-1",children:(0,a.jsx)(f.A,{title:p.remove,arrow:!0,children:(0,a.jsx)("button",{type:"button",className:"bg-red-500 text-white rounded-full p-1 hover:bg-red-600",onClick:()=>G(),children:(0,a.jsx)(b.$8F,{size:10})})})})]}),(0,a.jsx)(y.A,{onUpload:e=>I(e),folder:"blogs",size:20,userId:S})]})}),(0,a.jsxs)("div",{className:"",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-900 dark:text-gray-300",children:p.name}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 lg:grid-cols-2",children:[(0,a.jsx)("input",{type:"text",id:"name.th",name:"name.th",value:null==M?void 0:null===(r=M.name)||void 0===r?void 0:r.th,onChange:e=>Y({...M,name:{...M.name,th:e.target.value}}),className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white",placeholder:p.name_placeholder+" (th)",required:!0}),(0,a.jsx)("input",{type:"text",id:"name.en",name:"name.en",value:null==M?void 0:null===(s=M.name)||void 0===s?void 0:s.en,onChange:e=>Y({...M,name:{...M.name,en:e.target.value}}),className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white",placeholder:p.name_placeholder+" (en)",required:!0})]})]}),(0,a.jsxs)("div",{className:"",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-900 dark:text-gray-300",children:p.description}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1 lg:grid-cols-2",children:[(0,a.jsx)("textarea",{type:"text",id:"description.th",name:"description.th",value:null==M?void 0:null===(d=M.description)||void 0===d?void 0:d.th,onChange:e=>Y({...M,description:{...M.description,th:e.target.value}}),className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white",placeholder:p.description_placeholder+" (th)",rows:4}),(0,a.jsx)("textarea",{type:"text",id:"description.en",name:"description.en",value:null==M?void 0:null===(o=M.description)||void 0===o?void 0:o.en,onChange:e=>Y({...M,description:{...M.description,en:e.target.value}}),className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white",placeholder:p.description_placeholder+" (en)",rows:4})]})]}),(0,a.jsxs)("div",{className:"flex flex-row gap-2",children:[(0,a.jsxs)("div",{className:"w-1/2",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-900 dark:text-gray-300",children:p.group}),(0,a.jsx)(v.A,{type:"group",page:"blogs",value:M.group,setValue:e=>Y({...M,group:e})})]}),(0,a.jsxs)("div",{className:"w-1/2",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-900 dark:text-gray-300",children:p.subgroup}),(0,a.jsx)(v.A,{type:"subgroup",page:"blogs",value:M.subgroup,setValue:e=>Y({...M,subgroup:e})})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{htmlFor:"Tages",className:"block text-sm font-medium text-gray-900 dark:text-gray-300",children:p.tags}),(0,a.jsx)(j.A,{tags:R,setTags:H})]})]}),(0,a.jsxs)("div",{className:"px-4",children:[(0,a.jsx)("label",{htmlFor:"content",children:p.content}),(0,a.jsx)(A,{content:B,onChange:e=>F(e)})]}),(0,a.jsxs)("div",{className:"flex flex-row items-center justify-center gap-2 p-4 w-full",children:[(0,a.jsx)("button",{type:"submit",className:"w-56 py-2 text-white bg-orange-500 hover:bg-orange-600 rounded-lg",onClick:U,children:p.save}),(0,a.jsx)("button",{type:"button",className:"w-56 py-2 text-white bg-red-500 hover:bg-red-600 rounded-lg",onClick:q,children:p.cancel})]})]})})}var Y=r(95093),D=r.n(Y);r(55802);var E=r(77037);D().locale("th");let T=l.forwardRef(function(e,t){return(0,a.jsx)(o.A,{direction:"up",ref:t,...e})});function P(){let[e,t]=(0,l.useState)([]),[r,o]=(0,l.useState)(null),[g,m]=(0,l.useState)([]),[p,x]=(0,l.useState)(""),[b,f]=(0,l.useState)(!1),{lang:y,t:w}=(0,n.A)(),{subscribe:v,getAll:_,add:j,update:k,remove:N}
1=(0,s.A)("blogs");(0,l.useEffect)(()=>{let e=v(e=>{e&&(t(e),m(e))});return()=>e()},[]),(0,l.useEffect)(()=>{p?m(e.filter(e=>e.name.en.toLowerCase().includes(p.toLowerCase())||e.name.th.toLowerCase().includes(p.toLowerCase())||e.description.en.toLowerCase().includes(p.toLowerCase())||e.description.th.toLowerCase().includes(p.toLowerCase()))):m(e)},[p,e]);let C=()=>{o(null),f(!1)},S=e=>{o(e),f(!0)},L=async(e,t)=>{try{await k(t,{active:!e}),c.oR.success(y.blog_updated_successfully)}catch(e){console.error(e),c.oR.error(y.update_failed)}},A=e=>{h().fire({title:y.are_you_sure,text:y.you_wont_be_able_to_revert_this,icon:"warning",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:y.yes_delete_it,cancelButtonText:y.cancel}).then(async t=>{if(t.isConfirmed)try{await N(e.id.toString()),c.oR.success(y.deleted_successfully)}catch(e){console.error(e),c.oR.error(y.delete_failed)}})},Y=[{field:"id",headerName:"code",width:150},{field:"name",headerName:"Name",width:200,renderCell:e=>w(e.row.name)},{field:"description",headerName:"Description",width:200,renderCell:e=>w(e.row.description)},{field:"group",headerName:"Group",width:150},{field:"subgroup",headerName:"SubGroup",width:150},{field:"active",headerName:"Active",width:80,flex:.5,headerAlign:"center",align:"center",renderCell:e=>(0,a.jsx)("span",{className:"px-2 py-1 rounded-lg cursor-pointer ".concat(e.value?"bg-green-500 text-white":"bg-red-500 text-white"),onClick:()=>L(e.row.id),children:e.value?y.active:y.inactive})},{field:"created_at",headerName:"Created At",width:200,renderCell:e=>D()(e.row.created_at).format("lll")},{field:"updated_at",headerName:"Updated At",width:200,renderCell:e=>D()(e.row.updated_at).format("lll")},{field:"tools",headerName:"tools",width:200,flex:.5,headerAlign:"center",align:"center",renderCell:e=>(0,a.jsxs)("div",{className:"flex flex-row items-center gap-2 h-12 w-full",children:[(0,a.jsx)("button",{type:"button",className:"text-blue-500 hover:tex-blue-600",onClick:()=>S(e.row),children:(0,a.jsx)(E.uO9,{size:25})}),(0,a.jsx)("button",{type:"button",className:"text-red-500 hover:text-red-600",onClick:()=>A(e.row),children:(0,a.jsx)(E.RCe,{size:25})})]})}];return(0,a.jsxs)("div",{className:"bg-white dark:bg-gray-800",children:[(0,a.jsx)("div",{className:"max-w-screen-xl px-2 py-4",children:(0,a.jsx)("span",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:y.blog})}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex flex-row items-center justify-between gap-4",children:[(0,a.jsx)("div",{children:(0,a.jsx)("button",{type:"button",className:"bg-orange-500 text-white px-4 py-2 rounded-md hover:bg-orange-600",onClick:()=>{o(null),f(!0)},children:(0,a.jsx)("span",{children:y.create_blog})})}),(0,a.jsx)("div",{children:(0,a.jsx)(u.A,{search:p,setSearch:x})})]}),(0,a.jsx)("div",{className:"mt-4",children:(0,a.jsx)(d.z,{rows:g,columns:Y,pageSize:10,rowsPerPageOptions:[10],checkboxSelection:!0,disableSelectionOnClick:!0,autoHeight:!0})})]}),(0,a.jsx)(i.A,{fullScreen:!0,open:b,TransitionComponent:T,keepMounted:!0,onClose:C,"aria-describedby":"alert-dialog-slide-description",children:(0,a.jsx)(M,{onClose:C,blog:r,isNewBlog:!r})})]})}},28394:(e,t,r)=>{"use strict";r.d(t,{q:()=>s});var a=r(71884),l=r(79219);async function s(e,t){try{var r,s;let n=(0,a.H9)(l.db,"numbering",e),d=await (0,a.x7)(n);if(!d.exists())return"";let{prefix:o="",suffix:i="",number_digits:c=4,year:u,month:g,day:h,group:m=[],subgroup:p=[],formatCode:x=[]}=d.data(),b=new Date,f=u?b.getFullYear().toString().slice(-2):"",y=g?(b.getMonth()+1).toString().padStart(2,"0"):"",w=h?b.getDate().toString().padStart(2,"0"):"",v=m.length>0&&(null===(r=m[0])||void 0===r?void 0:r.value)||"",_=p.length>0&&(null===(s=p[0])||void 0===s?void 0:s.value)||"",j=null==t?void 0:t.toString().padStart(Number(c),"0");return x.map(e=>{switch(e){case"prefix":return o;case"group":return v;case"subgroup":return _;case"year":return f;case"month":return y;case"day":return w;case"number_digits":return j;case"suffix":return i;default:return""}}).join("")}catch(e){return console.error("เกิดข้อผิดพลาดใน getFormattedCode:",e),""}}}},e=>{var t=t=>e(e.s=t);e.O(0,[1544,2777,3197,8870,1839,6968,5583,3816,7097,5113,636,6593,8792],()=>t(86754)),_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.