mirror of
https://github.com/open-reception/appointment-booking-software.git
synced 2026-09-26 19:04:50 +02:00
Fix schedule endpoint so it only returns public channels
This commit is contained in:
@@ -10,8 +10,8 @@ import { checkPermission } from "$lib/server/utils/permissions";
|
||||
registerOpenAPIRoute("/tenants/{id}/calendar", "GET", {
|
||||
summary: "Get tenant calendar",
|
||||
description:
|
||||
"Retrieves the appointment calendar for a specific tenant within a date range. Shows available time slots, existing appointments, and agent availability. This is a public endpoint that doesn't require authentication.",
|
||||
tags: ["Calendar", "Public"],
|
||||
"Retrieves the appointment calendar for a specific tenant within a date range. Shows available time slots, existing appointments, and agent availability. This is a private endpoint that requires authentication.",
|
||||
tags: ["Calendar", "Private"],
|
||||
parameters: [
|
||||
{
|
||||
name: "id",
|
||||
|
||||
@@ -187,24 +187,26 @@ export const GET: RequestHandler = async ({ params, url }) => {
|
||||
const clientSchedule = schedule.schedule.map((daySchedule) => ({
|
||||
date: daySchedule.date,
|
||||
channels: Object.fromEntries(
|
||||
Object.entries(daySchedule.channels).map(([channelId, channelData]) => [
|
||||
channelId,
|
||||
{
|
||||
channel: {
|
||||
id: channelData.channel.id,
|
||||
names: channelData.channel.names,
|
||||
descriptions: channelData.channel.descriptions,
|
||||
requiresConfirmation: channelData.channel.requiresConfirmation,
|
||||
pause: channelData.channel.pause,
|
||||
Object.entries(daySchedule.channels)
|
||||
.filter(([_, channelData]) => channelData.channel.isPublic)
|
||||
.map(([channelId, channelData]) => [
|
||||
channelId,
|
||||
{
|
||||
channel: {
|
||||
id: channelData.channel.id,
|
||||
names: channelData.channel.names,
|
||||
descriptions: channelData.channel.descriptions,
|
||||
requiresConfirmation: channelData.channel.requiresConfirmation,
|
||||
pause: channelData.channel.pause,
|
||||
},
|
||||
availableSlots: channelData.availableSlots.map((slot) => ({
|
||||
from: slot.from,
|
||||
to: slot.to,
|
||||
duration: slot.duration,
|
||||
availableAgents: slot.availableAgents,
|
||||
})),
|
||||
},
|
||||
availableSlots: channelData.availableSlots.map((slot) => ({
|
||||
from: slot.from,
|
||||
to: slot.to,
|
||||
duration: slot.duration,
|
||||
availableAgents: slot.availableAgents,
|
||||
})),
|
||||
},
|
||||
]),
|
||||
]),
|
||||
),
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user