diff --git a/components/calendar/ShiftComponent.tsx b/components/calendar/ShiftComponent.tsx index 16fab95..c6c5ec2 100644 --- a/components/calendar/ShiftComponent.tsx +++ b/components/calendar/ShiftComponent.tsx @@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'; import axiosInstance from '../../src/axiosSecure'; import PublisherSearchBox from '../publisher/PublisherSearchBox'; // Update the path -import { DirectionsBus } from '@mui/material'; // Import MUI CircularProgress for loading indicator +import LocalShippingIcon from '@mui/icons-material/LocalShipping'; const common = require('src/helpers/common'); @@ -138,9 +138,6 @@ function ShiftComponent({ shift, onShiftSelect, isSelected, onPublisherSelect, a } catch (error) { } } - - - return (
@@ -148,6 +145,7 @@ function ShiftComponent({ shift, onShiftSelect, isSelected, onPublisherSelect, a
{`${common.getTimeRange(new Date(shift.startTime), new Date(shift.endTime))}`} + {/* {shift.requiresTransport && ()} */} {/* Copy All Names Button */} @@ -162,7 +160,6 @@ function ShiftComponent({ shift, onShiftSelect, isSelected, onPublisherSelect, a )}
- {/* Assignments */} {assignments.map((ass, index) => { const publisherInfo = allPublishersInfo.find(info => info?.id === ass.publisher.id) || ass.publisher; @@ -222,9 +219,9 @@ function ShiftComponent({ shift, onShiftSelect, isSelected, onPublisherSelect, a {shift.requiresTransport && ( toggleTransport(ass) : undefined} - className={`material-icons ${ass.isWithTransport || ass.canTransport ? 'text-green-500 font-bold' : (transportProvided ? 'text-gray-400 ' : 'text-orange-400 font-bold')} ${ass.canTransport ? ' cursor-pointer' : 'cursor-not-allowed'} px-3 py-1 ml-2 rounded-md`} + className={`material-icons ${ass.isWithTransport ? 'text-green-500 font-bold' : (transportProvided ? 'text-gray-400 ' : 'text-orange-400 font-bold')} ${ass.canTransport ? ' cursor-pointer' : 'cursor-not-allowed'} px-3 py-1 ml-2 rounded-md`} > - {ass.isWithTransport ? "транспорт" : ass.canTransport ? "може транспорт" : "без транспорт"} + {ass.isWithTransport ? "транспорт" : ass.canTransport ? "може транспорт" : "без транспорт"} )}
- -
- {/* */} -
{isModalOpen && setIsModalOpen(false)} />} @@ -844,69 +859,3 @@ export default function CalendarPage({ initialEvents, initialShifts }) { } } } - -import axiosServer from '../../../src/axiosServer'; -import { start } from 'repl'; -export const getServerSideProps = async (context) => { - const axios = await axiosServer(context); - const baseUrl = common.getBaseUrl(); - console.log('runtime BaseUrl: ' + baseUrl); - console.log('runtime NEXTAUTH_URL: ' + process.env.NEXTAUTH_URL); - console.log('Runtime Axios Base URL:', axios.defaults.baseURL); - - const currentDate = new Date(); - const firstDayOfMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() - 3, 1); - const lastDayOfMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0); // 0th day of the next month gives the last day of the current month - - const url = `/api/data/shifts?where={"startTime":{"$and":[{"$gte":"${common.getISODateOnly(firstDayOfMonth)}","$lt":"${common.getISODateOnly(lastDayOfMonth)}"}]}}`; - - const prismaClient = common.getPrismaClient(); - // let events = await prismaClient.cartEvent.findMany({ where: { isactive: true } }); - // events = events.map(event => ({ - // ...event, - // // Convert Date objects to ISO strings - // startTime: event.startTime.toISOString(), - // endTime: event.endTime.toISOString(), - // })); - const { data: events } = await axios.get(`/api/data/cartevents?where={"isactive":true}`); - //const { data: shifts } = await axios.get(url); - - // get all shifts for the month, including assigments - let shifts = await prismaClient.shift.findMany({ - where: { - isactive: true, - startTime: { - gte: firstDayOfMonth, - //lt: lastDayOfMonth - } - }, - include: { - assignments: { - include: { - publisher: { - select: { - id: true, - } - } - } - } - } - }); - - //calculate assCount for each shift - shifts = shifts.map(shift => ({ - ...shift, - assignedCount: shift.assignments.length, - startTime: shift.startTime.toISOString(), - endTime: shift.endTime.toISOString(), - })); - - - return { - props: { - initialEvents: events, - initialShifts: shifts, - }, - }; - -} \ No newline at end of file