|
|
|
@ -17,9 +17,11 @@ export function normalizeMarriageField(raw: any): MarriageField | null { |
|
|
|
const key = raw.key ?? raw.field_key ?? raw.fieldKey ?? raw.name ?? ""; |
|
|
|
const label = raw.label ?? raw.title ?? ""; |
|
|
|
const value = raw.value ?? raw.val ?? ""; |
|
|
|
const type = raw.type ?? raw.field_type ?? raw.fieldType ?? "text"; |
|
|
|
return { |
|
|
|
key: String(key), |
|
|
|
label: String(label), |
|
|
|
type: String(type), |
|
|
|
value: value ?? "", |
|
|
|
option_id: raw.option_id ?? raw.optionId ?? null, |
|
|
|
private: Boolean(raw.private ?? raw.is_private ?? false), |
|
|
|
@ -95,17 +97,36 @@ export function normalizeMarriageProfile( |
|
|
|
const active_case: MarriageActiveCase | null = |
|
|
|
rawActiveCase && typeof rawActiveCase === "object" |
|
|
|
? { |
|
|
|
case_id: String( |
|
|
|
case_id: Number( |
|
|
|
rawActiveCase.case_id ?? |
|
|
|
rawActiveCase.caseId ?? |
|
|
|
rawActiveCase.id ?? |
|
|
|
"", |
|
|
|
0, |
|
|
|
), |
|
|
|
status: |
|
|
|
rawActiveCase.status ?? |
|
|
|
rawActiveCase.case_status ?? |
|
|
|
rawActiveCase.caseStatus ?? |
|
|
|
"", |
|
|
|
"introduced", |
|
|
|
introduced_at: |
|
|
|
rawActiveCase.introduced_at ?? |
|
|
|
rawActiveCase.introducedAt ?? |
|
|
|
new Date().toISOString(), |
|
|
|
contact_shared_at: |
|
|
|
rawActiveCase.contact_shared_at ?? |
|
|
|
rawActiveCase.contactSharedAt ?? |
|
|
|
null, |
|
|
|
minutes_since_contact_shared: |
|
|
|
rawActiveCase.minutes_since_contact_shared ?? |
|
|
|
rawActiveCase.minutesSinceContactShared ?? |
|
|
|
null, |
|
|
|
can_report_no_contact: Boolean( |
|
|
|
rawActiveCase.can_report_no_contact ?? |
|
|
|
rawActiveCase.canReportNoContact ?? |
|
|
|
false, |
|
|
|
), |
|
|
|
my_action: |
|
|
|
rawActiveCase.my_action ?? rawActiveCase.myAction ?? "pending", |
|
|
|
other_action: |
|
|
|
rawActiveCase.other_action ?? |
|
|
|
rawActiveCase.otherAction ?? |
|
|
|
@ -118,6 +139,24 @@ export function normalizeMarriageProfile( |
|
|
|
const active_subscription: MarriageActiveSubscription | null = |
|
|
|
rawActiveSub && typeof rawActiveSub === "object" |
|
|
|
? { |
|
|
|
id: Number(rawActiveSub.id ?? 1), |
|
|
|
plan: { |
|
|
|
id: Number(rawActiveSub.plan?.id ?? 1), |
|
|
|
title: String(rawActiveSub.plan?.title ?? "Subscription"), |
|
|
|
price: String(rawActiveSub.plan?.price ?? "0"), |
|
|
|
plan_type: String(rawActiveSub.plan?.plan_type ?? "standard"), |
|
|
|
duration_days: |
|
|
|
rawActiveSub.plan?.duration_days !== undefined |
|
|
|
? Number(rawActiveSub.plan.duration_days) |
|
|
|
: null, |
|
|
|
usage_limit: |
|
|
|
rawActiveSub.plan?.usage_limit !== undefined |
|
|
|
? Number(rawActiveSub.plan.usage_limit) |
|
|
|
: null, |
|
|
|
}, |
|
|
|
start_date: String(rawActiveSub.start_date ?? new Date().toISOString()), |
|
|
|
end_date: rawActiveSub.end_date ? String(rawActiveSub.end_date) : null, |
|
|
|
total_usages: Number(rawActiveSub.total_usages ?? 0), |
|
|
|
is_active: Boolean( |
|
|
|
rawActiveSub.is_active ?? |
|
|
|
rawActiveSub.isActive ?? |
|
|
|
@ -130,10 +169,10 @@ export function normalizeMarriageProfile( |
|
|
|
rawActiveSub.valid ?? |
|
|
|
true, |
|
|
|
), |
|
|
|
plan_title: |
|
|
|
rawActiveSub.plan_title ?? rawActiveSub.planTitle ?? undefined, |
|
|
|
expires_at: |
|
|
|
rawActiveSub.expires_at ?? rawActiveSub.expiresAt ?? undefined, |
|
|
|
remaining_days: |
|
|
|
rawActiveSub.remaining_days !== undefined |
|
|
|
? Number(rawActiveSub.remaining_days) |
|
|
|
: undefined, |
|
|
|
} |
|
|
|
: null; |
|
|
|
|
|
|
|
@ -144,19 +183,7 @@ export function normalizeMarriageProfile( |
|
|
|
? { |
|
|
|
id: Number(rawRecommendedPlan.id ?? 1), |
|
|
|
title: String(rawRecommendedPlan.title ?? ""), |
|
|
|
price: Number(rawRecommendedPlan.price ?? 50), |
|
|
|
discounted_price: |
|
|
|
rawRecommendedPlan.discounted_price !== undefined |
|
|
|
? Number(rawRecommendedPlan.discounted_price) |
|
|
|
: rawRecommendedPlan.discountedPrice !== undefined |
|
|
|
? Number(rawRecommendedPlan.discountedPrice) |
|
|
|
: undefined, |
|
|
|
discount_percent: |
|
|
|
rawRecommendedPlan.discount_percent !== undefined |
|
|
|
? Number(rawRecommendedPlan.discount_percent) |
|
|
|
: rawRecommendedPlan.discountPercent !== undefined |
|
|
|
? Number(rawRecommendedPlan.discountPercent) |
|
|
|
: undefined, |
|
|
|
price: String(rawRecommendedPlan.price ?? "50"), |
|
|
|
} |
|
|
|
: null; |
|
|
|
|
|
|
|
|