This commit is contained in:
Dobromir Popov
2024-10-31 13:08:29 +02:00
30 changed files with 1027 additions and 525 deletions

View File

@ -77,6 +77,10 @@ export const authOptions: NextAuthOptions = {
{ id: "1", name: "admin", email: "admin@example.com", password: process.env.ADMIN_PASSWORD, role: "ADMIN", static: true }
];
if (process.env.ADMIN_PASSWORD !== credentials.password) {
throw new Error('невалидна парола');
}
const user = users.find(user =>
user.name === credentials.username && user.password === credentials.password
);

View File

@ -12,6 +12,7 @@ import fs from 'fs';
import path from 'path';
import { all } from "axios";
import { logger } from "src/helpers/common";
import { excel } from "src/helpers/excel";
/**
*
@ -432,7 +433,13 @@ export default async function handler(req, res) {
case "getAllPublishersWithStatistics":
let noEndDate = common.parseBool(req.query.noEndDate);
res.status(200).json(await dataHelper.getAllPublishersWithStatisticsMonth(day, noEndDate));
case "exportPublishersExcel":
try {
await excel.ExportPublishersToExcel(req, res);
} catch (error) {
console.error(JSON.stringify(error));
}
break;
default:
res.status(200).json({
"message": "no action '" + action + "' found"

View File

@ -94,6 +94,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
where: {
isActive: true,
isPublished: true,
// OR: [
// { isPublished: true },
// { user: { role: 'admin' } } // Todo: example. fix this
// ],
startTime: {
gte: fromDate,
//lt: toDate,
@ -152,15 +156,17 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
//bold the text after - in the notes
notes: notes,
notes_bold: notes_bold,
names: shift.assignments
.map((assignment) => {
return (
assignment.publisher.firstName +
" " +
assignment.publisher.lastName
);
})
.join(", "),
names: shift.assignments.length > 0
? shift.assignments
.map((assignment) => {
return (
assignment.publisher.firstName +
" " +
assignment.publisher.lastName
);
})
.join(", ")
: shift.name,
};
if (shiftSchedule.names.length > 0) {
@ -246,6 +252,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
);
}
catch (error) {
console.log(error);
res.status(500).json({ error: "Internal Server Error" });
}
} else {