From 3b90128927dd8f30bfec6549c867fa38893752a2 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Sat, 4 May 2024 16:19:31 +0300 Subject: [PATCH 1/2] fix missing shifts in myshifts; fix serialization error --- pages/cart/publishers/myschedule.tsx | 14 ++++++++------ pages/dash.tsx | 23 +++++++++++++++++------ src/helpers/data.js | 7 +++---- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/pages/cart/publishers/myschedule.tsx b/pages/cart/publishers/myschedule.tsx index 10b953f..97b66d0 100644 --- a/pages/cart/publishers/myschedule.tsx +++ b/pages/cart/publishers/myschedule.tsx @@ -168,10 +168,12 @@ export const getServerSideProps = async (context) => { } const prisma = common.getPrismaClient(); - const monthInfo = common.getMonthInfo(new Date()); - //minus 1 day from the firstMonday to get the last Sunday - const lastSunday = new Date(monthInfo.firstMonday); - lastSunday.setDate(lastSunday.getDate() - 1); + let today = new Date(); + today.setHours(0, 0, 0, 0); + // const monthInfo = common.getMonthInfo(today); + // //minus 1 day from the firstMonday to get the last Sunday + // const lastSunday = new Date(monthInfo.firstMonday); + // lastSunday.setDate(lastSunday.getDate() - 1); const publisher = await prisma.publisher.findUnique({ where: { id: session.user.id, @@ -179,7 +181,7 @@ export const getServerSideProps = async (context) => { some: { shift: { startTime: { - gte: lastSunday, + gte: today, }, }, }, @@ -208,7 +210,7 @@ export const getServerSideProps = async (context) => { }, }); - const assignments = publisher?.assignments.filter(a => a.shift.startTime >= lastSunday && a.shift.isPublished) || []; + const assignments = publisher?.assignments.filter(a => a.shift.startTime >= today && a.shift.isPublished) || []; const transformedAssignments = assignments?.sort((a, b) => a.shift.startTime - b.shift.startTime) diff --git a/pages/dash.tsx b/pages/dash.tsx index 4ba7281..8dee455 100644 --- a/pages/dash.tsx +++ b/pages/dash.tsx @@ -204,13 +204,24 @@ export const getServerSideProps = async (context) => { var items = await dataHelper.getCalendarEvents(session.user.id); // common.convertDatesToISOStrings(items); //serializable dates - items = items.map(item => ({ - ...item, - startTime: item.startTime.toISOString(), - endTime: item.endTime.toISOString(), - date: item.date.toISOString(), - })); + items = items.map(item => { + const updatedItem = { + ...item, + startTime: item.startTime.toISOString(), + endTime: item.endTime.toISOString(), + date: item.date.toISOString() + }; + if (updatedItem.shift) { + updatedItem.shift = { + ...updatedItem.shift, + startTime: updatedItem.shift.startTime.toISOString(), + endTime: updatedItem.shift.endTime.toISOString() + }; + } + + return updatedItem; + }); return { props: { diff --git a/src/helpers/data.js b/src/helpers/data.js index c344a39..79a5079 100644 --- a/src/helpers/data.js +++ b/src/helpers/data.js @@ -647,6 +647,7 @@ async function getCalendarEvents(publisherId, date, availabilities = true, assig assignments: { select: { id: true, + // publisherId: true, shift: { select: { id: true, @@ -689,15 +690,13 @@ async function getCalendarEvents(publisherId, date, availabilities = true, assig date: new Date(item.shift.startTime), startTime: new Date(item.shift.startTime), endTime: new Date(item.shift.endTime), - publisherId: item.publisherid, + // publisherId: item.publisherId, + publisherId: publisher.id, type: "assignment", }); }); - } } - - return result; } From 9d37985720bd85c938cac3adf558cbc0c0fdbe59 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Sat, 4 May 2024 16:22:57 +0300 Subject: [PATCH 2/2] update staging environment --- .env.test => .env.test.staging | 0 ...deoloy.azure.demo.yml => deoloy.azure.staging.yml} | 11 ++++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) rename .env.test => .env.test.staging (100%) rename _deploy/{deoloy.azure.demo.yml => deoloy.azure.staging.yml} (82%) diff --git a/.env.test b/.env.test.staging similarity index 100% rename from .env.test rename to .env.test.staging diff --git a/_deploy/deoloy.azure.demo.yml b/_deploy/deoloy.azure.staging.yml similarity index 82% rename from _deploy/deoloy.azure.demo.yml rename to _deploy/deoloy.azure.staging.yml index 44a440c..d478c07 100644 --- a/_deploy/deoloy.azure.demo.yml +++ b/_deploy/deoloy.azure.staging.yml @@ -1,12 +1,13 @@ version: "3" services: - nextjs-app: # https://sofia.mwitnessing.com/ + nextjs-app: # https://sofia.mwhitnessing.com/ hostname: jwpw-app-staging # jwpw-nextjs-app-1 image: docker.d-popov.com/jwpw:latest volumes: - /mnt/docker_volumes/pw-demo/app/public/content/uploads/:/app/public/content/uploads + - /mnt/docker_volumes/pw-demo/app/logs:/app/logs environment: - - APP_ENV=test + - APP_ENV=test.staging - NODE_ENV=test - TZ=Europe/Sofia - DATABASE=mysql://jwpwsofia_demo:dwxhns9p9vp248@mariadb-demo:3306/jwpwsofia_demo @@ -14,12 +15,13 @@ services: - GIT_BRANCH=main - GIT_USERNAME=deploy - GIT_PASSWORD=L3Kr2R438u4F7 - command: sh -c " cd /app && npm install && npx next build && npm run nodeenv; tail -f /dev/null" + command: sh -c " cd /app && npm install && npx next build && npm run start-env; tail -f /dev/null" tty: true stdin_open: true restart: always networks: - infrastructure_default + - default mariadb: deploy: replicas: 1 @@ -33,6 +35,9 @@ services: MYSQL_DATABASE: jwpwsofia_demo MYSQL_USER: jwpwsofia_demo MYSQL_PASSWORD: dwxhns9p9vp248 + # networks: + # - infrastructure_default + # - default networks: infrastructure_default: external: true