fix modal afrer refactoring
This commit is contained in:
@ -93,7 +93,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
const shifts = await prisma.shift.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
isPublished: true,
|
||||
OR: [
|
||||
{ isPublished: true },
|
||||
{ user: { role: 'admin' } } // Todo: example. fix this
|
||||
],
|
||||
startTime: {
|
||||
gte: fromDate,
|
||||
//lt: toDate,
|
||||
|
@ -821,8 +821,7 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
|
||||
className={`flex justify-between items-center p-4 sm:py-2 rounded-lg shadow-sm mb-2
|
||||
${bgAndBorderColorClass} ${selectedBorderClass} ${activeOpacityClass}
|
||||
${pub.currentMonthAssignments === pub.desiredShiftsPerMonth ? 'text-gray-400' : pub.currentMonthAssignments > pub.desiredShiftsPerMonth ? 'text-orange-300' : 'text-gray-800'}`}
|
||||
onDoubleClick={(handlePublisherModalOpen.bind(this, pub))}
|
||||
onClick={handleSelectedPublisher.bind(this, pub)}
|
||||
onDoubleClick={() => handlePublisherModalOpen(pub)}
|
||||
>
|
||||
<span className={`${pub.isAvailableForShift ? 'font-bold' : 'font-medium'} `}>
|
||||
{pub.firstName} {pub.lastName}
|
||||
@ -838,11 +837,10 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
|
||||
<button tooltip="желани участия на месец" title="желани участия" className={`badge py-1 px-2 rounded-md text-xs ${pub.desiredShiftsPerMonth ? 'bg-purple-500 text-white' : 'bg-purple-200 text-gray-400'}`}>{pub.desiredShiftsPerMonth || 0}</button>
|
||||
<button tooltip="push" title="push" className={`badge py-1 px-2 rounded-md text-xs bg-red-100`}
|
||||
onClick={async () => {
|
||||
if (selectedPublisher && selectedShiftId)
|
||||
addAssignment(selectedPublisher, selectedShiftId);
|
||||
handleSelectedPublisher(pub);
|
||||
addAssignment(pub, selectedShiftId);
|
||||
}}
|
||||
>+</button>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
@ -881,24 +879,21 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
|
||||
<div>
|
||||
{/* <CustomCalendar date={value} shifts={shifts} /> */}
|
||||
</div>
|
||||
{isModalOpen && <PublisherShiftsModal publisher={modalPub} shifts={allShifts} onClose={() => setIsModalOpen(false)} />}
|
||||
{isModalOpen && (
|
||||
<PublisherShiftsModal
|
||||
publisher={modalPub}
|
||||
shifts={allShifts}
|
||||
onClose={() => setIsModalOpen(false)}
|
||||
date={value}
|
||||
/>
|
||||
)}
|
||||
</ProtectedRoute >
|
||||
</Layout >
|
||||
</>
|
||||
);
|
||||
|
||||
|
||||
function getColorForShift(shift) {
|
||||
const assignedCount = shift.assignedCount || 0; // Assuming each shift has an assignedCount property
|
||||
switch (assignedCount) {
|
||||
case 0: return 'bg-blue-300';
|
||||
case 1: return 'bg-green-300';
|
||||
case 2: return 'bg-yellow-300';
|
||||
case 3: return 'bg-orange-300';
|
||||
case 4: return 'bg-red-200';
|
||||
default: return 'bg-gray-300';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
import axiosServer from '../../../src/axiosServer';
|
||||
|
Reference in New Issue
Block a user