task-l
This commit is contained in:
@@ -26,13 +26,19 @@ export async function PATCH(request: NextRequest, { params }: Params) {
|
||||
permission: PERMISSIONS.crmEnquiryFollowupUpdate
|
||||
});
|
||||
const payload = followupRequestSchema.parse(await request.json());
|
||||
const accessContext = {
|
||||
organizationId: organization.id,
|
||||
userId: session.user.id,
|
||||
membershipRole: membership.role,
|
||||
businessRole: membership.businessRole,
|
||||
branchScopeIds: membership.branchScopeIds ?? [],
|
||||
productTypeScopeIds: membership.productTypeScopeIds ?? [],
|
||||
ownershipScope: membership.ownershipScope ?? 'organization',
|
||||
branchScopeMode: membership.branchScopeMode === 'assigned' ? 'assigned' : 'all',
|
||||
productScopeMode: membership.productScopeMode === 'assigned' ? 'assigned' : 'all'
|
||||
};
|
||||
const before = (
|
||||
await listEnquiryFollowups(id, organization.id, {
|
||||
organizationId: organization.id,
|
||||
userId: session.user.id,
|
||||
membershipRole: membership.role,
|
||||
businessRole: membership.businessRole
|
||||
})
|
||||
await listEnquiryFollowups(id, organization.id, accessContext)
|
||||
).find(
|
||||
(item) => item.id === followupId
|
||||
);
|
||||
@@ -47,12 +53,7 @@ export async function PATCH(request: NextRequest, { params }: Params) {
|
||||
organization.id,
|
||||
session.user.id,
|
||||
payload,
|
||||
{
|
||||
organizationId: organization.id,
|
||||
userId: session.user.id,
|
||||
membershipRole: membership.role,
|
||||
businessRole: membership.businessRole
|
||||
}
|
||||
accessContext
|
||||
);
|
||||
|
||||
await auditUpdate({
|
||||
@@ -95,13 +96,19 @@ export async function DELETE(_request: NextRequest, { params }: Params) {
|
||||
const { organization, session, membership } = await requireOrganizationAccess({
|
||||
permission: PERMISSIONS.crmEnquiryFollowupDelete
|
||||
});
|
||||
const accessContext = {
|
||||
organizationId: organization.id,
|
||||
userId: session.user.id,
|
||||
membershipRole: membership.role,
|
||||
businessRole: membership.businessRole,
|
||||
branchScopeIds: membership.branchScopeIds ?? [],
|
||||
productTypeScopeIds: membership.productTypeScopeIds ?? [],
|
||||
ownershipScope: membership.ownershipScope ?? 'organization',
|
||||
branchScopeMode: membership.branchScopeMode === 'assigned' ? 'assigned' : 'all',
|
||||
productScopeMode: membership.productScopeMode === 'assigned' ? 'assigned' : 'all'
|
||||
};
|
||||
const before = (
|
||||
await listEnquiryFollowups(id, organization.id, {
|
||||
organizationId: organization.id,
|
||||
userId: session.user.id,
|
||||
membershipRole: membership.role,
|
||||
businessRole: membership.businessRole
|
||||
})
|
||||
await listEnquiryFollowups(id, organization.id, accessContext)
|
||||
).find(
|
||||
(item) => item.id === followupId
|
||||
);
|
||||
@@ -115,12 +122,7 @@ export async function DELETE(_request: NextRequest, { params }: Params) {
|
||||
followupId,
|
||||
organization.id,
|
||||
session.user.id,
|
||||
{
|
||||
organizationId: organization.id,
|
||||
userId: session.user.id,
|
||||
membershipRole: membership.role,
|
||||
businessRole: membership.businessRole
|
||||
}
|
||||
accessContext
|
||||
);
|
||||
|
||||
await auditDelete({
|
||||
|
||||
Reference in New Issue
Block a user