Skip to content
Open
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
32 changes: 18 additions & 14 deletions backend/src/infrastructure/email/email.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,16 @@ export class EmailService implements IEmailService {
}

async sendBookingConfirmation(data: BookingConfirmationEmailData): Promise<void> {
const startFormatted = data.startTime.toLocaleString('en-US', {
timeZone: 'UTC',
weekday: 'long', year: 'numeric', month: 'long', day: 'numeric',
hour: '2-digit', minute: '2-digit',
});
const endFormatted = data.endTime.toLocaleString('en-US', {
timeZone: 'UTC',
hour: '2-digit', minute: '2-digit',
});
const formatIST = (date: Date, opts: Intl.DateTimeFormatOptions): string =>
date.toLocaleString('en-IN', { timeZone: 'Asia/Kolkata', ...opts });

const startFormatted =
formatIST(data.startTime, {
weekday: 'long', year: 'numeric', month: 'long', day: 'numeric',
hour: '2-digit', minute: '2-digit',
}) + ' IST';
const endFormatted =
formatIST(data.endTime, { hour: '2-digit', minute: '2-digit' }) + ' IST';

try {
await this._transporter.sendMail({
Expand Down Expand Up @@ -134,11 +135,14 @@ export class EmailService implements IEmailService {
}

async sendBookingCancelled(data: BookingCancelledEmailData): Promise<void> {
const startFormatted = data.startTime.toLocaleString('en-US', {
timeZone: 'UTC',
weekday: 'long', year: 'numeric', month: 'long', day: 'numeric',
hour: '2-digit', minute: '2-digit',
});
const formatIST = (date: Date, opts: Intl.DateTimeFormatOptions): string =>
date.toLocaleString('en-IN', { timeZone: 'Asia/Kolkata', ...opts });

const startFormatted =
formatIST(data.startTime, {
weekday: 'long', year: 'numeric', month: 'long', day: 'numeric',
hour: '2-digit', minute: '2-digit',
}) + ' IST';

try {
await this._transporter.sendMail({
Expand Down
14 changes: 11 additions & 3 deletions backend/src/services/mentor/mentor-booking.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isAfter, differenceInHours, format } from 'date-fns';
import { isAfter, differenceInHours } from 'date-fns';
import { IMentorBookingService, MentorDashboardStats } from '../../interfaces/service-interfaces/mentor/IMentorBookingService';
import { Types } from 'mongoose';
import { IMentorBookingRepository } from '../../interfaces/repository-interfaces/mentor/IMentorBookingRepository';
Expand Down Expand Up @@ -130,7 +130,11 @@ export class MentorBookingService implements IMentorBookingService {
}

const bookingId = (booking._id as { toString(): string }).toString();
const formattedTime = format(startTime, 'MMM d, yyyy \'at\' h:mm a');
const formattedTime = startTime.toLocaleString('en-IN', {
timeZone: 'Asia/Kolkata',
month: 'short', day: 'numeric', year: 'numeric',
hour: 'numeric', minute: '2-digit',
}) + ' IST';

// Candidate: "Your session is confirmed"
void this.notificationService.create({
Expand Down Expand Up @@ -192,7 +196,11 @@ export class MentorBookingService implements IMentorBookingService {
return;
}

const formattedTime = format(booking.startTime, 'MMM d, yyyy \'at\' h:mm a');
const formattedTime = booking.startTime.toLocaleString('en-IN', {
timeZone: 'Asia/Kolkata',
month: 'short', day: 'numeric', year: 'numeric',
hour: 'numeric', minute: '2-digit',
}) + ' IST';
const cancelledByName = cancelledBy.fullName;

const sharedData = {
Expand Down