1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8309],{54262:function(e,t,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/features",function(){return r(55529)}])},63164:function(e,t,r){"use strict";r.d(t,{$L:function(){return x},DK:function(){return p},K$:function(){return c},RX:function(){return d},hz:function(){return g},iA:function(){return h},iy:function(){return m},u4:function(){return y},y5:function(){return f}});var s=r(51740),n=r(3628),i=r(30190),a=r(87066);let o="/api",u=()=>localStorage.getItem("admin_token"),l=()=>({headers:{Authorization:`Bearer ${u()}`}}),c=()=>(0,s.a)({queryKey:["featureCategories"],queryFn:async()=>{let{data:e}=await a.Z.get(`${o}/feature-categories`,l());return e}}),d=()=>(0,s.a)({queryKey:["groupedFeatures"],queryFn:async()=>{let{data:e}=await a.Z.get(`${o}/features/public/grouped`);return e},staleTime:0,gcTime:6e5,refetchOnMount:"always",refetchOnWindowFocus:!0}),h=()=>{let e=(0,n.NL)();return(0,i.D)({mutationFn:async e=>(await a.Z.post(`${o}/feature-categories`,e,l())).data,onSuccess:()=>e.invalidateQueries({queryKey:["featureCategories"]})})},m=()=>{let e=(0,n.NL)();return(0,i.D)({mutationFn:async e=>{let{id:t,data:r}=e;return(await a.Z.put(`${o}/feature-categories/${t}`,r,l())).data},onSuccess:()=>e.invalidateQueries({queryKey:["featureCategories"]})})},f=()=>{let e=(0,n.NL)();return(0,i.D)({mutationFn:async e=>(await a.Z.delete(`${o}/feature-categories/${e}`,l())).data,onSuccess:()=>e.invalidateQueries({queryKey:["featureCategories"]})})},g=e=>(0,s.a)({queryKey:["features",e],queryFn:async()=>{let t=e?`${o}/features?category_id=${e}`:`${o}/features`,{data:r}=await a.Z.get(t,l());return r}}),x=()=>{let e=(0,n.NL)();return(0,i.D)({mutationFn:async e=>(await a.Z.post(`${o}/features`,e,l())).data,onSuccess:()=>e.invalidateQueries({queryKey:["features"]})})},y=()=>{let e=(0,n.NL)();return(0,i.D)({mutationFn:async e=>{let{id:t,data:r}=e;return(await a.Z.put(`${o}/features/${t}`,r,l())).data},onSuccess:()=>e.invalidateQueries({queryKey:["features"]})})},p=()=>{let e=(0,n.NL)();return(0,i.D)({mutationFn:async e=>(await a.Z.delete(`${o}/features/${e}`,l())).data,onSuccess:()=>e.invalidateQueries({queryKey:["features"]})})}},60322:function(e,t,r){"use strict";r.d(t,{_:function(){return s},u:function(){return n}});let s=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"vi",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"vi";if(!e)return"";if("string"==typeof e)return e;let s=e[t];if(s&&s.trim())return s;let n=e[r];return n&&n.trim()?n:e.vi||e.en||""},n=e=>e?"string"==typeof e?{vi:e,en:"",zh:""}:{vi:e.vi||"",en:e.en||"",zh:e.zh||"",...e}:{vi:"",en:"",zh:""}},55529:function(e,t,r){"use strict";r.r(t),r.d(t,{__N_SSP:function(){return g},default:function(){return x}});var s=r(85893),n=r(67294),i=r(9008),a=r.n(i),o=r(41664),u=r.n(o),l=r(29882),c=r(31412),d=r(40971),h=r(63164),m=r(14879),f=r(60322),g=!0;function x(){let{showToast:e}=(0,d.p)(),[t,r]=(0,n.useState)(!1),[i,o]=(0,n.useState)(null),{data:g}=(0,h.K$)(),{data:x,isLoading:y}=(0,h.hz)(),p=(0,h.u4)(),b=(0,h.DK)(),[v,w]=(0,n.useState)(""),[j,N]=(0,n.useState)("all"),_=g?.data||[],C=e=>"blog"===e.type&&e.blog_articles?(0,f._)(e.blog_articles.title,"vi"):(0,f._)(e.title,"vi")||"Untitled",$=(0,n.useMemo)(()=>{let e=x?.data||[];if(v){let t=v.toLowerCase();e=e.filter(e=>C(e).toLowerCase().includes(t))}return"all"!==j&&(e=e.filter(e=>e.feature_category_id===j)),e},[x,v,j]),k=async t=>{try{await p.mutateAsync({id:t.id,data:{...t,is_active:!t.is_active}}),e("success",`ð Ä\xe3 ${t.is_active?"ẩn":"hiá»n"} t\xednh nÄng!`)}catch(t){e("error","â Cáºp nháºt trạng th\xe1i thất bại")}},O=async t=>{try{await p.mutateAsync({id:t.id,data:{...t,is_featured:!t.is_featured}}),e("success",`â Ä\xe3 ${t.is_featured?"gỡ":"Äặt"} ná»i báºt!`)}catch(t){e("error","â Cáºp nháºt trạng th\xe1i ná»i báºt thất bại")}},D=async()=>{if(i)try{await b.mutateAsync(i.id),e("success","\uD83D\uDDD1ï¸ Ä\xe3 x\xf3a t\xednh nÄng!")}catch(t){e("error",`â ${t?.response?.data?.message||"X\xf3a thất bại"}`)}finally{r(!1),o(null)}};return(0,s.jsxs)(c.default,{title:"Quản l\xfd T\xednh nÄng",children:[(0,s.jsx)(a(),{children:(0,s.jsx)("title",{children:"T\xednh nÄng - RedAI Admin"})}),(0,s.jsxs)("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center gap-4 mb-8",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-3xl font-extrabold text-gray-900 tracking-tight",children:"T\xednh nÄng há» thá»ng"}),(0,s.jsx)("p",{className:"text-gray-500 mt-1 text-sm font-medium",children:"Quản l\xfd kho ná»i dung Video Demo v\xe0 c\xe1c B\xe0i viết t\xednh nÄng cá»t l\xf5i"})]}),(0,s.jsx)(u(),{href:"/admin/features/new",children:(0,s.jsxs)(m.zx,{variant:"primary",className:"shadow-lg shadow-red-100 px-6 py-2.5 rounded-xl transition-all hover:scale-105 active:scale-95",children:[(0,s.jsx)(l.Z,{name:"plus",className:"mr-2 h-5 w-5"})," Th\xeam T\xednh nÄng"]})})]}),(0,s.jsxs)("div",{className:"flex flex-col md:flex-row gap-4 mb-6 bg-white p-4 rounded-2xl border border-gray-100 shadow-sm",children:[(0,s.jsxs)("div",{className:"relative flex-1",children:[(0,s.jsx)(l.Z,{name:"search",className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 w-5 h-5"}),(0,s.jsx)("input",{type:"text",placeholder:"T\xecm kiếm theo ti\xeau Äá»...",className:"w-full pl-10 pr-4 py-2.5 rounded-xl border-gray-100 focus:ring-red-500 focus:border-red-500 bg-gray-50/50",value:v,onCh
1ange:e=>w(e.target.value)})]}),(0,s.jsx)("div",{className:"w-full md:w-64",children:(0,s.jsxs)("select",{className:"w-full px-4 py-2.5 rounded-xl border-gray-100 focus:ring-red-500 focus:border-red-500 bg-gray-50/50 font-medium text-gray-700",value:j,onChange:e=>N(e.target.value),children:[(0,s.jsx)("option",{value:"all",children:"Tất cả danh mục"}),_.map(e=>(0,s.jsx)("option",{value:e.id,children:(0,f._)(e.title,"vi")},e.id))]})})]}),(0,s.jsx)("div",{className:"bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden",children:(0,s.jsx)(m.wQ,{keyExtractor:e=>e.id,columns:[{key:"title",header:"Ti\xeau Äá» / Ná»i dung",render:e=>(0,s.jsxs)("div",{className:"flex items-center gap-4 py-1",children:["video"===e.type?(0,s.jsxs)("div",{className:"relative group w-14 h-14 bg-gray-50 rounded-xl overflow-hidden border border-gray-100 shadow-sm flex-shrink-0",children:[e.thumbnail_url?(0,s.jsx)("img",{src:e.thumbnail_url,className:"w-full h-full object-cover transition-transform group-hover:scale-110"}):(0,s.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,s.jsx)(l.Z,{name:"video",className:"text-gray-300 w-6 h-6"})}),(0,s.jsx)("div",{className:"absolute inset-0 bg-black/10 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:(0,s.jsx)(l.Z,{name:"play-circle",className:"text-white w-6 h-6"})})]}):(0,s.jsx)("div",{className:"w-14 h-14 bg-red-50 rounded-xl flex items-center justify-center text-red-500 border border-red-100 flex-shrink-0",children:(0,s.jsx)(l.Z,{name:"file-text",className:"w-6 h-6"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"font-bold text-gray-900 text-base truncate max-w-[300px]",children:C(e)}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,s.jsx)("span",{className:`text-[10px] uppercase font-bold px-2 py-0.5 rounded-md ${"video"===e.type?"bg-orange-100 text-orange-700":"bg-blue-100 text-blue-700"}`,children:"video"===e.type?"\uD83C\uDF9Eï¸ Video":"\uD83D\uDCF0 Blog"}),(0,s.jsx)("span",{className:"text-[11px] font-semibold text-gray-400 bg-gray-50 px-2 py-0.5 rounded-md border border-gray-100",children:(0,f._)(e.feature_categories?.title,"vi")||"Chưa ph\xe2n loại"})]})]})]})},{key:"is_featured",header:"Ná»i báºt",align:"center",render:e=>(0,s.jsx)("button",{onClick:()=>O(e),className:`p-1.5 rounded-lg border shadow-sm transition-all ${e.is_featured?"bg-yellow-50 text-yellow-600 border-yellow-100":"text-gray-300 border-gray-100 hover:border-yellow-200 hover:text-yellow-400"}`,title:e.is_featured?"Gỡ ná»i báºt":"Äặt ná»i báºt",children:(0,s.jsx)(l.Z,{name:"star",className:`w-4 h-4 ${e.is_featured?"fill-current":""}`})})},{key:"sort_order",header:"Thứ tá»±",align:"center",render:e=>(0,s.jsx)("span",{className:"font-mono text-gray-600 font-medium",children:e.sort_order})},{key:"is_active",header:"Hiá»n thá»",align:"center",render:e=>(0,s.jsx)("button",{onClick:()=>k(e),className:"flex items-center justify-center group",children:(0,s.jsxs)("span",{className:`inline-flex items-center px-3 py-1 rounded-full text-xs font-bold border transition-all group-hover:scale-105 ${e.is_active?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-gray-50 text-gray-500 border-gray-200"}`,children:[(0,s.jsx)("span",{className:`w-1.5 h-1.5 rounded-full mr-2 ${e.is_active?"bg-emerald-500 animate-pulse":"bg-gray-400"}`}),e.is_active?"C\xf4ng khai":"Nh\xe1p"]})})},{key:"actions",header:"Quản l\xfd",align:"right",render:e=>(0,s.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,s.jsx)(u(),{href:`/admin/features/${e.id}/edit`,children:(0,s.jsx)("button",{className:"p-2.5 text-indigo-600 hover:bg-indigo-50 rounded-xl transition-all hover:shadow-md border border-transparent hover:border-indigo-100",title:"Chá»nh sá»a",children:(0,s.jsx)(l.Z,{name:"edit",className:"w-5 h-5"})})}),(0,s.jsx)("button",{onClick:()=>{o({id:e.id,title:C(e)}),r(!0)},className:"p-2.5 text-rose-600 hover:bg-rose-50 rounded-xl transition-all hover:shadow-md border border-transparent hover:border-rose-100",title:"X\xf3a",children:(0,s.jsx)(l.Z,{name:"trash-2",className:"w-5 h-5"})})]})}],data:$,isLoading:y})}),(0,s.jsx)(m.sm,{isOpen:t,onClose:()=>r(!1),onConfirm:D,title:"X\xe1c nháºn x\xf3a",message:`Dữ liá»u vá» "${i?.title}" sẽ bá» x\xf3a vÄ©nh viá»
n khá»i há» thá»ng. Bạn c\xf3 chắc chắn?`,variant:"danger"})]})}},30190:function(e,t,r){"use strict";r.d(t,{D:function(){return c}});var s=r(67294),n=r(59289),i=r(27037),a=r(7506),o=r(24139),u=class extends a.l{#e;#t=void 0;#r;#s;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#n()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),(0,o.VS)(this.options,t)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#r,observer:this}),t?.mutationKey&&this.options.mutationKey&&(0,o.Ym)(t.mutationKey)!==(0,o.Ym)(this.options.mutationKey)?this.reset():this.#r?.state.status==="pending"&&this.#r.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#r?.removeObserver(this)}onMutationUpdate(e){this.#n(),this.#i(e)}getCurrentResult(){return this.#t}reset(){this.#r?.removeObserver(this),this.#r=void 0,this.#n(),this.#i()}mutate(e,t){return this.#s=t,this.#r?.removeObserver(this),this.#r=this.#e.getMutationCache().build(this.#e,this.options),this.#r.addObserver(this),this.#r.execute(e)}#n(){let e=this.#r?.state??(0,n.R)();this.#t={...e,isPending:"pending"===e.status,isSuccess:"success"===e.status,isError:"error"===e.status,isIdle:"idle"===e.status,mutate:this.mutate,reset:this.reset}}#i(e){i.Vr.batch(()=>
1{if(this.#s&&this.hasListeners()){let t=this.#t.variables,r=this.#t.context,s={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};e?.type==="success"?(this.#s.onSuccess?.(e.data,t,r,s),this.#s.onSettled?.(e.data,null,t,r,s)):e?.type==="error"&&(this.#s.onError?.(e.error,t,r,s),this.#s.onSettled?.(void 0,e.error,t,r,s))}this.listeners.forEach(e=>{e(this.#t)})})}},l=r(3628);function c(e,t){let r=(0,l.NL)(t),[n]=s.useState(()=>new u(r,e));s.useEffect(()=>{n.setOptions(e)},[n,e]);let a=s.useSyncExternalStore(s.useCallback(e=>n.subscribe(i.Vr.batchCalls(e)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),c=s.useCallback((e,t)=>{n.mutate(e,t).catch(o.ZT)},[n]);if(a.error&&(0,o.L3)(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:c,mutateAsync:a.mutate}}}},function(e){e.O(0,[1664,5675,7066,1740,9882,1412,4879,2888,9774,179],function(){return e(e.s=54262)}),_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.