1import{_ as K}from"./Doy9htle.js";import{_ as O}from"./BD7RKQAa.js";import{e as G,f as J,h as Q,j as X,c as o,a,k as l,t as p,l as m,b as D,w as u,p as C,s as Y,q as y,o as r,x as Z,d,F as R,r as U,z as ee,n as i,v as k,A as b,B as te}from"./DfNc4eJv.js";const ae={class:"animate-fade-in space-y-4"},se={key:0,class:"text-sm text-red-600"},le={class:"rounded-full bg-primary-100 px-2.5 py-1 text-xs font-bold text-primary-700 dark:bg-primary-500/20 dark:text-primary-300"},ne={class:"font-medium"},ie={class:"flex flex-wrap gap-1"},oe={key:0,class:"rounded-full bg-slate-100 px-2 py-0.5 text-xs dark:bg-slate-800"},re={key:1,class:"rounded-full bg-slate-100 px-2 py-0.5 text-xs dark:bg-slate-800"},de={key:2,class:"rounded-full bg-slate-100 px-2 py-0.5 text-xs dark:bg-slate-800"},pe={key:3,class:"rounded-full bg-slate-100 px-2 py-0.5 text-xs dark:bg-slate-800"},ue={key:4,class:"rounded-full bg-amber-50 px-2 py-0.5 text-xs text-amber-700 dark:bg-amber-500/10 dark:text-amber-300"},ce=["onClick"],me=["onClick"],be={class:"sm:col-span-2 text-sm"},xe={class:"sm:col-span-2 text-sm"},ye={class:"text-sm"},fe={class:"flex items-center gap-2 self-end text-sm"},ge={class:"text-sm"},he={class:"mb-1 flex items-center gap-2 text-slate-500"},ke={class:"text-sm"},_e={class:"mb-1 flex items-center gap-2 text-slate-500"},ve={class:"sm:col-span-2 flex flex-wrap gap-4 text-sm"},Ae={class:"flex items-center gap-2"},Me={class:"flex items-center gap-2"},Pe={class:"flex items-center gap-2"},Be={class:"flex items-center gap-2"},we={class:"flex items-center gap-2"},Ce={class:"sm:col-span-2 text-sm"},Ve={class:"flex flex-wrap gap-3"},Ee=["checked","onChange"],Se=["disabled"],We=G({__name:"paket",setup(De){const V={push_mobile:"Push Mobile",push_web:"Push Web",whatsapp:"WhatsApp",telegram:"Telegram"},{token:N,user:E,apiFetch:v,fetchMe:T,logout:W}=J(),A=Q(),S=y([]),M=y(!0),f=y(""),_=y(!1),F=[{key:"code",label:"Kode"},{key:"name",label:"Nama Paket"},{key:"price_per_person_month",label:"Harga/Siswa+Pegawai/Bulan",align:"right"},{key:"max_students",label:"Maks Siswa",align:"right"},{key:"features",label:"Fitur"},{key:"active_school_count",label:"Sekolah Pakai",align:"right"},{key:"is_active",label:"Status"},{key:"actions",label:"",align:"right"}],x=y(null),P=Y({get:()=>x.value!==null,set:n=>{n||(x.value=null)}}),s=te({name:"",description:"",pricePerPersonMonth:0,maxStudents:null,trialDays:null,hasWeb:!0,hasMobileApp:!1,hasEmployeeMobileAttendance:!1,hasRfidBarcodeAttendance:!1,hasBiometricAttendance:!1,notificationChannels:[],isActive:!0}),g=y(!1),h=y(!1);function B(n){const e=n;return e?.data?.error?.message??e?.message??"Terjadi kesalahan, silakan coba lagi"}async function w(){M.value=!0;try{const n=await v("/admin/packages");S.value=n.packages}catch(n){f.value=B(n)}finally{M.value=!1}}function $(n){x.value=n,Object.assign(s,{name:n.name,description:n.description??"",pricePerPersonMonth:Number(n.price_per_person_month),maxStudents:n.max_students,trialDays:n.trial_days,hasWeb:n.has_web,hasMobileApp:n.has_mobile_app,hasEmployeeMobileAttendance:n.has_employee_mobile_attendance,hasRfidBarcodeAttendance:n.has_rfid_barcode_attendance,hasBiometricAttendance:n.has_biometric_attendance,notificationChannels:[...n.notification_channels],isActive:n.is_active}),g.value=n.max_students!==null,h.value=n.trial_days!==null}function H(n){const e=s.notificationChannels.indexOf(n);e===-1?s.notificationChannels.push(n):s.notificationChannels.splice(e,1)}async function I(){if(x.value){f.value="",_.value=!0;try{await v(`/admin/packages/${x.value.id}`,{method:"PATCH",body:{name:s.name,description:s.description||void 0,pricePerPersonMonth:s.pricePerPersonMonth,maxStudents:g.value?s.maxStudents:null,trialDays:h.value?s.trialDays:null,hasWeb:s.hasWeb,hasMobileApp:s.hasMobileApp,hasEmployeeMobileAttendance:s.hasEmployeeMobileAttendance,hasRfidBarcodeAttendance:s.hasRfidBarcodeAttendance,hasBiometricAttendance:s.hasBiometricAttendance,notificationChannels:s.notificationChannels,isActive:s.isActive}}),x.value=null,await w()}catch(n){f.value=B(n)}finally{_.value=!1}}}async function L(n){try{await v(`/admin/packages/${n.id}`,{method:"PATCH",body:{isActive:!n.is_active}}),await w()}catch(e){f.value=B(e)}}function j(n){return new Intl.NumberFormat("id-ID").format(Number(n))}return X(async()=>
1{if(!N.value){A.push("/login");return}if(!E.value)try{await T()}catch{W(),A.push("/login");return}if(E.value?.userType!=="saas_owner"){A.push("/login");return}await w()}),(n,e)=>{const q=K,z=O;return r(),o("div",ae,[e[27]||(e[27]=a("div",{class:"card"},[a("h1",{class:"text-xl font-bold text-slate-900 dark:text-slate-50"},"Paket Berlangganan"),a("p",{class:"mt-1 text-sm text-slate-500 dark:text-slate-400"},"Katalog paket FREEâELITE: harga, batas siswa, dan fitur bisa diubah di sini tanpa deploy ulang kode.")],-1)),l(f)?(r(),o("p",se,p(l(f)),1)):m("",!0),D(q,{loading:l(M),columns:F,rows:l(S),"page-size":10,"empty-text":"Belum ada paket."},{"cell-code":u(({row:t})=>[a("span",le,p(t.code),1)]),"cell-name":u(({row:t})=>[a("span",ne,p(t.name),1)]),"cell-price_per_person_month":u(({row:t})=>[d("Rp"+p(j(t.price_per_person_month)),1)]),"cell-max_students":u(({row:t})=>[d(p(t.max_students??"Tanpa batas"),1)]),"cell-features":u(({row:t})=>[a("div",ie,[e[14]||(e[14]=a("span",{class:"rounded-full bg-slate-100 px-2 py-0.5 text-xs dark:bg-slate-800"},"Web",-1)),t.has_mobile_app?(r(),o("span",oe,"App")):m("",!0),t.has_employee_mobile_attendance?(r(),o("span",re,"Absensi Pegawai Mobile")):m("",!0),t.has_rfid_barcode_attendance?(r(),o("span",de,"RFID/Barcode")):m("",!0),t.has_biometric_attendance?(r(),o("span",pe,"Biometrik")):m("",!0),(r(!0),o(R,null,U(t.notification_channels,c=>(r(),o("span",{key:c,class:"rounded-full bg-primary-50 px-2 py-0.5 text-xs text-primary-700 dark:bg-primary-500/10 dark:text-primary-300"},p(V[c]),1))),128)),t.trial_days?(r(),o("span",ue,"Trial "+p(t.trial_days)+" hari",1)):m("",!0)])]),"cell-active_school_count":u(({row:t})=>[d(p(t.active_school_count),1)]),"cell-is_active":u(({row:t})=>[a("button",{type:"button",class:Z(["rounded-full px-2 py-0.5 text-xs font-medium transition-all active:scale-95",t.is_active?"bg-green-100 text-green-700 hover:bg-green-200":"bg-slate-200 text-slate-600 hover:bg-slate-300"]),onClick:c=>L(t)},p(t.is_active?"Aktif":"Nonaktif"),11,ce)]),"cell-actions":u(({row:t})=>[a("button",{type:"button",class:"text-xs font-medium text-primary-600 hover:underline",onClick:c=>$(t)},"Edit",8,me)]),_:1},8,["loading","rows"]),D(z,{modelValue:l(P),"onUpdate:modelValue":e[13]||(e[13]=t=>C(P)?P.value=t:null),title:`Edit Paket ${l(x)?.code??""}`,"max-width":"max-w-xl"},{default:u(()=>[a("form",{class:"grid grid-cols-1 gap-3 sm:grid-cols-2",onSubmit:ee(I,["prevent"])},[a("label",be,[e[15]||(e[15]=a("span",{class:"mb-1 block text-slate-500"},"Nama Paket",-1)),i(a("input",{"onUpdate:modelValue":e[0]||(e[0]=t=>l(s).name=t),required:"",class:"w-full rounded-lg border border-slate-300 px-3 py-2 text-sm dark:border-slate-700 dark:bg-slate-800"},null,512),[[k,l(s).name]])]),a("label",xe,[e[16]||(e[16]=a("span",{class:"mb-1 block text-slate-500"},"Deskripsi",-1)),i(a("input",{"onUpdate:modelValue":e[1]||(e[1]=t=>l(s).description=t),class:"w-full rounded-lg border border-slate-300 px-3 py-2 text-sm dark:border-slate-700 dark:bg-slate-800"},null,512),[[k,l(s).description]])]),a("label",ye,[e[17]||(e[17]=a("span",{class:"mb-1 block text-slate-500"},"Harga per Siswa+Pegawai/Bulan (Rp)",-1)),i(a("input",{"onUpdate:modelValue":e[2]||(e[2]=t=>l(s).pricePerPersonMonth=t),type:"number",min:"0",required:"",class:"w-full rounded-lg border border-slate-300 px-3 py-2 text-sm dark:border-slate-700 dark:bg-slate-800"},null,512),[[k,l(s).pricePerPersonMonth,void 0,{number:!0}]])]),a("label",fe,[i(a("input",{"onUpdate:modelValue":e[3]||(e[3]=t=>l(s).isActive=t),type:"checkbox",class:"h-4 w-4 rounded border-slate-300 text-primary-600"},null,512),[[b,l(s).isActive]]),e[18]||(e[18]=d(" Paket aktif ditawarkan ",-1))]),a("div",ge,[a("label",he,[i(a("input",{"onUpdate:modelValue":e[4]||(e[4]=t=>C(g)?g.value=t:null),type:"checkbox",class:"h-4 w-4 rounded border-slate-300 text-primary-600"},null,512),[[b,l(g)]]),e[19]||(e[19]=d(" Batasi maksimal siswa ",-1))]),l(g)?i((r(),o("input",{key:0,"onUpdate:modelValue":e[5]||(e[5]=t=>l(s).maxStudents=t),type:"number",min:"1",class:"w-full rounded-lg border border-slate-300 px-3 py-2 text-sm dark:border-slate-700 dark:bg-slate-800"},null,512)),[[k,l(s).maxStudents,void 0,{number:!0}]]):m("",!0)]),a("div",ke,[a("label",_e,[i(a("input",{"onUpdate:modelValue":e[6]||(e[6]=t=>
1C(h)?h.value=t:null),type:"checkbox",class:"h-4 w-4 rounded border-slate-300 text-primary-600"},null,512),[[b,l(h)]]),e[20]||(e[20]=d(" Berupa trial (hari) ",-1))]),l(h)?i((r(),o("input",{key:0,"onUpdate:modelValue":e[7]||(e[7]=t=>l(s).trialDays=t),type:"number",min:"1",class:"w-full rounded-lg border border-slate-300 px-3 py-2 text-sm dark:border-slate-700 dark:bg-slate-800"},null,512)),[[k,l(s).trialDays,void 0,{number:!0}]]):m("",!0)]),a("div",ve,[a("label",Ae,[i(a("input",{"onUpdate:modelValue":e[8]||(e[8]=t=>l(s).hasWeb=t),type:"checkbox",class:"h-4 w-4 rounded border-slate-300 text-primary-600"},null,512),[[b,l(s).hasWeb]]),e[21]||(e[21]=d(" Aplikasi Web ",-1))]),a("label",Me,[i(a("input",{"onUpdate:modelValue":e[9]||(e[9]=t=>l(s).hasMobileApp=t),type:"checkbox",class:"h-4 w-4 rounded border-slate-300 text-primary-600"},null,512),[[b,l(s).hasMobileApp]]),e[22]||(e[22]=d(" Aplikasi Mobile ",-1))]),a("label",Pe,[i(a("input",{"onUpdate:modelValue":e[10]||(e[10]=t=>l(s).hasEmployeeMobileAttendance=t),type:"checkbox",class:"h-4 w-4 rounded border-slate-300 text-primary-600"},null,512),[[b,l(s).hasEmployeeMobileAttendance]]),e[23]||(e[23]=d(" Absensi Mobile untuk Pegawai ",-1))]),a("label",Be,[i(a("input",{"onUpdate:modelValue":e[11]||(e[11]=t=>l(s).hasRfidBarcodeAttendance=t),type:"checkbox",class:"h-4 w-4 rounded border-slate-300 text-primary-600"},null,512),[[b,l(s).hasRfidBarcodeAttendance]]),e[24]||(e[24]=d(" Absensi RFID/Barcode ",-1))]),a("label",we,[i(a("input",{"onUpdate:modelValue":e[12]||(e[12]=t=>l(s).hasBiometricAttendance=t),type:"checkbox",class:"h-4 w-4 rounded border-slate-300 text-primary-600"},null,512),[[b,l(s).hasBiometricAttendance]]),e[25]||(e[25]=d(" Absensi Biometrik ",-1))])]),a("div",Ce,[e[26]||(e[26]=a("span",{class:"mb-1 block text-slate-500"},"Channel Notifikasi",-1)),a("div",Ve,[(r(),o(R,null,U(V,(t,c)=>a("label",{key:c,class:"flex items-center gap-2"},[a("input",{type:"checkbox",checked:l(s).notificationChannels.includes(c),class:"h-4 w-4 rounded border-slate-300 text-primary-600",onChange:Re=>H(c)},null,40,Ee),d(" "+p(t),1)])),64))])]),a("button",{type:"submit",class:"btn-primary sm:col-span-2",disabled:l(_)},p(l(_)?"Menyimpan...":"Simpan Perubahan"),9,Se)],32)]),_:1},8,["modelValue","title"])])}}});export{We 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.