add payment details modified and making seeder of pqq
This commit is contained in:
@@ -6,6 +6,10 @@ export const hostBankDetailsSchema = z.object({
|
||||
.string()
|
||||
.nonempty("Account number is required"),
|
||||
|
||||
confirmAccountNumber: z
|
||||
.string()
|
||||
.nonempty("Confirm account number is required"),
|
||||
|
||||
accountHolderName: z
|
||||
.string()
|
||||
.nonempty("Account holder name is required")
|
||||
@@ -30,6 +34,11 @@ export const hostBankDetailsSchema = z.object({
|
||||
.number()
|
||||
.int({ message: "Bank branch ID must be an integer" })
|
||||
.positive({ message: "Bank branch ID must be a positive number" }),
|
||||
|
||||
currencyXid: z
|
||||
.number()
|
||||
.int({ message: "Currency ID must be an integer" })
|
||||
.positive({ message: "Currency ID must be a positive number" }),
|
||||
});
|
||||
|
||||
export type HostBankDetailsSchema = z.infer<typeof hostBankDetailsSchema>;
|
||||
|
||||
@@ -81,8 +81,9 @@ export class AddPaymentDetailsDTO {
|
||||
accountHolderName: string;
|
||||
ifscCode: string;
|
||||
hostXid: number;
|
||||
currencyXid: number;
|
||||
|
||||
constructor(bankXid: number, bankBranchXid: number, accountNumber: string, accountHolderName: string, ifscCode: string, hostXid: number) {
|
||||
constructor(bankXid: number, bankBranchXid: number, accountNumber: string, accountHolderName: string, ifscCode: string, hostXid: number, currencyXid: number) {
|
||||
this.bankXid = bankXid;
|
||||
this.bankBranchXid = bankBranchXid;
|
||||
this.accountNumber = accountNumber;
|
||||
|
||||
@@ -33,7 +33,7 @@ export const handler = safeHandler(async (
|
||||
}
|
||||
|
||||
// Parse request body
|
||||
let body: { bankXid?: number; bankBranchXid?: number; accountNumber?: string; accountHolderName?: string; ifscCode?: string };
|
||||
let body: { bankXid?: number; bankBranchXid?: number; accountNumber?: string; confirmAccountNumber?: string; accountHolderName?: string; ifscCode?: string; currencyXid?: number };
|
||||
|
||||
try {
|
||||
body = event.body ? JSON.parse(event.body) : {};
|
||||
|
||||
47
src/modules/prepopulate/handlers/getAllBankDetails.ts
Normal file
47
src/modules/prepopulate/handlers/getAllBankDetails.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { verifyOnlyMinglarAdminToken } from '@/common/middlewares/jwt/authForOnlyMinglarAdmin';
|
||||
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 { PrePopulateService } from '../services/prepopulate.service';
|
||||
import { verifyHostToken } from '@/common/middlewares/jwt/authForHost';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const prePopulateService = new PrePopulateService(prismaService);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
context?: Context
|
||||
): Promise<APIGatewayProxyResult> => {
|
||||
// Extract token from headers
|
||||
const token = event.headers['x-auth-token'] || event.headers['X-Auth-Token']
|
||||
if (!token) {
|
||||
throw new ApiError(400, 'This is a protected route. Please provide a valid token.');
|
||||
}
|
||||
|
||||
// Authenticate user using the shared authForHost function
|
||||
await verifyHostToken(token);
|
||||
|
||||
const bankDetails = await prePopulateService.getAllBankDetails();
|
||||
|
||||
const currencyDetails = await prePopulateService.getAllCurrencyDetails();
|
||||
|
||||
const result = {
|
||||
banks: bankDetails,
|
||||
currencies: currencyDetails,
|
||||
}
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
message: 'Data retrieved successfully',
|
||||
data: result,
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
35
src/modules/prepopulate/services/prepopulate.service.ts
Normal file
35
src/modules/prepopulate/services/prepopulate.service.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class PrePopulateService {
|
||||
constructor(private prisma: PrismaService) { }
|
||||
|
||||
async getAllBankDetails() {
|
||||
return await this.prisma.banks.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
deletedAt: null,
|
||||
},
|
||||
include: {
|
||||
BankBranches: {
|
||||
select: {
|
||||
id: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async getAllCurrencyDetails() {
|
||||
return await this.prisma.currencies.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
deletedAt: null,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user