Skip to content

Commit

Permalink
added model schemas for chapter and birthdayRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
kygchng committed Oct 17, 2024
1 parent c4f4619 commit 6b61250
Show file tree
Hide file tree
Showing 2 changed files with 214 additions and 0 deletions.
141 changes: 141 additions & 0 deletions server/src/models/birthdayRequest.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import mongoose from 'mongoose';

const BirthdayRequestSchema = new mongoose.Schema({
chapterId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Chapter',
required: true,
},
deadlineDate: {
type: Date,
required: true,
},
childBirthday: {
type: Date,
required: true,
},
childAge: {
type: Number,
required: true,
},
childName: {
type: String,
required: true,
},
childGender: {
type: String,
enum: ['Boy', 'Girl'],
required: true,
},
childRace: {
type: String,
enum: [
'White',
'Black or African American',
'Hispanic or Latino',
'Native American or American Indian',
'Asian / Pacific Islander',
'Not Sure',
],
required: true,
},
childInterests: {
type: String,
required: true,
},
childAllergies: {
type: Boolean,
required: true,
},
allergyDetails: {
type: String,
required: false,
},
giftSuggestions: {
type: String,
required: false,
},
additionalInfo: {
type: String,
required: false,
},
agencyWorkerName: {
type: String,
required: true,
},
agencyOrganization: {
type: String,
required: true,
},
agencyWorkerPhone: {
type: String,
required: true,
},
agencyWorkerEmail: {
type: String,
required: true,
match:
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,
},
isFirstReferral: {
type: Boolean,
required: true,
},
agreeFeedback: {
type: Boolean,
required: true,
},
requestedDate: {
type: Date,
required: true,
default: Date.now,
},
status: {
type: String,
enum: ['Pending', 'Approved', 'Delivered'],
required: true,
default: 'Pending',
},
deliveryDate: {
type: Date,
required: false,
},
});

interface IBirthdayRequest extends mongoose.Document {
_id: string;
chapterId: string;
deadlineDate: Date;
childBirthday: Date;
childAge: number;
childName: string;
childGender: 'Boy' | 'Girl';
childRace:
| 'White'
| 'Black or African American'
| 'Hispanic or Latino'
| 'Native American or American Indian'
| 'Asian / Pacific Islander'
| 'Not Sure';
childInterests: string;
childAllergies: boolean;
allergyDetails: string;
giftSuggestions: string;
additionalInfo: string;
agencyWorkerName: string;
agencyOrganization: string;
agencyWorkerPhone: string;
agencyWorkerEmail: string;
isFirstReferral: boolean;
agreeFeedback: boolean;
requestedDate: Date;
status: 'Pending' | 'Approved' | 'Delivered';
deliveryDate: Date | null;
}

const BirthdayRequest = mongoose.model<IBirthdayRequest>(
'BirthdayRequest',
BirthdayRequestSchema,
);

export { IBirthdayRequest, BirthdayRequest };
73 changes: 73 additions & 0 deletions server/src/models/chapter.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import mongoose from 'mongoose';

const ChapterSchema = new mongoose.Schema({
username: {
type: String,
required: true,
unique: true,
},
location: {
type: String,
required: true,
},
isAcceptingRequests: {
type: Boolean,
required: true,
default: true,
},
email: {
type: String,
required: true,
unique: true,
match:
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,
},
password: {
type: String,
required: true,
},
verified: {
type: Boolean,
required: true,
default: false,
},
verificationToken: {
type: String,
required: false,
unique: true,
sparse: true,
},
resetPasswordToken: {
type: String,
required: false,
unique: true,
sparse: true,
},
resetPasswordTokenExpiryDate: {
type: Date,
required: false,
},
isAdmin: {
type: Boolean,
required: true,
default: false,
},
});

interface IChapter extends mongoose.Document {
_id: string;
username: string;
location: string;
isAcceptingRequests: boolean;
email: string;
password: string;
verified: boolean;
verificationToken: string | null | undefined;
resetPasswordToken: string | null | undefined;
resetPasswordTokenExpiryDate: Date | null | undefined;
isAdmin: boolean;
}

const Chapter = mongoose.model<IChapter>('Chapter', ChapterSchema);

export { IChapter, Chapter };

0 comments on commit 6b61250

Please sign in to comment.