Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions apps/backend/src/donations/donation.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export enum donationType {
}

export enum recurringInterval {
'monthly',
'yearly',
'weekly',
'monthly',
'bimonthly',
'biweekly',
'quarterly',
'annually',
}

@Entity()
Expand Down Expand Up @@ -44,6 +44,9 @@ export class Donation {
@Column({ nullable: true })
dedicationMessage: string;

@Column({ default: false })
showDedicationPublicly: boolean;

@Column()
createdAt: Date;

Expand Down
106 changes: 106 additions & 0 deletions apps/backend/src/donations/dtos/create-donation-dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { ApiProperty } from '@nestjs/swagger';
import {
IsString,
IsEmail,
IsNumber,
IsBoolean,
IsEnum,
IsOptional,
Min,
IsNotEmpty,
} from 'class-validator';

export enum DonationType {
ONE_TIME = 'one_time',
RECURRING = 'recurring',
}

export enum RecurringInterval {
WEEKLY = 'weekly',
MONTHLY = 'monthly',
BIMONTHLY = 'bimonthly',
QUARTERLY = 'quarterly',
ANNUALLY = 'annually',
}

export class CreateDonationDto {
@ApiProperty({
description: 'donor first name',
example: 'John',
})
@IsString()
@IsNotEmpty()
firstName: string;

@ApiProperty({
description: 'donor last name',
example: 'Smith',
})
@IsString()
@IsNotEmpty()
lastName: string;

@ApiProperty({
description: 'donor email address',
example: 'john.smith@example.com',
})
@IsEmail()
@IsNotEmpty()
email: string;

@ApiProperty({
description: 'the donation amount in dollars',
example: 100.0,
minimum: 0.01,
})
@IsNumber()
@Min(0.01)
amount: number;

@ApiProperty({
description: 'whether the donation should be anonymous',
example: false,
required: false,
default: false,
})
@IsBoolean()
@IsOptional()
isAnonymous?: boolean = false;

@ApiProperty({
description: 'the type of donation',
enum: DonationType,
example: DonationType.ONE_TIME,
})
@IsEnum(DonationType)
donationType: DonationType;

@ApiProperty({
description: 'recurring interval for recurring donations',
enum: RecurringInterval,
required: false,
example: RecurringInterval.MONTHLY,
})
@IsEnum(RecurringInterval)
@IsOptional()
recurringInterval?: RecurringInterval;

@ApiProperty({
description: 'optional dedication message',
example: 'for the Fenway community',
required: false,
})
@IsString()
@IsOptional()
dedicationMessage?: string;

@ApiProperty({
description: 'whether to show dedication message publicly',
example: false,
required: false,
default: false,
})
@IsBoolean()
@IsOptional()
showDedicationPublicly?: boolean = false;
}
101 changes: 101 additions & 0 deletions apps/backend/src/donations/dtos/donation-response-dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { ApiProperty } from '@nestjs/swagger';
import { DonationType, RecurringInterval } from './create-donation-dto';

export enum DonationStatus {
PENDING = 'pending',
COMPLETED = 'completed',
FAILED = 'failed',
CANCELLED = 'cancelled',
}

export class DonationResponseDto {
@ApiProperty({
description: 'Unique donation identifier',
example: 123,
})
id: number;

@ApiProperty({
description: 'donor first name',
example: 'John',
})
firstName: string;

@ApiProperty({
description: 'donor last name',
example: 'Smith',
})
lastName: string;

@ApiProperty({
description: 'donor email address',
example: 'john.smith@example.com',
})
email: string;

@ApiProperty({
description: 'donation amount in dollars',
example: 100.0,
})
amount: number;

@ApiProperty({
description: 'whether the donation is anonymous',
example: false,
})
isAnonymous: boolean;

@ApiProperty({
description: 'the type of donation',
enum: DonationType,
example: DonationType.ONE_TIME,
})
donationType: DonationType;

@ApiProperty({
description: 'the recurring interval for recurring donations',
enum: RecurringInterval,
required: false,
example: RecurringInterval.MONTHLY,
})
recurringInterval?: RecurringInterval;

@ApiProperty({
description: 'optional dedication message',
example: 'for the Fenway community',
required: false,
})
dedicationMessage?: string;

@ApiProperty({
description: 'whether to show dedication message publicly',
example: false,
})
showDedicationPublicly: boolean;

@ApiProperty({
description: 'the current donation status',
enum: DonationStatus,
example: DonationStatus.COMPLETED,
})
status: DonationStatus;

@ApiProperty({
description: 'timestamp when donation was created',
example: '2024-01-15T10:30:00Z',
})
createdAt: Date;

@ApiProperty({
description: 'timestamp when donation was last updated',
example: '2024-01-15T10:35:00Z',
})
updatedAt: Date;

@ApiProperty({
description: 'payment processor transaction ID',
example: 'txn_1234567890',
required: false,
})
transactionId?: string;
}
66 changes: 66 additions & 0 deletions apps/backend/src/donations/dtos/public-donation-dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { ApiProperty } from '@nestjs/swagger';
import { DonationType, RecurringInterval } from './create-donation-dto';
import { DonationStatus } from './donation-response-dto';

export class PublicDonationDto {
@ApiProperty({
description: 'unique donation identifier',
example: 123,
})
id: number;

@ApiProperty({
description: 'donor name, hidden if anonymous',
example: 'John Smith',
required: false,
})
donorName?: string;

@ApiProperty({
description: 'donation amount, in dollars',
example: 100.0,
})
amount: number;

@ApiProperty({
description: 'whether or not the donation is anonymous',
example: false,
})
isAnonymous: boolean;

@ApiProperty({
description: 'the type of donation',
enum: DonationType,
example: DonationType.ONE_TIME,
})
donationType: DonationType;

@ApiProperty({
description: 'the recurring interval for recurring donations',
enum: RecurringInterval,
required: false,
example: RecurringInterval.MONTHLY,
})
recurringInterval?: RecurringInterval;

@ApiProperty({
description:
'the dedication message, shown if showDedicationPublicly is true',
example: 'for the Fenway community',
required: false,
})
dedicationMessage?: string;

@ApiProperty({
description: 'the current donation status',
enum: DonationStatus,
example: DonationStatus.COMPLETED,
})
status: DonationStatus;

@ApiProperty({
description: 'timestamp when donation was created',
example: '2024-01-15T10:30:00Z',
})
createdAt: Date;
}
Loading
Loading