Merge branch 'mayankSprint2' of http://git.wdipl.com/Mayank.Mishra/MinglarBackendNestJS into paritosh-main1
This commit is contained in:
@@ -569,7 +569,7 @@ model AgeRestrictions {
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
ActivityEligibility ActivityEligibility[]
|
||||
// ActivityEligibility ActivityEligibility[]
|
||||
|
||||
@@map("age_restrictions")
|
||||
@@schema("mst")
|
||||
@@ -1046,8 +1046,13 @@ model ActivityEligibility {
|
||||
activityXid Int @map("activity_xid")
|
||||
activity Activities @relation(fields: [activityXid], references: [id], onDelete: Cascade)
|
||||
isAgeRestriction Boolean @default(false) @map("is_age_restriction")
|
||||
ageRestrictionXid Int? @map("age_restriction_xid")
|
||||
ageRestriction AgeRestrictions? @relation(fields: [ageRestrictionXid], references: [id], onDelete: Restrict)
|
||||
// ageRestrictionXid Int? @map("age_restriction_xid")
|
||||
// ageRestriction AgeRestrictions? @relation(fields: [ageRestrictionXid], references: [id], onDelete: Restrict)
|
||||
ageRestrictionName String? @map("age_restriction_name") @db.VarChar(30)
|
||||
ageEntered Int? @map("age_entered")
|
||||
ageIn String? @map("age_in") @db.VarChar(30)
|
||||
minAge Int? @map("min_age")
|
||||
maxAge Int? @map("max_age")
|
||||
isWeightRestriction Boolean @default(false) @map("is_weight_restriction")
|
||||
weightRestrictionName String? @map("weight_restriction_name") @db.VarChar(30)
|
||||
weightEntered Int? @map("weight_entered")
|
||||
@@ -1064,6 +1069,8 @@ model ActivityEligibility {
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
// ageRestrictions AgeRestrictions? @relation(fields: [ageRestrictionsId], references: [id])
|
||||
// ageRestrictionsId Int?
|
||||
|
||||
@@map("activity_eligibility")
|
||||
@@schema("act")
|
||||
|
||||
@@ -22,3 +22,8 @@ export const USER_STATUS = {
|
||||
DE_ACTIVATED: "De-activated",
|
||||
REJECTED: "Rejected"
|
||||
}
|
||||
|
||||
export const RESTRICTION_NAME = {
|
||||
ABOVE: "Above",
|
||||
BELOW: "Below",
|
||||
}
|
||||
@@ -62,7 +62,11 @@ export const EquipmentDto = z.object({
|
||||
/* ================= ELIGIBILITY ================= */
|
||||
export const EligibilityDto = z.object({
|
||||
isAgeRestriction: z.boolean().optional().default(false),
|
||||
ageRestrictionXid: z.number().int().nullable().optional(),
|
||||
ageRestrictionName: z.string().nullable().optional(),
|
||||
ageEntered: z.number().int().nullable().optional(),
|
||||
ageIn: z.string().nullable().optional(),
|
||||
minAge: z.number().int().nullable().optional(),
|
||||
maxAge: z.number().int().nullable().optional(),
|
||||
|
||||
isWeightRestriction: z.boolean().optional().default(false),
|
||||
weightRestrictionName: z.string().nullable().optional(),
|
||||
@@ -159,6 +163,9 @@ export const CreateActivityDto = z.object({
|
||||
otherDetails: OtherDetailsDto.optional(),
|
||||
|
||||
allowedEntryTypes: z.array(z.number().int()).optional().default([]),
|
||||
navigationModeIsChargeable: z.boolean().optional().default(false),
|
||||
trainerTotalAmount: z.number().int().optional().default(0),
|
||||
navigationModeTotalPrice: z.number().int().optional().default(0),
|
||||
});
|
||||
|
||||
export type CreateActivityInput = z.infer<typeof CreateActivityDto>;
|
||||
|
||||
@@ -27,12 +27,14 @@ import {
|
||||
MINGLAR_STATUS_INTERNAL,
|
||||
} from '../../../common/utils/constants/minglar.constant';
|
||||
import {
|
||||
RESTRICTION_NAME,
|
||||
ROLE,
|
||||
ROLE_NAME,
|
||||
USER_STATUS,
|
||||
} from '../../../common/utils/constants/common.constant';
|
||||
import { getPresignedUrl } from '../../../common/middlewares/aws/getPreSignedUrl';
|
||||
import config from '../../../config/config';
|
||||
import { CreateActivityInput } from '../dto/createActivity.schema';
|
||||
|
||||
function sanitizeDocumentName(name?: string) {
|
||||
if (!name) return null;
|
||||
@@ -105,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 });
|
||||
@@ -1894,14 +1896,18 @@ export class HostService {
|
||||
select: {
|
||||
id: true,
|
||||
isAgeRestriction: true,
|
||||
ageRestriction: {
|
||||
select: {
|
||||
id: true,
|
||||
// ageRestriction: {
|
||||
// select: {
|
||||
// id: true,
|
||||
// ageRestrictionName: true,
|
||||
// minAge: true,
|
||||
// maxAge: true,
|
||||
// },
|
||||
// },
|
||||
ageRestrictionName: true,
|
||||
ageEntered: true,
|
||||
minAge: true,
|
||||
maxAge: true,
|
||||
},
|
||||
},
|
||||
isWeightRestriction: true,
|
||||
weightRestrictionName: true,
|
||||
weightEntered: true,
|
||||
@@ -2278,7 +2284,7 @@ export class HostService {
|
||||
* ActivityPickUpTransport/Details + ActivityNavigationModes + ActivityEquipments +
|
||||
* ActivityAmenities + ActivityEligibility
|
||||
*/
|
||||
async createOrUpdateActivity(userId: number, payload: any, isDraft: boolean) {
|
||||
async createOrUpdateActivity(userId: number, payload: CreateActivityInput, isDraft: boolean) {
|
||||
/* =====================================================
|
||||
* HELPERS
|
||||
* ===================================================== */
|
||||
@@ -2397,6 +2403,36 @@ export class HostService {
|
||||
throw new ApiError(400, 'Invalid or inactive tax provided');
|
||||
}
|
||||
|
||||
const eligibility = payload.eligibility;
|
||||
|
||||
if (eligibility?.isAgeRestriction) {
|
||||
if (eligibility.ageRestrictionName == RESTRICTION_NAME.ABOVE) {
|
||||
eligibility.minAge = toNumber(eligibility.ageEntered);
|
||||
eligibility.maxAge = 150;
|
||||
} else if (eligibility.ageRestrictionName == RESTRICTION_NAME.BELOW) {
|
||||
eligibility.maxAge = toNumber(eligibility.ageEntered);
|
||||
eligibility.minAge = 0;
|
||||
}
|
||||
}
|
||||
if (eligibility?.isWeightRestriction) {
|
||||
if (eligibility.weightRestrictionName == RESTRICTION_NAME.ABOVE) {
|
||||
eligibility.minWeight = toNumber(eligibility.weightEntered);
|
||||
eligibility.maxWeight = 400;
|
||||
} else if (eligibility.weightRestrictionName == RESTRICTION_NAME.BELOW) {
|
||||
eligibility.maxWeight = toNumber(eligibility.weightEntered);
|
||||
eligibility.minWeight = 0;
|
||||
}
|
||||
}
|
||||
if (eligibility?.isHeightRestriction) {
|
||||
if (eligibility.heightRestrictionName == RESTRICTION_NAME.ABOVE) {
|
||||
eligibility.minHeight = toNumber(eligibility.heightEntered);
|
||||
eligibility.maxHeight = 250;
|
||||
} else if (eligibility.heightRestrictionName == RESTRICTION_NAME.BELOW) {
|
||||
eligibility.maxHeight = toNumber(eligibility.heightEntered);
|
||||
eligibility.minHeight = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* =====================================================
|
||||
* TRANSACTION
|
||||
* ===================================================== */
|
||||
@@ -2896,7 +2932,6 @@ export class HostService {
|
||||
data: {
|
||||
activityXid,
|
||||
isAgeRestriction: toBool(payload.eligibility.isAgeRestriction),
|
||||
ageRestrictionXid: toNumber(payload.eligibility.ageRestrictionXid),
|
||||
isWeightRestriction: toBool(
|
||||
payload.eligibility.isWeightRestriction,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user