astro-admin/dist/assets/Payments-BjNHIYXT.js

1 line
4.1 KiB
JavaScript
Raw 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,p as u,v as d,w as f,x as p,y as m}from"./index-DzvFzRSs.js";var h={class:`flex gap-2 mb-4 overflow-x-auto pb-1 -mx-1 px-1`},g=[`onClick`],_={key:0,class:`text-slate-500 py-12 text-center`},v={key:1,class:`hidden md:block bg-white rounded-xl shadow-sm border overflow-hidden`},y={class:`w-full text-sm`},b={class:`divide-y`},x={class:`px-4 py-3 text-slate-500`},S={class:`px-4 py-3`},C={class:`px-4 py-3 text-right font-medium`},w={class:`px-4 py-3 text-center`},T={class:`px-4 py-3 font-mono text-xs text-slate-400`},E={class:`px-4 py-3`},D=[`onClick`],O={key:2,class:`md:hidden space-y-3`},k={class:`flex items-start justify-between`},A={class:`font-semibold`},j={class:`text-xs text-slate-500 mt-2`},M={class:`mt-2 flex items-center justify-between`},N={class:`font-mono text-xs text-slate-400 truncate`},P=[`onClick`],F={key:3,class:`text-slate-400 text-center py-12`},I={__name:`Payments`,setup(I){let L=f([]),R=f(!0),z=f(``),B=[{value:``,label:`Все`},{value:`succeeded`,label:`Успешные`},{value:`pending`,label:`Ожидают`},{value:`failed`,label:`Неудачные`},{value:`refunded`,label:`Возвраты`}];r(()=>V());async function V(){R.value=!0;try{let e=z.value?{status:z.value}:{},{data:t}=await l.get(`/admin/api/payments`,{params:e});L.value=t.payments}finally{R.value=!1}}async function H(e){if(confirm(`Вернуть средства?`))try{await l.post(`/admin/api/payments/${e}/refund`),V()}catch(e){alert(e.response?.data?.detail||`Ошибка`)}}function U(e){return{succeeded:`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`,failed:`px-2 py-0.5 bg-red-100 text-red-700 rounded-full text-xs`,refunded:`px-2 py-0.5 bg-purple-100 text-purple-700 rounded-full text-xs`}[e]||`text-slate-600`}function W(e){return e?new Date(e).toLocaleString(`ru-RU`,{day:`2-digit`,month:`2-digit`,year:`2-digit`,hour:`2-digit`,minute:`2-digit`}):`—`}return(r,l)=>{let f=p(`router-link`);return d(),c(`div`,null,[l[1]||=i(`h1`,{class:`text-xl md:text-2xl font-bold mb-4 md:mb-6`},`💳 Платежи`,-1),i(`div`,h,[(d(),c(s,null,m(B,n=>i(`button`,{key:n.value,onClick:e=>{z.value=n.value,V()},class:t([`px-3 py-1.5 rounded-lg text-sm whitespace-nowrap`,z.value===n.value?`bg-indigo-600 text-white`:`bg-white border`])},e(n.label),11,g)),64))]),R.value?(d(),c(`div`,_,`Загрузка...`)):L.value.length?[(d(),c(`div`,v,[i(`table`,y,[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-right`},`Сумма`),i(`th`,{class:`px-4 py-3 text-center`},`Статус`),i(`th`,{class:`px-4 py-3 text-left`},`YooKassa ID`),i(`th`,{class:`px-4 py-3`})])],-1),i(`tbody`,b,[(d(!0),c(s,null,m(L.value,r=>(d(),c(`tr`,{key:r.id,class:`hover:bg-slate-50`},[i(`td`,x,e(W(r.paid_at||r.created_at)),1),i(`td`,S,[a(f,{to:`/users/${r.user_id}`,class:`text-indigo-600 hover:underline`},{default:n(()=>[o(e(r.user_id),1)]),_:2},1032,[`to`])]),i(`td`,C,e(r.amount_rub)+`₽`,1),i(`td`,w,[i(`span`,{class:t(U(r.status))},e(r.status),3)]),i(`td`,T,e(r.yookassa_payment_id?.slice(0,16)),1),i(`td`,E,[r.status===`succeeded`?(d(),c(`button`,{key:0,onClick:e=>H(r.yookassa_payment_id),class:`text-red-600 hover:underline text-xs`},`возврат`,8,D)):u(``,!0)])]))),128))])])])),(d(),c(`div`,O,[(d(!0),c(s,null,m(L.value,r=>(d(),c(`div`,{key:r.id,class:`bg-white rounded-xl border border-slate-200 shadow-sm p-4`},[i(`div`,k,[i(`div`,null,[i(`p`,A,e(r.amount_rub)+`₽`,1),a(f,{to:`/users/${r.user_id}`,class:`text-xs text-indigo-600`},{default:n(()=>[o(`клиент `+e(r.user_id),1)]),_:2},1032,[`to`])]),i(`span`,{class:t(U(r.status))},e(r.status),3)]),i(`p`,j,e(W(r.paid_at||r.created_at)),1),i(`div`,M,[i(`span`,N,e(r.yookassa_payment_id?.slice(0,16)),1),r.status===`succeeded`?(d(),c(`button`,{key:0,onClick:e=>H(r.yookassa_payment_id),class:`text-red-600 text-xs ml-2`},`возврат`,8,P)):u(``,!0)])]))),128))]))]:(d(),c(`div`,F,`Платежей нет`))])}}};export{I as default};