fix schedule
This commit is contained in:
2
.env
2
.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=
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -27,3 +27,4 @@ certificates
|
||||
content/output/*
|
||||
baseUrl.txt
|
||||
public/content/output/*
|
||||
public/content/output/shifts 2024.1.json
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user