renames
This commit is contained in:
@ -143,7 +143,7 @@ export default async function handler(req, res) {
|
||||
|
||||
case "getUnassignedPublishers":
|
||||
//let monthInfo = common.getMonthDatesInfo(date);
|
||||
let allPubs = await filterPublishers("id,firstName,lastName,email,isactive".split(","), "", date, true, true, false);
|
||||
let allPubs = await filterPublishers("id,firstName,lastName,email,isActive".split(","), "", date, true, true, false);
|
||||
let unassignedPubs = allPubs.filter(pub => pub.currentMonthAssignments == 0 && pub.availabilities.length > 0);
|
||||
res.status(200).json(unassignedPubs);
|
||||
break;
|
||||
@ -690,7 +690,7 @@ async function replaceInAssignment(oldPublisherId, newPublisherId, shiftId) {
|
||||
data: {
|
||||
publisherId: newPublisherId,
|
||||
isConfirmed: false,
|
||||
isTentative: true,
|
||||
isBySystem: true,
|
||||
isMailSent: false
|
||||
}
|
||||
});
|
||||
|
@ -89,7 +89,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
|
||||
const shifts = await prisma.shift.findMany({
|
||||
where: {
|
||||
isactive: true,
|
||||
isActive: true,
|
||||
startTime: {
|
||||
gte: fromDate,
|
||||
lt: toDate,
|
||||
|
@ -68,7 +68,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
case "test":
|
||||
var data = prisma.shift.findMany({
|
||||
where: {
|
||||
isactive: true
|
||||
isActive: true
|
||||
}
|
||||
});
|
||||
|
||||
@ -110,7 +110,7 @@ async function GenerateSchedule(axios: Axios, date: string, copyFromPreviousMont
|
||||
}
|
||||
|
||||
console.log("finding shifts for previous 3 months for statistics (between " + new Date(monthInfo.date.getFullYear(), monthInfo.date.getMonth() - 3, 1).toISOString() + " and " + monthInfo.firstDay.toISOString() + ")");
|
||||
const { data: events } = await axios.get(`/api/data/cartevents?where={"isactive":{"$eq":true}}`);
|
||||
const { data: events } = await axios.get(`/api/data/cartevents?where={"isActive":{"$eq":true}}`);
|
||||
|
||||
//// let [shiftsLastMonth, publishers] = await getShiftsAndPublishersForPreviousMonths(lastMonthInfo);
|
||||
//use filterPublishers from /pages/api/data/index.ts to get publishers with stats
|
||||
@ -308,7 +308,7 @@ async function GenerateSchedule(axios: Axios, date: string, copyFromPreviousMont
|
||||
assignments: 'true',
|
||||
availabilities: 'true',
|
||||
date: common.getISODateOnly(shiftStart),
|
||||
select: 'id,firstName,lastName,isactive,desiredShiftsPerMonth'
|
||||
select: 'id,firstName,lastName,isActive,desiredShiftsPerMonth'
|
||||
});
|
||||
let allAvailablePublishers = (await axios.get(`/api/?${queryParams.toString()}`)).data;
|
||||
let availablePublishers = allAvailablePublishers;
|
||||
@ -616,12 +616,12 @@ async function ImportShiftsFromDocx(axios: Axios) {
|
||||
|
||||
// prisma.publisher.findMany({
|
||||
// where: {
|
||||
// isactive: true,
|
||||
// isActive: true,
|
||||
// },
|
||||
// include: {
|
||||
// availabilities: {
|
||||
// where: {
|
||||
// isactive: true,
|
||||
// isActive: true,
|
||||
// },
|
||||
// },
|
||||
// assignments: {
|
||||
|
@ -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(
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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: {
|
||||
|
@ -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 || [];
|
||||
|
@ -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>
|
||||
|
@ -86,7 +86,7 @@ async function getAvailabilities(userId) {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
isactive: true,
|
||||
isActive: true,
|
||||
isFromPreviousAssignment: true,
|
||||
dayofweek: true,
|
||||
dayOfMonth: true,
|
||||
@ -121,7 +121,7 @@ async function getAvailabilities(userId) {
|
||||
shiftId Int
|
||||
publisher Publisher @relation(fields: [publisherId], references: [id], onDelete: Cascade)
|
||||
publisherId String
|
||||
isactive Boolean @default(true)
|
||||
isActive Boolean @default(true)
|
||||
isConfirmed Boolean @default(false)
|
||||
isWithTransport Boolean @default(false)
|
||||
Report Report[]
|
||||
@ -133,7 +133,7 @@ async function getAvailabilities(userId) {
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
isTentative: true,
|
||||
isBySystem: true,
|
||||
isConfirmed: true,
|
||||
isWithTransport: true,
|
||||
shift: {
|
||||
|
Reference in New Issue
Block a user