fix myschedule start date to be first day of the month
This commit is contained in:
@ -165,14 +165,18 @@ export const getServerSideProps = async (context) => {
|
||||
}
|
||||
|
||||
const prisma = common.getPrismaClient();
|
||||
const publisher = await prisma.publisher.findMany({
|
||||
const monthInfo = common.getMonthInfo(new Date());
|
||||
//minus 1 day from the firstMonday to get the last Sunday
|
||||
const lastSunday = new Date(monthInfo.firstMonday);
|
||||
lastSunday.setDate(lastSunday.getDate() - 1);
|
||||
const publisher = await prisma.publisher.findUnique({
|
||||
where: {
|
||||
id: session.user.id,
|
||||
assignments: {
|
||||
some: {
|
||||
shift: {
|
||||
startTime: {
|
||||
gte: new Date(),
|
||||
gte: lastSunday,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -201,7 +205,7 @@ export const getServerSideProps = async (context) => {
|
||||
},
|
||||
});
|
||||
|
||||
const assignments = publisher[0]?.assignments || [];
|
||||
const assignments = publisher?.assignments || [];
|
||||
|
||||
const transformedAssignments = assignments?.map(assignment => {
|
||||
if (assignment.shift && assignment.shift.startTime) {
|
||||
|
@ -288,6 +288,7 @@ exports.getMonthDatesInfo = function (date) {
|
||||
nrOfWeeks: Math.ceil((lastMonday.getDate() - firstMonday.getDate()) / 7)
|
||||
};
|
||||
};
|
||||
exports.getMonthInfo = exports.getMonthDatesInfo;
|
||||
|
||||
exports.getMonthlyScheduleRange = function (date) {
|
||||
let info = exports.getMonthDatesInfo(date);
|
||||
|
Reference in New Issue
Block a user