-
+
{pub.currentMonthAvailabilityDaysCount || 0} | {pub.currentMonthAvailabilityHoursCount || 0}
{pub.currentWeekAssignments || 0}
@@ -809,7 +836,27 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
headers: {
'Content-Type': 'application/json'
},
- body: JSON.stringify({ broadcast: true, message: "Тестово съобщение", title: "Това е тестово съобщение от https://sofia.mwitnessing.com" })
+ body: JSON.stringify({
+ id: pub.id,
+ message: "Тестово съобщение",
+ title: "Това е тестово съобщение от https://sofia.mwitnessing.com",
+ actions: [
+ { action: 'OK', title: 'OK', icon: '✅' },
+ { action: 'close', title: 'Затвори', icon: '❌' }
+ ]
+ // actions: [
+ // {
+ // title: 'Open URL',
+ // action: 'open_url',
+ // icon: '/images/open-url.png'
+ // },
+ // {
+ // title: 'Dismiss',
+ // action: 'dismiss',
+ // icon: '/images/dismiss.png'
+ // }
+ // ]
+ })
})
}}
>+
diff --git a/pages/cart/publishers/stats.tsx b/pages/cart/publishers/stats.tsx
index 69e33f6..6b9d615 100644
--- a/pages/cart/publishers/stats.tsx
+++ b/pages/cart/publishers/stats.tsx
@@ -253,7 +253,7 @@ function ContactsPage({ allPublishers }) {
<>
{pub.availabilities.length > 0 ? (
-
+
{pub.currentMonthAvailabilityDaysCount} | {pub.currentMonthAvailabilityHoursCount}
) : 0}
@@ -324,10 +324,22 @@ export default ContactsPage;
export const getServerSideProps = async (context) => {
const allPublishers = await data.getAllPublishersWithStatisticsMonth(new Date());
- //merge first and last name
+ // Merge first and last name and serialize Date objects
allPublishers.forEach(publisher => {
publisher.name = `${publisher.firstName} ${publisher.lastName}`;
+
+ if (publisher.currentMonthAvailability) {
+ publisher.currentMonthAvailability = publisher.currentMonthAvailability.map(availability => {
+ return {
+ ...availability,
+ startTime: availability.startTime instanceof Date ? availability.startTime.toISOString() : availability.startTime,
+ endTime: availability.endTime instanceof Date ? availability.endTime.toISOString() : availability.endTime,
+ dateOfEntry: availability.dateOfEntry instanceof Date ? availability.dateOfEntry.toISOString() : availability.dateOfEntry,
+ };
+ });
+ }
});
+
return {
props: {
allPublishers
diff --git a/pages/cart/surveys/index.tsx b/pages/cart/surveys/index.tsx
new file mode 100644
index 0000000..f8cf1e8
--- /dev/null
+++ b/pages/cart/surveys/index.tsx
@@ -0,0 +1,86 @@
+import React, { useState, useEffect } from 'react';
+import Layout from "../../../components/layout";
+import { GetServerSideProps } from 'next';
+import { Location, UserRole } from "@prisma/client";
+import axiosServer from '../../../src/axiosServer';
+const common = require('../../../src/helpers/common');
+// import * as common from '../../../src/helpers/common';
+import SurveyForm from '../../../components/survey/SurveyForm';
+import _ from 'lodash';
+import ProtectedRoute from 'components/protectedRoute';
+
+const SurveyPage = ({ serverSurveys }) => {
+ const [selectedSurvey, setSelectedSurvey] = useState(null);
+
+ return (
+
+
+
+ Анкети
+
+
+
+ Списък
+
+
+
+
+ Детайли
+
+
+
+
+
+
+
+
+ );
+};
+
+export default SurveyPage;
+
+export const getServerSideProps: GetServerSideProps = async (context) => {
+ const prisma = common.getPrismaClient();
+ let serverSurveys = await prisma.survey.findMany({
+ where: {
+ },
+ include: {
+ messages: true,
+ },
+ });
+ serverSurveys = common.convertDatesToISOStrings(serverSurveys);
+
+ context.res.setHeader("Cache-Control", "s-maxage=1, stale-while-revalidate");
+ return {
+ props: {
+ serverSurveys: serverSurveys
+ },
+ };
+};
+
diff --git a/pages/dash.tsx b/pages/dash.tsx
index 53c74bd..8128311 100644
--- a/pages/dash.tsx
+++ b/pages/dash.tsx
@@ -1,7 +1,8 @@
import { useSession } from "next-auth/react"
import { useRouter } from 'next/router';
-import React, { useState, useEffect } from 'react';
+import React, { useState, useEffect, use } from 'react';
import Layout from "../components/layout"
+import { toast } from 'react-toastify';
import AvCalendar from '../components/calendar/avcalendar';
import { getSession } from "next-auth/react";
@@ -25,9 +26,9 @@ interface IProps {
initialUserId: string;
cartEvents: any;
lastPublishedDate: Date;
+ messages: any;
}
-export default function DashboardPage({ initialItems, initialUserId, cartEvents, lastPublishedDate }: IProps) {
-
+export default function DashboardPage({ initialItems, initialUserId, cartEvents, lastPublishedDate, messages }: IProps) {
const router = useRouter();
const { newLogin } = router.query;
const { data: session } = useSession();
@@ -51,17 +52,145 @@ export default function DashboardPage({ initialItems, initialUserId, cartEvents,
}, [session]);
+
+ // MESSAGES
//const [notificationsVisible, setNotificationsVisible] = useState(false);
- useEffect(() => {
- //if (newLogin === 'true')
- {
- // alert("Мили братя, искаме само да ви напомним да ни изпратите вашите предпочитания за юни до 25-то число като използвате меню 'Възможности'. Ако имате проблем, моля пишете ни на 'specialnosvidetelstvanesofia@gmail.com'");
- const currentPath = router.pathname;
- router.replace(currentPath, undefined, { shallow: true }); // Removes the query without affecting the history
- }
- }, []);// show the message every time we load the page
+ // useEffect(() => {
+ // //if (newLogin === 'true')
+ // {
+ // // alert("Мили братя, искаме само да ви напомним да ни изпратите вашите предпочитания за юни до 25-то число като използвате меню 'Възможности'. Ако имате проблем, моля пишете ни на 'specialnosvidetelstvanesofia@gmail.com'");
+ // const currentPath = router.pathname;
+ // router.replace(currentPath, undefined, { shallow: true }); // Removes the query without affecting the history
+ // }
+ // }, []);// show the message every time we load the page
+
+ // const [processedMessages, setProcessedMessages] = useState(new Set());
+ // useEffect(() => {
+ // if (messages && messages.length > 0) {
+ // const unprocessedMessages = messages.filter(message => !processedMessages.has(message.id));
+ // if (unprocessedMessages.length > 0) {
+ // showMessageToasts(unprocessedMessages);
+ // setProcessedMessages(new Set([...processedMessages, ...unprocessedMessages.map(msg => msg.id)]));
+ // }
+ // }
+ // }, [messages, processedMessages]);
+
+ useEffect(() => {
+ if (messages && messages.length > 0) {
+ showMessageToasts(messages);
+ }
+ }, [messages]);
+
+ const showMessageToasts = (messages) => {
+ const handleOptionClick = async (messageId, option, toastId) => {
+ try {
+ await axiosInstance.put(`/api/data/messages/${messageId}`, { answer: option });
+ handleClose(toastId);
+ } catch (error) {
+ console.error("Error updating message:", error);
+ toast.error("Error updating message. Please try again.");
+ }
+ };
+
+ const handleClose = (toastId) => {
+ toast.dismiss(toastId);
+ };
+
+ messages.forEach((message, messageIndex) => {
+ const toastId = `message-${message.id}-${messageIndex}`;
+ const content = (
+
+ {message.content.message}
+
+ {message.content.options?.map((option, index) => (
+
+ ))}
+
+
+ );
+
+ toast(content, {
+ toastId,
+ autoClose: false,
+ closeButton: true,
+ onClose: () => handleClose(toastId),
+ });
+ });
+ };
+
+
+ // const showMessageToastNewModal = (messages, handleMessageOptionAnswer) => {
+ // let currentMessageIndex = 0;
+
+ // const showModal = () => {
+ // if (currentMessageIndex >= messages.length) {
+ // return; // All messages have been shown
+ // }
+
+ // const message = messages[currentMessageIndex];
+ // const content = (
+ //
+ //
+ //
+ //
+ //
+ // {message.content.message}
+ //
+ // {message.content.options?.map((option, index) => (
+ //
+ // ))}
+ //
+ //
+ //
+ // );
+
+ // toast(content, {
+ // autoClose: false, // Keep the toast open until manually closed
+ // closeButton: false,
+ // onClose: handleClose,
+ // //className: 'custom-toast', // Optional custom class for additional styling
+ // });
+ // };
+
+ // const handleOptionClick = async (messageId, option) => {
+ // try {
+ // await axiosInstance.put(`/api/data/messages/${messageId}`, { answer: option });
+ // toast.dismiss();
+ // currentMessageIndex++;
+ // showModal();
+ // } catch (error) {
+ // console.error("Error updating message:", error);
+ // toast.error("Error updating message. Please try again.");
+ // }
+ // };
+
+ // const handleClose = () => {
+ // toast.dismiss();
+ // };
+
+ // showModal();
+ // };
+
+ // FOR ADMINS ONLY
const handleUserSelection = async (publisher) => {
if (!publisher || publisher.id === undefined) return;
console.log("selecting publisher", publisher.id);
@@ -107,107 +236,6 @@ export default function DashboardPage({ initialItems, initialUserId, cartEvents,
}
-// async function getAvailabilities(userId) {
-// const prismaClient = common.getPrismaClient();
-// const items = await prismaClient.availability.findMany({
-// where: {
-// publisherId: userId,
-// },
-// select: {
-// id: true,
-// name: true,
-// isActive: true,
-// isFromPreviousAssignment: true,
-// isFromPreviousMonth: true,
-// dayofweek: true,
-// dayOfMonth: true,
-// startTime: true,
-// endTime: true,
-// repeatWeekly: true,
-// endDate: true,
-// publisher: {
-// select: {
-// firstName: true,
-// lastName: true,
-// id: true,
-// },
-// },
-// },
-// });
-// // Convert Date objects to ISO strings
-// const serializableItems = items.map(item => ({
-// ...item,
-// startTime: item.startTime.toISOString(),
-// endTime: item.endTime.toISOString(),
-// name: common.getTimeFormatted(item.startTime) + "-" + common.getTimeFormatted(item.endTime),
-// //endDate can be null
-// endDate: item.endDate ? item.endDate.toISOString() : null,
-// type: 'availability',
-// // Convert other Date fields similarly if they exist
-// }));
-
-// /*model Assignment {
-// id Int @id @default(autoincrement())
-// shift Shift @relation(fields: [shiftId], references: [id], onDelete: Cascade)
-// shiftId Int
-// publisher Publisher @relation(fields: [publisherId], references: [id], onDelete: Cascade)
-// publisherId String
-// isActive Boolean @default(true)
-// isConfirmed Boolean @default(false)
-// isWithTransport Boolean @default(false)
-// Report Report[]
-// }*/
-// //get assignments for this user
-// const assignments = await prismaClient.assignment.findMany({
-// where: {
-// publisherId: userId,
-// },
-// select: {
-// id: true,
-// isBySystem: true,
-// isConfirmed: true,
-// isWithTransport: true,
-// shift: {
-// select: {
-// id: true,
-// name: true,
-// startTime: true,
-// endTime: true,
-// //select all assigned publishers names as name - comma separated
-// assignments: {
-// select: {
-// publisher: {
-// select: {
-// firstName: true,
-// lastName: true,
-// }
-// }
-// }
-// }
-// }
-// }
-// }
-// });
-
-// const serializableAssignments = assignments.map(item => ({
-// ...item,
-// startTime: item.shift.startTime.toISOString(),
-// endTime: item.shift.endTime.toISOString(),
-// // name: item.shift.publishers.map(p => p.firstName + " " + p.lastName).join(", "),
-// //name: item.shift.assignments.map(a => a.publisher.firstName[0] + " " + a.publisher.lastName).join(", "),
-// name: common.getTimeFormatted(new Date(item.shift.startTime)) + "-" + common.getTimeFormatted(new Date(item.shift.endTime)),
-// type: 'assignment',
-// //delete shift object
-// shift: null,
-// publisher: { id: userId }
-// }));
-
-// serializableItems.push(...serializableAssignments);
-
-// return serializableItems;
-
-// }
-
export const getServerSideProps = async (context) => {
const auth = await serverSideAuth({
req: context.req,
@@ -270,7 +298,7 @@ export const getServerSideProps = async (context) => {
}
});
cartEvents = common.convertDatesToISOStrings(cartEvents);
- const lastPublishedDate = (await prisma.shift.findFirst({
+ let lastPublishedDate = (await prisma.shift.findFirst({
where: {
isPublished: true,
},
@@ -280,7 +308,43 @@ export const getServerSideProps = async (context) => {
orderBy: {
endTime: 'desc'
}
- })).endTime;
+ }))?.endTime || new Date();
+
+ let blockedDate = await prisma.settings.findUnique({
+ where: {
+ key: "AvailabilityBlockDate"
+ }
+ });
+
+ if (blockedDate) {
+ blockedDate.value = new Date(blockedDate.value);
+ lastPublishedDate = lastPublishedDate > blockedDate.value ? lastPublishedDate : blockedDate.value;
+ }
+
+ let messages = await prisma.message.findMany({
+ where: {
+ publisherId: userId,
+ isPublic: false,
+ answer: null,
+ },
+ include: {
+ Survey: true,
+ }
+ });
+
+ messages = messages.filter((message) => {
+ return (!message.Survey.publicFrom || message.Survey.publicFrom >= common.getStartOfDay(new Date()))
+ && (!message.Survey.publicUntil || message.Survey.publicUntil <= common.getEndOfDay(new Date()))
+ });
+ messages = common.convertDatesToISOStrings(messages);
+ messages = messages.map(message => {
+ if (message.content) {
+ message.content = JSON.parse(message.content);
+ message.content.options = message.content.options?.split(",");
+
+ }
+ return message;
+ });
return {
props: {
@@ -288,7 +352,7 @@ export const getServerSideProps = async (context) => {
userId: sessionServer?.user.id,
cartEvents: cartEvents,
lastPublishedDate: lastPublishedDate.toISOString(),
- // messages: (await import(`../content/i18n/${context.locale}.json`)).default
+ messages: messages
},
};
}
diff --git a/prisma/migrations/20221130072538_updates/migration.sql b/prisma/migrations/20221130072538_updates/migration.sql
deleted file mode 100644
index 978530e..0000000
--- a/prisma/migrations/20221130072538_updates/migration.sql
+++ /dev/null
@@ -1,80 +0,0 @@
--- CreateTable
-CREATE TABLE `Publisher` (
- `id` INTEGER NOT NULL AUTO_INCREMENT,
- `firstName` VARCHAR(191) NOT NULL,
- `lastName` VARCHAR(191) NOT NULL,
- `email` VARCHAR(191) NOT NULL,
- `phone` VARCHAR(191) NULL,
- `isActive` BOOLEAN NOT NULL DEFAULT true,
- `age` INTEGER NULL,
-
- UNIQUE INDEX `Publisher_email_key`(`email`),
- PRIMARY KEY (`id`)
-) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
--- CreateTable
-CREATE TABLE `Availability` (
- `id` INTEGER NOT NULL AUTO_INCREMENT,
- `publisherId` INTEGER NOT NULL,
- `name` VARCHAR(191) NOT NULL,
- `dayofweek` ENUM('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday') NOT NULL,
- `startTime` DATETIME(3) NOT NULL,
- `endTime` DATETIME(3) NOT NULL,
-
- PRIMARY KEY (`id`)
-) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
--- CreateTable
-CREATE TABLE `CartEvent` (
- `id` INTEGER NOT NULL AUTO_INCREMENT,
- `startTime` DATETIME(3) NOT NULL,
- `endTime` DATETIME(3) NOT NULL,
- `dayofweek` ENUM('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday') NOT NULL,
-
- PRIMARY KEY (`id`)
-) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
--- CreateTable
-CREATE TABLE `Shift` (
- `id` INTEGER NOT NULL AUTO_INCREMENT,
- `cartEventId` INTEGER NOT NULL,
- `name` VARCHAR(191) NOT NULL,
- `startTime` DATETIME(3) NOT NULL,
- `endTime` DATETIME(3) NOT NULL,
- `isActive` BOOLEAN NOT NULL DEFAULT true,
- `requiresTransport` BOOLEAN NOT NULL DEFAULT false,
-
- PRIMARY KEY (`id`)
-) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
--- CreateTable
-CREATE TABLE `Location` (
- `id` INTEGER NOT NULL AUTO_INCREMENT,
- `name` VARCHAR(191) NOT NULL,
- `address` VARCHAR(191) NOT NULL,
- `isActive` BOOLEAN NOT NULL DEFAULT true,
- `dayofweek` ENUM('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday') NOT NULL,
-
- PRIMARY KEY (`id`)
-) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
--- CreateTable
-CREATE TABLE `_PublisherToShift` (
- `A` INTEGER NOT NULL,
- `B` INTEGER NOT NULL,
-
- UNIQUE INDEX `_PublisherToShift_AB_unique`(`A`, `B`),
- INDEX `_PublisherToShift_B_index`(`B`)
-) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
--- AddForeignKey
-ALTER TABLE `Availability` ADD CONSTRAINT `Availability_publisherId_fkey` FOREIGN KEY (`publisherId`) REFERENCES `Publisher`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-
--- AddForeignKey
-ALTER TABLE `Shift` ADD CONSTRAINT `Shift_cartEventId_fkey` FOREIGN KEY (`cartEventId`) REFERENCES `CartEvent`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-
--- AddForeignKey
-ALTER TABLE `_PublisherToShift` ADD CONSTRAINT `_PublisherToShift_A_fkey` FOREIGN KEY (`A`) REFERENCES `Publisher`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-
--- AddForeignKey
-ALTER TABLE `_PublisherToShift` ADD CONSTRAINT `_PublisherToShift_B_fkey` FOREIGN KEY (`B`) REFERENCES `Shift`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/prisma/migrations/20221201223336_/migration.sql b/prisma/migrations/20221201223336_/migration.sql
deleted file mode 100644
index 446e110..0000000
--- a/prisma/migrations/20221201223336_/migration.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- Warnings:
-
- - Added the required column `locationId` to the `CartEvent` table without a default value. This is not possible if the table is not empty.
- - Added the required column `shiftDuration` to the `CartEvent` table without a default value. This is not possible if the table is not empty.
-
-*/
--- AlterTable
-ALTER TABLE `Availability` ADD COLUMN `isActive` BOOLEAN NOT NULL DEFAULT true;
-
--- AlterTable
-ALTER TABLE `CartEvent` ADD COLUMN `isActive` BOOLEAN NOT NULL DEFAULT true,
- ADD COLUMN `locationId` INTEGER NOT NULL,
- ADD COLUMN `shiftDuration` INTEGER NOT NULL;
-
--- AddForeignKey
-ALTER TABLE `CartEvent` ADD CONSTRAINT `CartEvent_locationId_fkey` FOREIGN KEY (`locationId`) REFERENCES `Location`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
diff --git a/prisma/migrations/20221203232123_shifts/migration.sql b/prisma/migrations/20221203232123_shifts/migration.sql
deleted file mode 100644
index c138b9f..0000000
--- a/prisma/migrations/20221203232123_shifts/migration.sql
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `dayofweek` on the `Location` table. All the data in the column will be lost.
- - Added the required column `date` to the `Shift` table without a default value. This is not possible if the table is not empty.
-
-*/
--- AlterTable
-ALTER TABLE `Location` DROP COLUMN `dayofweek`;
-
--- AlterTable
-ALTER TABLE `Shift` ADD COLUMN `date` DATETIME(3) NOT NULL;
diff --git a/prisma/migrations/20221204144131_/migration.sql b/prisma/migrations/20221204144131_/migration.sql
deleted file mode 100644
index 197c65a..0000000
--- a/prisma/migrations/20221204144131_/migration.sql
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `date` on the `Shift` table. All the data in the column will be lost.
-
-*/
--- AlterTable
-ALTER TABLE `Shift` DROP COLUMN `date`;
diff --git a/prisma/migrations/20221217220721_added_shift_is_tentative_event_type/migration.sql b/prisma/migrations/20221217220721_added_shift_is_tentative_event_type/migration.sql
deleted file mode 100644
index d24041b..0000000
--- a/prisma/migrations/20221217220721_added_shift_is_tentative_event_type/migration.sql
+++ /dev/null
@@ -1,5 +0,0 @@
--- AlterTable
-ALTER TABLE `CartEvent` ADD COLUMN `eventType` ENUM('PW_Cart', 'KH_Cleaning') NOT NULL DEFAULT 'PW_Cart';
-
--- AlterTable
-ALTER TABLE `Shift` ADD COLUMN `isTentaive` BOOLEAN NOT NULL DEFAULT false;
diff --git a/prisma/migrations/20221217221944_publisher_to_shift_renamed_assignment/migration.sql b/prisma/migrations/20221217221944_publisher_to_shift_renamed_assignment/migration.sql
deleted file mode 100644
index cd87cb8..0000000
--- a/prisma/migrations/20221217221944_publisher_to_shift_renamed_assignment/migration.sql
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the `_PublisherToShift` table. If the table is not empty, all the data it contains will be lost.
-
-*/
--- DropForeignKey
-ALTER TABLE `_PublisherToShift` DROP FOREIGN KEY `_PublisherToShift_A_fkey`;
-
--- DropForeignKey
-ALTER TABLE `_PublisherToShift` DROP FOREIGN KEY `_PublisherToShift_B_fkey`;
-
--- DropTable
-DROP TABLE `_PublisherToShift`;
-
--- CreateTable
-CREATE TABLE `Assignment` (
- `id` INTEGER NOT NULL AUTO_INCREMENT,
- `shiftId` INTEGER NOT NULL,
- `publisherId` INTEGER NOT NULL,
- `isActive` BOOLEAN NOT NULL DEFAULT true,
-
- PRIMARY KEY (`id`)
-) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
--- AddForeignKey
-ALTER TABLE `Assignment` ADD CONSTRAINT `Assignment_shiftId_fkey` FOREIGN KEY (`shiftId`) REFERENCES `Shift`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-
--- AddForeignKey
-ALTER TABLE `Assignment` ADD CONSTRAINT `Assignment_publisherId_fkey` FOREIGN KEY (`publisherId`) REFERENCES `Publisher`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
diff --git a/prisma/migrations/20221218164331_fix_tentative_assignment_property/migration.sql b/prisma/migrations/20221218164331_fix_tentative_assignment_property/migration.sql
deleted file mode 100644
index 5a4eb5b..0000000
--- a/prisma/migrations/20221218164331_fix_tentative_assignment_property/migration.sql
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `isTentaive` on the `Shift` table. All the data in the column will be lost.
-
-*/
--- AlterTable
-ALTER TABLE `Assignment` ADD COLUMN `isTentaive` BOOLEAN NOT NULL DEFAULT false;
-
--- AlterTable
-ALTER TABLE `Shift` DROP COLUMN `isTentaive`;
diff --git a/prisma/migrations/20221218164950_fix_name/migration.sql b/prisma/migrations/20221218164950_fix_name/migration.sql
deleted file mode 100644
index 7afb51c..0000000
--- a/prisma/migrations/20221218164950_fix_name/migration.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `isTentaive` on the `Assignment` table. All the data in the column will be lost.
-
-*/
--- AlterTable
-ALTER TABLE `Assignment` DROP COLUMN `isTentaive`,
- ADD COLUMN `isTentative` BOOLEAN NOT NULL DEFAULT false;
diff --git a/prisma/migrations/20221218183319_test/migration.sql b/prisma/migrations/20221218183319_test/migration.sql
deleted file mode 100644
index effa85f..0000000
--- a/prisma/migrations/20221218183319_test/migration.sql
+++ /dev/null
@@ -1,23 +0,0 @@
--- DropForeignKey
-ALTER TABLE `Assignment` DROP FOREIGN KEY `Assignment_publisherId_fkey`;
-
--- DropForeignKey
-ALTER TABLE `Assignment` DROP FOREIGN KEY `Assignment_shiftId_fkey`;
-
--- DropForeignKey
-ALTER TABLE `Availability` DROP FOREIGN KEY `Availability_publisherId_fkey`;
-
--- DropForeignKey
-ALTER TABLE `Shift` DROP FOREIGN KEY `Shift_cartEventId_fkey`;
-
--- AddForeignKey
-ALTER TABLE `Availability` ADD CONSTRAINT `Availability_publisherId_fkey` FOREIGN KEY (`publisherId`) REFERENCES `Publisher`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-
--- AddForeignKey
-ALTER TABLE `Shift` ADD CONSTRAINT `Shift_cartEventId_fkey` FOREIGN KEY (`cartEventId`) REFERENCES `CartEvent`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-
--- AddForeignKey
-ALTER TABLE `Assignment` ADD CONSTRAINT `Assignment_shiftId_fkey` FOREIGN KEY (`shiftId`) REFERENCES `Shift`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-
--- AddForeignKey
-ALTER TABLE `Assignment` ADD CONSTRAINT `Assignment_publisherId_fkey` FOREIGN KEY (`publisherId`) REFERENCES `Publisher`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/prisma/migrations/20221218224910_users_auth/migration.sql b/prisma/migrations/20221218224910_users_auth/migration.sql
deleted file mode 100644
index d2b570d..0000000
--- a/prisma/migrations/20221218224910_users_auth/migration.sql
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- Warnings:
-
- - The primary key for the `Publisher` table will be changed. If it partially fails, the table could be left without primary key constraint.
-
-*/
--- DropForeignKey
-ALTER TABLE `Assignment` DROP FOREIGN KEY `Assignment_publisherId_fkey`;
-
--- DropForeignKey
-ALTER TABLE `Availability` DROP FOREIGN KEY `Availability_publisherId_fkey`;
-
--- AlterTable
-ALTER TABLE `Assignment` MODIFY `publisherId` VARCHAR(191) NOT NULL;
-
--- AlterTable
-ALTER TABLE `Availability` MODIFY `publisherId` VARCHAR(191) NOT NULL;
-
--- AlterTable
-ALTER TABLE `Publisher` DROP PRIMARY KEY,
- ADD COLUMN `emailVerified` DATETIME(3) NULL,
- MODIFY `id` VARCHAR(191) NOT NULL,
- ADD PRIMARY KEY (`id`);
-
--- CreateTable
-CREATE TABLE `Account` (
- `id` VARCHAR(191) NOT NULL,
- `userId` VARCHAR(191) NOT NULL,
- `type` VARCHAR(191) NOT NULL,
- `provider` VARCHAR(191) NOT NULL,
- `providerAccountId` VARCHAR(191) NOT NULL,
- `refresh_token` VARCHAR(191) NULL,
- `access_token` VARCHAR(191) NULL,
- `expires_at` INTEGER NULL,
- `token_type` VARCHAR(191) NULL,
- `scope` VARCHAR(191) NULL,
- `id_token` VARCHAR(191) NULL,
- `session_state` VARCHAR(191) NULL,
-
- UNIQUE INDEX `Account_provider_providerAccountId_key`(`provider`, `providerAccountId`),
- PRIMARY KEY (`id`)
-) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
--- CreateTable
-CREATE TABLE `Session` (
- `id` VARCHAR(191) NOT NULL,
- `sessionToken` VARCHAR(191) NOT NULL,
- `userId` VARCHAR(191) NOT NULL,
- `expires` DATETIME(3) NOT NULL,
-
- UNIQUE INDEX `Session_sessionToken_key`(`sessionToken`),
- PRIMARY KEY (`id`)
-) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
--- CreateTable
-CREATE TABLE `VerificationToken` (
- `identifier` VARCHAR(191) NOT NULL,
- `token` VARCHAR(191) NOT NULL,
- `expires` DATETIME(3) NOT NULL,
-
- UNIQUE INDEX `VerificationToken_token_key`(`token`),
- UNIQUE INDEX `VerificationToken_identifier_token_key`(`identifier`, `token`)
-) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
--- AddForeignKey
-ALTER TABLE `Availability` ADD CONSTRAINT `Availability_publisherId_fkey` FOREIGN KEY (`publisherId`) REFERENCES `Publisher`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-
--- AddForeignKey
-ALTER TABLE `Assignment` ADD CONSTRAINT `Assignment_publisherId_fkey` FOREIGN KEY (`publisherId`) REFERENCES `Publisher`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-
--- AddForeignKey
-ALTER TABLE `Account` ADD CONSTRAINT `Account_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `Publisher`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-
--- AddForeignKey
-ALTER TABLE `Session` ADD CONSTRAINT `Session_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `Publisher`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/prisma/migrations/20230326221139_added_daily_availability_support/migration.sql b/prisma/migrations/20230326221139_added_daily_availability_support/migration.sql
deleted file mode 100644
index ba33e31..0000000
--- a/prisma/migrations/20230326221139_added_daily_availability_support/migration.sql
+++ /dev/null
@@ -1,8 +0,0 @@
--- AlterTable
-ALTER TABLE `Availability` ADD COLUMN `dayOfMonth` INTEGER NULL;
-
--- AlterTable
-ALTER TABLE `CartEvent` ADD COLUMN `numberOfPublishers` INTEGER NOT NULL DEFAULT 3;
-
--- AlterTable
-ALTER TABLE `Publisher` ADD COLUMN `role` ENUM('ADMIN', 'USER') NOT NULL DEFAULT 'USER';
diff --git a/prisma/migrations/20230331002935_/migration.sql b/prisma/migrations/20230331002935_/migration.sql
deleted file mode 100644
index a85ab7f..0000000
--- a/prisma/migrations/20230331002935_/migration.sql
+++ /dev/null
@@ -1,3 +0,0 @@
--- AlterTable
-ALTER TABLE `Publisher` ADD COLUMN `desiredShiftsPerMonth` INTEGER NOT NULL DEFAULT 4,
- MODIFY `role` ENUM('ADMIN', 'USER', 'EXTERNAL') NOT NULL DEFAULT 'USER';
diff --git a/prisma/migrations/20230427092015_add_publisher_details/migration.sql b/prisma/migrations/20230427092015_add_publisher_details/migration.sql
deleted file mode 100644
index 7727ba8..0000000
--- a/prisma/migrations/20230427092015_add_publisher_details/migration.sql
+++ /dev/null
@@ -1,7 +0,0 @@
--- AlterTable
-ALTER TABLE `Publisher` ADD COLUMN `isMale` BOOLEAN NOT NULL DEFAULT true,
- ADD COLUMN `isNameForeign` BOOLEAN NOT NULL DEFAULT false,
- ADD COLUMN `parentId` VARCHAR(191) NULL;
-
--- AddForeignKey
-ALTER TABLE `Publisher` ADD CONSTRAINT `Publisher_parentId_fkey` FOREIGN KEY (`parentId`) REFERENCES `Publisher`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
diff --git a/prisma/migrations/20230427203518_added_isimported_flag_in_publishers/migration.sql b/prisma/migrations/20230427203518_added_isimported_flag_in_publishers/migration.sql
deleted file mode 100644
index 02829c1..0000000
--- a/prisma/migrations/20230427203518_added_isimported_flag_in_publishers/migration.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- AlterTable
-ALTER TABLE `Publisher` ADD COLUMN `isImported` BOOLEAN NOT NULL DEFAULT false;
diff --git a/prisma/migrations/20230519203524_/migration.sql b/prisma/migrations/20230519203524_/migration.sql
deleted file mode 100644
index 5bbcbb9..0000000
--- a/prisma/migrations/20230519203524_/migration.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- AlterTable
-ALTER TABLE `Shift` ADD COLUMN `notes` VARCHAR(191) NULL;
diff --git a/prisma/migrations/20230528174049_add_availability_weekofmonth_for_weekly_availabilities/migration.sql b/prisma/migrations/20230528174049_add_availability_weekofmonth_for_weekly_availabilities/migration.sql
deleted file mode 100644
index 499f13e..0000000
--- a/prisma/migrations/20230528174049_add_availability_weekofmonth_for_weekly_availabilities/migration.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- AlterTable
-ALTER TABLE `Availability` ADD COLUMN `weekOfMonth` INTEGER NULL;
diff --git a/prisma/migrations/20231101100714_added_transport_and_availability_type/migration.sql b/prisma/migrations/20231101100714_added_transport_and_availability_type/migration.sql
deleted file mode 100644
index 993eb6e..0000000
--- a/prisma/migrations/20231101100714_added_transport_and_availability_type/migration.sql
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `parentId` on the `Publisher` table. All the data in the column will be lost.
-
-*/
--- DropForeignKey
-ALTER TABLE `Publisher` DROP FOREIGN KEY `Publisher_parentId_fkey`;
-
--- AlterTable
-ALTER TABLE `Assignment` ADD COLUMN `isWithTransport` BOOLEAN NOT NULL DEFAULT false;
-
--- AlterTable
-ALTER TABLE `Publisher` DROP COLUMN `parentId`,
- ADD COLUMN `familyHeadId` VARCHAR(191) NULL;
-
--- AddForeignKey
-ALTER TABLE `Publisher` ADD CONSTRAINT `Publisher_familyHeadId_fkey` FOREIGN KEY (`familyHeadId`) REFERENCES `Publisher`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
diff --git a/prisma/migrations/20231103095610_added_publisher_type/migration.sql b/prisma/migrations/20231103095610_added_publisher_type/migration.sql
deleted file mode 100644
index 9875500..0000000
--- a/prisma/migrations/20231103095610_added_publisher_type/migration.sql
+++ /dev/null
@@ -1,8 +0,0 @@
--- AlterTable
-ALTER TABLE `Availability` ADD COLUMN `isWithTransport` BOOLEAN NOT NULL DEFAULT false,
- ADD COLUMN `type` ENUM('Weekly', 'Monthly', 'OneTime', 'PreviousAssignment') NOT NULL DEFAULT 'Weekly';
-
--- AlterTable
-ALTER TABLE `Publisher` ADD COLUMN `comments` VARCHAR(191) NULL,
- ADD COLUMN `town` VARCHAR(191) NULL,
- ADD COLUMN `type` ENUM('Publisher', 'Bethelite', 'RegularPioneer', 'SpecialPioneer', 'Missionary', 'CircuitOverseer') NOT NULL DEFAULT 'Publisher';
diff --git a/prisma/migrations/20231130130317_added_more_availability_flags/migration.sql b/prisma/migrations/20231130130317_added_more_availability_flags/migration.sql
deleted file mode 100644
index a1fad6d..0000000
--- a/prisma/migrations/20231130130317_added_more_availability_flags/migration.sql
+++ /dev/null
@@ -1,3 +0,0 @@
--- AlterTable
-ALTER TABLE `Availability` ADD COLUMN `isFromPreviousAssignment` BOOLEAN NOT NULL DEFAULT false,
- ADD COLUMN `isFromPreviousMonth` BOOLEAN NOT NULL DEFAULT false;
diff --git a/prisma/migrations/20231214163235_fix_nextauth_schema/migration.sql b/prisma/migrations/20231214163235_fix_nextauth_schema/migration.sql
deleted file mode 100644
index de2253a..0000000
--- a/prisma/migrations/20231214163235_fix_nextauth_schema/migration.sql
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `emailVerified` on the `Publisher` table. All the data in the column will be lost.
- - A unique constraint covering the columns `[userId]` on the table `Publisher` will be added. If there are existing duplicate values, this will fail.
-
-*/
--- DropForeignKey
-ALTER TABLE `Account` DROP FOREIGN KEY `Account_userId_fkey`;
-
--- DropForeignKey
-ALTER TABLE `Session` DROP FOREIGN KEY `Session_userId_fkey`;
-
--- AlterTable
-ALTER TABLE `Publisher` DROP COLUMN `emailVerified`,
- ADD COLUMN `userId` VARCHAR(191) NULL;
-
--- CreateTable
-CREATE TABLE `User` (
- `id` VARCHAR(191) NOT NULL,
- `name` VARCHAR(191) NULL,
- `email` VARCHAR(191) NULL,
- `emailVerified` DATETIME(3) NULL,
- `image` VARCHAR(191) NULL,
- `publisherId` VARCHAR(191) NULL,
-
- UNIQUE INDEX `User_email_key`(`email`),
- UNIQUE INDEX `User_publisherId_key`(`publisherId`),
- PRIMARY KEY (`id`)
-) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
--- CreateIndex
-CREATE UNIQUE INDEX `Publisher_userId_key` ON `Publisher`(`userId`);
-
--- AddForeignKey
-ALTER TABLE `Publisher` ADD CONSTRAINT `Publisher_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
-
--- AddForeignKey
-ALTER TABLE `Account` ADD CONSTRAINT `Account_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-
--- AddForeignKey
-ALTER TABLE `Session` ADD CONSTRAINT `Session_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/prisma/migrations/20240109131156_email_is_unique_again/migration.sql b/prisma/migrations/20240109131156_email_is_unique_again/migration.sql
deleted file mode 100644
index 26247f8..0000000
--- a/prisma/migrations/20240109131156_email_is_unique_again/migration.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- This is an empty migration.
--- CREATE INDEX `Publisher_email_key` ON `Publisher` (email);
diff --git a/prisma/migrations/20240110211115_create_report_table/migration.sql b/prisma/migrations/20240110211115_create_report_table/migration.sql
deleted file mode 100644
index 913114e..0000000
--- a/prisma/migrations/20240110211115_create_report_table/migration.sql
+++ /dev/null
@@ -1,23 +0,0 @@
--- AlterTable
-ALTER TABLE `Publisher` MODIFY `role` ENUM('ADMIN', 'POWERUSER', 'USER', 'EXTERNAL') NOT NULL DEFAULT 'USER';
-
--- CreateTable
-CREATE TABLE `Report` (
- `id` INTEGER NOT NULL AUTO_INCREMENT,
- `date` DATETIME(3) NOT NULL,
- `publisherId` VARCHAR(191) NOT NULL,
- `assignmentId` INTEGER NOT NULL,
- `placementCount` INTEGER NOT NULL,
- `videoCount` INTEGER NOT NULL,
- `returnVisitInfoCount` INTEGER NOT NULL,
- `conversationCount` INTEGER NOT NULL,
- `experienceInfo` VARCHAR(191) NOT NULL,
-
- PRIMARY KEY (`id`)
-) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
--- AddForeignKey
-ALTER TABLE `Report` ADD CONSTRAINT `Report_publisherId_fkey` FOREIGN KEY (`publisherId`) REFERENCES `Publisher`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-
--- AddForeignKey
-ALTER TABLE `Report` ADD CONSTRAINT `Report_assignmentId_fkey` FOREIGN KEY (`assignmentId`) REFERENCES `Assignment`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/prisma/migrations/20240110220327_link_experiece_to_location/migration.sql b/prisma/migrations/20240110220327_link_experiece_to_location/migration.sql
deleted file mode 100644
index 696c379..0000000
--- a/prisma/migrations/20240110220327_link_experiece_to_location/migration.sql
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- Warnings:
-
- - Added the required column `locationId` to the `Report` table without a default value. This is not possible if the table is not empty.
-
-*/
--- DropForeignKey
-ALTER TABLE `Report` DROP FOREIGN KEY `Report_assignmentId_fkey`;
-
--- AlterTable
-ALTER TABLE `Report` ADD COLUMN `locationId` INTEGER NOT NULL,
- MODIFY `assignmentId` INTEGER NULL,
- MODIFY `placementCount` INTEGER NULL,
- MODIFY `videoCount` INTEGER NULL,
- MODIFY `returnVisitInfoCount` INTEGER NULL,
- MODIFY `conversationCount` INTEGER NULL,
- MODIFY `experienceInfo` VARCHAR(191) NULL;
-
--- AddForeignKey
-ALTER TABLE `Report` ADD CONSTRAINT `Report_locationId_fkey` FOREIGN KEY (`locationId`) REFERENCES `Location`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-
--- AddForeignKey
-ALTER TABLE `Report` ADD CONSTRAINT `Report_assignmentId_fkey` FOREIGN KEY (`assignmentId`) REFERENCES `Assignment`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
diff --git a/prisma/migrations/20240110225201_modify_experience_info_type/migration.sql b/prisma/migrations/20240110225201_modify_experience_info_type/migration.sql
deleted file mode 100644
index 5f60026..0000000
--- a/prisma/migrations/20240110225201_modify_experience_info_type/migration.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- AlterTable
-ALTER TABLE `Report` MODIFY `experienceInfo` LONGTEXT NULL;
diff --git a/prisma/migrations/20240110233944_report_s_location_is_optional/migration.sql b/prisma/migrations/20240110233944_report_s_location_is_optional/migration.sql
deleted file mode 100644
index b998bae..0000000
--- a/prisma/migrations/20240110233944_report_s_location_is_optional/migration.sql
+++ /dev/null
@@ -1,8 +0,0 @@
--- DropForeignKey
-ALTER TABLE `Report` DROP FOREIGN KEY `Report_locationId_fkey`;
-
--- AlterTable
-ALTER TABLE `Report` MODIFY `locationId` INTEGER NULL;
-
--- AddForeignKey
-ALTER TABLE `Report` ADD CONSTRAINT `Report_locationId_fkey` FOREIGN KEY (`locationId`) REFERENCES `Location`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
diff --git a/prisma/migrations/20240111221838_update_availability/migration.sql b/prisma/migrations/20240111221838_update_availability/migration.sql
deleted file mode 100644
index 2813d14..0000000
--- a/prisma/migrations/20240111221838_update_availability/migration.sql
+++ /dev/null
@@ -1,3 +0,0 @@
--- AlterTable
-ALTER TABLE `Availability` ADD COLUMN `endDate` DATETIME(3) NULL,
- ADD COLUMN `repeatWeekly` BOOLEAN NULL;
diff --git a/prisma/migrations/20240112104657_adding_assignment_guids/migration.sql b/prisma/migrations/20240112104657_adding_assignment_guids/migration.sql
deleted file mode 100644
index 1fb983b..0000000
--- a/prisma/migrations/20240112104657_adding_assignment_guids/migration.sql
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `isTentative` on the `assignment` table. All the data in the column will be lost.
- - You are about to drop the column `assignmentId` on the `report` table. All the data in the column will be lost.
- - A unique constraint covering the columns `[publicGuid]` on the table `Assignment` will be added. If there are existing duplicate values, this will fail.
- - A unique constraint covering the columns `[reportId]` on the table `Shift` will be added. If there are existing duplicate values, this will fail.
-
-*/
--- DropForeignKey
-ALTER TABLE `Report` DROP FOREIGN KEY `Report_assignmentId_fkey`;
-
--- AlterTable
-ALTER TABLE `Assignment` DROP COLUMN `isTentative`,
- ADD COLUMN `isConfirmed` BOOLEAN NOT NULL DEFAULT false,
- ADD COLUMN `isMailSent` BOOLEAN NOT NULL DEFAULT false,
- ADD COLUMN `publicGuid` VARCHAR(191) NULL;
-
--- AlterTable
-ALTER TABLE `Report` DROP COLUMN `assignmentId`;
-
--- AlterTable
-ALTER TABLE `Shift` ADD COLUMN `reportId` INTEGER NULL;
-
--- CreateIndex
-CREATE UNIQUE INDEX `Assignment_publicGuid_key` ON `Assignment`(`publicGuid`);
-
--- CreateIndex
-CREATE UNIQUE INDEX `Shift_reportId_key` ON `Shift`(`reportId`);
-
--- AddForeignKey
-ALTER TABLE `Shift` ADD CONSTRAINT `Shift_reportId_fkey` FOREIGN KEY (`reportId`) REFERENCES `Report`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
diff --git a/prisma/migrations/20240127235643_add_location_content/migration.sql b/prisma/migrations/20240127235643_add_location_content/migration.sql
deleted file mode 100644
index b266a3d..0000000
--- a/prisma/migrations/20240127235643_add_location_content/migration.sql
+++ /dev/null
@@ -1,9 +0,0 @@
--- AlterTable
-ALTER TABLE `Location` ADD COLUMN `backupLocationId` INTEGER NULL,
- ADD COLUMN `content` TEXT NULL;
-
--- AlterTable
-ALTER TABLE `Publisher` ADD COLUMN `isTrained` BOOLEAN NOT NULL DEFAULT false;
-
--- AddForeignKey
-ALTER TABLE `Location` ADD CONSTRAINT `Location_backupLocationId_fkey` FOREIGN KEY (`backupLocationId`) REFERENCES `Location`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
diff --git a/prisma/migrations/20240131113517_assignment_isactive_renamed_istetative/migration.sql b/prisma/migrations/20240131113517_assignment_isactive_renamed_istetative/migration.sql
deleted file mode 100644
index 55bc254..0000000
--- a/prisma/migrations/20240131113517_assignment_isactive_renamed_istetative/migration.sql
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `isActive` on the `assignment` table. All the data in the column will be lost.
-
-*/
--- AlterTable
-ALTER TABLE `Assignment` DROP COLUMN `isActive`,
- ADD COLUMN `isTentative` BOOLEAN NOT NULL DEFAULT false;
-
--- AlterTable
-ALTER TABLE `Location` MODIFY `content` LONGTEXT NULL;
diff --git a/prisma/migrations/20240201214719_assignment_add_repeat_frequency/migration.sql b/prisma/migrations/20240201214719_assignment_add_repeat_frequency/migration.sql
deleted file mode 100644
index bf28ae4..0000000
--- a/prisma/migrations/20240201214719_assignment_add_repeat_frequency/migration.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- AlterTable
-ALTER TABLE `Availability` ADD COLUMN `repeatFrequency` INTEGER NULL;
diff --git a/prisma/migrations/20240203144059_add_location_pictures/migration.sql b/prisma/migrations/20240203144059_add_location_pictures/migration.sql
deleted file mode 100644
index 54b1fae..0000000
--- a/prisma/migrations/20240203144059_add_location_pictures/migration.sql
+++ /dev/null
@@ -1,4 +0,0 @@
--- AlterTable
-ALTER TABLE `Location` ADD COLUMN `picture1` VARCHAR(191) NULL,
- ADD COLUMN `picture2` VARCHAR(191) NULL,
- ADD COLUMN `picture3` VARCHAR(191) NULL;
diff --git a/prisma/migrations/20240221154126_misc/migration.sql b/prisma/migrations/20240221154126_misc/migration.sql
deleted file mode 100644
index 0ff9a68..0000000
--- a/prisma/migrations/20240221154126_misc/migration.sql
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `isWithTransport` on the `Availability` table. All the data in the column will be lost.
- - The values [SpecialPioneer,Missionary,CircuitOverseer] on the enum `Publisher_type` will be removed. If these variants are still used in the database, this will fail.
-
-*/
--- AlterTable
-ALTER TABLE `Availability` DROP COLUMN `isWithTransport`,
- ADD COLUMN `isWithTransportIn` BOOLEAN NOT NULL DEFAULT false,
- ADD COLUMN `isWithTransportOut` BOOLEAN NOT NULL DEFAULT false,
- MODIFY `type` ENUM('Weekly', 'Monthly', 'OneTime', 'PreviousAssignment', 'ReplacementOnly') NOT NULL DEFAULT 'Weekly';
-
--- AlterTable
-ALTER TABLE `Publisher` MODIFY `type` ENUM('Publisher', 'Bethelite', 'RegularPioneer', 'SpecialPioneer_Missionary') NOT NULL DEFAULT 'Publisher';
diff --git a/prisma/migrations/20240302161855_some_new_fields/migration.sql b/prisma/migrations/20240302161855_some_new_fields/migration.sql
deleted file mode 100644
index 730a0bb..0000000
--- a/prisma/migrations/20240302161855_some_new_fields/migration.sql
+++ /dev/null
@@ -1,5 +0,0 @@
--- AlterTable
-ALTER TABLE `Publisher` ADD COLUMN `alwaysAsFamily` BOOLEAN NULL DEFAULT false;
-
--- AlterTable
-ALTER TABLE `Shift` ADD COLUMN `isPublished` BOOLEAN NOT NULL DEFAULT false;
diff --git a/prisma/migrations/20240305111150_add_availability_date_of_entry/migration.sql b/prisma/migrations/20240305111150_add_availability_date_of_entry/migration.sql
deleted file mode 100644
index d0d0e08..0000000
--- a/prisma/migrations/20240305111150_add_availability_date_of_entry/migration.sql
+++ /dev/null
@@ -1,18 +0,0 @@
--- AlterTable
-ALTER TABLE `Availability` ADD COLUMN `dateOfEntry` DATETIME(3) NULL;
-
--- CreateTable
-CREATE TABLE `Message` (
- `id` INTEGER NOT NULL AUTO_INCREMENT,
- `publisherId` VARCHAR(191) NOT NULL,
- `date` DATETIME(3) NOT NULL,
- `content` VARCHAR(191) NOT NULL,
- `isRead` BOOLEAN NOT NULL DEFAULT false,
- `isPublic` BOOLEAN NOT NULL DEFAULT false,
- `type` ENUM('Email', 'SMS', 'Push', 'InApp') NOT NULL DEFAULT 'Email',
-
- PRIMARY KEY (`id`)
-) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
--- AddForeignKey
-ALTER TABLE `Message` ADD CONSTRAINT `Message_publisherId_fkey` FOREIGN KEY (`publisherId`) REFERENCES `Publisher`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
diff --git a/prisma/migrations/20240325214807_misc_renames/migration.sql b/prisma/migrations/20240325214807_misc_renames/migration.sql
deleted file mode 100644
index 890be7a..0000000
--- a/prisma/migrations/20240325214807_misc_renames/migration.sql
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `isTentative` on the `Assignment` table. All the data in the column will be lost.
-
-*/
-
--- AlterTable
-ALTER TABLE `Assignment`
- ADD COLUMN `isBySystem` BOOLEAN NOT NULL DEFAULT FALSE;
-
--- Depending on your DBMS, you might need to execute one statement at a time.
--- Especially, the UPDATE statement should be run separately.
-UPDATE `Assignment` SET `isBySystem` = isTentative;
-
--- Drop the isTentative column
-ALTER TABLE `Assignment` DROP COLUMN `isTentative`;
-
--- AlterTable
-ALTER TABLE `Report`
- ADD COLUMN `type` ENUM('ServiceReport', 'Experience', 'Feedback_Problem', 'Feedback_Suggestion', 'Feedback') NOT NULL DEFAULT 'ServiceReport';
diff --git a/prisma/migrations/20240328162213_add_availability_self_ref/migration.sql b/prisma/migrations/20240328162213_add_availability_self_ref/migration.sql
deleted file mode 100644
index bd11572..0000000
--- a/prisma/migrations/20240328162213_add_availability_self_ref/migration.sql
+++ /dev/null
@@ -1,5 +0,0 @@
--- AlterTable
-ALTER TABLE `Availability` ADD COLUMN `parentAvailabilityId` INTEGER NULL;
-
--- AddForeignKey
-ALTER TABLE `Availability` ADD CONSTRAINT `Availability_parentAvailabilityId_fkey` FOREIGN KEY (`parentAvailabilityId`) REFERENCES `Availability`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
diff --git a/prisma/migrations/20240401231200_add_publisher_email_sbscription_options/migration.sql b/prisma/migrations/20240401231200_add_publisher_email_sbscription_options/migration.sql
deleted file mode 100644
index e7f91bc..0000000
--- a/prisma/migrations/20240401231200_add_publisher_email_sbscription_options/migration.sql
+++ /dev/null
@@ -1,3 +0,0 @@
--- AlterTable
-ALTER TABLE `Publisher` ADD COLUMN `isSubscribedToCoverMe` BOOLEAN NOT NULL DEFAULT false,
- ADD COLUMN `isSubscribedToReminders` BOOLEAN NOT NULL DEFAULT false;
diff --git a/prisma/migrations/20240418092928_add_event_log_table/migration.sql b/prisma/migrations/20240418092928_add_event_log_table/migration.sql
deleted file mode 100644
index 2f4ef0d..0000000
--- a/prisma/migrations/20240418092928_add_event_log_table/migration.sql
+++ /dev/null
@@ -1,20 +0,0 @@
--- CreateTable
-CREATE TABLE `EventLog` (
- `id` INTEGER NOT NULL AUTO_INCREMENT,
- `date` DATETIME(3) NOT NULL,
- `publisherId` VARCHAR(191) NULL,
- `shiftId` INTEGER NULL,
- `content` VARCHAR(5000) NOT NULL,
- `type` ENUM('AssignmentReplacementRequested', 'AssignmentReplacementAccepted', 'SentEmail') NOT NULL,
-
-
- PRIMARY KEY (`id`)
-) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
--- AddForeignKey
-ALTER TABLE `EventLog`
-ADD CONSTRAINT `EventLog_publisherId_fkey` FOREIGN KEY (`publisherId`) REFERENCES `Publisher` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;
-
--- AddForeignKey
-ALTER TABLE `EventLog`
-ADD CONSTRAINT `EventLog_shiftId_fkey` FOREIGN KEY (`shiftId`) REFERENCES `Shift` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;
\ No newline at end of file
diff --git a/prisma/migrations/20240425155607_add_publisher_last_login/migration.sql b/prisma/migrations/20240425155607_add_publisher_last_login/migration.sql
deleted file mode 100644
index 10d5928..0000000
--- a/prisma/migrations/20240425155607_add_publisher_last_login/migration.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- AlterTable
-ALTER TABLE `Publisher` ADD COLUMN `lastLogin` DATETIME(3) NULL;
\ No newline at end of file
diff --git a/prisma/migrations/20240429133812_/migration.sql b/prisma/migrations/20240429133812_/migration.sql
deleted file mode 100644
index 76f1dda..0000000
--- a/prisma/migrations/20240429133812_/migration.sql
+++ /dev/null
@@ -1,3 +0,0 @@
--- AlterTable
-ALTER TABLE `User`
-ADD COLUMN `passwordHashLocalAccount` VARCHAR(191) NULL;
\ No newline at end of file
diff --git a/prisma/migrations/20240429233926_add_eventlog_types/migration.sql b/prisma/migrations/20240429233926_add_eventlog_types/migration.sql
deleted file mode 100644
index 50a566d..0000000
--- a/prisma/migrations/20240429233926_add_eventlog_types/migration.sql
+++ /dev/null
@@ -1,5 +0,0 @@
--- AlterTable
-ALTER TABLE `EventLog`
-MODIFY `type` ENUM(
- 'AssignmentReplacementRequested', 'AssignmentReplacementAccepted', 'SentEmail', 'PasswordResetRequested', 'PasswordResetEmailConfirmed', 'PasswordResetCompleted'
-) NOT NULL;
\ No newline at end of file
diff --git a/prisma/migrations/20240506162944_add_publiher_push_subsctiption/migration.sql b/prisma/migrations/20240506162944_add_publiher_push_subsctiption/migration.sql
deleted file mode 100644
index 332899f..0000000
--- a/prisma/migrations/20240506162944_add_publiher_push_subsctiption/migration.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- AlterTable
-ALTER TABLE `Publisher` ADD COLUMN `pushSubscription` JSON NULL;
\ No newline at end of file
diff --git a/prisma/migrations/20240510131656_publisher_congregation/migration.sql b/prisma/migrations/20240510131656_publisher_congregation/migration.sql
deleted file mode 100644
index 133bedf..0000000
--- a/prisma/migrations/20240510131656_publisher_congregation/migration.sql
+++ /dev/null
@@ -1,33 +0,0 @@
--- AlterTable
-ALTER TABLE `Assignment`
-ADD COLUMN `originalPublisherId` VARCHAR(191) NULL;
-
--- AlterTable
-ALTER TABLE `Message` ADD COLUMN `publicUntil` DATETIME(3) NULL;
-
--- AlterTable
-ALTER TABLE `Publisher`
-ADD COLUMN `congregationId` INTEGER NULL,
-ADD COLUMN `locale` VARCHAR(191) NULL DEFAULT 'bg';
-
--- AlterTable
-ALTER TABLE `Report` ADD COLUMN `comments` VARCHAR(191) NULL;
-
--- CreateTable
-CREATE TABLE `Congregation` (
- `id` INTEGER NOT NULL AUTO_INCREMENT,
- `name` VARCHAR(191) NOT NULL,
- `address` VARCHAR(191) NOT NULL,
- `isActive` BOOLEAN NOT NULL DEFAULT true,
-
-
- PRIMARY KEY (`id`)
-) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
--- AddForeignKey
-ALTER TABLE `Publisher`
-ADD CONSTRAINT `Publisher_congregationId_fkey` FOREIGN KEY (`congregationId`) REFERENCES `Congregation` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;
-
--- AddForeignKey
-ALTER TABLE `Assignment`
-ADD CONSTRAINT `Assignment_originalPublisherId_fkey` FOREIGN KEY (`originalPublisherId`) REFERENCES `Publisher` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;
\ No newline at end of file
diff --git a/prisma/migrations/20240511112711_aded_enum_options/migration.sql b/prisma/migrations/20240511112711_aded_enum_options/migration.sql
deleted file mode 100644
index 2769eb0..0000000
--- a/prisma/migrations/20240511112711_aded_enum_options/migration.sql
+++ /dev/null
@@ -1,19 +0,0 @@
--- AlterTable
-ALTER TABLE `EventLog`
-MODIFY `type` ENUM(
- 'AssignmentReplacementManual', 'AssignmentReplacementRequested', 'AssignmentReplacementAccepted', 'SentEmail', 'PasswordResetRequested', 'PasswordResetEmailConfirmed', 'PasswordResetCompleted'
-) NOT NULL;
-
-INSERT INTO
- `Congregation`
-VALUES (1, 'Перник', '', 1),
- (2, 'София Люлин', '', 1),
- (3, 'София Юг', '', 1),
- (4, 'София Надежда', '', 1),
- (5, 'София Руски', '', 1),
- (6, 'София Факултета', '', 1),
- (7, 'София Изток', '', 1),
- (8, 'София Младост', '', 1),
- (9, 'София Английски', '', 1),
- (10, 'Ботевград', '', 1),
- (11, 'София Дружба', '', 1);
\ No newline at end of file
diff --git a/prisma/migrations/20240524150310_/migration.sql b/prisma/migrations/20240524150310_/migration.sql
deleted file mode 100644
index 9fa4e1a..0000000
--- a/prisma/migrations/20240524150310_/migration.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- AlterTable
-ALTER TABLE `User` ADD COLUMN `emailVerifyToken` VARCHAR(191) NULL;
\ No newline at end of file
diff --git a/prisma/migrations/20240618075438_squash_database_migrations_v_1_3_0/migration.sql b/prisma/migrations/20240618075438_squash_database_migrations_v_1_3_0/migration.sql
new file mode 100644
index 0000000..41e3aa3
--- /dev/null
+++ b/prisma/migrations/20240618075438_squash_database_migrations_v_1_3_0/migration.sql
@@ -0,0 +1,313 @@
+-- CreateTable
+CREATE TABLE `Publisher` (
+ `id` VARCHAR(191) NOT NULL,
+ `firstName` VARCHAR(191) NOT NULL,
+ `lastName` VARCHAR(191) NOT NULL,
+ `email` VARCHAR(191) NOT NULL,
+ `phone` VARCHAR(191) NULL,
+ `isActive` BOOLEAN NOT NULL DEFAULT true,
+ `isImported` BOOLEAN NOT NULL DEFAULT false,
+ `isTrained` BOOLEAN NOT NULL DEFAULT false,
+ `age` INTEGER NULL,
+ `userId` VARCHAR(191) NULL,
+ `role` ENUM('ADMIN', 'POWERUSER', 'USER', 'EXTERNAL') NOT NULL DEFAULT 'USER',
+ `desiredShiftsPerMonth` INTEGER NOT NULL DEFAULT 4,
+ `isMale` BOOLEAN NOT NULL DEFAULT true,
+ `isNameForeign` BOOLEAN NOT NULL DEFAULT false,
+ `isSubscribedToCoverMe` BOOLEAN NOT NULL DEFAULT false,
+ `isSubscribedToReminders` BOOLEAN NOT NULL DEFAULT false,
+ `familyHeadId` VARCHAR(191) NULL,
+ `alwaysAsFamily` BOOLEAN NULL DEFAULT false,
+ `type` ENUM('Publisher', 'Bethelite', 'RegularPioneer', 'SpecialPioneer_Missionary') NOT NULL DEFAULT 'Publisher',
+ `town` VARCHAR(191) NULL,
+ `comments` VARCHAR(191) NULL,
+ `lastLogin` DATETIME(3) NULL,
+ `pushSubscription` JSON NULL,
+ `congregationId` INTEGER NULL,
+ `locale` VARCHAR(191) NULL DEFAULT 'bg',
+
+ UNIQUE INDEX `Publisher_email_key`(`email`),
+ UNIQUE INDEX `Publisher_userId_key`(`userId`),
+ PRIMARY KEY (`id`)
+) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+
+-- CreateTable
+CREATE TABLE `Congregation` (
+ `id` INTEGER NOT NULL AUTO_INCREMENT,
+ `name` VARCHAR(191) NOT NULL,
+ `address` VARCHAR(191) NOT NULL,
+ `isActive` BOOLEAN NOT NULL DEFAULT true,
+
+ PRIMARY KEY (`id`)
+) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+
+-- CreateTable
+CREATE TABLE `Availability` (
+ `id` INTEGER NOT NULL AUTO_INCREMENT,
+ `publisherId` VARCHAR(191) NOT NULL,
+ `name` VARCHAR(191) NOT NULL,
+ `dayofweek` ENUM('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday') NOT NULL,
+ `dayOfMonth` INTEGER NULL,
+ `weekOfMonth` INTEGER NULL,
+ `startTime` DATETIME(3) NOT NULL,
+ `endTime` DATETIME(3) NOT NULL,
+ `isActive` BOOLEAN NOT NULL DEFAULT true,
+ `type` ENUM('Weekly', 'Monthly', 'OneTime', 'PreviousAssignment', 'ReplacementOnly') NOT NULL DEFAULT 'Weekly',
+ `isWithTransportIn` BOOLEAN NOT NULL DEFAULT false,
+ `isWithTransportOut` BOOLEAN NOT NULL DEFAULT false,
+ `isFromPreviousAssignment` BOOLEAN NOT NULL DEFAULT false,
+ `isFromPreviousMonth` BOOLEAN NOT NULL DEFAULT false,
+ `repeatWeekly` BOOLEAN NULL,
+ `repeatFrequency` INTEGER NULL,
+ `endDate` DATETIME(3) NULL,
+ `dateOfEntry` DATETIME(3) NULL,
+ `parentAvailabilityId` INTEGER NULL,
+
+ PRIMARY KEY (`id`)
+) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+
+-- CreateTable
+CREATE TABLE `CartEvent` (
+ `id` INTEGER NOT NULL AUTO_INCREMENT,
+ `startTime` DATETIME(3) NOT NULL,
+ `endTime` DATETIME(3) NOT NULL,
+ `shiftDuration` INTEGER NOT NULL,
+ `dayofweek` ENUM('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday') NOT NULL,
+ `isActive` BOOLEAN NOT NULL DEFAULT true,
+ `locationId` INTEGER NOT NULL,
+ `eventType` ENUM('PW_Cart', 'KH_Cleaning') NOT NULL DEFAULT 'PW_Cart',
+ `numberOfPublishers` INTEGER NOT NULL DEFAULT 3,
+
+ PRIMARY KEY (`id`)
+) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+
+-- CreateTable
+CREATE TABLE `Shift` (
+ `id` INTEGER NOT NULL AUTO_INCREMENT,
+ `cartEventId` INTEGER NOT NULL,
+ `name` VARCHAR(191) NOT NULL,
+ `startTime` DATETIME(3) NOT NULL,
+ `endTime` DATETIME(3) NOT NULL,
+ `isActive` BOOLEAN NOT NULL DEFAULT true,
+ `requiresTransport` BOOLEAN NOT NULL DEFAULT false,
+ `notes` VARCHAR(191) NULL,
+ `reportId` INTEGER NULL,
+ `isPublished` BOOLEAN NOT NULL DEFAULT false,
+
+ UNIQUE INDEX `Shift_reportId_key`(`reportId`),
+ PRIMARY KEY (`id`)
+) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+
+-- CreateTable
+CREATE TABLE `Assignment` (
+ `id` INTEGER NOT NULL AUTO_INCREMENT,
+ `shiftId` INTEGER NOT NULL,
+ `publisherId` VARCHAR(191) NOT NULL,
+ `isBySystem` BOOLEAN NOT NULL DEFAULT false,
+ `isConfirmed` BOOLEAN NOT NULL DEFAULT false,
+ `isWithTransport` BOOLEAN NOT NULL DEFAULT false,
+ `isMailSent` BOOLEAN NOT NULL DEFAULT false,
+ `publicGuid` VARCHAR(191) NULL,
+ `originalPublisherId` VARCHAR(191) NULL,
+
+ UNIQUE INDEX `Assignment_publicGuid_key`(`publicGuid`),
+ PRIMARY KEY (`id`)
+) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+
+-- CreateTable
+CREATE TABLE `Location` (
+ `id` INTEGER NOT NULL AUTO_INCREMENT,
+ `name` VARCHAR(191) NOT NULL,
+ `address` VARCHAR(191) NOT NULL,
+ `isActive` BOOLEAN NOT NULL DEFAULT true,
+ `content` LONGTEXT NULL,
+ `picture1` VARCHAR(191) NULL,
+ `picture2` VARCHAR(191) NULL,
+ `picture3` VARCHAR(191) NULL,
+ `backupLocationId` INTEGER NULL,
+
+ PRIMARY KEY (`id`)
+) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+
+-- CreateTable
+CREATE TABLE `Report` (
+ `id` INTEGER NOT NULL AUTO_INCREMENT,
+ `date` DATETIME(3) NOT NULL,
+ `publisherId` VARCHAR(191) NOT NULL,
+ `locationId` INTEGER NULL,
+ `placementCount` INTEGER NULL,
+ `videoCount` INTEGER NULL,
+ `returnVisitInfoCount` INTEGER NULL,
+ `conversationCount` INTEGER NULL,
+ `experienceInfo` LONGTEXT NULL,
+ `type` ENUM('ServiceReport', 'Experience', 'Feedback_Problem', 'Feedback_Suggestion', 'Feedback') NOT NULL DEFAULT 'ServiceReport',
+ `comments` VARCHAR(191) NULL,
+
+ PRIMARY KEY (`id`)
+) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+
+-- CreateTable
+CREATE TABLE `Survey` (
+ `id` INTEGER NOT NULL AUTO_INCREMENT,
+ `content` VARCHAR(191) NOT NULL,
+ `answers` JSON NULL,
+ `publicFrom` DATETIME(3) NULL,
+ `publicUntil` DATETIME(3) NULL,
+
+ PRIMARY KEY (`id`)
+) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+
+-- CreateTable
+CREATE TABLE `Message` (
+ `id` INTEGER NOT NULL AUTO_INCREMENT,
+ `publisherId` VARCHAR(191) NOT NULL,
+ `date` DATETIME(3) NOT NULL,
+ `content` VARCHAR(191) NOT NULL,
+ `isRead` BOOLEAN NOT NULL DEFAULT false,
+ `isPublic` BOOLEAN NOT NULL DEFAULT false,
+ `type` ENUM('Email', 'SMS', 'Push', 'InApp') NOT NULL DEFAULT 'Email',
+ `publicUntil` DATETIME(3) NULL,
+ `shownDate` DATETIME(3) NULL,
+ `answer` VARCHAR(191) NULL,
+ `answerDate` DATETIME(3) NULL,
+ `surveyId` INTEGER NULL,
+
+ PRIMARY KEY (`id`)
+) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+
+-- CreateTable
+CREATE TABLE `EventLog` (
+ `id` INTEGER NOT NULL AUTO_INCREMENT,
+ `date` DATETIME(3) NOT NULL,
+ `publisherId` VARCHAR(191) NULL,
+ `shiftId` INTEGER NULL,
+ `content` VARCHAR(5000) NOT NULL,
+ `type` ENUM('AssignmentReplacementManual', 'AssignmentReplacementRequested', 'AssignmentReplacementAccepted', 'SentEmail', 'PasswordResetRequested', 'PasswordResetEmailConfirmed', 'PasswordResetCompleted') NOT NULL,
+
+ PRIMARY KEY (`id`)
+) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+
+-- CreateTable
+CREATE TABLE `User` (
+ `id` VARCHAR(191) NOT NULL,
+ `name` VARCHAR(191) NULL,
+ `email` VARCHAR(191) NULL,
+ `emailVerifyToken` VARCHAR(191) NULL,
+ `emailVerified` DATETIME(3) NULL,
+ `image` VARCHAR(191) NULL,
+ `passwordHashLocalAccount` VARCHAR(191) NULL,
+ `publisherId` VARCHAR(191) NULL,
+
+ UNIQUE INDEX `User_email_key`(`email`),
+ UNIQUE INDEX `User_publisherId_key`(`publisherId`),
+ PRIMARY KEY (`id`)
+) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+
+-- CreateTable
+CREATE TABLE `Account` (
+ `id` VARCHAR(191) NOT NULL,
+ `userId` VARCHAR(191) NOT NULL,
+ `type` VARCHAR(191) NOT NULL,
+ `provider` VARCHAR(191) NOT NULL,
+ `providerAccountId` VARCHAR(191) NOT NULL,
+ `refresh_token` VARCHAR(191) NULL,
+ `access_token` VARCHAR(191) NULL,
+ `expires_at` INTEGER NULL,
+ `token_type` VARCHAR(191) NULL,
+ `scope` VARCHAR(191) NULL,
+ `id_token` VARCHAR(191) NULL,
+ `session_state` VARCHAR(191) NULL,
+
+ UNIQUE INDEX `Account_provider_providerAccountId_key`(`provider`, `providerAccountId`),
+ PRIMARY KEY (`id`)
+) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+
+-- CreateTable
+CREATE TABLE `Session` (
+ `id` VARCHAR(191) NOT NULL,
+ `sessionToken` VARCHAR(191) NOT NULL,
+ `userId` VARCHAR(191) NOT NULL,
+ `expires` DATETIME(3) NOT NULL,
+
+ UNIQUE INDEX `Session_sessionToken_key`(`sessionToken`),
+ PRIMARY KEY (`id`)
+) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+
+-- CreateTable
+CREATE TABLE `VerificationToken` (
+ `identifier` VARCHAR(191) NOT NULL,
+ `token` VARCHAR(191) NOT NULL,
+ `expires` DATETIME(3) NOT NULL,
+
+ UNIQUE INDEX `VerificationToken_token_key`(`token`),
+ UNIQUE INDEX `VerificationToken_identifier_token_key`(`identifier`, `token`)
+) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+
+-- CreateTable
+CREATE TABLE `Settings` (
+ `key` VARCHAR(191) NOT NULL,
+ `value` VARCHAR(191) NOT NULL,
+ `description` VARCHAR(191) NULL,
+
+ PRIMARY KEY (`key`)
+) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+
+-- AddForeignKey
+ALTER TABLE `Publisher` ADD CONSTRAINT `Publisher_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `Publisher` ADD CONSTRAINT `Publisher_familyHeadId_fkey` FOREIGN KEY (`familyHeadId`) REFERENCES `Publisher`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `Publisher` ADD CONSTRAINT `Publisher_congregationId_fkey` FOREIGN KEY (`congregationId`) REFERENCES `Congregation`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `Availability` ADD CONSTRAINT `Availability_publisherId_fkey` FOREIGN KEY (`publisherId`) REFERENCES `Publisher`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `Availability` ADD CONSTRAINT `Availability_parentAvailabilityId_fkey` FOREIGN KEY (`parentAvailabilityId`) REFERENCES `Availability`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `CartEvent` ADD CONSTRAINT `CartEvent_locationId_fkey` FOREIGN KEY (`locationId`) REFERENCES `Location`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `Shift` ADD CONSTRAINT `Shift_cartEventId_fkey` FOREIGN KEY (`cartEventId`) REFERENCES `CartEvent`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `Shift` ADD CONSTRAINT `Shift_reportId_fkey` FOREIGN KEY (`reportId`) REFERENCES `Report`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `Assignment` ADD CONSTRAINT `Assignment_shiftId_fkey` FOREIGN KEY (`shiftId`) REFERENCES `Shift`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `Assignment` ADD CONSTRAINT `Assignment_publisherId_fkey` FOREIGN KEY (`publisherId`) REFERENCES `Publisher`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `Assignment` ADD CONSTRAINT `Assignment_originalPublisherId_fkey` FOREIGN KEY (`originalPublisherId`) REFERENCES `Publisher`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `Location` ADD CONSTRAINT `Location_backupLocationId_fkey` FOREIGN KEY (`backupLocationId`) REFERENCES `Location`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `Report` ADD CONSTRAINT `Report_publisherId_fkey` FOREIGN KEY (`publisherId`) REFERENCES `Publisher`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `Report` ADD CONSTRAINT `Report_locationId_fkey` FOREIGN KEY (`locationId`) REFERENCES `Location`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `Message` ADD CONSTRAINT `Message_publisherId_fkey` FOREIGN KEY (`publisherId`) REFERENCES `Publisher`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `Message` ADD CONSTRAINT `Message_surveyId_fkey` FOREIGN KEY (`surveyId`) REFERENCES `Survey`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `EventLog` ADD CONSTRAINT `EventLog_publisherId_fkey` FOREIGN KEY (`publisherId`) REFERENCES `Publisher`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `EventLog` ADD CONSTRAINT `EventLog_shiftId_fkey` FOREIGN KEY (`shiftId`) REFERENCES `Shift`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `Account` ADD CONSTRAINT `Account_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE `Session` ADD CONSTRAINT `Session_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index c5cc4d8..35996b6 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -264,6 +264,15 @@ enum MessageType {
InApp
}
+model Survey {
+ id Int @id @default(autoincrement())
+ content String
+ answers Json?
+ messages Message[]
+ publicFrom DateTime?
+ publicUntil DateTime?
+}
+
model Message {
id Int @id @default(autoincrement())
publisher Publisher @relation(fields: [publisherId], references: [id])
@@ -274,6 +283,12 @@ model Message {
isPublic Boolean @default(false)
type MessageType @default(Email)
publicUntil DateTime?
+ shownDate DateTime?
+ answer String?
+ answerDate DateTime?
+
+ Survey Survey? @relation(fields: [surveyId], references: [id], onDelete: Cascade)
+ surveyId Int?
}
enum EventLogType {
@@ -348,3 +363,9 @@ model VerificationToken {
@@unique([identifier, token])
}
+
+model Settings {
+ key String @id
+ value String
+ description String?
+}
diff --git a/src/helpers/data.js b/src/helpers/data.js
index 4713e0e..3ae8dd0 100644
--- a/src/helpers/data.js
+++ b/src/helpers/data.js
@@ -390,43 +390,7 @@ async function filterPublishersNew(selectFields, filterDate, isExactTime = false
///console.log(`publishers: ${publishers.length}, WhereClause: ${JSON.stringify(whereClause)}`);
- // include repeating weekly availabilities. generate occurrences for the month
- // convert matching weekly availabilities to availabilities for the day to make further processing easier on the client.
- publishers.forEach(pub => {
- pub.availabilities = pub.availabilities.map(avail => {
- if (avail.dayOfMonth == null) {
- if (filterAvailabilitiesByDate && !isForTheMonth) {
- // filter out repeating availabilities when on other day of week
- if (filterTimeFrom) {
- if (avail.dayofweek != dayOfWeekEnum) {
- return null;
- }
- }
- }
- let newStart = new Date(filterDate);
- newStart.setHours(avail.startTime.getHours(), avail.startTime.getMinutes(), 0, 0);
- let newEnd = new Date(filterDate);
- newEnd.setHours(avail.endTime.getHours(), avail.endTime.getMinutes(), 0, 0);
- return {
- ...avail,
- startTime: newStart,
- endTime: newEnd
- }
- }
- else {
- if (filterAvailabilitiesByDate && !isForTheMonth) {
- if (avail.startTime >= filterTimeFrom && avail.startTime <= filterTimeTo) {
- return avail;
- }
- return null;
- }
- return avail;
- }
- })
- .filter(avail => avail !== null);
- });
-
-
+ // ---------------------------------------------- statistics ----------------------------------------------
let currentWeekStart, currentWeekEnd;
if (isWithStats) {
@@ -494,8 +458,45 @@ async function filterPublishersNew(selectFields, filterDate, isExactTime = false
return avail.startTime >= filterDate && avail.startTime <= filterTimeTo;
});
}
-
});
+
+ // ----------------------------------------------
+ // include repeating weekly availabilities. generate occurrences for the month
+ // convert matching weekly availabilities to availabilities for the day to make further processing easier on the client.
+ publishers.forEach(pub => {
+ pub.availabilities = pub.availabilities.map(avail => {
+ if (avail.dayOfMonth == null) {
+ if (filterAvailabilitiesByDate && !isForTheMonth) {
+ // filter out repeating availabilities when on other day of week
+ if (filterTimeFrom) {
+ if (avail.dayofweek != dayOfWeekEnum) {
+ return null;
+ }
+ }
+ }
+ let newStart = new Date(filterDate);
+ newStart.setHours(avail.startTime.getHours(), avail.startTime.getMinutes(), 0, 0);
+ let newEnd = new Date(filterDate);
+ newEnd.setHours(avail.endTime.getHours(), avail.endTime.getMinutes(), 0, 0);
+ return {
+ ...avail,
+ startTime: newStart,
+ endTime: newEnd
+ }
+ }
+ else {
+ if (filterAvailabilitiesByDate && !isForTheMonth) {
+ if (avail.startTime >= filterTimeFrom && avail.startTime <= filterTimeTo) {
+ return avail;
+ }
+ return null;
+ }
+ return avail;
+ }
+ })
+ .filter(avail => avail !== null);
+ });
+
// ToDo: test case/unit test
// ToDo: check and validate the filtering and calculations
if (isExactTime) {
@@ -835,246 +836,302 @@ async function getCoverMePublisherEmails(shiftId) {
return { shift, availablePublishers: availablePublishers, subscribedPublishers };
}
-// ### COPIED TO shift api (++) ###
+// ### COPIED TO shift api (/shiftgenerate.ts) (++) ###
-/** JSDoc
- * Generates a schedule.
- *
-0. generate shifts and assign publishers from the previous month if still available
-1. Make sure we always put people only when they are available.
-2. First provision one male or two females that are available for transport in the first and last shifts.
-3, Then gradually fill all other shifts with day by day troughout the whole month (monthInfo.firstMonday to .lastSunday) with first one, then two, then 3 and wherever possible more (up to CartEvent.numberOfPublishers number)
-4. Some publishers are available only at specific time (somoetimes only once) and other are more available. if people are available only for this time, prioritize them so they are not left behind.
-5. prioritize based on publisher's desiredShiftsPerMonth and previous months assignments.
-6. Idealy noone should be more than once a week. disqualify publishers already on a shift this week. only assign them if there are no other options and we have less than 3 publishers on a specific shift.
- *
- * @param {Axios} axios Axios instance for making requests.
- * @param {string} date The date for the schedule.
- * @param {boolean} [copyFromPreviousMonth=false] Whether to copy from the previous month.
- * @param {boolean} [autoFill=false] Whether to autofill data.
- * @param {boolean} forDay Specific day flag.
- */
-async function GenerateSchedule(axios, date, copyFromPreviousMonth = false, autoFill = false, forDay) {
- let missingPublishers = [];
- let publishersWithChangedPref = [];
+// /** JSDoc
+// * Generates a schedule.
+// *
+// 0. generate shifts and assign publishers from the previous month if still available
+// 1. Make sure we always put people only when they are available.
+// 2. First provision one male or two females that are available for transport in the first and last shifts.
+// 3, Then gradually fill all other shifts with day by day troughout the whole month (monthInfo.firstMonday to .lastSunday) with first one, then two, then 3 and wherever possible more (up to CartEvent.numberOfPublishers number)
+// 4. Some publishers are available only at specific time (somoetimes only once) and other are more available. if people are available only for this time, prioritize them so they are not left behind.
+// 5. prioritize based on publisher's desiredShiftsPerMonth and previous months assignments.
+// 6. Idealy noone should be more than once a week. disqualify publishers already on a shift this week. only assign them if there are no other options and we have less than 3 publishers on a specific shift.
+// *
+// * @param {Axios} axios Axios instance for making requests.
+// * @param {string} date The date for the schedule.
+// * @param {boolean} [copyFromPreviousMonth=false] Whether to copy from the previous month.
+// * @param {boolean} [autoFill=false] Whether to autofill data.
+// * @param {boolean} forDay Specific day flag.
+// */
+// async function GenerateSchedule(axios, date, copyFromPreviousMonth = false, autoFill = false, forDay) {
+// let missingPublishers = [];
+// let publishersWithChangedPref = [];
- const prisma = common.getPrismaClient();
- try {
- const monthInfo = common.getMonthDatesInfo(new Date(date));
- const lastMonthInfo = common.getMonthDatesInfo(new Date(monthInfo.date.getFullYear(), monthInfo.date.getMonth() - 1, 1));
+// const prisma = common.getPrismaClient();
+// try {
+// const monthInfo = common.getMonthDatesInfo(new Date(date));
+// const lastMonthInfo = common.getMonthDatesInfo(new Date(monthInfo.date.getFullYear(), monthInfo.date.getMonth() - 1, 1));
- if (forDay) {
- await DeleteShiftsForDay(monthInfo.date);
- } else {
- await DeleteShiftsForMonth(monthInfo);
- }
+// if (forDay) {
+// await DeleteShiftsForDay(monthInfo.date);
+// } else {
+// await DeleteShiftsForMonth(monthInfo);
+// }
- const events = await prisma.cartEvent.findMany({
- where: {
- isActive: true
- }
- });
- let shiftsLastMonth = await getShiftsFromLastMonth(lastMonthInfo);
- let publishers = await getAllPublishersWithStatisticsMonth('id,firstName,lastName,email,isActive,desiredShiftsPerMonth,lastLogin,type', date, false, true, false, true, true);
+// const events = await prisma.cartEvent.findMany({
+// where: {
+// isActive: true
+// }
+// });
+// let shiftsLastMonth = await getShiftsFromLastMonth(lastMonthInfo);
+// let publishers = await getAllPublishersWithStatisticsMonth('id,firstName,lastName,email,isActive,desiredShiftsPerMonth,lastLogin,type', date, false, true, false, true, true);
- let shiftAssignments = [];
- let day = new Date(monthInfo.firstMonday);
- let endDate = monthInfo.lastSunday;
- let dayNr = 1;
- let weekNr = 1;
+// let shiftAssignments = [];
+// let day = new Date(monthInfo.firstMonday);
+// let endDate = monthInfo.lastSunday;
+// let dayNr = 1;
+// let weekNr = 1;
- if (forDay) {
- day = monthInfo.date;
- endDate.setDate(monthInfo.date.getDate() + 1);
- dayNr = monthInfo.date.getDate();
- weekNr = common.getWeekNumber(monthInfo.date);
- }
+// if (forDay) {
+// day = monthInfo.date;
+// endDate.setDate(monthInfo.date.getDate() + 1);
+// dayNr = monthInfo.date.getDate();
+// weekNr = common.getWeekNumber(monthInfo.date);
+// }
- let publishersThisWeek = [];
+// let publishersThisWeek = [];
- // 0. generate shifts and assign publishers from the previous month if still available
- while (day < endDate) {
- let availablePubsForTheDay = await filterPublishersNew('id,firstName,lastName,email,isActive,desiredShiftsPerMonth,lastLogin,type', day, false, false, false, true, true);
- console.log("passing schedule generation for " + day.toLocaleDateString());
- const dayOfM = day.getDate();
- let dayOfWeekEnum = common.getDayOfWeekNameEnEnumForDate(day);
- let dayName = common.DaysOfWeekArray[day.getDayEuropean()];
- const event = events.find((event) => event.dayofweek == dayName && (event.dayOfMonth == null || event.dayOfMonth == dayOfM));
+// // 0. generate shifts and assign publishers from the previous month if still available
+// while (day < endDate) {
+// let availablePubsForTheDay = await filterPublishersNew('id,firstName,lastName,email,isActive,desiredShiftsPerMonth,lastLogin,type', day, false, false, false, true, true);
+// console.log("passing schedule generation for " + day.toLocaleDateString());
+// const dayOfM = day.getDate();
+// let dayOfWeekEnum = common.getDayOfWeekNameEnEnumForDate(day);
+// let dayName = common.DaysOfWeekArray[day.getDayEuropean()];
+// const event = events.find((event) => event.dayofweek == dayName && (event.dayOfMonth == null || event.dayOfMonth == dayOfM));
- if (!event) {
- day.setDate(day.getDate() + 1);
- continue;
- }
+// if (!event) {
+// day.setDate(day.getDate() + 1);
+// continue;
+// }
- event.startTime = new Date(event.startTime);
- event.endTime = new Date(event.endTime);
+// event.startTime = new Date(event.startTime);
+// event.endTime = new Date(event.endTime);
- let startTime = new Date(day);
- startTime.setHours(event.startTime.getHours());
- startTime.setMinutes(event.startTime.getMinutes());
- let endTime = new Date(day);
- endTime.setHours(event.endTime.getHours());
- endTime.setMinutes(event.endTime.getMinutes());
+// let startTime = new Date(day);
+// startTime.setHours(event.startTime.getHours());
+// startTime.setMinutes(event.startTime.getMinutes());
+// let endTime = new Date(day);
+// endTime.setHours(event.endTime.getHours());
+// endTime.setMinutes(event.endTime.getMinutes());
- let shiftStart = new Date(startTime);
- let shiftEnd = new Date(startTime);
- shiftEnd.setMinutes(shiftStart.getMinutes() + event.shiftDuration);
+// let shiftStart = new Date(startTime);
+// let shiftEnd = new Date(startTime);
+// shiftEnd.setMinutes(shiftStart.getMinutes() + event.shiftDuration);
- let shiftNr = 0;
- while (shiftEnd <= endTime) {
- 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");
- shiftAssignments = [];
- let isTransportRequired = shiftNr == 1 || shiftEnd.getTime() == endTime.getTime();
+// let shiftNr = 0;
+// while (shiftEnd <= endTime) {
+// 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");
+// shiftAssignments = [];
+// let isTransportRequired = shiftNr == 1 || shiftEnd.getTime() == endTime.getTime();
- const shiftLastMonthSameDay = findTheSameShiftFromLastMonth(shiftsLastMonth, day, weekNr, shiftNr);
+// const shiftLastMonthSameDay = findTheSameShiftFromLastMonth(shiftsLastMonth, day, weekNr, shiftNr);
- if (shiftLastMonthSameDay) {
- for (let assignment of shiftLastMonthSameDay.assignments) {
- let publisher = assignment.publisher;
- console.log("found publisher from last month: " + publisher.firstName + " " + publisher.lastName);
- let availability = await FindPublisherAvailability(publisher.id, shiftStart, shiftEnd, dayOfWeekEnum, weekNr);
- console.log("availability " + availability?.id + ": " + common.getDateFormattedShort(availability?.startTime) + " " + common.getTimeFormatted(availability?.startTime) + " - " + common.getTimeFormatted(availability?.endTime));
+// if (shiftLastMonthSameDay) {
+// for (let assignment of shiftLastMonthSameDay.assignments) {
+// let publisher = assignment.publisher;
+// console.log("found publisher from last month: " + publisher.firstName + " " + publisher.lastName);
+// let availability = await FindPublisherAvailability(publisher.id, shiftStart, shiftEnd, dayOfWeekEnum, weekNr);
+// console.log("availability " + availability?.id + ": " + common.getDateFormattedShort(availability?.startTime) + " " + common.getTimeFormatted(availability?.startTime) + " - " + common.getTimeFormatted(availability?.endTime));
- if (availability && copyFromPreviousMonth && !publishersThisWeek.includes(publisher.id)) {
- shiftAssignments.push({
- publisherId: publisher.id,
- isConfirmed: true,
- isWithTransportIn: availability.isWithTransportIn,
- isWithTransportOut: availability.isWithTransportOut
- });
- publishersThisWeek.push(publisher.id);
- }
- }
- }
+// if (availability && copyFromPreviousMonth && !publishersThisWeek.includes(publisher.id)) {
+// shiftAssignments.push({
+// publisherId: publisher.id,
+// isConfirmed: true,
+// isWithTransportIn: availability.isWithTransportIn,
+// isWithTransportOut: availability.isWithTransportOut
+// });
+// publishersThisWeek.push(publisher.id);
+// }
+// }
+// }
- let publishersNeeded = event.numberOfPublishers - shiftAssignments.length;
- //ToDo: check if getAvailablePublishersForShift is working correctly
- let availablePublishers = await getAvailablePublishersForShift(shiftStart, shiftEnd, publishers, publishersThisWeek);
+// let publishersNeeded = event.numberOfPublishers - shiftAssignments.length;
+// //ToDo: check if getAvailablePublishersForShift is working correctly
+// let availablePublishers = await getAvailablePublishersForShift(shiftStart, shiftEnd, publishers, publishersThisWeek);
- console.log("shift " + __shiftName + " needs " + publishersNeeded + " publishers, available: " + availablePublishers.length + " for the day: " + availablePubsForTheDay.length);
+// console.log("shift " + __shiftName + " needs " + publishersNeeded + " publishers, available: " + availablePublishers.length + " for the day: " + availablePubsForTheDay.length);
- // Prioritize publishers with minimal availability
- // SKIP ADDING PUBLISHERS FOR NOW
- // availablePublishers = availablePublishers.sort((a, b) => a.currentMonthAvailabilityHoursCount - b.currentMonthAvailabilityHoursCount);
+// // Prioritize publishers with minimal availability
+// // SKIP ADDING PUBLISHERS FOR NOW
+// // availablePublishers = availablePublishers.sort((a, b) => a.currentMonthAvailabilityHoursCount - b.currentMonthAvailabilityHoursCount);
- // for (let i = 0; i < publishersNeeded; i++) {
- // if (availablePublishers[i]) {
- // shiftAssignments.push({ publisherId: availablePublishers[i].id });
- // publishersThisWeek.push(availablePublishers[i].id);
- // }
- // }
+// // for (let i = 0; i < publishersNeeded; i++) {
+// // if (availablePublishers[i]) {
+// // shiftAssignments.push({ publisherId: availablePublishers[i].id });
+// // publishersThisWeek.push(availablePublishers[i].id);
+// // }
+// // }
- const createdShift = await prisma.shift.create({
- data: {
- startTime: shiftStart,
- endTime: shiftEnd,
- name: event.dayofweek + " " + shiftStart.toLocaleTimeString() + " - " + shiftEnd.toLocaleTimeString(),
- requiresTransport: isTransportRequired,
- cartEvent: {
- connect: {
- id: event.id,
- },
- },
- assignments: {
- create: shiftAssignments.map((a) => {
- return {
- publisher: {
- connect: { id: a.publisherId }
- },
- isConfirmed: a.isConfirmed,
- isBySystem: true,
- };
- }),
- },
- },
- });
+// const createdShift = await prisma.shift.create({
+// data: {
+// startTime: shiftStart,
+// endTime: shiftEnd,
+// name: event.dayofweek + " " + shiftStart.toLocaleTimeString() + " - " + shiftEnd.toLocaleTimeString(),
+// requiresTransport: isTransportRequired,
+// cartEvent: {
+// connect: {
+// id: event.id,
+// },
+// },
+// assignments: {
+// create: shiftAssignments.map((a) => {
+// return {
+// publisher: {
+// connect: { id: a.publisherId }
+// },
+// isConfirmed: a.isConfirmed,
+// isBySystem: true,
+// };
+// }),
+// },
+// },
+// });
- shiftStart = new Date(shiftEnd);
- shiftEnd.setMinutes(shiftStart.getMinutes() + event.shiftDuration);
- }
+// shiftStart = new Date(shiftEnd);
+// shiftEnd.setMinutes(shiftStart.getMinutes() + event.shiftDuration);
+// }
- day.setDate(day.getDate() + 1);
- dayNr++;
- if (common.DaysOfWeekArray[day.getDayEuropean()] === DayOfWeek.Sunday) {
- weekNr++;
- publishersThisWeek = [];
- publishers.forEach(p => p.currentWeekAssignments = 0);
- }
- if (forDay) break;
- }
+// day.setDate(day.getDate() + 1);
+// dayNr++;
+// if (common.DaysOfWeekArray[day.getDayEuropean()] === DayOfWeek.Sunday) {
+// weekNr++;
+// publishersThisWeek = [];
+// publishers.forEach(p => p.currentWeekAssignments = 0);
+// }
+// if (forDay) break;
+// }
- let allShifts = await prisma.shift.findMany({
- where: {
- startTime: {
- gte: monthInfo.firstMonday,
- lt: monthInfo.lastSunday,
- },
- },
- include: {
- assignments: {
- include: {
- publisher: true,
- },
- },
- },
- });
+// let allShifts = await prisma.shift.findMany({
+// where: {
+// startTime: {
+// gte: monthInfo.firstMonday,
+// lt: monthInfo.lastSunday,
+// },
+// },
+// include: {
+// assignments: {
+// include: {
+// publisher: true,
+// },
+// },
+// },
+// });
- console.log(" second pass " + monthInfo.monthName + " " + monthInfo.year);
- // 2. First pass - prioritize shifts with transport where it is needed
- day = monthInfo.firstMonday;
- dayNr = 1;
- weekNr = 1;
- while (day < endDate) {
- let dayOfWeekEnum = common.getDayOfWeekNameEnEnumForDate(day);
- let event = events.find((event) => event.dayofweek == common.DaysOfWeekArray[day.getDayEuropean()]);
- if (event) {
- let availablePubsForTheDay = await filterPublishersNew('id,firstName,lastName,email,isActive,desiredShiftsPerMonth,lastLogin,type', day, false, false, false, true, true);
+// console.log(" second pass " + monthInfo.monthName + " " + monthInfo.year);
+// // 2. First pass - prioritize shifts with transport where it is needed
+// day = monthInfo.firstMonday;
+// dayNr = 1;
+// weekNr = 1;
+// while (day < endDate) {
+// let dayOfWeekEnum = common.getDayOfWeekNameEnEnumForDate(day);
+// let event = events.find((event) => event.dayofweek == common.DaysOfWeekArray[day.getDayEuropean()]);
+// if (event) {
+// let availablePubsForTheDay = await filterPublishersNew('id,firstName,lastName,email,isActive,desiredShiftsPerMonth,lastLogin,type', day, false, false, false, true, true);
- let shifts = allShifts.filter(s => common.getISODateOnly(s.startTime) === common.getISODateOnly(day));
- let transportShifts = shifts.filter(s => s.requiresTransport);
- transportShifts.forEach(shift => {
- let availablePublishers = availablePubsForTheDay.filter(p => !shift.assignments.some(a => a.publisher.id === p.id));
- availablePublishers = availablePublishers.sort((a, b) => a.currentMonthAvailabilityHoursCount - b.currentMonthAvailabilityHoursCount);
- let publishersNeeded = event.numberOfPublishers - shift.assignments.length;
- if (publishersNeeded > 0) {//get the beset match
- if (availablePublishers[0]) {
- shift.assignments.push({ publisherId: availablePublishers[i].id });
- }
+// let shifts = allShifts.filter(s => common.getISODateOnly(s.startTime) === common.getISODateOnly(day));
+// let transportShifts = shifts.filter(s => s.requiresTransport);
+// transportShifts.forEach(shift => {
+// let availablePublishers = availablePubsForTheDay.filter(p => !shift.assignments.some(a => a.publisher.id === p.id));
+// availablePublishers = availablePublishers.sort((a, b) => a.currentMonthAvailabilityHoursCount - b.currentMonthAvailabilityHoursCount);
+// let publishersNeeded = event.numberOfPublishers - shift.assignments.length;
+// if (publishersNeeded > 0) {//get the beset match
+// if (availablePublishers[0]) {
+// shift.assignments.push({ publisherId: availablePublishers[i].id });
+// }
- }
- });
- // 3. Second pass - fill the rest of the shifts
- let shiftsToFill = shifts.filter(s => !s.requiresTransport);
- shiftsToFill.forEach(shift => {
- let availablePublishers = availablePubsForTheDay.filter(p => !shift.assignments.some(a => a.publisher.id === p.id));
- availablePublishers = availablePublishers.sort((a, b) => a.currentMonthAvailabilityHoursCount - b.currentMonthAvailabilityHoursCount);
- let publishersNeeded = event.numberOfPublishers - shift.assignments.length;
- if (publishersNeeded > 0) {//get the beset match
- if (availablePublishers[0]) {
- shift.assignments.push({ publisherId: availablePublishers[i].id });
- }
+// }
+// });
+// // 3. Second pass - fill the rest of the shifts
+// let shiftsToFill = shifts.filter(s => !s.requiresTransport);
+// shiftsToFill.forEach(shift => {
+// let availablePublishers = availablePubsForTheDay.filter(p => !shift.assignments.some(a => a.publisher.id === p.id));
+// availablePublishers = availablePublishers.sort((a, b) => a.currentMonthAvailabilityHoursCount - b.currentMonthAvailabilityHoursCount);
+// let publishersNeeded = event.numberOfPublishers - shift.assignments.length;
+// if (publishersNeeded > 0) {//get the beset match
+// if (availablePublishers[0]) {
+// shift.assignments.push({ publisherId: availablePublishers[i].id });
+// }
- }
- });
- }
+// }
+// });
+// }
- day.setDate(day.getDate() + 1);
- }
+// day.setDate(day.getDate() + 1);
+// }
- if (!forDay) {
- console.log("###############################################");
- console.log(" DONE CREATING SCHEDULE FOR " + monthInfo.monthName + " " + monthInfo.year);
- console.log("###############################################");
- }
+// if (!forDay) {
+// console.log("###############################################");
+// console.log(" DONE CREATING SCHEDULE FOR " + monthInfo.monthName + " " + monthInfo.year);
+// console.log("###############################################");
+// }
- return {};
- } catch (error) {
- console.log(error);
- return { error: error };
- }
-}
+// return {};
+// } catch (error) {
+// console.log(error);
+// return { error: error };
+// }
+// }
+
+
+
+// async function getShiftsFromLastMonth(monthInfo) {
+// const prisma = common.getPrismaClient();
+// // Fetch shifts for the month
+// const rawShifts = await prisma.shift.findMany({
+// where: {
+// startTime: {
+// gte: monthInfo.firstMonday,
+// lte: monthInfo.lastSunday,
+// },
+// },
+// include: {
+// assignments: {
+// include: {
+// publisher: true,
+// },
+// },
+// },
+// });
+
+// // Process shifts to add weekNr and shiftNr
+// return rawShifts.map(shift => ({
+// ...shift,
+// weekNr: common.getWeekNumber(new Date(shift.startTime)),
+// shiftNr: rawShifts.filter(s => common.getISODateOnly(s.startTime) === common.getISODateOnly(shift.startTime)).indexOf(shift) + 1,
+// weekDay: common.DaysOfWeekArray[new Date(shift.startTime).getDayEuropean()],
+// }));
+// }
+// function findTheSameShiftFromLastMonth(shiftsLastMonth, day, weekNr, shiftNr) {
+// let weekDay = common.DaysOfWeekArray[day.getDayEuropean()];
+// return shiftsLastMonth.find(s => {
+// return s.weekNr === weekNr &&
+// s.shiftNr === shiftNr &&
+// s.weekDay === weekDay;
+// });
+// }
+
+// //ToDo use bulk find instead of loop
+// async function getAvailablePublishersForShift(startTime, endTime, allPublishers, publishersThisWeek) {
+// let availablePublishers = [];
+
+// for (let publisher of allPublishers) {
+// let availability = await FindPublisherAvailability(publisher.id, startTime, endTime);
+
+// if (availability && !publishersThisWeek.includes(publisher.id)) {
+// availablePublishers.push(publisher);
+// }
+// }
+
+// return availablePublishers;
+// }
+
+
+// ### COPIED TO shift api (--) ###
async function DeleteShiftsForMonth(monthInfo) {
try {
@@ -1109,57 +1166,6 @@ async function DeleteShiftsForDay(date) {
}
}
-async function getShiftsFromLastMonth(monthInfo) {
- const prisma = common.getPrismaClient();
- // Fetch shifts for the month
- const rawShifts = await prisma.shift.findMany({
- where: {
- startTime: {
- gte: monthInfo.firstMonday,
- lte: monthInfo.lastSunday,
- },
- },
- include: {
- assignments: {
- include: {
- publisher: true,
- },
- },
- },
- });
-
- // Process shifts to add weekNr and shiftNr
- return rawShifts.map(shift => ({
- ...shift,
- weekNr: common.getWeekNumber(new Date(shift.startTime)),
- shiftNr: rawShifts.filter(s => common.getISODateOnly(s.startTime) === common.getISODateOnly(shift.startTime)).indexOf(shift) + 1,
- weekDay: common.DaysOfWeekArray[new Date(shift.startTime).getDayEuropean()],
- }));
-}
-function findTheSameShiftFromLastMonth(shiftsLastMonth, day, weekNr, shiftNr) {
- let weekDay = common.DaysOfWeekArray[day.getDayEuropean()];
- return shiftsLastMonth.find(s => {
- return s.weekNr === weekNr &&
- s.shiftNr === shiftNr &&
- s.weekDay === weekDay;
- });
-}
-
-//ToDo use bulk find instead of loop
-async function getAvailablePublishersForShift(startTime, endTime, allPublishers, publishersThisWeek) {
- let availablePublishers = [];
-
- for (let publisher of allPublishers) {
- let availability = await FindPublisherAvailability(publisher.id, startTime, endTime);
-
- if (availability && !publishersThisWeek.includes(publisher.id)) {
- availablePublishers.push(publisher);
- }
- }
-
- return availablePublishers;
-}
-
async function FindPublisherAvailability(publisherId, startDate, endDate, dayOfWeekEnum, weekNr) {
const prisma = common.getPrismaClient();
const start = new Date(startDate);
@@ -1219,9 +1225,6 @@ async function FindPublisherAvailability(publisherId, startDate, endDate, dayOfW
return exactAvailabilities.length > 0 ? exactAvailabilities[0] : repeatingAvailabilities.length > 0 ? repeatingAvailabilities[0] : null;
}
-// ### COPIED TO shift api (--) ###
-
-
// function matchesAvailability(avail, filterDate) {
// // Setting the start and end time of the filterDate
// filterDate.setHours(0, 0, 0, 0);
@@ -1267,7 +1270,7 @@ module.exports = {
getCoverMePublisherEmails,
getAllPublishersWithStatisticsMonth,
getCalendarEvents,
- GenerateSchedule,
+ // GenerateSchedule,
DeleteShiftsForMonth,
DeleteShiftsForDay,
};
\ No newline at end of file
diff --git a/src/logger.js b/src/logger.js
index 5cf11b9..5d951b0 100644
--- a/src/logger.js
+++ b/src/logger.js
@@ -1,11 +1,22 @@
const winston = require('winston');
require('winston-daily-rotate-file');
+const fs = require('fs');
+const path = require('path');
+// Define the logs directory path
+const logDirectory = path.join(__dirname, '../logs');
+
+// Ensure the logs directory exists
+if (!fs.existsSync(logDirectory)) {
+ fs.mkdirSync(logDirectory);
+}
+
+// Define the log configuration
const logConfiguration = {
- 'transports': [
+ transports: [
new winston.transports.DailyRotateFile({
- filename: './logs/application-%DATE%.log',
- datePattern: 'YYYY-MM-DD', // new file is created every hour: 'YYYY-MM-DD-HH'
+ filename: path.join(logDirectory, 'application-%DATE%.log'),
+ datePattern: 'YYYY-MM-DD', // new file is created every day
zippedArchive: true,
maxSize: '20m',
maxFiles: '90d',
@@ -20,6 +31,7 @@ const logConfiguration = {
)
};
+// Create the logger
const logger = winston.createLogger(logConfiguration);
module.exports = logger;
diff --git a/tsconfig.json b/tsconfig.json
index e903954..ed853ff 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -32,7 +32,8 @@
"components/location/LocationForm.js",
"pages/cart/locations/[id].tsx.old",
"components/publisher/ShiftsList.js",
- "src/helpers/data.js"
+ "src/helpers/data.js",
+ "components/survey/SurveyForm.js"
],
"exclude": [
"node_modules"
|