Positioning, sizing and sorting of the gadgets improved.
This commit is contained in:
@@ -77,7 +77,10 @@ export class AppointmentsService {
|
||||
}
|
||||
|
||||
async list(query: ListAppointmentsDto, organizationId: string, actorUserId: string) {
|
||||
await this.assertCanViewAppointments(actorUserId, organizationId);
|
||||
const { scopeToProvider } = await this.assertCanListAppointmentsForTreatment(
|
||||
actorUserId,
|
||||
organizationId,
|
||||
);
|
||||
|
||||
const from = new Date(query.from);
|
||||
const to = new Date(query.to);
|
||||
@@ -95,6 +98,7 @@ export class AppointmentsService {
|
||||
organizationId,
|
||||
startAt: { lt: to },
|
||||
endAt: { gt: from },
|
||||
...(scopeToProvider ? { providerUserId: actorUserId } : {}),
|
||||
},
|
||||
include: {
|
||||
patient: {
|
||||
@@ -256,18 +260,34 @@ export class AppointmentsService {
|
||||
return;
|
||||
}
|
||||
const names = m.permissions.map((p) => p.permission.name);
|
||||
if (names.includes('TAB_APPOINTMENTS_READ')) {
|
||||
return;
|
||||
}
|
||||
if (names.includes('TAB_TREATMENT_EDIT')) {
|
||||
return;
|
||||
}
|
||||
if (names.includes('TAB_TREATMENT_READ')) {
|
||||
if (names.includes('TAB_APPOINTMENTS_READ') || names.includes('TAB_APPOINTMENTS_EDIT')) {
|
||||
return;
|
||||
}
|
||||
throw new ForbiddenException('You do not have access to appointments');
|
||||
}
|
||||
|
||||
private async assertCanListAppointmentsForTreatment(
|
||||
userId: string,
|
||||
organizationId: string,
|
||||
) {
|
||||
const m = await this.getMembership(userId, organizationId);
|
||||
if (!m) {
|
||||
throw new ForbiddenException('You are not a member of this organization');
|
||||
}
|
||||
if (m.isOwner) {
|
||||
return { membership: m, scopeToProvider: false as const };
|
||||
}
|
||||
const names = m.permissions.map((p) => p.permission.name);
|
||||
const canViewSchedule =
|
||||
names.includes('TAB_APPOINTMENTS_READ') || names.includes('TAB_APPOINTMENTS_EDIT');
|
||||
const canViewTreatment =
|
||||
names.includes('TAB_TREATMENT_READ') || names.includes('TAB_TREATMENT_EDIT');
|
||||
if (!canViewSchedule && !canViewTreatment) {
|
||||
throw new ForbiddenException('You do not have access to appointments');
|
||||
}
|
||||
return { membership: m, scopeToProvider: !canViewSchedule && canViewTreatment };
|
||||
}
|
||||
|
||||
private async assertCanEditAppointments(userId: string, organizationId: string) {
|
||||
const m = await this.getMembership(userId, organizationId);
|
||||
if (!m) {
|
||||
@@ -280,9 +300,6 @@ export class AppointmentsService {
|
||||
if (names.includes('TAB_APPOINTMENTS_EDIT')) {
|
||||
return;
|
||||
}
|
||||
if (names.includes('TAB_TREATMENT_EDIT')) {
|
||||
return;
|
||||
}
|
||||
throw new ForbiddenException('You cannot create or modify appointments');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user