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:
@ -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":
|
||||
|
Reference in New Issue
Block a user