fix initial calendar loading;

show unpublished events in calendar for ADMINS
mark unavailable publishers when they are available on another time on the same day;
This commit is contained in:
Dobromir Popov
2024-05-07 19:16:03 +03:00
parent 8d4ae3ebf5
commit 4b45342877
7 changed files with 40 additions and 17 deletions

View File

@ -1,6 +1,8 @@
import { getToken } from "next-auth/jwt";
import { authOptions } from './auth/[...nextauth]'
import { getServerSession } from "next-auth/next"
import { NextApiRequest, NextApiResponse } from 'next'
import { DayOfWeek, AvailabilityType } from '@prisma/client';
import { DayOfWeek, AvailabilityType, UserRole } from '@prisma/client'; s
const common = require('../../src/helpers/common');
const dataHelper = require('../../src/helpers/data');
const subq = require('../../prisma/bl/subqueries');
@ -46,6 +48,9 @@ export default async function handler(req, res) {
let monthInfo = common.getMonthDatesInfo(day);
const searchText = req.query.searchText?.normalize('NFC');
const sessionServer = await getServerSession(req, res, authOptions)
var isAdmin = sessionServer?.user.role == UserRole.ADMIN
try {
switch (action) {
case "initDb":
@ -137,7 +142,7 @@ export default async function handler(req, res) {
break;
case "getCalendarEvents":
let events = await dataHelper.getCalendarEvents(req.query.publisherId, day);
let events = await dataHelper.getCalendarEvents(req.query.publisherId, true, true, isAdmin);
res.status(200).json(events);
case "getPublisherInfo":