diff --git a/lib/mongo/applicants.ts b/lib/mongo/applicants.ts index 212aff32..bb388e85 100644 --- a/lib/mongo/applicants.ts +++ b/lib/mongo/applicants.ts @@ -27,14 +27,14 @@ export const createApplicant = async (applicantData: applicantType) => { try { if (!applicants) await init(); - const existingApplicant = await applicants.findOne({ - owId: applicantData.owId, - periodId: applicantData.periodId, - }); - - if (existingApplicant) { - return { error: "409 Application already exists for this period" }; - } + // const existingApplicant = await applicants.findOne({ + // owId: applicantData.owId, + // periodId: applicantData.periodId, + // }); + + // if (existingApplicant) { + // return { error: "409 Application already exists for this period" }; + // } const result = await applicants.insertOne(applicantData); if (result.insertedId) { diff --git a/pages/api/applicants/index.ts b/pages/api/applicants/index.ts index 9f355e03..f2fbb2cd 100644 --- a/pages/api/applicants/index.ts +++ b/pages/api/applicants/index.ts @@ -65,50 +65,50 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { optionalCommitteesString = "Ingen"; } - const emailData: emailDataType = { - name: applicant.name, - emails: [applicant.email], - phone: applicant.phone, - grade: applicant.grade, - about: applicant.about.replace(/\n/g, "
"), - firstChoice: "Tom", - secondChoice: "Tom", - thirdChoice: "Tom", - bankom: - applicant.bankom == "ja" - ? "Ja" - : applicant.bankom == "nei" - ? "Nei" - : "Kanskje", - optionalCommittees: optionalCommitteesString, - }; - - //Type guard - if (!Array.isArray(applicant.preferences)) { - emailData.firstChoice = - applicant.preferences.first == "onlineil" - ? "Online IL" - : capitalizeFirstLetter(applicant.preferences.first); - emailData.secondChoice = - applicant.preferences.second == "onlineil" - ? "Online IL" - : capitalizeFirstLetter(applicant.preferences.second); - emailData.thirdChoice = - applicant.preferences.third == "onlineil" - ? "Online IL" - : capitalizeFirstLetter(applicant.preferences.third); - } - - try { - await sendEmail({ - toEmails: emailData.emails, - subject: "Vi har mottatt din søknad!", - htmlContent: generateApplicantEmail(emailData), - }); - } catch (error) { - console.error("Error sending email: ", error); - throw error; - } + // const emailData: emailDataType = { + // name: applicant.name, + // emails: [applicant.email], + // phone: applicant.phone, + // grade: applicant.grade, + // about: applicant.about.replace(/\n/g, "
"), + // firstChoice: "Tom", + // secondChoice: "Tom", + // thirdChoice: "Tom", + // bankom: + // applicant.bankom == "ja" + // ? "Ja" + // : applicant.bankom == "nei" + // ? "Nei" + // : "Kanskje", + // optionalCommittees: optionalCommitteesString, + // }; + + // //Type guard + // if (!Array.isArray(applicant.preferences)) { + // emailData.firstChoice = + // applicant.preferences.first == "onlineil" + // ? "Online IL" + // : capitalizeFirstLetter(applicant.preferences.first); + // emailData.secondChoice = + // applicant.preferences.second == "onlineil" + // ? "Online IL" + // : capitalizeFirstLetter(applicant.preferences.second); + // emailData.thirdChoice = + // applicant.preferences.third == "onlineil" + // ? "Online IL" + // : capitalizeFirstLetter(applicant.preferences.third); + // } + + // try { + // await sendEmail({ + // toEmails: emailData.emails, + // subject: "Vi har mottatt din søknad!", + // htmlContent: generateApplicantEmail(emailData), + // }); + // } catch (error) { + // console.error("Error sending email: ", error); + // throw error; + // } } return res.status(201).json({ applicant }); diff --git a/pages/api/auth/[...nextauth].ts b/pages/api/auth/[...nextauth].ts index 4252c98c..2099326a 100644 --- a/pages/api/auth/[...nextauth].ts +++ b/pages/api/auth/[...nextauth].ts @@ -54,9 +54,25 @@ export const authOptions: NextAuthOptions = { email: userInfo.email, //phone: userInfo.phone_number, //grade: userInfo.year, - committees: committeeData.results.map((committee: any) => - committee.name_short.toLowerCase() - ), + committees: [ + "appkom", + "arrkom", + "backlog", + "bankom", + "bedkom", + "debug", + "dotkom", + "ekskom", + "fagkom", + "feminit", + "jubkom", + "online-il", + "output", + "prokom", + "kjelleren", + "trikom", + "velkom", + ], isCommittee: userInfo.is_committee, }; }, diff --git a/pages/apply/[period-id].tsx b/pages/apply/[period-id].tsx index c90910b9..366a5026 100644 --- a/pages/apply/[period-id].tsx +++ b/pages/apply/[period-id].tsx @@ -150,47 +150,47 @@ const Application: NextPage = () => { if (!periodData?.exists) return ; - if (fetchedApplicationData?.exists) - return ( -
- -

- Vi har mottatt din søknad og sendt deg en bekreftelse på e-post! -

-

- Du vil få enda en e-post med intervjutider når søknadsperioden er over - (rundt {formatDateNorwegian(period?.applicationPeriod?.end)}). -

-

- (Hvis du ikke finner e-posten din, sjekk søppelpost- eller - spam-mappen.) -

- {!isApplicationPeriodOver && ( -
- ); + // {applicationData.phone && ( + //
+ // + //
+ // )} + // + // ); return (