import/parse and generate respects withTransport and requiresTransport properties. parsing rransport initials
This commit is contained in:
@ -11,5 +11,5 @@ TELEGRAM_BOT=true
|
|||||||
SSL_KEY=./certificates/localhost-key.pem
|
SSL_KEY=./certificates/localhost-key.pem
|
||||||
SSL_CERT=./certificates/localhost.pem
|
SSL_CERT=./certificates/localhost.pem
|
||||||
|
|
||||||
DATABASE_URL=mysql://root:Zelen0ku4e@192.168.0.10:3306/cart_dev
|
# DATABASE_URL=mysql://root:Zelen0ku4e@192.168.0.10:3306/cart_dev
|
||||||
# DATABASE_URL=mysql://cart:cartpw@localhost:3306/cart
|
DATABASE_URL=mysql://cart:cartpw@localhost:3306/cart
|
||||||
|
@ -194,17 +194,31 @@ function ShiftComponent({ shift, onShiftSelect, isSelected, onPublisherSelect, a
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
function toggleTransport(id: any): void {
|
||||||
|
throw new Error('Function not implemented.');
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={index}
|
<div key={index}
|
||||||
className={`flow space-x-2 rounded-md px-2 py-1 my-1 ${ass.isConfirmed ? 'bg-yellow-100' : 'bg-gray-100'} ${borderStyles}`}
|
className={`flow space-x-2 rounded-md px-2 py-1 my-1 ${ass.isConfirmed ? 'bg-green-100' : 'bg-gray-100'} ${borderStyles}`}
|
||||||
>
|
>
|
||||||
<div className="flex justify-between items-center" onClick={() => handlePublisherClick(ass.publisher)}>
|
<div className="flex justify-between items-center" onClick={() => handlePublisherClick(ass.publisher)}>
|
||||||
<span className="text-gray-700">{publisherInfo.firstName} {publisherInfo.lastName}</span>
|
<span className="text-gray-700">{publisherInfo.firstName} {publisherInfo.lastName}</span>
|
||||||
<button onClick={() => removeAssignment(ass.id)}
|
<div className="flex items-left" >
|
||||||
className="text-white bg-red-500 hover:bg-red-600 px-3 py-1 ml-2 rounded-md"
|
{/* //if shift.isWithTransport, add trnsport button toggle, which sets ass.isWithTransportIn */}
|
||||||
>
|
{shift.requiresTransport &&
|
||||||
махни
|
(
|
||||||
</button>
|
<button onClick={() => toggleTransport(ass.id)} className={`text-white hover:bg-orange-600 px-3 py-1 ml-2 rounded-md ${ass.isWithTransport ? 'bg-green-500' : 'bg-orange-500'}`} >
|
||||||
|
транспорт
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
<button onClick={() => removeAssignment(ass.id)} className="text-white bg-red-500 hover:bg-red-600 px-3 py-1 ml-2 rounded-md" >
|
||||||
|
махни
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -178,7 +178,8 @@ async function GenerateSchedule(axios: Axios, date: string, copyFromPreviousMont
|
|||||||
shiftNr++;
|
shiftNr++;
|
||||||
const __shiftName = String(shiftStart.getHours()).padStart(2, "0") + ":" + String(shiftStart.getMinutes()).padStart(2, "0") + " - " + String(shiftEnd.getHours()).padStart(2, "0") + ":" + String(shiftEnd.getMinutes()).padStart(2, "0");
|
const __shiftName = String(shiftStart.getHours()).padStart(2, "0") + ":" + String(shiftStart.getMinutes()).padStart(2, "0") + " - " + String(shiftEnd.getHours()).padStart(2, "0") + ":" + String(shiftEnd.getMinutes()).padStart(2, "0");
|
||||||
shiftAssignments = [];
|
shiftAssignments = [];
|
||||||
console.log("[shift " + shiftNr + "] " + __shiftName);
|
let isTransportRequired = shiftNr == 1 || shiftEnd.getTime() == endTime.getTime();
|
||||||
|
console.log("[shift " + shiftNr + "] " + __shiftName + ", transport: " + (isTransportRequired ? "yes" : "no") + ", " + shiftStart.toLocaleTimeString() + " - " + shiftEnd.toLocaleTimeString() + " (end time: " + endTime.toLocaleTimeString() + ", " + event.shiftDuration + " min)");
|
||||||
|
|
||||||
if (autoFill || copyFromPreviousMonth) {
|
if (autoFill || copyFromPreviousMonth) {
|
||||||
// ###########################################
|
// ###########################################
|
||||||
@ -395,6 +396,7 @@ async function GenerateSchedule(axios: Axios, date: string, copyFromPreviousMont
|
|||||||
startTime: shiftStart,
|
startTime: shiftStart,
|
||||||
endTime: shiftEnd,
|
endTime: shiftEnd,
|
||||||
name: event.dayofweek + " " + shiftStart.toLocaleTimeString() + " - " + shiftEnd.toLocaleTimeString(),
|
name: event.dayofweek + " " + shiftStart.toLocaleTimeString() + " - " + shiftEnd.toLocaleTimeString(),
|
||||||
|
requiresTransport: isTransportRequired,
|
||||||
cartEvent: {
|
cartEvent: {
|
||||||
connect: {
|
connect: {
|
||||||
id: event.id,
|
id: event.id,
|
||||||
|
@ -95,6 +95,9 @@ export const getServerSideProps = async (context) => {
|
|||||||
if (availability.startTime) {
|
if (availability.startTime) {
|
||||||
availability.startTime = availability.startTime.toISOString();
|
availability.startTime = availability.startTime.toISOString();
|
||||||
availability.endTime = availability.endTime.toISOString();
|
availability.endTime = availability.endTime.toISOString();
|
||||||
|
if (availability.dateOfEntry) {
|
||||||
|
availability.dateOfEntry = availability.dateOfEntry.toISOString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -404,20 +404,21 @@ exports.processEvents = async function (events, year, monthNumber, progressCallb
|
|||||||
s.cartEventId === cartEvent.id &&
|
s.cartEventId === cartEvent.id &&
|
||||||
new Date(s.startTime).getTime() === new Date(start).getTime()
|
new Date(s.startTime).getTime() === new Date(start).getTime()
|
||||||
);
|
);
|
||||||
|
// get only hh:mm from the date
|
||||||
|
let isTransportRequired = event.shiftNr == 1 || end.toLocaleTimeString().substring(0, 5) == cartEvent.endTime.toLocaleTimeString().substring(0, 5);
|
||||||
if (!shift) {
|
if (!shift) {
|
||||||
//if shiftnr = 1, notes = "Докарва" + event.transport
|
//if shiftnr = 1, notes = "Докарва" + event.transport
|
||||||
//if shiftnr = 8, notes = "Взема" + event.transport
|
//if shiftnr = 8, notes = "Взема" + event.transport
|
||||||
|
|
||||||
|
let note = isTransportRequired ? event.transport : "";
|
||||||
let note = event.shiftNr === 1 ? "Докарва количка от Люлин - " + event.transport :
|
// "Докарва количка от Люлин/Прибира количка в Люлин"
|
||||||
event.shiftNr === 6 ? "Прибира количка в Люлин - " + event.transport : "";
|
|
||||||
const shiftEntity = await prisma.shift.create({
|
const shiftEntity = await prisma.shift.create({
|
||||||
data: {
|
data: {
|
||||||
name: event.dayOfWeek + " " + event.dayOfMonth + ", " + start.toLocaleTimeString() + " - " + end.toLocaleTimeString(),
|
name: event.dayOfWeek + " " + event.dayOfMonth + ", " + start.toLocaleTimeString() + " - " + end.toLocaleTimeString(),
|
||||||
startTime: start,
|
startTime: start,
|
||||||
endTime: end,
|
endTime: end,
|
||||||
notes: note,
|
notes: note,
|
||||||
|
requiresTransport: isTransportRequired,
|
||||||
cartEvent: {
|
cartEvent: {
|
||||||
connect: {
|
connect: {
|
||||||
id: cartEvent.id,
|
id: cartEvent.id,
|
||||||
@ -506,6 +507,13 @@ exports.processEvents = async function (events, year, monthNumber, progressCallb
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (location != null && publisher != null && shift != null) {
|
if (location != null && publisher != null && shift != null) {
|
||||||
|
let isWithTransport = false;
|
||||||
|
if (isTransportRequired) {
|
||||||
|
const pubInitials = publisher.firstName[0] + publisher.lastName[0];
|
||||||
|
// get cotent after last - or long dash-`-` and remove spaces, trim dots and make lowercase
|
||||||
|
let transportInitials = event.transport.split("-").pop().replace(/[\s.]/g, "").toUpperCase();
|
||||||
|
isWithTransport = transportInitials.includes(pubInitials);
|
||||||
|
}
|
||||||
const assignment = await prisma.assignment.create({
|
const assignment = await prisma.assignment.create({
|
||||||
data: {
|
data: {
|
||||||
//publisherId: publisher.id,
|
//publisherId: publisher.id,
|
||||||
@ -520,6 +528,7 @@ exports.processEvents = async function (events, year, monthNumber, progressCallb
|
|||||||
id: shift.id,
|
id: shift.id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
isWithTransport: isWithTransport,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
//ToDo: fix findPublisherAvailability and creation of availabilities
|
//ToDo: fix findPublisherAvailability and creation of availabilities
|
||||||
|
Reference in New Issue
Block a user