feat: add country selection during onboarding and implement payment management features
- Introduced CountryStep component for selecting the country during onboarding, affecting payment currency. - Updated FirstGroupStep to include country information. - Enhanced PaymentsProvider to manage payment states and renewals. - Created PaymentRow component for displaying individual payment details. - Implemented PaymentsView for listing and filtering payments by group and status. - Added API endpoints for fetching and creating payments, including batch processing. - Defined payment schemas for validation and data handling. - Updated GroupHeader and GroupDetailView to include charging functionality for group members.
This commit is contained in:
37
apps/backend/src/modules/payments/lib/helpers.ts
Normal file
37
apps/backend/src/modules/payments/lib/helpers.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import type { PaymentDto } from '@gruperly/shared';
|
||||
|
||||
export type PaymentRecord = {
|
||||
id: string;
|
||||
groupId: string;
|
||||
attendeeId: string;
|
||||
amount: { toString(): string } | number;
|
||||
currency: string;
|
||||
status: PaymentDto['status'];
|
||||
description: string | null;
|
||||
checkoutUrl: string | null;
|
||||
dueDate: Date;
|
||||
paidAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
group: { name: string; price: unknown };
|
||||
attendee: { fullName: string };
|
||||
};
|
||||
|
||||
export function toPaymentDto(record: PaymentRecord): PaymentDto {
|
||||
return {
|
||||
id: record.id,
|
||||
groupId: record.groupId,
|
||||
groupName: record.group.name,
|
||||
attendeeId: record.attendeeId,
|
||||
attendeeName: record.attendee.fullName,
|
||||
amount: Number(record.amount.toString()),
|
||||
currency: record.currency,
|
||||
status: record.status,
|
||||
description: record.description,
|
||||
checkoutUrl: record.checkoutUrl,
|
||||
dueDate: record.dueDate.toISOString(),
|
||||
paidAt: record.paidAt ? record.paidAt.toISOString() : null,
|
||||
createdAt: record.createdAt.toISOString(),
|
||||
updatedAt: record.updatedAt.toISOString(),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user