chore: Remove unused billing-related collections, types, and utility modules

- Drop `customers` collection and associated types (`types/index.ts`, `payload.ts`)
- Remove generated `payload-types.ts` file
- Clean up unused exports and dependencies across modules
- Streamline codebase by eliminating redundant billing logic
This commit is contained in:
2025-09-15 23:14:25 +02:00
parent 28e9e8d208
commit f17b4c064e
11 changed files with 338 additions and 1378 deletions

View File

@@ -1,12 +1,5 @@
import type { CollectionConfig } from 'payload'
import type {
AccessArgs,
CollectionAfterChangeHook,
CollectionBeforeChangeHook,
PaymentData,
PaymentDocument
} from '../types/payload'
import { AccessArgs, CollectionAfterChangeHook, CollectionBeforeChangeHook, CollectionConfig } from 'payload'
import { Payment } from '@/plugin/types'
export function createPaymentsCollection(slug: string = 'payments'): CollectionConfig {
return {
@@ -131,21 +124,14 @@ export function createPaymentsCollection(slug: string = 'payments'): CollectionC
},
],
hooks: {
afterChange: [
({ doc, operation, req }: CollectionAfterChangeHook<PaymentDocument>) => {
if (operation === 'create') {
req.payload.logger.info(`Payment created: ${doc.id} (${doc.provider})`)
}
},
],
beforeChange: [
({ data, operation }: CollectionBeforeChangeHook<PaymentData>) => {
({ data, operation }) => {
if (operation === 'create') {
// Validate amount format
if (data.amount && !Number.isInteger(data.amount)) {
throw new Error('Amount must be an integer (in cents)')
}
// Validate currency format
if (data.currency) {
data.currency = data.currency.toUpperCase()
@@ -155,8 +141,8 @@ export function createPaymentsCollection(slug: string = 'payments'): CollectionC
}
}
},
],
] satisfies CollectionBeforeChangeHook<Payment>[],
},
timestamps: true,
}
}
}