Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#238 Improve calendar functionality #290

Merged
merged 1 commit into from
Sep 27, 2024
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
65 changes: 65 additions & 0 deletions src/helpers/sendEventEmails.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { sendEmail } from "../utils/sendEmail"
import { eventCancellationTemplate, eventInvitationTemplate, invitationCancellationTemplate } from "../utils/templates/eventInvitationTemplates";

export async function sendEventInvitations(
email: string,
eventId: string,
eventTitle: string,
hostName: string,
eventStart: string,
eventEnd: string,
eventTimeToStart: string,
eventTimeToEnd: string,
){
try{
const content: string = eventInvitationTemplate(eventId,eventTitle,hostName,eventStart,eventEnd,eventTimeToStart,eventTimeToEnd)
await sendEmail(
email,
'Event Invitation',
content,
null,
process.env.ADMIN_EMAIL,
process.env.ADMIN_PASS,
)
}catch(err){
return err
}
}

export async function sendEventCancellations(
email: string,
eventTitle: string,
){
try{
const content: string = eventCancellationTemplate(eventTitle)
await sendEmail(
email,
'Event Cancelled',
content,
null,
process.env.ADMIN_EMAIL,
process.env.ADMIN_PASS,
)
}catch(err){
return err
}
}

export async function sendInvitationCancellations(
email: string,
eventTitle: string,
){
try{
const content: string = invitationCancellationTemplate(eventTitle)
await sendEmail(
email,
'Invitation Cancelled',
content,
null,
process.env.ADMIN_EMAIL,
process.env.ADMIN_PASS,
)
}catch(err){
return err
}
}
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import StatisticsResolvers from './resolvers/invitationStatics.resolvers'
import { IResolvers } from '@graphql-tools/utils'
import invitationSchema from './schema/invitation.schema'
import TableViewInvitationResolver from './resolvers/TableViewInvitationResolver'
import eventSchema from './schema/event.schema'


const PORT: number = parseInt(process.env.PORT!) || 4000
Expand All @@ -64,6 +65,7 @@ export const typeDefs = mergeTypeDefs([
invitationSchema,
notificationSchema,
statisticsSchema,
eventSchema,
])

export const resolvers = mergeResolvers([
Expand Down
20 changes: 20 additions & 0 deletions src/models/event.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import mongoose, { Schema } from 'mongoose';

const INVITEE_STATUS = {
PENDING: 'pending',
ACCEPTED: 'accepted',
DECLINED: 'declined'
}

const Event = mongoose.model(
'Event',
new Schema({
Expand Down Expand Up @@ -31,6 +38,19 @@ const Event = mongoose.model(
type: String,
required: true,
},
invitees: [
{
email:{
type: String,
required: true
},
status:{
type: String,
enum: INVITEE_STATUS,
default: INVITEE_STATUS.PENDING,
}
}
]
})
);
export { Event };
Loading
Loading