made updateSuggestionAsReviewed lambda api
This commit is contained in:
@@ -234,34 +234,34 @@ submitCompanyDetails:
|
||||
timeout: 30
|
||||
package:
|
||||
patterns:
|
||||
- 'src/modules/host/handlers/addCompanyDetails.*'
|
||||
- 'src/modules/host/services/**'
|
||||
- 'src/common/**'
|
||||
- 'node_modules/@prisma/client/**'
|
||||
- 'node_modules/.prisma/client/libquery_engine-rhel-openssl-3.0.x.so.node'
|
||||
# Only include specific AWS SDK modules needed for S3
|
||||
- 'node_modules/@aws-sdk/client-s3/**'
|
||||
- 'node_modules/@aws-sdk/s3-request-presigner/**'
|
||||
- 'node_modules/@aws-sdk/types/**'
|
||||
- 'node_modules/@aws-sdk/middleware-logger/**'
|
||||
- 'node_modules/@aws-sdk/util-utf8-node/**'
|
||||
- 'node_modules/@aws-sdk/util-utf8-browser/**'
|
||||
- 'node_modules/@smithy/**'
|
||||
- 'node_modules/tslib/**'
|
||||
# Remove these large/unnecessary packages:
|
||||
- 'node_modules/fast-xml-parser/**' # Remove if not used
|
||||
- 'node_modules/lambda-multipart-parser/**' # You're using busboy directly
|
||||
- 'node_modules/busboy/**'
|
||||
# Remove these AWS utility packages (included in main SDK):
|
||||
- 'node_modules/@aws-crypto/**'
|
||||
# - 'node_modules/uuid/**' # AWS SDK includes its own
|
||||
# - 'node_modules/@aws/util-uri-escape/**'
|
||||
# - 'node_modules/@aws/util-middleware/**'
|
||||
- 'node_modules/@aws/smithy-client/**'
|
||||
# - 'node_modules/@aws/lambda-invoke-store/**'
|
||||
- 'src/modules/host/handlers/addCompanyDetails.*'
|
||||
- 'src/modules/host/services/**'
|
||||
- 'src/common/**'
|
||||
- 'node_modules/@prisma/client/**'
|
||||
- 'node_modules/.prisma/client/libquery_engine-rhel-openssl-3.0.x.so.node'
|
||||
# Only include specific AWS SDK modules needed for S3
|
||||
- 'node_modules/@aws-sdk/client-s3/**'
|
||||
- 'node_modules/@aws-sdk/s3-request-presigner/**'
|
||||
- 'node_modules/@aws-sdk/types/**'
|
||||
- 'node_modules/@aws-sdk/middleware-logger/**'
|
||||
- 'node_modules/@aws-sdk/util-utf8-node/**'
|
||||
- 'node_modules/@aws-sdk/util-utf8-browser/**'
|
||||
- 'node_modules/@smithy/**'
|
||||
- 'node_modules/tslib/**'
|
||||
# Remove these large/unnecessary packages:
|
||||
- 'node_modules/fast-xml-parser/**' # Remove if not used
|
||||
- 'node_modules/lambda-multipart-parser/**' # You're using busboy directly
|
||||
- 'node_modules/busboy/**'
|
||||
# Remove these AWS utility packages (included in main SDK):
|
||||
- 'node_modules/@aws-crypto/**'
|
||||
# - 'node_modules/uuid/**' # AWS SDK includes its own
|
||||
# - 'node_modules/@aws/util-uri-escape/**'
|
||||
# - 'node_modules/@aws/util-middleware/**'
|
||||
- 'node_modules/@aws/smithy-client/**'
|
||||
# - 'node_modules/@aws/lambda-invoke-store/**'
|
||||
events:
|
||||
- httpApi:
|
||||
path: /host/Host_Admin/onboarding/add-company-details
|
||||
path: /host/Host_Admin/onboarding/add-company-details
|
||||
method: patch
|
||||
|
||||
submitPQQ_Answer:
|
||||
@@ -295,7 +295,7 @@ updatePQQ_LastAnswer:
|
||||
- httpApi:
|
||||
path: /host/Activity_Hub/OnBoarding/submit-final-pqq-answer
|
||||
method: post
|
||||
|
||||
|
||||
getAllPQQwithSubmittedAns:
|
||||
handler: src/modules/host/handlers/Activity_Hub/OnBoarding/getAllPQQwithSubmittedAns.handler
|
||||
memorySize: 512
|
||||
@@ -309,4 +309,19 @@ getAllPQQwithSubmittedAns:
|
||||
events:
|
||||
- httpApi:
|
||||
path: /host/Activity_Hub/OnBoarding/get-all-pqq-ques-submited-ans
|
||||
method: get
|
||||
method: get
|
||||
|
||||
updateSuggestionAsReviewed:
|
||||
handler: src/modules/host/handlers/Activity_Hub/OnBoarding/updateSuggestionAsReviewed.handler
|
||||
memorySize: 512
|
||||
package:
|
||||
patterns:
|
||||
- 'src/modules/host/handlers/Activity_Hub/OnBoarding/**'
|
||||
- ${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: /host/Activity_Hub/OnBoarding/update-suggestion-reviewed
|
||||
method: patch
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { verifyHostToken } from '@/common/middlewares/jwt/authForHost';
|
||||
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';
|
||||
import { HostService } from '../../../services/host.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const hostService = new HostService(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 verifyHostToken(token);
|
||||
|
||||
let body: any = {};
|
||||
try {
|
||||
body = event.body ? JSON.parse(event.body) : {};
|
||||
} catch (err) {
|
||||
throw new ApiError(400, 'Invalid JSON in request body');
|
||||
}
|
||||
|
||||
const { activityPqqHeaderXid, activityPQQSuggestionId } = body;
|
||||
|
||||
if (!activityPqqHeaderXid) {
|
||||
throw new ApiError(400, 'activityPqqHeaderXid is required');
|
||||
}
|
||||
|
||||
await hostService.markPQQSuggestionReviewed(
|
||||
userInfo.id,
|
||||
Number(activityPqqHeaderXid),
|
||||
Number(activityPQQSuggestionId)
|
||||
);
|
||||
|
||||
return {
|
||||
statusCode: 201,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
message: 'Suggestion reviewed successfully',
|
||||
data: null,
|
||||
}),
|
||||
};
|
||||
});
|
||||
@@ -936,6 +936,22 @@ export class HostService {
|
||||
});
|
||||
}
|
||||
|
||||
async markPQQSuggestionReviewed(user_xid: number, activityPqqHeaderXid: number, activityPQQSuggestionId: number) {
|
||||
return await this.prisma.activityPQQSuggestions.update({
|
||||
where: {
|
||||
id: activityPQQSuggestionId,
|
||||
activityPqqHeaderXid: activityPqqHeaderXid,
|
||||
isActive: true,
|
||||
isReviewed: false
|
||||
},
|
||||
data: {
|
||||
isReviewed: true,
|
||||
reviewedByXid: user_xid,
|
||||
reviewedOn: new Date()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async getAllPQQQuesAndSubmittedAns() {
|
||||
return await this.prisma.activityPQQheader.findMany({
|
||||
where: { isActive: true },
|
||||
|
||||
@@ -1193,9 +1193,31 @@ export class MinglarService {
|
||||
return this.prisma.user.findUnique({
|
||||
where: { id: id, isActive: true, userStatus: USER_STATUS.ACTIVE },
|
||||
include: {
|
||||
userAddressDetails: true,
|
||||
userDocuments: true,
|
||||
userRevenues: true,
|
||||
userAddressDetails: {
|
||||
select: {
|
||||
id: true,
|
||||
userXid: true,
|
||||
address1: true,
|
||||
address2: true,
|
||||
locationAddress: true,
|
||||
locationLat: true,
|
||||
locationLong: true,
|
||||
locationName: true,
|
||||
}
|
||||
},
|
||||
userDocuments: {
|
||||
select: {
|
||||
id: true,
|
||||
fileName: true,
|
||||
}
|
||||
},
|
||||
userRevenues: {
|
||||
select: {
|
||||
id: true,
|
||||
is_fixed_salary: true,
|
||||
per_value: true
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user