fix statistics;
rewrite availability filters; fix availability filters; ProtectedRoute.IsInRole helper
This commit is contained in:
@ -603,7 +603,7 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
|
||||
message="Това ще изпрати имейли до всички участници за смените им през избрания месец. Сигурни ли сте?"
|
||||
/>
|
||||
<button
|
||||
className={`button btn m-2 ${isPublished ? 'hover:bg-gray-100 bg-yellow-500' : 'hover:bg-red-300 bg-blue-400'}`}
|
||||
className={`button btn m-2 ${isPublished ? 'hover:bg-gray-500 bg-yellow-500' : 'hover:bg-red-300 bg-blue-400'}`}
|
||||
onClick={togglePublished}>
|
||||
<i className={`fas ${isPublished ? 'fa-check' : 'fa-close'} mr-2`}></i>
|
||||
{isPublished ? "Скрий" : "Публикувай"} графика (м.)
|
||||
|
@ -3,6 +3,8 @@ import NewPubPage from "../new";
|
||||
export default NewPubPage;
|
||||
|
||||
import { Assignment, Shift, UserRole, AvailabilityType } from "prisma/prisma-client";
|
||||
//import ProtectedRoute from '../../../../components/protectedRoute';
|
||||
|
||||
// import { monthNamesBG } from "~/src/helpers/const"
|
||||
import { monthNamesBG } from "src/helpers/const";
|
||||
|
||||
@ -38,6 +40,7 @@ function getShiftGroups(shifts: [Shift]) {
|
||||
export const getServerSideProps = async (context) => {
|
||||
const axios = await axiosServer(context);
|
||||
|
||||
// const isAdmin = await ProtectedRoute.IsInRole(UserRole.ADMIN); does not work on server side
|
||||
context.res.setHeader("Cache-Control", "s-maxage=1, stale-while-revalidate");
|
||||
if (!context.query || !context.query.id) {
|
||||
return {
|
||||
@ -50,11 +53,9 @@ export const getServerSideProps = async (context) => {
|
||||
|
||||
// item.allShifts = item.assignments.map((a: Assignment[]) => a.shift);
|
||||
|
||||
//group shifts by month, remove duplicates
|
||||
//sort availabilities by start time
|
||||
// item.availabilities = item.availabilities
|
||||
// .sort((a, b) => b.startTime - a.startTime);
|
||||
|
||||
// ============================================================
|
||||
// don't show past availabilities (if user not admin) ToDo: add admin check
|
||||
// ============================================================
|
||||
item.availabilities = item.availabilities.filter((a) => new Date(a.startTime) >= new Date() || a.type == AvailabilityType.Weekly);
|
||||
item.assignments = item.assignments
|
||||
.sort((a, b) => b.startTime - a.startTime)
|
||||
|
@ -127,7 +127,7 @@ export const getServerSideProps = async (context) => {
|
||||
const prisma = common.getPrismaClient();
|
||||
const dateStr = new Date().toISOString().split('T')[0];
|
||||
|
||||
let publishers = await data.filterPublishersNew('id,firstName,lastName,email,isActive,desiredShiftsPerMonth,lastLogin', dateStr, false, true, true, true);
|
||||
let publishers = await data.filterPublishersNew('id,firstName,lastName,email,isActive,desiredShiftsPerMonth,lastLogin', dateStr, false, true, true, true, true);
|
||||
|
||||
// const axios = await axiosServer(context);
|
||||
// const { data: publishers } = await axios.get(`api/?action=filterPublishers&assignments=true&availabilities=true&date=${dateStr}&select=id,firstName,lastName,isActive,desiredShiftsPerMonth`);
|
||||
|
Reference in New Issue
Block a user