This commit is contained in:
Dobromir Popov
2024-03-26 01:08:57 +02:00
parent 3fcdfc1347
commit acd776e988
37 changed files with 143 additions and 107 deletions

View File

@ -30,7 +30,7 @@ export default function AvPage({ initialItems, id }: IProps) {
date: new Date(item.startTime),
start: new Date(item.startTime),
end: new Date(item.endTime),
isactive: item.isactive,
isActive: item.isActive,
publisherId: item.publisher.id,
dayOfMonth: item.dayOfMonth,
dayOfWeek: item.dayOfWeek,
@ -66,9 +66,9 @@ export default function AvPage({ initialItems, id }: IProps) {
</thead>
<tbody>
{initialItems?.map((item: Availability) => (
<tr key={item.id} className={item.isactive ? "" : "text-gray-300"}>
<tr key={item.id} className={item.isActive ? "" : "text-gray-300"}>
<td className="px-6 py-4 whitespace-nowrap ">
{item.id} {item.isactive}
{item.id} {item.isActive}
</td>
<td className="px-6 py-4 whitespace-nowrap">
{item.publisher.lastName}, {item.publisher.firstName}
@ -133,14 +133,14 @@ export const getServerSideProps = async (context) => {
const role = session?.user.role;
console.log("server role: " + role);
var queryUrl = process.env.NEXTAUTH_URL + "/api/data/availabilities?select=id,name,isactive,dayofweek,dayOfMonth,startTime,endTime,publisher.firstName,publisher.lastName,publisher.id";
var queryUrl = process.env.NEXTAUTH_URL + "/api/data/availabilities?select=id,name,isActive,dayofweek,dayOfMonth,startTime,endTime,publisher.firstName,publisher.lastName,publisher.id";
if (role === UserRole.USER || context.query.my) {
queryUrl += `&where={"publisherId":"${session?.user.id}"}`;
} else if (role == UserRole.ADMIN) {
if (context.query.id) {
queryUrl += `&where={"publisherId":"${context.query.id}"}`;
} else {
queryUrl += `&where={"isactive":true}`;
queryUrl += `&where={"isActive":true}`;
}
}
var resp = await axios.get(

View File

@ -100,7 +100,7 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
console.log("Setting date to '" + date.toLocaleDateString() + "' from '" + selectedDate.toLocaleDateString() + "'. ISO: " + date.toISOString(), "locale ISO:", common.getISODateOnly(date));
if (isCheckboxChecked) {
console.log(`getting unassigned publishers for ${common.getMonthName(date.getMonth())} ${date.getFullYear()}`);
const { data: availablePubsForDate } = await axiosInstance.get(`/api/?action=getUnassignedPublishers&date=${dateStr}&select=id,firstName,lastName,isactive,desiredShiftsPerMonth`);
const { data: availablePubsForDate } = await axiosInstance.get(`/api/?action=getUnassignedPublishers&date=${dateStr}&select=id,firstName,lastName,isActive,desiredShiftsPerMonth`);
setAvailablePubs(availablePubsForDate);
}
else {
@ -108,7 +108,7 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
try {
const { data: shiftsForDate } = await axiosInstance.get(`/api/?action=getShiftsForDay&date=${dateStr}`);
setShifts(shiftsForDate);
let { data: availablePubsForDate } = await axiosInstance.get(`/api/?action=filterPublishers&assignments=true&availabilities=true&date=${dateStr}&select=id,firstName,lastName,isactive,desiredShiftsPerMonth`);
let { data: availablePubsForDate } = await axiosInstance.get(`/api/?action=filterPublishers&assignments=true&availabilities=true&date=${dateStr}&select=id,firstName,lastName,isActive,desiredShiftsPerMonth`);
availablePubsForDate.forEach(pub => {
pub.canTransport = pub.availabilities.some(av =>
@ -172,8 +172,8 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
// currentMonthAssignments and previousMonthAssignments properties
// Sort publishers based on availability and then by assignment counts.
const sortedPubs = updatedPubs.sort((a, b) => {
if (a.isactive !== b.isactive) {
return a.isactive ? -1 : 1;
if (a.isActive !== b.isActive) {
return a.isActive ? -1 : 1;
}
// First, sort by isselected.
if (a.isSelected !== b.isSelected) {
@ -355,7 +355,7 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
const newAssignment = {
publisher: { connect: { id: publisher.id } },
shift: { connect: { id: shiftId } },
isactive: true,
isActive: true,
isConfirmed: true
};
const { data } = await axiosInstance.post("/api/data/assignments", newAssignment);
@ -669,7 +669,7 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
// Determine border class if selected
const selectedBorderClass = pub.isSelected ? 'border-blue-400 border-b-4' : '';
// Determine opacity class
const activeOpacityClass = pub.isactive ? '' : 'opacity-25';
const activeOpacityClass = pub.isActive ? '' : 'opacity-25';
return (
@ -878,20 +878,20 @@ export const getServerSideProps = async (context) => {
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 } });
// 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: 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,
isActive: true,
startTime: {
gte: firstDayOfMonth,
//lt: lastDayOfMonth

View File

@ -69,7 +69,7 @@ export default function CartEventPage({ items, locations }: ICartEventPageProps)
{item.shiftDuration}
</td>
<td className="px-6 py-4 whitespace-nowrap">
{item.isactive ? "Yes" : "No"}
{item.isActive ? "Yes" : "No"}
</td>
<td>
<button className="button bg-blue-500 hover:bg-blue-700"

View File

@ -194,7 +194,7 @@ export default function ImportPage() {
let personNames = names.join(' ');
try {
try {
const select = "&select=id,firstName,lastName,phone,isTrained,desiredShiftsPerMonth,isactive,type,availabilities";
const select = "&select=id,firstName,lastName,phone,isTrained,desiredShiftsPerMonth,isActive,type,availabilities";
const responseByName = await axiosInstance.get(`/api/?action=findPublisher&filter=${names.join(' ')}${select}`);
let existingPublisher = responseByName.data[0];
if (!existingPublisher) {
@ -248,7 +248,7 @@ export default function ImportPage() {
{ key: 'phone', value: phone },
{ key: 'desiredShiftsPerMonth', value: desiredShiftsPerMonth, parse: parseInt },
{ key: 'isTrained', value: isTrained },
{ key: 'isactive', value: isActive },
{ key: 'isActive', value: isActive },
{ key: 'type', value: publisherType, parse: common.getPubTypeEnum }
];
@ -286,7 +286,7 @@ export default function ImportPage() {
phone,
firstName: names[0],
lastName: names[1],
isactive: isActive,
isActive: isActive,
isTrained,
desiredShiftsPerMonth,
});
@ -301,7 +301,7 @@ export default function ImportPage() {
phone,
firstName: firstname,
lastName: names[names.length - 1],
isactive: isActive,
isActive: isActive,
isTrained,
desiredShiftsPerMonth
});
@ -530,7 +530,7 @@ export default function ImportPage() {
weekOfMonth: weekNr, // Add the missing 'weekOfMonth'
startTime,
endTime,
isactive: true,
isActive: true,
type: AvailabilityType.OneTime,
isWithTransportIn: false, // Add the missing 'isWithTransport' property
isWithTransportOut: false, // Add the missing 'isWithTransport' property

View File

@ -225,7 +225,7 @@ export default PublishersPage;
export const getServerSideProps = async (context) => {
const axios = await axiosServer(context);
//ToDo: refactor all axios calls to use axiosInstance and this URL
const { data: publishers } = await axios.get('/api/data/publishers?select=id,firstName,lastName,email,isactive,isTrained,isImported,assignments.shift.startTime,availabilities.startTime&dev=fromuseefect');
const { data: publishers } = await axios.get('/api/data/publishers?select=id,firstName,lastName,email,isActive,isTrained,isImported,assignments.shift.startTime,availabilities.startTime&dev=fromuseefect');
return {
props: {

View File

@ -74,12 +74,12 @@ export default ContactsPage;
export const getServerSideProps = async (context) => {
const dateStr = new Date().toISOString().split('T')[0];
let publishers = await filterPublishers('id,firstName,lastName,email,isactive,desiredShiftsPerMonth', "", new Date(), true, true, false);
let publishers = await filterPublishers('id,firstName,lastName,email,isActive,desiredShiftsPerMonth', "", new Date(), true, true, false);
// 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`);
// const { data: publishers } = await axios.get(`api/?action=filterPublishers&assignments=true&availabilities=true&date=${dateStr}&select=id,firstName,lastName,isActive,desiredShiftsPerMonth`);
// api/index?action=filterPublishers&assignments=true&availabilities=true&date=2024-03-14&select=id%2CfirstName%2ClastName%2Cisactive%2CdesiredShiftsPerMonth
// api/index?action=filterPublishers&assignments=true&availabilities=true&date=2024-03-14&select=id%2CfirstName%2ClastName%2CisActive%2CdesiredShiftsPerMonth
publishers.forEach(publisher => {
publisher.desiredShiftsPerMonth = publisher.desiredShiftsPerMonth || 0;
publisher.assignments = publisher.assignments || [];

View File

@ -74,6 +74,18 @@ export default function Reports() {
Добави нов отчет
</button>
</Link>
<label className="mr-4">
<input type="radio" name="reportType" value="ServiceReport" defaultChecked />
Отчети
</label>
<label className="mr-4">
<input type="radio" name="reportType" value="Experience" />
Случка
</label>
<label className="mr-4">
<input type="radio" name="reportType" value="Feedback" />
Отзиви
</label>
<div className="mt-4 w-full overflow-x-auto">
<table className="w-full table-auto">
<thead>