mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-11 00:08:37 +01:00
fix dashboard + payments
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import { getUserProjectFromId } from "~/server/LIVE_DEMO_DATA";
|
||||
import { Redis } from "~/server/services/CacheService";
|
||||
import StripeService from '~/server/services/StripeService';
|
||||
import { PaymentServiceHelper } from "~/server/services/PaymentServiceHelper";
|
||||
import { PremiumModel } from "~/shared/schema/PremiumSchema";
|
||||
|
||||
|
||||
export type InvoiceData = {
|
||||
date: number,
|
||||
cost: number,
|
||||
@@ -21,11 +19,14 @@ export default defineEventHandler(async event => {
|
||||
|
||||
const premium = await PremiumModel.findOne({ user_id: data.user.id });
|
||||
if (!premium) return [];
|
||||
|
||||
const invoices = await StripeService.getInvoices(premium.customer_id);
|
||||
if (!invoices) return [];
|
||||
|
||||
return invoices?.data.map(e => {
|
||||
const [ok, invoicesOrError] = await PaymentServiceHelper.invoices_list(data.user.id);
|
||||
if (!ok) {
|
||||
console.error(invoicesOrError);
|
||||
return [];
|
||||
}
|
||||
|
||||
return invoicesOrError.invoices.map(e => {
|
||||
const result: InvoiceData = {
|
||||
link: e.invoice_pdf || '',
|
||||
id: e.number || '',
|
||||
@@ -36,7 +37,6 @@ export default defineEventHandler(async event => {
|
||||
return result;
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user