diff --git a/drizzle/0008_mysterious_celestials.sql b/drizzle/0008_mysterious_celestials.sql new file mode 100644 index 00000000..8b390090 --- /dev/null +++ b/drizzle/0008_mysterious_celestials.sql @@ -0,0 +1,2 @@ +ALTER TABLE "easyinvoice_recurring_payment" ADD COLUMN "payer" text NOT NULL;--> statement-breakpoint +ALTER TABLE "easyinvoice_subscription_plans" ADD COLUMN "active" boolean DEFAULT true NOT NULL; \ No newline at end of file diff --git a/drizzle/meta/0008_snapshot.json b/drizzle/meta/0008_snapshot.json new file mode 100644 index 00000000..ff34dbfd --- /dev/null +++ b/drizzle/meta/0008_snapshot.json @@ -0,0 +1,968 @@ +{ + "id": "296b4b36-5687-473f-9650-cf716a005485", + "prevId": "08bffac7-21f6-431f-86b2-5669186d769b", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.easyinvoice_invoice_me": { + "name": "easyinvoice_invoice_me", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "easyinvoice_invoice_me_userId_easyinvoice_user_id_fk": { + "name": "easyinvoice_invoice_me_userId_easyinvoice_user_id_fk", + "tableFrom": "easyinvoice_invoice_me", + "tableTo": "easyinvoice_user", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.easyinvoice_payment_details_payers": { + "name": "easyinvoice_payment_details_payers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "paymentDetailsId": { + "name": "paymentDetailsId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payerId": { + "name": "payerId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payment_details_status": { + "name": "payment_details_status", + "type": "payment_details_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": false, + "default": "'pending'" + }, + "externalPaymentDetailId": { + "name": "externalPaymentDetailId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "easyinvoice_payment_details_payers_paymentDetailsId_easyinvoice_payment_details_id_fk": { + "name": "easyinvoice_payment_details_payers_paymentDetailsId_easyinvoice_payment_details_id_fk", + "tableFrom": "easyinvoice_payment_details_payers", + "tableTo": "easyinvoice_payment_details", + "columnsFrom": ["paymentDetailsId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "easyinvoice_payment_details_payers_payerId_easyinvoice_user_id_fk": { + "name": "easyinvoice_payment_details_payers_payerId_easyinvoice_user_id_fk", + "tableFrom": "easyinvoice_payment_details_payers", + "tableTo": "easyinvoice_user", + "columnsFrom": ["payerId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.easyinvoice_payment_details": { + "name": "easyinvoice_payment_details", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bankName": { + "name": "bankName", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "accountName": { + "name": "accountName", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "accountNumber": { + "name": "accountNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "routingNumber": { + "name": "routingNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "account_type": { + "name": "account_type", + "type": "account_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": false, + "default": "'checking'" + }, + "sortCode": { + "name": "sortCode", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "iban": { + "name": "iban", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "swiftBic": { + "name": "swiftBic", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "documentNumber": { + "name": "documentNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "documentType": { + "name": "documentType", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ribNumber": { + "name": "ribNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bsbNumber": { + "name": "bsbNumber", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ncc": { + "name": "ncc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "branchCode": { + "name": "branchCode", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bankCode": { + "name": "bankCode", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ifsc": { + "name": "ifsc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "beneficiary_type": { + "name": "beneficiary_type", + "type": "beneficiary_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "dateOfBirth": { + "name": "dateOfBirth", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "addressLine1": { + "name": "addressLine1", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "addressLine2": { + "name": "addressLine2", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postalCode": { + "name": "postalCode", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "country": { + "name": "country", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rails_type": { + "name": "rails_type", + "type": "rails_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": false, + "default": "'local'" + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "businessActivity": { + "name": "businessActivity", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "nationality": { + "name": "nationality", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "gender", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "easyinvoice_payment_details_userId_easyinvoice_user_id_fk": { + "name": "easyinvoice_payment_details_userId_easyinvoice_user_id_fk", + "tableFrom": "easyinvoice_payment_details", + "tableTo": "easyinvoice_user", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.easyinvoice_recurring_payment": { + "name": "easyinvoice_recurring_payment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "externalPaymentId": { + "name": "externalPaymentId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "recurring_payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "totalAmount": { + "name": "totalAmount", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "paymentCurrency": { + "name": "paymentCurrency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chain": { + "name": "chain", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "totalNumberOfPayments": { + "name": "totalNumberOfPayments", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "currentNumberOfPayments": { + "name": "currentNumberOfPayments", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subscriptionId": { + "name": "subscriptionId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payer": { + "name": "payer", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recurrence": { + "name": "recurrence", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "recipient": { + "name": "recipient", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "payments": { + "name": "payments", + "type": "json", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "easyinvoice_recurring_payment_userId_easyinvoice_user_id_fk": { + "name": "easyinvoice_recurring_payment_userId_easyinvoice_user_id_fk", + "tableFrom": "easyinvoice_recurring_payment", + "tableTo": "easyinvoice_user", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "easyinvoice_recurring_payment_subscriptionId_easyinvoice_subscription_plans_id_fk": { + "name": "easyinvoice_recurring_payment_subscriptionId_easyinvoice_subscription_plans_id_fk", + "tableFrom": "easyinvoice_recurring_payment", + "tableTo": "easyinvoice_subscription_plans", + "columnsFrom": ["subscriptionId"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.easyinvoice_request": { + "name": "easyinvoice_request", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "dueDate": { + "name": "dueDate", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "issuedDate": { + "name": "issuedDate", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "clientName": { + "name": "clientName", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "clientEmail": { + "name": "clientEmail", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "creatorName": { + "name": "creatorName", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "creatorEmail": { + "name": "creatorEmail", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invoiceNumber": { + "name": "invoiceNumber", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "items": { + "name": "items", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invoiceCurrency": { + "name": "invoiceCurrency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "paymentCurrency": { + "name": "paymentCurrency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "request_status": { + "name": "request_status", + "type": "request_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "payee": { + "name": "payee", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "requestId": { + "name": "requestId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "paymentReference": { + "name": "paymentReference", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "originalRequestPaymentReference": { + "name": "originalRequestPaymentReference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "originalRequestId": { + "name": "originalRequestId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invoicedTo": { + "name": "invoicedTo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recurrence": { + "name": "recurrence", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "isRecurrenceStopped": { + "name": "isRecurrenceStopped", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "isCryptoToFiatAvailable": { + "name": "isCryptoToFiatAvailable", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "paymentDetailsId": { + "name": "paymentDetailsId", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "easyinvoice_request_userId_easyinvoice_user_id_fk": { + "name": "easyinvoice_request_userId_easyinvoice_user_id_fk", + "tableFrom": "easyinvoice_request", + "tableTo": "easyinvoice_user", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "easyinvoice_request_paymentDetailsId_easyinvoice_payment_details_id_fk": { + "name": "easyinvoice_request_paymentDetailsId_easyinvoice_payment_details_id_fk", + "tableFrom": "easyinvoice_request", + "tableTo": "easyinvoice_payment_details", + "columnsFrom": ["paymentDetailsId"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.easyinvoice_session": { + "name": "easyinvoice_session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "easyinvoice_session_userId_easyinvoice_user_id_fk": { + "name": "easyinvoice_session_userId_easyinvoice_user_id_fk", + "tableFrom": "easyinvoice_session", + "tableTo": "easyinvoice_user", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.easyinvoice_subscription_plans": { + "name": "easyinvoice_subscription_plans", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "trialDays": { + "name": "trialDays", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "paymentCurrency": { + "name": "paymentCurrency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chain": { + "name": "chain", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "totalNumberOfPayments": { + "name": "totalNumberOfPayments", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "frequency": { + "name": "frequency", + "type": "frequency_enum", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipient": { + "name": "recipient", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "easyinvoice_subscription_plans_userId_easyinvoice_user_id_fk": { + "name": "easyinvoice_subscription_plans_userId_easyinvoice_user_id_fk", + "tableFrom": "easyinvoice_subscription_plans", + "tableTo": "easyinvoice_user", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.easyinvoice_user": { + "name": "easyinvoice_user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "googleId": { + "name": "googleId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agreement_status": { + "name": "agreement_status", + "type": "agreement_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": false, + "default": "'pending'" + }, + "kyc_status": { + "name": "kyc_status", + "type": "kyc_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": false, + "default": "'pending'" + }, + "isCompliant": { + "name": "isCompliant", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "easyinvoice_user_googleId_unique": { + "name": "easyinvoice_user_googleId_unique", + "nullsNotDistinct": false, + "columns": ["googleId"] + }, + "easyinvoice_user_email_unique": { + "name": "easyinvoice_user_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.account_type": { + "name": "account_type", + "schema": "public", + "values": ["checking", "savings"] + }, + "public.agreement_status": { + "name": "agreement_status", + "schema": "public", + "values": ["not_started", "pending", "completed"] + }, + "public.beneficiary_type": { + "name": "beneficiary_type", + "schema": "public", + "values": ["individual", "business"] + }, + "public.frequency_enum": { + "name": "frequency_enum", + "schema": "public", + "values": ["DAILY", "WEEKLY", "MONTHLY", "YEARLY"] + }, + "public.gender": { + "name": "gender", + "schema": "public", + "values": ["male", "female", "other", "prefer_not_to_say"] + }, + "public.kyc_status": { + "name": "kyc_status", + "schema": "public", + "values": ["not_started", "initiated", "pending", "approved"] + }, + "public.payment_details_status": { + "name": "payment_details_status", + "schema": "public", + "values": ["pending", "approved", "rejected"] + }, + "public.rails_type": { + "name": "rails_type", + "schema": "public", + "values": ["local", "swift", "wire"] + }, + "public.recurring_payment_status": { + "name": "recurring_payment_status", + "schema": "public", + "values": ["pending", "active", "paused", "completed", "cancelled"] + }, + "public.request_status": { + "name": "request_status", + "schema": "public", + "values": [ + "pending", + "paid", + "crypto_paid", + "offramp_initiated", + "offramp_failed", + "offramp_pending", + "processing", + "overdue" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 6c5c3e21..f9e15e1a 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -57,6 +57,13 @@ "when": 1752764223067, "tag": "0007_slimy_tyger_tiger", "breakpoints": true + }, + { + "idx": 8, + "version": "7", + "when": 1753346217295, + "tag": "0008_mysterious_celestials", + "breakpoints": true } ] } diff --git a/src/app/i/[id]/page.tsx b/src/app/i/[id]/page.tsx index 4b02f158..abaa45c3 100644 --- a/src/app/i/[id]/page.tsx +++ b/src/app/i/[id]/page.tsx @@ -19,6 +19,8 @@ export default async function InvoiceMePage({ }: { params: { id: string }; }) { + // TODO solve unauthenticated access + // TODO solve not found error like the subscription plan page const invoiceMeLink = await api.invoiceMe.getById.query(params.id); if (!invoiceMeLink) { diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx new file mode 100644 index 00000000..aa8187fd --- /dev/null +++ b/src/app/not-found.tsx @@ -0,0 +1,26 @@ +import Link from "next/link"; + +export default function NotFound() { + return ( +
+
+
+

404

+

+ Not Found +

+

+ Sorry, we couldn't find the page you're looking for. +

+
+ + + Go Home + +
+
+ ); +} diff --git a/src/app/payouts/recurring/page.tsx b/src/app/payouts/recurring/page.tsx index de09c788..d5d77746 100644 --- a/src/app/payouts/recurring/page.tsx +++ b/src/app/payouts/recurring/page.tsx @@ -15,7 +15,7 @@ export default async function RecurringPaymentsSlot() { } const recurringPayments = - await api.recurringPayment.getRecurringPayments.query(); + await api.recurringPayment.getNonSubscriptionRecurringPayments.query(); return ; } diff --git a/src/app/s/[id]/helpers.ts b/src/app/s/[id]/helpers.ts new file mode 100644 index 00000000..af2cc756 --- /dev/null +++ b/src/app/s/[id]/helpers.ts @@ -0,0 +1,13 @@ +import { isNotFoundError } from "@/lib/utils"; +import { api } from "@/trpc/server"; + +export async function getSubscriptionPlan(id: string) { + try { + return await api.subscriptionPlan.getById.query(id); + } catch (error) { + if (isNotFoundError(error)) { + return null; + } + throw error; // Re-throw unexpected errors + } +} diff --git a/src/app/s/[id]/page.tsx b/src/app/s/[id]/page.tsx index b0041be3..3a4fc32b 100644 --- a/src/app/s/[id]/page.tsx +++ b/src/app/s/[id]/page.tsx @@ -2,9 +2,10 @@ import { BackgroundWrapper } from "@/components/background-wrapper"; import { Footer } from "@/components/footer"; import { Header } from "@/components/header"; import { SubscriptionPlanPreview } from "@/components/subscription-plan-preview"; -import { api } from "@/trpc/server"; +import { getCurrentSession } from "@/server/auth"; import type { Metadata } from "next"; -import { notFound } from "next/navigation"; +import { notFound, redirect } from "next/navigation"; +import { getSubscriptionPlan } from "./helpers"; export const metadata: Metadata = { title: "Subscribe | EasyInvoice", @@ -16,7 +17,10 @@ export default async function SubscriptionPlanPage({ }: { params: { id: string }; }) { - const subscriptionPlan = await api.subscriptionPlan.getById.query(params.id); + const { user } = await getCurrentSession(); + if (!user) redirect("/"); + + const subscriptionPlan = await getSubscriptionPlan(params.id); if (!subscriptionPlan) { notFound(); diff --git a/src/app/subscription-plans/page.tsx b/src/app/subscription-plans/page.tsx index c9a5aac5..c6869622 100644 --- a/src/app/subscription-plans/page.tsx +++ b/src/app/subscription-plans/page.tsx @@ -1,8 +1,13 @@ import { Footer } from "@/components/footer"; import { Header } from "@/components/header"; -import { SubscriptionPlans } from "@/components/subscription-plans/subscription-plans"; +import { PaymentsTable } from "@/components/subscription-plans/blocks/payments-table"; +import { SubscribersTable } from "@/components/subscription-plans/blocks/subscribers-table"; +import { SubscriptionPlansList } from "@/components/subscription-plans/blocks/subscription-plans-list"; +import { SubscriptionPlanTabs } from "@/components/subscription-plans/subscription-plan-tabs"; import { getCurrentSession } from "@/server/auth"; import { api } from "@/trpc/server"; +import { ArrowLeft } from "lucide-react"; +import Link from "next/link"; import { redirect } from "next/navigation"; export default async function SubscriptionPlansPage() { @@ -12,13 +17,49 @@ export default async function SubscriptionPlansPage() { redirect("/"); } - const subscriptionPlans = await api.subscriptionPlan.getAll.query(); + const [subscriptionPlans, allSubscribers, allPayments] = await Promise.all([ + api.subscriptionPlan.getAll.query(), + api.subscriptionPlan.getAllSubscribers.query(), + api.subscriptionPlan.getAllPayments.query(), + ]); + + const plansTab = ( + + ); + const subscribersTab = ( + + ); + const paymentsTab = ( + + ); return ( <>
-
- +
+
+ + + +

+ Subscription Plans +

+
+ +