making entries in host track
This commit is contained in:
@@ -19,7 +19,7 @@ export const handler = safeHandler(async (event: APIGatewayProxyEvent): Promise<
|
||||
? Number(event.queryStringParameters.activity_xid)
|
||||
: null;
|
||||
|
||||
await pqqService.submitpqqforreview(Number(activity_xid))
|
||||
await pqqService.submitpqqforreview(Number(activity_xid), Number(user.id))
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
|
||||
@@ -19,6 +19,8 @@ import {
|
||||
STEPPER,
|
||||
} from '@/common/utils/constants/host.constant';
|
||||
import {
|
||||
ACTIVITY_TRACK_STATUS,
|
||||
ACTIVITY_TRACK_TYPE,
|
||||
MINGLAR_STATUS_DISPLAY,
|
||||
MINGLAR_STATUS_INTERNAL,
|
||||
} from '@/common/utils/constants/minglar.constant';
|
||||
@@ -1244,46 +1246,74 @@ export class HostService {
|
||||
});
|
||||
}
|
||||
|
||||
async submitpqqforreview(activity_xid: number) {
|
||||
const activity = await this.prisma.activities.findFirst({
|
||||
where: { id: activity_xid, isActive: true },
|
||||
select: {
|
||||
id: true,
|
||||
activityTitle: true,
|
||||
activityRefNumber: true,
|
||||
activityDisplayStatus: true,
|
||||
activityInternalStatus: true,
|
||||
amInternalStatus: true,
|
||||
amDisplayStatus: true
|
||||
async submitpqqforreview(activity_xid: number, user_xid: number) {
|
||||
return await this.prisma.$transaction(async (tx) => {
|
||||
const activity = await this.prisma.activities.findFirst({
|
||||
where: { id: activity_xid, isActive: true },
|
||||
select: {
|
||||
id: true,
|
||||
activityTitle: true,
|
||||
activityRefNumber: true,
|
||||
activityDisplayStatus: true,
|
||||
activityInternalStatus: true,
|
||||
amInternalStatus: true,
|
||||
amDisplayStatus: true
|
||||
}
|
||||
})
|
||||
|
||||
if (!activity) {
|
||||
throw new ApiError(404, "Activity not found")
|
||||
}
|
||||
|
||||
if (activity.activityInternalStatus == ACTIVITY_INTERNAL_STATUS.PQ_TO_UPDATE) {
|
||||
return await this.prisma.$transaction(async (tx) => {
|
||||
await this.prisma.activities.update({
|
||||
where: { id: activity_xid },
|
||||
data: {
|
||||
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.PQ_SUBMITTED,
|
||||
activityDisplayStatus: ACTIVITY_DISPLAY_STATUS.PQ_IN_REVIEW,
|
||||
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.PQ_TO_REVIEW,
|
||||
amDisplayStatus: ACTIVITY_AM_DISPLAY_STATUS.REVISED
|
||||
}
|
||||
})
|
||||
|
||||
await tx.activityTrack.create({
|
||||
data: {
|
||||
activityXid: activity_xid,
|
||||
trackType: ACTIVITY_TRACK_TYPE.PQ,
|
||||
trackStatus: ACTIVITY_TRACK_STATUS.PQ_SUBMITTED,
|
||||
updatedByXid: user_xid,
|
||||
updatedByRole: ROLE_NAME.HOST,
|
||||
updatedOn: new Date()
|
||||
}
|
||||
})
|
||||
})
|
||||
} else {
|
||||
return await this.prisma.$transaction(async (tx) => {
|
||||
await this.prisma.activities.update({
|
||||
where: { id: activity_xid },
|
||||
data: {
|
||||
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.PQ_SUBMITTED,
|
||||
activityDisplayStatus: ACTIVITY_DISPLAY_STATUS.PQ_IN_REVIEW,
|
||||
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.PQ_TO_REVIEW,
|
||||
amDisplayStatus: ACTIVITY_AM_DISPLAY_STATUS.NEW
|
||||
}
|
||||
})
|
||||
|
||||
await tx.activityTrack.create({
|
||||
data: {
|
||||
activityXid: activity_xid,
|
||||
trackType: ACTIVITY_TRACK_TYPE.PQ,
|
||||
trackStatus: ACTIVITY_TRACK_STATUS.PQ_SUBMITTED,
|
||||
updatedByXid: user_xid,
|
||||
updatedByRole: ROLE_NAME.HOST,
|
||||
updatedOn: new Date()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
if (!activity) {
|
||||
throw new ApiError(404, "Activity not found")
|
||||
}
|
||||
|
||||
if (activity.activityInternalStatus == ACTIVITY_INTERNAL_STATUS.PQ_TO_UPDATE) {
|
||||
return await this.prisma.activities.update({
|
||||
where: { id: activity_xid },
|
||||
data: {
|
||||
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.PQ_SUBMITTED,
|
||||
activityDisplayStatus: ACTIVITY_DISPLAY_STATUS.PQ_IN_REVIEW,
|
||||
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.PQ_TO_REVIEW,
|
||||
amDisplayStatus: ACTIVITY_AM_DISPLAY_STATUS.REVISED
|
||||
}
|
||||
})
|
||||
} else {
|
||||
return await this.prisma.activities.update({
|
||||
where: { id: activity_xid },
|
||||
data: {
|
||||
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.PQ_SUBMITTED,
|
||||
activityDisplayStatus: ACTIVITY_DISPLAY_STATUS.PQ_IN_REVIEW,
|
||||
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.PQ_TO_REVIEW,
|
||||
amDisplayStatus: ACTIVITY_AM_DISPLAY_STATUS.NEW
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async updateSupportingFile(
|
||||
|
||||
@@ -17,13 +17,6 @@ export const handler = safeHandler(async (
|
||||
|
||||
const userInfo = await verifyMinglarAdminToken(token);
|
||||
|
||||
let body: any = {};
|
||||
try {
|
||||
body = event.body ? JSON.parse(event.body) : {};
|
||||
} catch (err) {
|
||||
throw new ApiError(400, 'Invalid JSON in request body');
|
||||
}
|
||||
|
||||
const activityId = event.pathParameters?.activityId;
|
||||
|
||||
if (!activityId) {
|
||||
@@ -32,6 +25,7 @@ export const handler = safeHandler(async (
|
||||
|
||||
await minglarService.acceptPQByAM(
|
||||
Number(activityId),
|
||||
Number(userInfo.id)
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
@@ -17,13 +17,6 @@ export const handler = safeHandler(async (
|
||||
|
||||
const userInfo = await verifyMinglarAdminToken(token);
|
||||
|
||||
let body: any = {};
|
||||
try {
|
||||
body = event.body ? JSON.parse(event.body) : {};
|
||||
} catch (err) {
|
||||
throw new ApiError(400, 'Invalid JSON in request body');
|
||||
}
|
||||
|
||||
const activityId = event.pathParameters?.activityId;
|
||||
|
||||
if (!activityId) {
|
||||
@@ -32,6 +25,7 @@ export const handler = safeHandler(async (
|
||||
|
||||
await minglarService.rejectPQQbyAM(
|
||||
Number(activityId),
|
||||
Number(userInfo.id)
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
@@ -13,6 +13,8 @@ import {
|
||||
STEPPER,
|
||||
} from '@/common/utils/constants/host.constant';
|
||||
import {
|
||||
ACTIVITY_TRACK_STATUS,
|
||||
ACTIVITY_TRACK_TYPE,
|
||||
MINGLAR_INVITATION_STATUS,
|
||||
MINGLAR_STATUS_DISPLAY,
|
||||
MINGLAR_STATUS_INTERNAL,
|
||||
@@ -27,6 +29,7 @@ import { sendAMEmailForHostAssign } from './AMEmail.service';
|
||||
import { getPresignedUrl } from '@/common/middlewares/aws/getPreSignedUrl';
|
||||
import config from '@/config/config';
|
||||
import { PaginationOptions } from '@/common/utils/pagination/pagination.types';
|
||||
import { ROLES_KEY } from '@/common/decorators/roles.decorator';
|
||||
|
||||
const bucket = config.aws.bucketName;
|
||||
|
||||
@@ -1675,33 +1678,59 @@ export class MinglarService {
|
||||
})
|
||||
}
|
||||
|
||||
async rejectPQQbyAM(activityId: number) {
|
||||
return await this.prisma.activities.update({
|
||||
where: {
|
||||
id: activityId,
|
||||
isActive: true
|
||||
},
|
||||
data: {
|
||||
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.PQ_TO_UPDATE,
|
||||
activityDisplayStatus: ACTIVITY_DISPLAY_STATUS.ENHANCING,
|
||||
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.PQ_REJECTED,
|
||||
amDisplayStatus: ACTIVITY_AM_DISPLAY_STATUS.ENHANCING
|
||||
}
|
||||
async rejectPQQbyAM(activityId: number, user_xid: number) {
|
||||
return await this.prisma.$transaction(async (tx) => {
|
||||
await tx.activities.update({
|
||||
where: {
|
||||
id: activityId,
|
||||
isActive: true
|
||||
},
|
||||
data: {
|
||||
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.PQ_TO_UPDATE,
|
||||
activityDisplayStatus: ACTIVITY_DISPLAY_STATUS.ENHANCING,
|
||||
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.PQ_REJECTED,
|
||||
amDisplayStatus: ACTIVITY_AM_DISPLAY_STATUS.ENHANCING
|
||||
}
|
||||
})
|
||||
|
||||
await tx.activityTrack.create({
|
||||
data: {
|
||||
activityXid: activityId,
|
||||
trackType: ACTIVITY_TRACK_TYPE.PQ,
|
||||
trackStatus: ACTIVITY_TRACK_STATUS.REJECTED_BY_AM,
|
||||
updatedByXid: user_xid,
|
||||
updatedByRole: ROLE_NAME.ACCOUNT_MANAGER,
|
||||
updatedOn: new Date()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async acceptPQByAM(activityId: number) {
|
||||
return await this.prisma.activities.update({
|
||||
where: {
|
||||
id: activityId,
|
||||
isActive: true
|
||||
},
|
||||
data: {
|
||||
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.PQ_APPROVED,
|
||||
activityDisplayStatus: ACTIVITY_DISPLAY_STATUS.PQ_APPROVED,
|
||||
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.PQ_APPROVED,
|
||||
amDisplayStatus: ACTIVITY_AM_DISPLAY_STATUS.PQ_APPROVED
|
||||
}
|
||||
async acceptPQByAM(activityId: number, user_xid: number) {
|
||||
return await this.prisma.$transaction(async (tx) => {
|
||||
await tx.activities.update({
|
||||
where: {
|
||||
id: activityId,
|
||||
isActive: true
|
||||
},
|
||||
data: {
|
||||
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.PQ_APPROVED,
|
||||
activityDisplayStatus: ACTIVITY_DISPLAY_STATUS.PQ_APPROVED,
|
||||
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.PQ_APPROVED,
|
||||
amDisplayStatus: ACTIVITY_AM_DISPLAY_STATUS.PQ_APPROVED
|
||||
}
|
||||
})
|
||||
|
||||
await tx.activityTrack.create({
|
||||
data: {
|
||||
activityXid: activityId,
|
||||
trackType: ACTIVITY_TRACK_TYPE.PQ,
|
||||
trackStatus: ACTIVITY_TRACK_STATUS.ACCEPTED_BY_AM,
|
||||
updatedByXid: user_xid,
|
||||
updatedByRole: ROLE_NAME.ACCOUNT_MANAGER,
|
||||
updatedOn: new Date()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user