@@ -715,8 +738,9 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
-
-
+ {/*
+ */}
+
)}
@@ -795,7 +819,7 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
{pub.canTransport && ()}
-
+
{pub.currentMonthAvailabilityDaysCount || 0} | {pub.currentMonthAvailabilityHoursCount || 0}
{pub.currentWeekAssignments || 0}
diff --git a/pages/cart/publishers/stats.tsx b/pages/cart/publishers/stats.tsx
index 69e33f6..0e10c77 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}
diff --git a/pages/dash.tsx b/pages/dash.tsx
index 53c74bd..4e2fbd3 100644
--- a/pages/dash.tsx
+++ b/pages/dash.tsx
@@ -270,7 +270,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 +280,17 @@ 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;
return {
props: {
diff --git a/prisma/migrations/20240614185207_/migration.sql b/prisma/migrations/20240614185207_/migration.sql
new file mode 100644
index 0000000..fb8827e
--- /dev/null
+++ b/prisma/migrations/20240614185207_/migration.sql
@@ -0,0 +1,9 @@
+-- CreateTable
+CREATE TABLE `Settings` (
+ `id` INTEGER NOT NULL AUTO_INCREMENT,
+ `key` VARCHAR(191) NOT NULL,
+ `value` VARCHAR(191) NOT NULL,
+ `description` VARCHAR(191) NULL,
+
+ PRIMARY KEY (`id`)
+) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
diff --git a/prisma/migrations/20240614213436_modify_settings_table/migration.sql b/prisma/migrations/20240614213436_modify_settings_table/migration.sql
new file mode 100644
index 0000000..8c71f7c
--- /dev/null
+++ b/prisma/migrations/20240614213436_modify_settings_table/migration.sql
@@ -0,0 +1,10 @@
+/*
+Warnings:
+- The primary key for the `settings` table will be changed. If it partially fails, the table could be left without primary key constraint.
+- You are about to drop the column `id` on the `settings` table. All the data in the column will be lost.
+*/
+-- AlterTable
+ALTER TABLE `Settings`
+DROP PRIMARY KEY,
+DROP COLUMN `id`,
+ADD PRIMARY KEY (`key`);
\ No newline at end of file
diff --git a/prisma/migrations/20240616203120_add_survey_table/migration.sql b/prisma/migrations/20240616203120_add_survey_table/migration.sql
new file mode 100644
index 0000000..a53e34c
--- /dev/null
+++ b/prisma/migrations/20240616203120_add_survey_table/migration.sql
@@ -0,0 +1,19 @@
+-- AlterTable
+ALTER TABLE `message` ADD COLUMN `answer` VARCHAR(191) NULL,
+ ADD COLUMN `answerDate` DATETIME(3) NULL,
+ ADD COLUMN `shownDate` DATETIME(3) NULL,
+ ADD COLUMN `surveyId` INTEGER NULL;
+
+-- 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;
+
+-- AddForeignKey
+ALTER TABLE `Message` ADD CONSTRAINT `Message_surveyId_fkey` FOREIGN KEY (`surveyId`) REFERENCES `Survey`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index c5cc4d8..0ecb8b8 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])
+ surveyId Int?
}
enum EventLogType {
@@ -348,3 +363,9 @@ model VerificationToken {
@@unique([identifier, token])
}
+
+model Settings {
+ key String @id
+ value String
+ description String?
+}
|