astro-admin/dist/assets/Subscriptions-CGNWQzow.js

1 line
3.4 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{D as e,E as t,S as n,_ as r,d as i,g as a,h as o,l as s,m as c,n as l,v as u,w as d,x as f,y as p}from"./index-DzvFzRSs.js";var m={class:`flex gap-2 mb-4 overflow-x-auto pb-1`},h=[`onClick`],g={key:0,class:`text-slate-500 py-12 text-center`},_={key:1,class:`hidden md:block bg-white rounded-xl shadow-sm border overflow-hidden`},v={class:`w-full text-sm`},y={class:`divide-y`},b={class:`px-4 py-3 text-slate-500`},x={class:`px-4 py-3`},S={class:`px-4 py-3 text-center`},C={class:`px-4 py-3 text-slate-500`},w={class:`px-4 py-3 text-slate-500`},T={class:`px-4 py-3 text-center`},E={key:2,class:`md:hidden space-y-3`},D={class:`flex items-start justify-between`},O={class:`grid grid-cols-2 gap-2 mt-3 text-xs`},k={class:`text-slate-700`},A={class:`text-slate-700`},j={key:3,class:`text-slate-400 text-center py-12`},M={__name:`Subscriptions`,setup(M){let N=d([]),P=d(!0),F=d(``),I=[``,`active`,`expired`,`pending`,`cancelled`];r(()=>L());async function L(){P.value=!0;try{let e=F.value?{status:F.value}:{},{data:t}=await l.get(`/admin/api/subscriptions`,{params:e});N.value=t.subscriptions}finally{P.value=!1}}function R(e){return{active:`px-2 py-0.5 bg-green-100 text-green-700 rounded-full text-xs`,pending:`px-2 py-0.5 bg-amber-100 text-amber-700 rounded-full text-xs`,expired:`px-2 py-0.5 bg-slate-100 text-slate-600 rounded-full text-xs`,cancelled:`px-2 py-0.5 bg-red-100 text-red-700 rounded-full text-xs`}[e]||`text-slate-600`}function z(e){return e?new Date(e).toLocaleDateString(`ru-RU`,{day:`2-digit`,month:`2-digit`,year:`2-digit`}):`—`}return(r,l)=>{let d=f(`router-link`);return u(),c(`div`,null,[l[3]||=i(`h1`,{class:`text-xl md:text-2xl font-bold mb-4 md:mb-6`},`📱 Подписки`,-1),i(`div`,m,[(u(),c(s,null,p(I,n=>i(`button`,{key:n,onClick:e=>{F.value=n,L()},class:t([`px-3 py-1.5 rounded-lg text-sm whitespace-nowrap capitalize`,F.value===n?`bg-indigo-600 text-white`:`bg-white border`])},e(n||`Все`),11,h)),64))]),P.value?(u(),c(`div`,g,`Загрузка...`)):N.value.length?[(u(),c(`div`,_,[i(`table`,v,[l[0]||=i(`thead`,{class:`bg-slate-50`},[i(`tr`,null,[i(`th`,{class:`px-4 py-3 text-left`},`Создана`),i(`th`,{class:`px-4 py-3 text-left`},`Клиент`),i(`th`,{class:`px-4 py-3 text-center`},`Статус`),i(`th`,{class:`px-4 py-3 text-left`},`Начало`),i(`th`,{class:`px-4 py-3 text-left`},`Конец`),i(`th`,{class:`px-4 py-3 text-center`},`Auto-renew`)])],-1),i(`tbody`,y,[(u(!0),c(s,null,p(N.value,r=>(u(),c(`tr`,{key:r.id,class:`hover:bg-slate-50`},[i(`td`,b,e(z(r.created_at)),1),i(`td`,x,[a(d,{to:`/users/${r.user_id}`,class:`text-indigo-600 hover:underline`},{default:n(()=>[o(e(r.user_id),1)]),_:2},1032,[`to`])]),i(`td`,S,[i(`span`,{class:t(R(r.status))},e(r.status),3)]),i(`td`,C,e(z(r.started_at)),1),i(`td`,w,e(z(r.ends_at)),1),i(`td`,T,e(r.auto_renew?`✅`:`—`),1)]))),128))])])])),(u(),c(`div`,E,[(u(!0),c(s,null,p(N.value,r=>(u(),c(`div`,{key:r.id,class:`bg-white rounded-xl border border-slate-200 shadow-sm p-4`},[i(`div`,D,[a(d,{to:`/users/${r.user_id}`,class:`text-indigo-600 text-sm`},{default:n(()=>[o(`клиент `+e(r.user_id),1)]),_:2},1032,[`to`]),i(`span`,{class:t(R(r.status))},e(r.status),3)]),i(`div`,O,[i(`div`,null,[l[1]||=i(`p`,{class:`text-slate-400`},`Начало`,-1),i(`p`,k,e(z(r.started_at)),1)]),i(`div`,null,[l[2]||=i(`p`,{class:`text-slate-400`},`Конец`,-1),i(`p`,A,e(z(r.ends_at)),1)])])]))),128))]))]:(u(),c(`div`,j,`Подписок нет`))])}}};export{M as default};