edit business
This commit is contained in:
@@ -388,13 +388,14 @@ export class BookingsService {
|
||||
|
||||
const windows = await this.loadAvailabilityWindows(businessId);
|
||||
const busy = await this.loadBusyIntervals(businessId, dateYmd);
|
||||
const concurrentCapacity = await this.getConcurrentCapacity(businessId);
|
||||
const { concurrentCapacity, slotStepMinutes } =
|
||||
await this.getBusinessBookingSettings(businessId);
|
||||
|
||||
const slots = generateAvailableSlotStarts({
|
||||
dateYmd,
|
||||
durationMinutes: totalDurationMinutes,
|
||||
leadMinutes: this.minLeadMinutes,
|
||||
slotStepMinutes: 15,
|
||||
slotStepMinutes,
|
||||
windows,
|
||||
busy,
|
||||
concurrentCapacity,
|
||||
@@ -403,13 +404,18 @@ export class BookingsService {
|
||||
return { date: dateYmd, slots, totalDurationMinutes };
|
||||
}
|
||||
|
||||
private async getConcurrentCapacity(businessId: string): Promise<number> {
|
||||
private async getBusinessBookingSettings(businessId: string): Promise<{
|
||||
concurrentCapacity: number;
|
||||
slotStepMinutes: number;
|
||||
}> {
|
||||
const business = await this.businessRepo.findOne({
|
||||
where: { id: businessId },
|
||||
select: ['id', 'concurrentCapacity'],
|
||||
select: ['id', 'concurrentCapacity', 'slotStepMinutes'],
|
||||
});
|
||||
const value = business?.concurrentCapacity ?? 1;
|
||||
return Math.max(1, value);
|
||||
return {
|
||||
concurrentCapacity: Math.max(1, business?.concurrentCapacity ?? 1),
|
||||
slotStepMinutes: Math.max(5, business?.slotStepMinutes ?? 30),
|
||||
};
|
||||
}
|
||||
|
||||
private async loadAvailabilityWindows(
|
||||
@@ -658,12 +664,13 @@ export class BookingsService {
|
||||
);
|
||||
}
|
||||
|
||||
const concurrentCapacity = await this.getConcurrentCapacity(businessId);
|
||||
const { concurrentCapacity, slotStepMinutes } =
|
||||
await this.getBusinessBookingSettings(businessId);
|
||||
const slots = generateAvailableSlotStarts({
|
||||
dateYmd,
|
||||
durationMinutes,
|
||||
leadMinutes: this.minLeadMinutes,
|
||||
slotStepMinutes: 15,
|
||||
slotStepMinutes,
|
||||
windows,
|
||||
busy: await this.loadBusyIntervals(businessId, dateYmd, {
|
||||
excludeBookingId,
|
||||
|
||||
@@ -91,4 +91,16 @@ export class UpdateBusinessDto {
|
||||
@Min(1)
|
||||
@Max(20)
|
||||
concurrentCapacity?: number;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: 30,
|
||||
description: 'Minutes between available booking slot start times',
|
||||
minimum: 5,
|
||||
maximum: 120,
|
||||
})
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(5)
|
||||
@Max(120)
|
||||
slotStepMinutes?: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user