schedule is for monthinfo periods

This commit is contained in:
Dobromir Popov
2024-04-20 12:09:30 +03:00
parent 2c062be8a1
commit b535d0853a
6 changed files with 24 additions and 11 deletions

2
.env
View File

@ -51,7 +51,7 @@ TWITTER_SECRET=
# EMAIL_BYPASS_TO=mwitnessing@gmail.com
EMAIL_SENDER='"ССС" <mwitnessing@gmail.com>'
# EMAIL_SERVER=smtp://8ec69527ff2104:c7bc05f171c96c@smtp.mailtrap.io:2525
EMAIL_FROM=noreply@mwitnessing.com
# ?EMAIL_FROM=noreply@mwitnessing.com
EMAIL_SERVICE=mailtrap
# MAILTRAP_HOST_BULK=bulk.smtp.mailtrap.io

View File

@ -17,6 +17,7 @@ AUTH0_ISSUER=https://dev-wkzi658ckibr1amv.us.auth0.com
# GOOGLE_ID=926212607479-d3m8hm8f8esp3rf1639prskn445sa01v.apps.googleusercontent.com
# GOOGLE_SECRET=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
EMAIL_SERVICE=mailtrap
MAILTRAP_HOST_BULK=bulk.smtp.mailtrap.io
MAILTRAP_HOST=live.smtp.mailtrap.io
MAILTRAP_USER=api

View File

@ -208,3 +208,11 @@ store replacement
test email
problem with my repeating availability3
relax add/remove transport for publishers
fix published schedule to cover end of the week
имейлите - ОК
графика - синк - ОК
вестителите от Фабио -
потребителите с двойни имейли -

View File

@ -337,7 +337,7 @@ export default async function handler(req, res) {
let updated = await prisma.shift.updateMany({
where: {
startTime: {
gte: new Date(monthInfo.firstMonday.getFullYear(), monthInfo.firstMonday.getMonth(), 1),
gte: new Date(monthInfo.firstMonday.getFullYear(), monthInfo.firstMonday.getMonth(), monthInfo.firstMonday.getDate()),
lt: new Date(monthInfo.lastSunday.getFullYear(), monthInfo.lastSunday.getMonth() + 1, 1),
}
},

View File

@ -73,17 +73,20 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
if (req.method === 'GET') {
// const { year, month } = req.query;
const { year, month } = req.query;
// let monthIndex = parseInt(month as string) - 1;
// const monthInfo = common.getMonthDatesInfo(new Date(year, month, 1));
// let fromDate = monthInfo.firstMonday;
// const toDate = monthInfo.lastSunday;
//ToDo: maybe we don't need that anymore as we are publishing the shifts and show all published shifts
let fromDate = new Date();
fromDate.setDate(fromDate.getDate() - 1);
fromDate.setHours(0, 0, 0, 0);
let toDate = new Date(fromDate);
toDate.setDate(toDate.getDate() + 40);
if (year && month) {
fromDate = new Date(parseInt(year as string), parseInt(month as string) - 1, 1);
}
const monthInfo = common.getMonthDatesInfo(fromDate);
//let toDate = new Date(monthInfo.lastSunday);
if (year && month) {
fromDate = monthInfo.firstMonday;
}
try {
@ -93,7 +96,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
isPublished: true,
startTime: {
gte: fromDate,
lt: toDate,
//lt: toDate,
},
},
orderBy: {

View File

@ -22,7 +22,8 @@ const SchedulePage = () => {
useEffect(() => {
const fetchHtmlContent = async () => {
try {
const response = await axiosInstance.get('/api/schedule?year=2024&month=1', { responseType: 'text' });
// const response = await axiosInstance.get('/api/schedule?year=2024&month=1', { responseType: 'text' });
const response = await axiosInstance.get('/api/schedule', { responseType: 'text' });
setHtmlContent(response.data); // Set the fetched HTML content in state
} catch (error) {
console.error("Failed to fetch schedule:", error);