improvement: notify counter badge added to treatment and tasks tabs for upadted and edited cases.
This commit is contained in:
@@ -3,10 +3,11 @@ import {
|
||||
Injectable,
|
||||
NotFoundException,
|
||||
} from '@nestjs/common';
|
||||
import { LabCaseCommentSide, Prisma } from '@prisma/client';
|
||||
import { LabCaseCommentSide, LabCaseActivityType, Prisma } from '@prisma/client';
|
||||
import { PrismaService } from '../../../prisma/prisma.service';
|
||||
import { CreateLabCaseCommentDto } from './dto/lab-case-comment.dto';
|
||||
import { hasEffectivePermission } from '../../common/membership-permissions';
|
||||
import { LabCaseActivityService } from '../notifications/lab-case-activity.service';
|
||||
|
||||
const commentInclude = {
|
||||
authorUser: { select: { id: true, name: true } },
|
||||
@@ -19,7 +20,10 @@ type CommentWithRelations = Prisma.LabCaseCommentGetPayload<{
|
||||
|
||||
@Injectable()
|
||||
export class LabCaseCommentsService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly labCaseActivity: LabCaseActivityService,
|
||||
) {}
|
||||
|
||||
// ---------- Lab side (TAB_TASKS_EDIT) ----------
|
||||
|
||||
@@ -47,6 +51,15 @@ export class LabCaseCommentsService {
|
||||
},
|
||||
include: commentInclude,
|
||||
});
|
||||
await this.labCaseActivity.record({
|
||||
labCaseId: caseId,
|
||||
type: LabCaseActivityType.LAB_COMMENT,
|
||||
actorUserId,
|
||||
payload: {
|
||||
commentId: created.id,
|
||||
visibleToClinic: created.visibleToClinic,
|
||||
},
|
||||
});
|
||||
return { success: true, data: this.mapComment(created, LabCaseCommentSide.LAB) };
|
||||
}
|
||||
|
||||
@@ -104,6 +117,12 @@ export class LabCaseCommentsService {
|
||||
},
|
||||
include: commentInclude,
|
||||
});
|
||||
await this.labCaseActivity.record({
|
||||
labCaseId: caseId,
|
||||
type: LabCaseActivityType.CLINIC_COMMENT,
|
||||
actorUserId,
|
||||
payload: { commentId: created.id },
|
||||
});
|
||||
return { success: true, data: this.mapComment(created, LabCaseCommentSide.CLINIC) };
|
||||
}
|
||||
|
||||
@@ -140,6 +159,12 @@ export class LabCaseCommentsService {
|
||||
},
|
||||
include: commentInclude,
|
||||
});
|
||||
await this.labCaseActivity.record({
|
||||
labCaseId: caseId,
|
||||
type: LabCaseActivityType.CLINIC_COMMENT,
|
||||
actorUserId,
|
||||
payload: { commentId: created.id },
|
||||
});
|
||||
return { success: true, data: this.mapComment(created, LabCaseCommentSide.CLINIC) };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user