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:
@@ -7,14 +7,19 @@ const pageSizeSchema = createPageSizeSchema(10);
|
||||
const paginationSchema = createPaginationSchema();
|
||||
|
||||
export const paymentStatusSchema = z.enum(['PENDING', 'PAID', 'OVERDUE', 'CANCELLED']);
|
||||
export type PaymentStatus = z.output<typeof paymentStatusSchema>;
|
||||
|
||||
export const PaymentDtoSchema = z.object({
|
||||
id: z.string(),
|
||||
groupId: z.string(),
|
||||
groupName: z.string(),
|
||||
attendeeId: z.string(),
|
||||
attendeeName: z.string(),
|
||||
amount: z.coerce.number().positive(),
|
||||
currency: z.string(),
|
||||
status: paymentStatusSchema,
|
||||
description: z.string().nullable(),
|
||||
checkoutUrl: z.string().nullable(),
|
||||
dueDate: isoDateTimeSchema,
|
||||
paidAt: isoDateTimeSchema.nullable(),
|
||||
createdAt: isoDateTimeSchema,
|
||||
@@ -25,6 +30,8 @@ export type PaymentDto = z.output<typeof PaymentDtoSchema>;
|
||||
export const PaymentQuerySchema = z.object({
|
||||
page: pageSchema,
|
||||
pageSize: pageSizeSchema,
|
||||
groupId: z.string().min(1).optional(),
|
||||
status: paymentStatusSchema.optional(),
|
||||
});
|
||||
export type PaymentQuery = z.output<typeof PaymentQuerySchema>;
|
||||
|
||||
@@ -32,4 +39,36 @@ export const PaymentListSchema = z.object({
|
||||
data: z.array(PaymentDtoSchema),
|
||||
pagination: paginationSchema,
|
||||
});
|
||||
export type PaymentList = z.output<typeof PaymentListSchema>;
|
||||
export type PaymentList = z.output<typeof PaymentListSchema>;
|
||||
|
||||
// Creates one payment link per active attendee of a group. The professor
|
||||
// triggers it from the group page for a period (e.g. June's monthly fee).
|
||||
export const CreatePaymentsBatchSchema = z.strictObject({
|
||||
dueDate: isoDateTimeSchema,
|
||||
description: z.string().trim().max(120, 'La descripción es demasiado larga').optional(),
|
||||
attendeeIds: z.array(z.string().min(1)).min(1).optional(),
|
||||
});
|
||||
export type CreatePaymentsBatch = z.output<typeof CreatePaymentsBatchSchema>;
|
||||
|
||||
export const paymentBatchOutcomeSchema = z.enum(['CREATED', 'LINKED', 'FAILED']);
|
||||
|
||||
export const PaymentBatchItemSchema = z.object({
|
||||
paymentId: z.string(),
|
||||
attendeeId: z.string(),
|
||||
attendeeName: z.string(),
|
||||
amount: z.number().positive(),
|
||||
currency: z.string(),
|
||||
checkoutUrl: z.string().nullable(),
|
||||
outcome: paymentBatchOutcomeSchema,
|
||||
reason: z.string().nullable(),
|
||||
});
|
||||
export type PaymentBatchItem = z.output<typeof PaymentBatchItemSchema>;
|
||||
|
||||
export const CreatePaymentsBatchResultSchema = z.object({
|
||||
groupId: z.string(),
|
||||
total: z.number().int().min(0),
|
||||
linked: z.number().int().min(0),
|
||||
failed: z.number().int().min(0),
|
||||
items: z.array(PaymentBatchItemSchema),
|
||||
});
|
||||
export type CreatePaymentsBatchResult = z.output<typeof CreatePaymentsBatchResultSchema>;
|
||||
Reference in New Issue
Block a user