diff --git a/.env b/.env index 1973ac5..37257a5 100644 --- a/.env +++ b/.env @@ -16,7 +16,7 @@ DATABASE_PROVIDER=mysql DATABASE_URL=mysql://root:Zelen0ku4e@192.168.0.10:3306/cart_dev # DATABASE_URL=mysql://cart:cartpw@20.101.62.76:3307/cart -#DATABASE_URL=mysql://cart:cartpw@localhost:3306/cart # migrate deploy #dev +# DATABASE_URL=mysql://cart:cartpw@localhost:3306/cart # npx prisma migrate dev APPLE_ID= APPLE_TEAM_ID= diff --git a/.gitignore b/.gitignore index 1798e4a..738df3e 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ certificates content/output/* baseUrl.txt public/content/output/* +public/content/output/shifts 2024.1.json diff --git a/pages/api/schedule.ts b/pages/api/schedule.ts index ea2825c..2e78c30 100644 --- a/pages/api/schedule.ts +++ b/pages/api/schedule.ts @@ -43,21 +43,17 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) if (req.method === 'GET') { - 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; - - // Ensure fromDate is not in the past - const today = new Date(); - today.setHours(0, 0, 0, 0); // Set time to midnight for accurate comparison - - if (fromDate < today) { - fromDate = today; - } + // 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; + let fromDate = new Date(); + fromDate.setDate(fromDate.getDate() - 1); + fromDate.setHours(0, 0, 0, 0); + let toDate = new Date(fromDate); + toDate.setDate(toDate.getDate() + 30); try { @@ -167,11 +163,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) fs.mkdirSync(outputPath, { recursive: true }); } - fs.writeFileSync(path.join(outputPath, `shifts ${year}.${month}.json`), JSON.stringify(monthlySchedule), 'utf8'); + //fs.writeFileSync(path.join(outputPath, `shifts ${year}.${month}.json`), JSON.stringify(monthlySchedule), 'utf8'); // Load the Handlebars template from a file const template = fs.readFileSync("./src/templates/schedule.hbs", "utf8"); generateTemplateFile(monthlySchedule, template).then((result) => { - const filename = path.join(outputPath, `schedule ${year}.${month}.html`) + const filename = path.join(outputPath, `schedule.html`) //fs.writeFileSync(filename, result, "utf8"); res.end(result); } diff --git a/pages/cart/calendar/schedule.tsx b/pages/cart/calendar/schedule.tsx index c418b9e..bf58876 100644 --- a/pages/cart/calendar/schedule.tsx +++ b/pages/cart/calendar/schedule.tsx @@ -20,10 +20,8 @@ const SchedulePage = () => { const [htmlContent, setHtmlContent] = useState(""); // State to hold fetched HTML content useEffect(() => { - // Define an async function to fetch the HTML content const fetchHtmlContent = async () => { try { - // Replace '/api/schedule' with your actual API endpoint const response = await axiosInstance.get('/api/schedule?year=2024&month=1', { responseType: 'text' }); setHtmlContent(response.data); // Set the fetched HTML content in state } catch (error) { diff --git a/public/content/output/shifts 2024.1.json b/public/content/output/shifts 2024.1.json deleted file mode 100644 index 2a8e6bc..0000000 --- a/public/content/output/shifts 2024.1.json +++ /dev/null @@ -1 +0,0 @@ -{"month":"февруари","year":2024,"events":[{"week":4,"dayOfWeek":"Сряда","dayOfMonth":28,"placeOfEvent":"метростанция Сердика","shifts":[{"date":"2024-02-28T07:00:00.000Z","placeOfEvent":"метростанция Сердика","time":"09:00-10:30","notes":"Докарва количка от Люлин -","notes_bold":" Докарва количка от Люлин – Д.А.","names":"Едит Ковач, Джеси Алберт, Ребека Алберт"},{"date":"2024-02-28T08:30:00.000Z","placeOfEvent":"метростанция Сердика","time":"10:30-12:00","notes":"","notes_bold":"","names":"Олга Ларченкова, Светломира Трифонова, Анастасия Билоус"},{"date":"2024-02-28T10:00:00.000Z","placeOfEvent":"метростанция Сердика","time":"12:00-13:30","notes":"","notes_bold":"","names":"Таня Павлова, Елена Павлова, Роберт Янчък, Алиця Янчък"},{"date":"2024-02-28T11:30:00.000Z","placeOfEvent":"метростанция Сердика","time":"13:30-15:00","notes":"","notes_bold":"","names":"Шилем Волпато, Чинуе Волпато, Илия Москвин, Елизавета Москвина"},{"date":"2024-02-28T13:00:00.000Z","placeOfEvent":"метростанция Сердика","time":"15:00-16:30","notes":"","notes_bold":"","names":"Даниела Стоянова, Юрий Чулак, Светлана Чулак"},{"date":"2024-02-28T14:30:00.000Z","placeOfEvent":"метростанция Сердика","time":"16:30-18:00","notes":"Прибира количка в Люлин -","notes_bold":" Прибира количка в Люлин - С.Р.","names":"Бранимира Съменова, Симоне Русо, Серена Русо"}]},{"week":4,"dayOfWeek":"Четвъртък","dayOfMonth":29,"placeOfEvent":"Лъвов Мост","shifts":[{"date":"2024-02-29T07:00:00.000Z","placeOfEvent":"Лъвов Мост","time":"09:00-10:30","notes":"Докарва количка от Люлин -","notes_bold":" Докарва количка от Люлин - И.М.,Т.З.","names":"Александра Карлсон, Татяна Зозулина, Даниела Димитрова, Илия Москвин"},{"date":"2024-02-29T08:30:00.000Z","placeOfEvent":"Лъвов Мост","time":"10:30-12:00","notes":"","notes_bold":"","names":"Светослав Георгиев, Сириел Георгиева, Шула Бейли, Виолета Христoва"},{"date":"2024-02-29T10:00:00.000Z","placeOfEvent":"Лъвов Мост","time":"12:00-13:30","notes":"","notes_bold":"","names":"Мая Стефанова, Анна Илиева, Александър Яцък, Лариса Яцък"},{"date":"2024-02-29T11:30:00.000Z","placeOfEvent":"Лъвов Мост","time":"13:30-15:00","notes":"","notes_bold":"","names":"Марсел Клайнер, Алина Клайнер, Александра Чернъшова, Абигаил Сантюсте"},{"date":"2024-02-29T13:00:00.000Z","placeOfEvent":"Лъвов Мост","time":"15:00-16:30","notes":"","notes_bold":"","names":"Мариане Вертхолц, Анна Карастоянова, Тимофей Ларченков"},{"date":"2024-02-29T14:30:00.000Z","placeOfEvent":"Лъвов Мост","time":"16:30-18:00","notes":"Прибира количка в Люлин -","notes_bold":" Прибира количка в Люлин-Е.М,П.П","names":"Евелин Манолова, Альона Иванчукова, Панагиотис Псиакидис"}]},{"week":0,"dayOfWeek":"Петък","dayOfMonth":1,"placeOfEvent":"паметник Патриарх Евтимий","shifts":[{"date":"2024-03-01T07:00:00.000Z","placeOfEvent":"паметник Патриарх Евтимий","time":"09:00-10:30","notes":"Докарва количка от Люлин -","notes_bold":" Докарва количка от Люлин – Я.В.","names":"Янко Ванчев, Алиса Ванчева, Марина Христова, Линда Мои"},{"date":"2024-03-01T08:30:00.000Z","placeOfEvent":"паметник Патриарх Евтимий","time":"10:30-12:00","notes":"","notes_bold":"","names":"Екатерина Димитрова, Марина Даракова, Инге Вандер Мейрен, Евелин Дзюба"},{"date":"2024-03-01T10:00:00.000Z","placeOfEvent":"паметник Патриарх Евтимий","time":"12:00-13:30","notes":"","notes_bold":"","names":"Витали Пашченко, Дариуш Йедлински, Елена Йедлинск, Лоран Баерт"},{"date":"2024-03-01T11:30:00.000Z","placeOfEvent":"паметник Патриарх Евтимий","time":"13:30-15:00","notes":"","notes_bold":"","names":"Радостина Илиева, Анжела Дойчинова, Агниешка Клишевска"},{"date":"2024-03-01T13:00:00.000Z","placeOfEvent":"паметник Патриарх Евтимий","time":"15:00-16:30","notes":"","notes_bold":"","names":"Елена Шаишникова, Аня Ван Ловерен, Добромир Попов, Зденка Рудлофова"},{"date":"2024-03-01T14:30:00.000Z","placeOfEvent":"паметник Патриарх Евтимий","time":"16:30-18:00","notes":"Прибира количка в Люлин -","notes_bold":" Прибира количка в Люлин - П.П.","names":"Прометей Подиматис, Девора Подимати, Светлана Юрушкина, Анастасия Неделчева"}]},{"week":0,"dayOfWeek":"Събота","dayOfMonth":2,"placeOfEvent":"метростанция НДК","shifts":[{"date":"2024-03-02T10:00:00.000Z","placeOfEvent":"метростанция НДК","time":"12:00-13:30","notes":"Докарва количка от Люлин -","notes_bold":" Докарва количка от Люлин - Г.К.","names":"Георги Калчев, Джихан Калчева, Марина Якимовская, Красимир Грудев"},{"date":"2024-03-02T11:30:00.000Z","placeOfEvent":"метростанция НДК","time":"13:30-15:00","notes":"","notes_bold":"","names":"Давид Господинов, Рубен Реч, Лилия Реч, Юстъна Хацкиевич"},{"date":"2024-03-02T13:00:00.000Z","placeOfEvent":"метростанция НДК","time":"15:00-16:30","notes":"","notes_bold":"","names":"Павел Манолов, Евелин Манолова, Стефан Господинов, Франческо Спиньо"},{"date":"2024-03-02T14:30:00.000Z","placeOfEvent":"метростанция НДК","time":"16:30-18:00","notes":"","notes_bold":"","names":"Красимир Велев, Кшищоф Гуронски, Емил Гюлев, Евелина Гюлева"}]}]} \ No newline at end of file