mirror of
https://github.com/open-reception/appointment-booking-software.git
synced 2026-09-13 12:47:39 +02:00
If staff creates an appointment, treat it as being already confirmed
This commit is contained in:
@@ -481,21 +481,24 @@ export class AppointmentService {
|
||||
/**
|
||||
* Add appointment to existing client tunnel
|
||||
*/
|
||||
public async addAppointmentToTunnel(appointmentData: {
|
||||
emailHash: string;
|
||||
tunnelId: string;
|
||||
channelId: string;
|
||||
agentId: string;
|
||||
appointmentDate: string;
|
||||
duration: number;
|
||||
clientEmail: string;
|
||||
clientLanguage?: string;
|
||||
encryptedAppointment: {
|
||||
encryptedPayload: string;
|
||||
iv: string;
|
||||
authTag: string;
|
||||
};
|
||||
}): Promise<AppointmentResponse> {
|
||||
public async addAppointmentToTunnel(
|
||||
appointmentData: {
|
||||
emailHash: string;
|
||||
tunnelId: string;
|
||||
channelId: string;
|
||||
agentId: string;
|
||||
appointmentDate: string;
|
||||
duration: number;
|
||||
clientEmail: string;
|
||||
clientLanguage?: string;
|
||||
encryptedAppointment: {
|
||||
encryptedPayload: string;
|
||||
iv: string;
|
||||
authTag: string;
|
||||
};
|
||||
},
|
||||
staffCreated = false,
|
||||
): Promise<AppointmentResponse> {
|
||||
const log = logger.setContext("AppointmentService");
|
||||
|
||||
log.info("Adding appointment to existing tunnel", {
|
||||
@@ -539,8 +542,11 @@ export class AppointmentService {
|
||||
throw new NotFoundError("Active channel not found");
|
||||
}
|
||||
|
||||
const initialStatus = channelResult[0].requiresConfirmation ? "NEW" : "CONFIRMED";
|
||||
const requiresConfirmation = channelResult[0].requiresConfirmation || false;
|
||||
const initialStatus =
|
||||
channelResult[0].requiresConfirmation && !staffCreated ? "NEW" : "CONFIRMED";
|
||||
const requiresConfirmation = staffCreated
|
||||
? false
|
||||
: channelResult[0].requiresConfirmation || false;
|
||||
|
||||
// Create encrypted appointment
|
||||
const appointmentResult = await db
|
||||
@@ -589,6 +595,7 @@ export class AppointmentService {
|
||||
*/
|
||||
public async createNewClientWithAppointment(
|
||||
clientData: ClientTunnelData,
|
||||
staffCreated = false,
|
||||
): Promise<AppointmentResponse> {
|
||||
const log = logger.setContext("AppointmentService");
|
||||
|
||||
@@ -685,8 +692,11 @@ export class AppointmentService {
|
||||
throw new NotFoundError("Channel not found");
|
||||
}
|
||||
|
||||
const initialStatus = channelResult[0].requiresConfirmation ? "NEW" : "CONFIRMED";
|
||||
const requiresConfirmation = channelResult[0].requiresConfirmation || false;
|
||||
const initialStatus =
|
||||
channelResult[0].requiresConfirmation && !staffCreated ? "NEW" : "CONFIRMED";
|
||||
const requiresConfirmation = staffCreated
|
||||
? false
|
||||
: channelResult[0].requiresConfirmation || false;
|
||||
|
||||
// 4. Create encrypted appointment
|
||||
const appointmentResult = await tx
|
||||
|
||||
@@ -321,7 +321,7 @@ export const POST: RequestHandler = async ({ params, request, locals }) => {
|
||||
encryptedAppointment: validatedData.encryptedAppointment,
|
||||
};
|
||||
|
||||
result = await appointmentService.addAppointmentToTunnel(appointmentData);
|
||||
result = await appointmentService.addAppointmentToTunnel(appointmentData, true);
|
||||
} else {
|
||||
// New client - create tunnel and appointment
|
||||
isNewClient = true;
|
||||
@@ -360,7 +360,7 @@ export const POST: RequestHandler = async ({ params, request, locals }) => {
|
||||
clientEncryptedTunnelKey: validatedData.clientEncryptedTunnelKey,
|
||||
};
|
||||
|
||||
result = await appointmentService.createNewClientWithAppointment(clientData);
|
||||
result = await appointmentService.createNewClientWithAppointment(clientData, true);
|
||||
|
||||
// For new clients with email: initiate PIN reset flow
|
||||
if (validatedData.clientEmail && !validatedData.hasNoEmail) {
|
||||
@@ -397,7 +397,7 @@ export const POST: RequestHandler = async ({ params, request, locals }) => {
|
||||
validatedData.channelId,
|
||||
validatedData.clientEmail,
|
||||
validatedData.clientLanguage,
|
||||
!!result.requiresConfirmation,
|
||||
false,
|
||||
);
|
||||
} catch (error) {
|
||||
logger.error("Failed to send appointment notification", {
|
||||
|
||||
Reference in New Issue
Block a user