Skip to content

Commit

Permalink
Merge pull request #136 from ms-club-sliit/development
Browse files Browse the repository at this point in the history
Development into Main
  • Loading branch information
senuravihanjayadeva authored Dec 24, 2021
2 parents f4cf788 + b8d0fd4 commit 606b4cd
Show file tree
Hide file tree
Showing 33 changed files with 1,633 additions and 402 deletions.
695 changes: 674 additions & 21 deletions LICENSE

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"@google-cloud/storage": "^5.16.0",
"@types/express": "^4.17.13",
"@types/node": "^16.11.9",
"@types/validator": "^13.7.0",
"cross-env": "^7.0.3",
"firebase-admin": "^10.0.0",
"nodemon": "^2.0.15",
Expand Down
63 changes: 16 additions & 47 deletions src/api/controllers/Application.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,25 @@ import { IApplication } from "../interfaces";
* @param {NextFunction} next - Next function
* @returns {IApplication} - New application document
*/
export const addApplication = async (
request: Request,
response: Response,
next: NextFunction
) => {
export const addApplication = async (request: Request, response: Response, next: NextFunction) => {
await ApplicationService.addApplication(request.body)
.then((data) => {
// Send email
const emailTemplate = "Application-Email-Template.html";
const to = data.email;
const subject = "MS Club SLIIT - Application Received";
const emailBodyData = {
studentId: data.studentId,
name: data.name,
email: data.email,
contactNumber: data.contactNumber,
currentAcademicYear: data.currentAcademicYear,
linkedIn : data.linkedIn,
gitHub: data.gitHub,
skillsAndTalents: data.skillsAndTalents
};

EmailService.sendEmailWithTemplate(
emailTemplate,
to,
subject,
emailBodyData
)
EmailService.sendEmailWithTemplate(emailTemplate, to, subject, emailBodyData)
.then((emailData) => {
request.handleResponse.successRespond(response)({
applicationData: data,
Expand All @@ -57,11 +54,7 @@ export const addApplication = async (
* @param {NextFunction} next - Next function
* @returns {IApplication} - Application document that relevent to the passed ID
*/
export const getApplicationById = async (
request: Request,
response: Response,
next: NextFunction
) => {
export const getApplicationById = async (request: Request, response: Response, next: NextFunction) => {
const applicationId = request.params.applicationId;
if (applicationId) {
await ApplicationService.fetchApplicationById(request.params.applicationId)
Expand All @@ -84,11 +77,7 @@ export const getApplicationById = async (
* @param {NextFunction} next - Next function
* @returns {IApplication} - All application documents
*/
export const getApplications = async (
request: Request,
response: Response,
next: NextFunction
) => {
export const getApplications = async (request: Request, response: Response, next: NextFunction) => {
await ApplicationService.fetchApplications()
.then((data) => {
request.handleResponse.successRespond(response)(data);
Expand All @@ -106,11 +95,7 @@ export const getApplications = async (
* @param {NextFunction} next - Next function
* @returns {IApplication} - Updated application document
*/
export const setApplicationArchive = async (
request: Request,
response: Response,
next: NextFunction
) => {
export const setApplicationArchive = async (request: Request, response: Response, next: NextFunction) => {
const applicationId = request.params.applicationId;
if (applicationId) {
await ApplicationService.archiveApplication(request.params.applicationId)
Expand Down Expand Up @@ -143,10 +128,7 @@ export const changeApplicationStatusIntoInterview = async (
) => {
const applicationId = request.params.applicationId;
if (applicationId) {
await ApplicationService.changeApplicationStatusIntoInterview(
request.params.applicationId,
request.body
)
await ApplicationService.changeApplicationStatusIntoInterview(request.params.applicationId, request.body)
.then((data) => {
request.handleResponse.successRespond(response)(data);
next();
Expand All @@ -169,17 +151,10 @@ export const changeApplicationStatusIntoInterview = async (
* @param {NextFunction} next - Next function
* @returns {IApplication} updated application document in the system
*/
export const changeApplicationStatusIntoSelected = async (
request: Request,
response: Response,
next: NextFunction
) => {
export const changeApplicationStatusIntoSelected = async (request: Request, response: Response, next: NextFunction) => {
const applicationId = request.params.applicationId;
if (applicationId) {
await ApplicationService.changeApplicationStatusIntoSelected(
request.params.applicationId,
request.body
)
await ApplicationService.changeApplicationStatusIntoSelected(request.params.applicationId, request.body)
.then((data) => {
request.handleResponse.successRespond(response)(data);
next();
Expand All @@ -201,16 +176,10 @@ export const changeApplicationStatusIntoSelected = async (
* @param {NextFunction} next - Next function
* @returns {IApplication} updated application document in the system
*/
export const changeApplicationStatusIntoRejected = async (
request: Request,
response: Response,
next: NextFunction
) => {
export const changeApplicationStatusIntoRejected = async (request: Request, response: Response, next: NextFunction) => {
const applicationId = request.params.applicationId;
if (applicationId) {
await ApplicationService.changeApplicationStatusIntoRejected(
request.params.applicationId
)
await ApplicationService.changeApplicationStatusIntoRejected(request.params.applicationId)
.then((data) => {
request.handleResponse.successRespond(response)(data);
next();
Expand Down
39 changes: 22 additions & 17 deletions src/api/controllers/BoardMember.controller.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { Express, Request, Response, NextFunction } from "express";
import BoardMemberService from "../services";
import logger from "../../util/logger";
import ImageService from "../../util/image.handler";

/**
* @param {Request} request - Request from the frontend
* @param {Response} response - Response that need to send to the client
* @param {NextFunction} next - Next function
* @returns boardMember
*/
export const getBoardMemberbyID = async (
request: Request,
response: Response,
next: NextFunction
) => {
export const getBoardMemberbyID = async (request: Request, response: Response, next: NextFunction) => {
const boardMemberId = request.params.boardMemberId;
if (boardMemberId) {
await BoardMemberService.getBoardMemberbyID(request.params.boardMemberId)
Expand All @@ -33,11 +31,7 @@ export const getBoardMemberbyID = async (
* @param {NextFunction} next - Next function
* @returns boardMember[]
*/
export const getAllBoardMembers = async (
request: Request,
response: Response,
next: NextFunction
) => {
export const getAllBoardMembers = async (request: Request, response: Response, next: NextFunction) => {
await BoardMemberService.getAllBoardMembers()
.then((data) => {
request.handleResponse.successRespond(response)(data);
Expand All @@ -59,11 +53,23 @@ export const updateBoardMemberDetails = async (
response: Response,
next: NextFunction
) => {
if (request.file) {
const bucketDirectoryName = "boardmember-flyers";

const boardMemberFlyerPath = await ImageService.uploadImage(
request.file,
bucketDirectoryName
);
request.body.imageUrl = boardMemberFlyerPath;
}
const boardMemberId = request.params.boardMemberId;
const updatedBy = request.user && request.user._id ? request.user._id : null;

if (boardMemberId) {
await BoardMemberService.updateBoardMemberDetails(
request.params.boardMemberId,
request.body
request.body,
updatedBy
)
.then((data) => {
request.handleResponse.successRespond(response)(data);
Expand All @@ -83,15 +89,14 @@ export const updateBoardMemberDetails = async (
* @param {NextFunction} next - Next function
* @returns updated boardMember
*/
export const deleteBoardMemberDetails = async (
request: Request,
response: Response,
next: NextFunction
) => {
export const deleteBoardMemberDetails = async (request: Request, response: Response, next: NextFunction) => {
const boardMemberId = request.params.boardMemberId;
const deletedBy = request.user && request.user._id ? request.user._id : null;

if (boardMemberId) {
await BoardMemberService.deleteBoardMemberDetails(
request.params.boardMemberId
request.params.boardMemberId,
deletedBy
)
.then((data) => {
request.handleResponse.successRespond(response)(data);
Expand Down
22 changes: 11 additions & 11 deletions src/api/controllers/Contact.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Request, Response, NextFunction } from 'express';
import ContactService from '../services';
import EmailService from '../../util/email.handler';
import moment from 'moment';
import { Request, Response, NextFunction } from "express";
import ContactService from "../services";
import EmailService from "../../util/email.handler";
import moment from "moment";

/**
* @param {Request} request - Request from the frontend
Expand All @@ -12,15 +12,15 @@ import moment from 'moment';
export const createContact = async (request: Request, response: Response, next: NextFunction) => {
await ContactService.insertContact(request.body)
.then((data) => {
// Send email
const emailTemplate = 'Contact-Us-Email-Template.html';
// Send email
const emailTemplate = "Contact-Us-Email-Template.html";
const to = data.email;
const subject = 'MS Club SLIIT - Contact Us';
const subject = "MS Club SLIIT - Contact Us";
const emailBodyData = {
name: data.name,
email: data.email,
message: data.message,
date_time: moment(data.createdAt).format('LLL'),
date_time: moment(data.createdAt).format("LLL"),
};

EmailService.sendEmailWithTemplate(emailTemplate, to, subject, emailBodyData)
Expand All @@ -41,7 +41,7 @@ export const createContact = async (request: Request, response: Response, next:
request.handleResponse.errorRespond(response)(error.message);
next();
});
}
};

/**
* @param {Request} request - Request from the frontend
Expand All @@ -58,7 +58,7 @@ export const getAllContacts = async (request: Request, response: Response, next:
request.handleResponse.errorRespond(response)(error.message);
next();
});
}
};

/**
* @param {Request} request - Request from the frontend
Expand All @@ -75,4 +75,4 @@ export const removeContact = async (request: Request, response: Response, next:
request.handleResponse.errorRespond(response)(error.message);
next();
});
}
};
Loading

0 comments on commit 606b4cd

Please sign in to comment.