Merge branch 'paritosh-main1' of http://git.wdipl.com/Mayank.Mishra/MinglarBackendNestJS into mayankSprint2
This commit is contained in:
@@ -107,7 +107,7 @@ const bucket = config.aws.bucketName;
|
||||
|
||||
@Injectable()
|
||||
export class HostService {
|
||||
constructor(private prisma: PrismaClient) { }
|
||||
constructor(private prisma: PrismaClient) {}
|
||||
|
||||
async createHost(data: CreateHostDto) {
|
||||
return this.prisma.user.create({ data });
|
||||
@@ -554,9 +554,9 @@ export class HostService {
|
||||
id: true,
|
||||
energyLevelName: true,
|
||||
energyIcon: true,
|
||||
energyColor: true
|
||||
}
|
||||
}
|
||||
energyColor: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -775,7 +775,7 @@ export class HostService {
|
||||
if (
|
||||
existingHostCompany &&
|
||||
existingHostCompany.hostStatusInternal ===
|
||||
HOST_STATUS_INTERNAL.HOST_TO_UPDATE &&
|
||||
HOST_STATUS_INTERNAL.HOST_TO_UPDATE &&
|
||||
!isDraft
|
||||
) {
|
||||
hostStatusInternal = HOST_STATUS_INTERNAL.HOST_SUBMITTED;
|
||||
@@ -788,7 +788,7 @@ export class HostService {
|
||||
else if (
|
||||
existingHostCompany &&
|
||||
existingHostCompany.hostStatusInternal ===
|
||||
HOST_STATUS_INTERNAL.HOST_TO_UPDATE &&
|
||||
HOST_STATUS_INTERNAL.HOST_TO_UPDATE &&
|
||||
isDraft
|
||||
) {
|
||||
// keep original
|
||||
@@ -899,19 +899,19 @@ export class HostService {
|
||||
// Safely handle city connection - only connect if valid ID exists
|
||||
cities:
|
||||
parentCompanyData?.cityXid &&
|
||||
!isNaN(Number(parentCompanyData.cityXid))
|
||||
!isNaN(Number(parentCompanyData.cityXid))
|
||||
? { connect: { id: Number(parentCompanyData.cityXid) } }
|
||||
: undefined,
|
||||
|
||||
states:
|
||||
parentCompanyData?.stateXid &&
|
||||
!isNaN(Number(parentCompanyData.stateXid))
|
||||
!isNaN(Number(parentCompanyData.stateXid))
|
||||
? { connect: { id: Number(parentCompanyData.stateXid) } }
|
||||
: undefined,
|
||||
|
||||
countries:
|
||||
parentCompanyData?.countryXid &&
|
||||
!isNaN(Number(parentCompanyData.countryXid))
|
||||
!isNaN(Number(parentCompanyData.countryXid))
|
||||
? { connect: { id: Number(parentCompanyData.countryXid) } }
|
||||
: undefined,
|
||||
pinCode: parentCompanyData.pinCode || null,
|
||||
@@ -1061,19 +1061,19 @@ export class HostService {
|
||||
address2: parentCompanyData.address2 || null,
|
||||
cities:
|
||||
parentCompanyData?.cityXid &&
|
||||
!isNaN(Number(parentCompanyData.cityXid))
|
||||
!isNaN(Number(parentCompanyData.cityXid))
|
||||
? { connect: { id: Number(parentCompanyData.cityXid) } }
|
||||
: undefined,
|
||||
|
||||
states:
|
||||
parentCompanyData?.stateXid &&
|
||||
!isNaN(Number(parentCompanyData.stateXid))
|
||||
!isNaN(Number(parentCompanyData.stateXid))
|
||||
? { connect: { id: Number(parentCompanyData.stateXid) } }
|
||||
: undefined,
|
||||
|
||||
countries:
|
||||
parentCompanyData?.countryXid &&
|
||||
!isNaN(Number(parentCompanyData.countryXid))
|
||||
!isNaN(Number(parentCompanyData.countryXid))
|
||||
? { connect: { id: Number(parentCompanyData.countryXid) } }
|
||||
: undefined,
|
||||
pinCode: parentCompanyData.pinCode || null,
|
||||
@@ -1119,19 +1119,19 @@ export class HostService {
|
||||
address2: parentCompanyData.address2 || null,
|
||||
cities:
|
||||
parentCompanyData?.cityXid &&
|
||||
!isNaN(Number(parentCompanyData.cityXid))
|
||||
!isNaN(Number(parentCompanyData.cityXid))
|
||||
? { connect: { id: Number(parentCompanyData.cityXid) } }
|
||||
: undefined,
|
||||
|
||||
states:
|
||||
parentCompanyData?.stateXid &&
|
||||
!isNaN(Number(parentCompanyData.stateXid))
|
||||
!isNaN(Number(parentCompanyData.stateXid))
|
||||
? { connect: { id: Number(parentCompanyData.stateXid) } }
|
||||
: undefined,
|
||||
|
||||
countries:
|
||||
parentCompanyData?.countryXid &&
|
||||
!isNaN(Number(parentCompanyData.countryXid))
|
||||
!isNaN(Number(parentCompanyData.countryXid))
|
||||
? { connect: { id: Number(parentCompanyData.countryXid) } }
|
||||
: undefined,
|
||||
pinCode: parentCompanyData.pinCode || null,
|
||||
@@ -2044,11 +2044,11 @@ export class HostService {
|
||||
id: true,
|
||||
userRefNumber: true,
|
||||
firstName: true,
|
||||
lastName: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lastName: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2379,7 +2379,6 @@ export class HostService {
|
||||
return v === true || v === 'true' || v === 1 || v === '1';
|
||||
};
|
||||
|
||||
|
||||
const toNumber = (v: any) =>
|
||||
v === undefined || v === null || v === '' ? undefined : Number(v);
|
||||
|
||||
@@ -2515,9 +2514,9 @@ export class HostService {
|
||||
const rootTaxes =
|
||||
taxIds.length > 0
|
||||
? await this.prisma.taxes.findMany({
|
||||
where: { id: { in: taxIds }, isActive: true },
|
||||
select: { id: true, taxPer: true },
|
||||
})
|
||||
where: { id: { in: taxIds }, isActive: true },
|
||||
select: { id: true, taxPer: true },
|
||||
})
|
||||
: [];
|
||||
|
||||
if (taxIds.length !== rootTaxes.length) {
|
||||
@@ -2980,7 +2979,7 @@ export class HostService {
|
||||
|
||||
await tx.activityPickUpTransport.deleteMany({
|
||||
where: {
|
||||
activityXid: Number(activityXid)
|
||||
activityXid: Number(activityXid),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2991,7 +2990,6 @@ export class HostService {
|
||||
|
||||
if (Array.isArray(payload.pickupTransports)) {
|
||||
for (const transport of payload.pickupTransports) {
|
||||
|
||||
// ✅ CREATE TRANSPORT ONCE PER MODE
|
||||
const pickupTransport = await tx.activityPickUpTransport.create({
|
||||
data: {
|
||||
@@ -3002,7 +3000,6 @@ export class HostService {
|
||||
|
||||
if (Array.isArray(transport.pickupDetails)) {
|
||||
for (const detail of transport.pickupDetails) {
|
||||
|
||||
const totalPrice = toNumber(detail.transportTotalPrice) ?? 0;
|
||||
|
||||
const { basePrice, taxDetails } = computeBasePriceAndTaxes(
|
||||
@@ -3039,7 +3036,6 @@ export class HostService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* --------------------------------
|
||||
* 1️⃣2️⃣ CLEAN & CREATE NAVIGATION MODES WITH TAXES
|
||||
* -------------------------------- */
|
||||
@@ -3240,6 +3236,25 @@ export class HostService {
|
||||
});
|
||||
}
|
||||
|
||||
/* --------------------------------
|
||||
* ✅ MARK ACTIVITY SUGGESTIONS AS REVIEWED
|
||||
* (REJECTED → ENHANCE → SUBMIT FLOW)
|
||||
* -------------------------------- */
|
||||
if (wasRejected && !isDraft) {
|
||||
await tx.activitySuggestions.updateMany({
|
||||
where: {
|
||||
activityXid: activityXid,
|
||||
isActive: true,
|
||||
isReviewed: false,
|
||||
},
|
||||
data: {
|
||||
isReviewed: true,
|
||||
reviewedByXid: userId,
|
||||
reviewedOn: new Date(),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/* --------------------------------
|
||||
* 1️⃣8️⃣ ACTIVITY TRACK
|
||||
* -------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user