made accept pq by am api

This commit is contained in:
2025-12-02 20:09:42 +05:30
parent 4f8274adb9
commit 3b723e5d1f
6 changed files with 106 additions and 12 deletions

View File

@@ -325,7 +325,23 @@ RejectPQQByAM:
- ${file(./serverless/patterns/base.yml):pattern4}
events:
- httpApi:
path: /minglaradmin/hosthub/hosts/reject-pqq-by-am
path: /minglaradmin/hosthub/hosts/reject-pq-by-am
method: patch
acceptPQByAM:
handler: src/modules/minglaradmin/handlers/hosthub/hosts/acceptPQByAM.handler
memorySize: 384
package:
patterns:
- 'src/modules/minglaradmin/handlers/hosthub/hosts/acceptPQByAM**'
- 'src/modules/minglaradmin/services/**'
- ${file(./serverless/patterns/base.yml):pattern1}
- ${file(./serverless/patterns/base.yml):pattern2}
- ${file(./serverless/patterns/base.yml):pattern3}
- ${file(./serverless/patterns/base.yml):pattern4}
events:
- httpApi:
path: /minglaradmin/hosthub/hosts/accept-pq-by-am
method: patch
rejectHostApplication:

View File

@@ -31,7 +31,8 @@ export const ACTIVITY_INTERNAL_STATUS = {
UNDER_REVIEW: 'Under-Review',
PQ_FAILED: 'PQ Failed',
PQ_TO_UPDATE: 'PQ To Update',
PQ_SUBMITTED: 'PQ Submitted'
PQ_SUBMITTED: 'PQ Submitted',
PQ_APPROVED: 'PQ Approved'
}
export const ACTIVITY_DISPLAY_STATUS = {
@@ -42,7 +43,8 @@ export const ACTIVITY_DISPLAY_STATUS = {
UNDER_REVIEW: 'Under-Review',
PQ_FAILED: 'PQ Failed',
ENHANCING: 'Enchancing',
PQ_IN_REVIEW: 'PQ In Review'
PQ_IN_REVIEW: 'PQ In Review',
PQ_APPROVED: 'PQ Approved'
}
export const ACTIVITY_AM_INTERNAL_STATUS = {
@@ -53,7 +55,8 @@ export const ACTIVITY_AM_INTERNAL_STATUS = {
UNDER_REVIEW: 'Under-Review',
PQ_FAILED: 'PQ Failed',
PQ_REJECTED: 'PQ Rejected',
PQ_TO_REVIEW: 'PQ To Review'
PQ_TO_REVIEW: 'PQ To Review',
PQ_APPROVED: 'PQ Approved'
}
export const ACTIVITY_AM_DISPLAY_STATUS = {
@@ -64,5 +67,6 @@ export const ACTIVITY_AM_DISPLAY_STATUS = {
UNDER_REVIEW: 'Under-Review',
PQ_FAILED: 'PQ Failed',
ENHANCING: 'Enchancing',
NEW: 'New'
NEW: 'New',
PQ_APPROVED: 'PQ Approved'
}

View File

@@ -54,7 +54,7 @@ export async function generateActivityRefNumber(tx: any) {
}
function round2(value: number) {
return Math.round(value * 100) / 100;
return Math.round(value);
}
const bucket = config.aws.bucketName;

View File

@@ -0,0 +1,49 @@
import { verifyMinglarAdminToken } from '@/common/middlewares/jwt/authForMinglarAdmin';
import { MinglarService } from '@/modules/minglaradmin/services/minglar.service';
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
import { PrismaService } from '../../../../../common/database/prisma.service';
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
import ApiError from '../../../../../common/utils/helper/ApiError';
const prismaService = new PrismaService();
const minglarService = new MinglarService(prismaService);
export const handler = safeHandler(async (
event: APIGatewayProxyEvent,
context?: Context
): Promise<APIGatewayProxyResult> => {
const token = event.headers['x-auth-token'] || event.headers['X-Auth-Token'];
if (!token) throw new ApiError(401, 'This is a protected route. Please provide a valid token.');
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) {
throw new ApiError(400, 'activityId is required');
}
await minglarService.acceptPQByAM(
Number(activityId),
);
return {
statusCode: 201,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
},
body: JSON.stringify({
success: true,
message: 'Approved PQ successfully',
data: null,
}),
};
});

View File

@@ -24,7 +24,7 @@ export const handler = safeHandler(async (
throw new ApiError(400, 'Invalid JSON in request body');
}
const { activityId } = body;
const activityId = event.pathParameters?.activityId;
if (!activityId) {
throw new ApiError(400, 'activityId is required');
@@ -42,7 +42,7 @@ export const handler = safeHandler(async (
},
body: JSON.stringify({
success: true,
message: 'Rejected successfully',
message: 'Rejected PQ successfully',
data: null,
}),
};

View File

@@ -256,11 +256,21 @@ export class MinglarService {
}
async getAllHostActivityForMinglar(search?: string, hostXid?: number) {
const hostActivities = await this.prisma.activities.findMany({
where: {
const where: any = {
isActive: true,
...(hostXid ? { hostXid } : {}), // Add only if provided
},
hostXid: hostXid
};
if (search && search.trim() !== '') {
const q = search.trim();
where.OR = [
{ activityTypeName: { contains: q, mode: 'insensitive' } },
{ interests: { interestName: { contains: q, mode: 'insensitive' } } },
];
}
const hostActivities = await this.prisma.activities.findMany({
where,
include: {
ActivitiesMedia: {
select: {
@@ -1678,6 +1688,21 @@ export class MinglarService {
})
}
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 getHostDetailsById(host_xid) {
const host = await this.prisma.hostHeader.findFirst({
where: { id: host_xid },