made minor fixes
This commit is contained in:
@@ -648,23 +648,23 @@ model HostHeader {
|
||||
userXid Int @map("user_xid")
|
||||
user User @relation("HostUser", fields: [userXid], references: [id], onDelete: Cascade)
|
||||
companyName String @map("company_name") @db.VarChar(100)
|
||||
hostRefNumber String @map("host_ref_number") @db.VarChar(30)
|
||||
address1 String @map("address_1") @db.VarChar(150)
|
||||
hostRefNumber String? @map("host_ref_number") @db.VarChar(30)
|
||||
address1 String? @map("address_1") @db.VarChar(150)
|
||||
address2 String? @map("address_2") @db.VarChar(150)
|
||||
cityXid Int @map("city_xid")
|
||||
cities Cities @relation(fields: [cityXid], references: [id], onDelete: Restrict)
|
||||
stateXid Int @map("state_xid")
|
||||
states States @relation(fields: [stateXid], references: [id], onDelete: Restrict)
|
||||
cityXid Int? @map("city_xid")
|
||||
cities Cities? @relation(fields: [cityXid], references: [id], onDelete: Restrict)
|
||||
stateXid Int? @map("state_xid")
|
||||
states States? @relation(fields: [stateXid], references: [id], onDelete: Restrict)
|
||||
countryXid Int? @map("country_xid")
|
||||
countries Countries? @relation(fields: [countryXid], references: [id], onDelete: Restrict)
|
||||
pinCode String @map("pin_code") @db.VarChar(30)
|
||||
pinCode String? @map("pin_code") @db.VarChar(30)
|
||||
logoPath String? @map("logo_path") @db.VarChar(400)
|
||||
isSubsidairy Boolean @default(false) @map("is_subsidairy")
|
||||
registrationNumber String @map("registration_number") @db.VarChar(30)
|
||||
panNumber String @map("pan_number") @db.VarChar(30)
|
||||
isSubsidairy Boolean? @default(false) @map("is_subsidairy")
|
||||
registrationNumber String? @map("registration_number") @db.VarChar(30)
|
||||
panNumber String? @map("pan_number") @db.VarChar(30)
|
||||
gstNumber String? @map("gst_number") @db.VarChar(30)
|
||||
formationDate DateTime @map("formation_date")
|
||||
companyType String @map("company_type") @db.VarChar(30)
|
||||
formationDate DateTime? @map("formation_date")
|
||||
companyType String? @map("company_type") @db.VarChar(30)
|
||||
websiteUrl String? @map("website_url") @db.VarChar(50)
|
||||
instagramUrl String? @map("instagram_url") @db.VarChar(80)
|
||||
facebookUrl String? @map("facebook_url") @db.VarChar(80)
|
||||
@@ -673,16 +673,16 @@ model HostHeader {
|
||||
currencyXid Int? @map("currency_xid")
|
||||
currencies Currencies? @relation(fields: [currencyXid], references: [id], onDelete: Restrict)
|
||||
stepper Int? @default(1) @map("stepper")
|
||||
hostStatusInternal String @default("pending") @map("host_status_internal") @db.VarChar(20)
|
||||
hostStatusDisplay String @default("pending") @map("host_status_Display") @db.VarChar(20)
|
||||
adminStatusInternal String @default("pending") @map("admin_status_internal") @db.VarChar(20)
|
||||
adminStatusDisplay String @default("pending") @map("admin_status_display") @db.VarChar(20)
|
||||
hostStatusInternal String? @default("pending") @map("host_status_internal") @db.VarChar(20)
|
||||
hostStatusDisplay String? @default("pending") @map("host_status_Display") @db.VarChar(20)
|
||||
adminStatusInternal String? @default("pending") @map("admin_status_internal") @db.VarChar(20)
|
||||
adminStatusDisplay String? @default("pending") @map("admin_status_display") @db.VarChar(20)
|
||||
amStatus String? @default("pending") @map("am_status") @db.VarChar(20)
|
||||
agreementAccepted Boolean @default(false) @map("agreement_accepted")
|
||||
agreementAccepted Boolean? @default(false) @map("agreement_accepted")
|
||||
accountManagerXid Int? @map("account_manager_xid")
|
||||
accountManager User? @relation("AccountManager", fields: [accountManagerXid], references: [id], onDelete: Restrict)
|
||||
assignedOn DateTime? @map("assigned_on")
|
||||
isApproved Boolean @default(false) @map("is_approved")
|
||||
isApproved Boolean? @default(false) @map("is_approved")
|
||||
agreementStartDate DateTime? @map("agreement_start_date")
|
||||
durationNumber Int? @map("duration_number")
|
||||
durationFrequency String? @map("duration_frequency") @db.VarChar(20)
|
||||
|
||||
@@ -279,7 +279,7 @@ acceptHostApplication:
|
||||
events:
|
||||
- httpApi:
|
||||
path: /minglaradmin/hosthub/hosts/accept-host-application
|
||||
method: post
|
||||
method: patch
|
||||
|
||||
acceptHostApplicationMinglar:
|
||||
handler: src/modules/minglaradmin/handlers/hosthub/onboarding/acceptHostAppMinglar.handler
|
||||
@@ -295,7 +295,7 @@ acceptHostApplicationMinglar:
|
||||
events:
|
||||
- httpApi:
|
||||
path: /minglaradmin/hosthub/onboarding/accept-host-application-minglar
|
||||
method: post
|
||||
method: patch
|
||||
|
||||
rejectHostApplication:
|
||||
handler: src/modules/minglaradmin/handlers/hosthub/onboarding/rejectHostApplication.handler
|
||||
|
||||
@@ -27,11 +27,11 @@ export const parentCompanySchema = z.object({
|
||||
// Parent companies do NOT need this
|
||||
isSubsidairy: z.boolean().optional(),
|
||||
|
||||
registrationNumber: z.string().min(1, "Registration number is required"),
|
||||
panNumber: z.string().min(1, "PAN number is required"),
|
||||
registrationNumber: z.string().optional(),
|
||||
panNumber: z.string().optional(),
|
||||
gstNumber: z.string().optional(),
|
||||
|
||||
formationDate: z.string().refine((val) => !isNaN(Date.parse(val)), {
|
||||
formationDate: z.string().optional().refine((val) => !isNaN(Date.parse(val)), {
|
||||
message: "Formation date must be a valid date",
|
||||
}),
|
||||
|
||||
@@ -58,7 +58,7 @@ export const hostCompanyDetailsSchema = z.object({
|
||||
registrationNumber: z.string().optional(),
|
||||
panNumber: z.string().min(1, "PAN number is required"),
|
||||
gstNumber: z.string().optional(),
|
||||
formationDate: z.string().refine((val) => !isNaN(Date.parse(val)), {
|
||||
formationDate: z.string().optional().refine((val) => !isNaN(Date.parse(val)), {
|
||||
message: "Formation date must be a valid date",
|
||||
}),
|
||||
companyType: z.string().min(1, "Company type is required"),
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
} from '../../../../../common/utils/validation/host/hostCompanyDetails.validation';
|
||||
import { HostService } from '../../../services/host.service';
|
||||
import { sendEmailToAM, sendEmailToMinglarAdmin } from '../../../services/sendHostResubmitEmailToAM.service';
|
||||
import { HOST_STATUS_INTERNAL } from '@/common/utils/constants/host.constant';
|
||||
|
||||
const prisma = new PrismaService();
|
||||
const hostService = new HostService(prisma);
|
||||
@@ -149,17 +150,31 @@ export const handler = safeHandler(async (event: APIGatewayProxyEvent): Promise<
|
||||
// 5) Parse companyDetails
|
||||
const companyDetailsRaw = normalizeJsonField(fields, "companyDetails");
|
||||
if (!companyDetailsRaw) throw new ApiError(400, "companyDetails is required.");
|
||||
// --- FIXED HOST ID INITIALIZATION ---
|
||||
let hostId: number;
|
||||
|
||||
// Get existing host to determine host ID for folder structure
|
||||
const existingHost = await prisma.hostHeader.findFirst({
|
||||
// Check if host already exists
|
||||
let existingHost = await prisma.hostHeader.findFirst({
|
||||
where: { userXid: userInfo.id },
|
||||
});
|
||||
|
||||
let hostId: number;
|
||||
if (existingHost) {
|
||||
hostId = existingHost.id;
|
||||
if (!existingHost) {
|
||||
// Create empty hostHeader FIRST before uploading files
|
||||
const createdHost = await prisma.hostHeader.create({
|
||||
data: {
|
||||
userXid: Number(userInfo.id),
|
||||
companyName: "", // temporary placeholder
|
||||
hostStatusInternal: HOST_STATUS_INTERNAL.DRAFT, // or whatever default
|
||||
}
|
||||
});
|
||||
|
||||
hostId = createdHost.id;
|
||||
existingHost = createdHost;
|
||||
|
||||
console.log("🔥 HostHeader created first. Host ID:", hostId);
|
||||
} else {
|
||||
hostId = userInfo.id;
|
||||
hostId = existingHost.id;
|
||||
console.log("ℹ Using existing Host ID:", hostId);
|
||||
}
|
||||
|
||||
// Define uploadToS3 function (same as before)
|
||||
@@ -376,13 +391,13 @@ export const handler = safeHandler(async (event: APIGatewayProxyEvent): Promise<
|
||||
},
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
message: isDraft
|
||||
? 'Company details saved as draft successfully.'
|
||||
message: isDraft
|
||||
? 'Company details saved as draft successfully.'
|
||||
: 'Company (and parent if provided) details and documents uploaded successfully.',
|
||||
data: {
|
||||
id: createdOrUpdated.id,
|
||||
data: {
|
||||
id: createdOrUpdated.id,
|
||||
hostRefNumber: (createdOrUpdated as any).hostRefNumber,
|
||||
isDraft
|
||||
isDraft
|
||||
}
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -90,7 +90,7 @@ export class PrePopulateService {
|
||||
}
|
||||
|
||||
async getAllDocumentTypeWithCountryStateCity() {
|
||||
const [documentDetails, countryDetails, stateDetails, cityDetails] =
|
||||
const [documentDetails, countryDetails, stateDetails] =
|
||||
await this.prisma.$transaction([
|
||||
this.prisma.documentType.findMany({
|
||||
where: { isActive: true, isVisible: true },
|
||||
@@ -102,12 +102,9 @@ export class PrePopulateService {
|
||||
this.prisma.states.findMany({
|
||||
where: { isActive: true },
|
||||
}),
|
||||
this.prisma.cities.findMany({
|
||||
where: { isActive: true },
|
||||
}),
|
||||
]);
|
||||
|
||||
return { documentDetails, countryDetails, stateDetails, cityDetails };
|
||||
return { documentDetails, countryDetails, stateDetails };
|
||||
}
|
||||
|
||||
async getAllFrequencies() {
|
||||
|
||||
Reference in New Issue
Block a user