Merge branch 'main' of https://git.d-popov.com/popov/mwhitnessing
This commit is contained in:
@ -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
|
||||
);
|
||||
|
@ -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"
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user