-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
fix: wrong locale in attendee email ics #8945
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
86d8c24
fix: pass attendee translator function
G3root 8f3bf5b
Merge branch 'main' into fix-wrong-ics-locale
G3root f22aefd
fix: type
G3root 59d0aa7
fix: t
G3root 35825c8
fix: t
G3root 56e7b67
Merge branch 'main' into fix-wrong-ics-locale
alannnc 6c4203f
Merge branch 'main' into fix-wrong-ics-locale
G3root File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import type { TFunction } from "next-i18next"; | ||
import short from "short-uuid"; | ||
import { v5 as uuidv5 } from "uuid"; | ||
|
||
|
@@ -10,65 +11,65 @@ const translator = short(); | |
|
||
// The odd indentation in this file is necessary because otherwise the leading tabs will be applied into the event description. | ||
|
||
export const getWhat = (calEvent: CalendarEvent) => { | ||
export const getWhat = (calEvent: CalendarEvent, t: TFunction) => { | ||
return ` | ||
${calEvent.organizer.language.translate("what")}: | ||
${t("what")}: | ||
${calEvent.type} | ||
`; | ||
}; | ||
|
||
export const getWhen = (calEvent: CalendarEvent) => { | ||
export const getWhen = (calEvent: CalendarEvent, t: TFunction) => { | ||
return calEvent.seatsPerTimeSlot | ||
? ` | ||
${calEvent.organizer.language.translate("organizer_timezone")}: | ||
${t("organizer_timezone")}: | ||
${calEvent.organizer.timeZone} | ||
` | ||
: ` | ||
${calEvent.organizer.language.translate("invitee_timezone")}: | ||
${t("invitee_timezone")}: | ||
${calEvent.attendees[0].timeZone} | ||
`; | ||
}; | ||
|
||
export const getWho = (calEvent: CalendarEvent) => { | ||
export const getWho = (calEvent: CalendarEvent, t: TFunction) => { | ||
let attendeesFromCalEvent = [...calEvent.attendees]; | ||
if (calEvent.seatsPerTimeSlot && !calEvent.seatsShowAttendees) { | ||
attendeesFromCalEvent = []; | ||
} | ||
const attendees = attendeesFromCalEvent | ||
.map((attendee) => { | ||
return ` | ||
${attendee?.name || calEvent.organizer.language.translate("guest")} | ||
${attendee?.name || t("guest")} | ||
${attendee.email} | ||
`; | ||
}) | ||
.join(""); | ||
|
||
const organizer = ` | ||
${calEvent.organizer.name} - ${calEvent.organizer.language.translate("organizer")} | ||
${calEvent.organizer.name} - ${t("organizer")} | ||
${calEvent.organizer.email} | ||
`; | ||
|
||
const teamMembers = calEvent.team?.members | ||
? calEvent.team.members.map((member) => { | ||
return ` | ||
${member.name} - ${calEvent.organizer.language.translate("team_member")} | ||
${member.name} - ${t("team_member")} | ||
${member.email} | ||
`; | ||
}) | ||
: []; | ||
|
||
return ` | ||
${calEvent.organizer.language.translate("who")}: | ||
${t("who")}: | ||
${organizer + attendees + teamMembers.join("")} | ||
`; | ||
}; | ||
|
||
export const getAdditionalNotes = (calEvent: CalendarEvent) => { | ||
export const getAdditionalNotes = (calEvent: CalendarEvent, t: TFunction) => { | ||
if (!calEvent.additionalNotes) { | ||
return ""; | ||
} | ||
return ` | ||
${calEvent.organizer.language.translate("additional_notes")}: | ||
${t("additional_notes")}: | ||
${calEvent.additionalNotes} | ||
`; | ||
}; | ||
|
@@ -94,11 +95,11 @@ ${labelValueMap[key]} | |
return responsesString; | ||
}; | ||
|
||
export const getAppsStatus = (calEvent: CalendarEvent) => { | ||
export const getAppsStatus = (calEvent: CalendarEvent, t: TFunction) => { | ||
if (!calEvent.appsStatus) { | ||
return ""; | ||
} | ||
return `\n${calEvent.organizer.language.translate("apps_status")} | ||
return `\n${t("apps_status")} | ||
${calEvent.appsStatus.map((app) => { | ||
return `\n- ${app.appName} ${ | ||
app.success >= 1 ? `✅ ${app.success > 1 ? `(x${app.success})` : ""}` : "" | ||
|
@@ -111,11 +112,11 @@ export const getAppsStatus = (calEvent: CalendarEvent) => { | |
`; | ||
}; | ||
|
||
export const getDescription = (calEvent: CalendarEvent) => { | ||
export const getDescription = (calEvent: CalendarEvent, t: TFunction) => { | ||
if (!calEvent.description) { | ||
return ""; | ||
} | ||
return `\n${calEvent.organizer.language.translate("description")} | ||
return `\n${t("description")} | ||
${calEvent.description} | ||
`; | ||
}; | ||
|
@@ -153,9 +154,9 @@ const getSeatReferenceId = (calEvent: CalendarEvent): string => { | |
return calEvent.attendeeSeatId ? calEvent.attendeeSeatId : ""; | ||
}; | ||
|
||
export const getManageLink = (calEvent: CalendarEvent) => { | ||
export const getManageLink = (calEvent: CalendarEvent, t: TFunction) => { | ||
return ` | ||
${calEvent.organizer.language.translate("need_to_reschedule_or_cancel")} | ||
${t("need_to_reschedule_or_cancel")} | ||
${WEBAPP_URL + "/booking/" + getUid(calEvent) + "?changes=true"} | ||
`; | ||
}; | ||
|
@@ -176,38 +177,40 @@ export const getRescheduleLink = (calEvent: CalendarEvent): string => { | |
return `${WEBAPP_URL}/reschedule/${seatUid ? seatUid : Uid}`; | ||
}; | ||
|
||
export const getRichDescription = (calEvent: CalendarEvent /*, attendee?: Person*/) => { | ||
export const getRichDescription = (calEvent: CalendarEvent, t_?: TFunction /*, attendee?: Person*/) => { | ||
const t = t_ ?? calEvent.organizer.language.translate; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would recommend making t_ required here so that from everywhere we are passing the language explicitly and it would avoid accidental use of organizer language for attendee if it's not passed. |
||
|
||
return ` | ||
${getCancellationReason(calEvent)} | ||
${getWhat(calEvent)} | ||
${getWhen(calEvent)} | ||
${getWho(calEvent)} | ||
${calEvent.organizer.language.translate("where")}: | ||
${getCancellationReason(calEvent, t)} | ||
${getWhat(calEvent, t)} | ||
${getWhen(calEvent, t)} | ||
${getWho(calEvent, t)} | ||
${t("where")}: | ||
${getLocation(calEvent)} | ||
${getDescription(calEvent)} | ||
${getAdditionalNotes(calEvent)} | ||
${getDescription(calEvent, t)} | ||
${getAdditionalNotes(calEvent, t)} | ||
${getUserFieldsResponses(calEvent)} | ||
${getAppsStatus(calEvent)} | ||
${getAppsStatus(calEvent, t)} | ||
${ | ||
// TODO: Only the original attendee can make changes to the event | ||
// Guests cannot | ||
!calEvent.seatsPerTimeSlot && getManageLink(calEvent) | ||
!calEvent.seatsPerTimeSlot && getManageLink(calEvent, t) | ||
} | ||
${ | ||
calEvent.paymentInfo | ||
? ` | ||
${calEvent.organizer.language.translate("pay_now")}: | ||
${t("pay_now")}: | ||
${calEvent.paymentInfo.link} | ||
` | ||
: "" | ||
} | ||
`.trim(); | ||
}; | ||
|
||
export const getCancellationReason = (calEvent: CalendarEvent) => { | ||
export const getCancellationReason = (calEvent: CalendarEvent, t: TFunction) => { | ||
if (!calEvent.cancellationReason) return ""; | ||
return ` | ||
${calEvent.organizer.language.translate("cancellation_reason")}: | ||
${t("cancellation_reason")}: | ||
${calEvent.cancellationReason} | ||
`; | ||
}; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.