Update TypeScript Environment and Refactor Salesforce Mapper Logic
- Updated the import path in next-env.d.ts to reference the development types directory. - Refactored the mapSimActivationFee function in the Salesforce mapper to remove reliance on Is_Default__c and Auto_Add__c fields, simplifying the logic for activation fees and handling default status through service fallback.
This commit is contained in:
parent
827e23c9c6
commit
8195e828e4
@ -413,11 +413,6 @@ export class CheckoutService {
|
|||||||
return { fee: explicitFee, autoAdded: false };
|
return { fee: explicitFee, autoAdded: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
const autoAddFee = activationFees.find(fee => fee.catalogMetadata?.autoAdd);
|
|
||||||
if (autoAddFee) {
|
|
||||||
return { fee: autoAddFee, autoAdded: true };
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaultFee = activationFees.find(fee => fee.catalogMetadata?.isDefault);
|
const defaultFee = activationFees.find(fee => fee.catalogMetadata?.isDefault);
|
||||||
if (defaultFee) {
|
if (defaultFee) {
|
||||||
return { fee: defaultFee, autoAdded: true };
|
return { fee: defaultFee, autoAdded: true };
|
||||||
|
|||||||
2
apps/portal/next-env.d.ts
vendored
2
apps/portal/next-env.d.ts
vendored
@ -1,6 +1,6 @@
|
|||||||
/// <reference types="next" />
|
/// <reference types="next" />
|
||||||
/// <reference types="next/image-types/global" />
|
/// <reference types="next/image-types/global" />
|
||||||
import "./.next/types/routes.d.ts";
|
import "./.next/dev/types/routes.d.ts";
|
||||||
|
|
||||||
// NOTE: This file should not be edited
|
// NOTE: This file should not be edited
|
||||||
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
||||||
|
|||||||
@ -56,11 +56,7 @@ export function SimConfigureView({
|
|||||||
if (!Array.isArray(fees) || fees.length === 0) {
|
if (!Array.isArray(fees) || fees.length === 0) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return (
|
return fees.find(fee => fee.catalogMetadata?.isDefault) || fees[0];
|
||||||
fees.find(fee => fee.catalogMetadata?.autoAdd) ||
|
|
||||||
fees.find(fee => fee.catalogMetadata?.isDefault) ||
|
|
||||||
fees[0]
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const resolveOneTimeCharge = (value?: {
|
const resolveOneTimeCharge = (value?: {
|
||||||
@ -511,8 +507,7 @@ export function SimConfigureView({
|
|||||||
¥{activationFeeDetails.amount.toLocaleString()}
|
¥{activationFeeDetails.amount.toLocaleString()}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{(requiredActivationFee?.catalogMetadata?.autoAdd ||
|
{requiredActivationFee?.catalogMetadata?.isDefault && (
|
||||||
requiredActivationFee?.catalogMetadata?.isDefault) && (
|
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
Required for all new SIM activations
|
Required for all new SIM activations
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@ -186,15 +186,14 @@ export function mapSimActivationFee(
|
|||||||
pricebookEntry?: SalesforcePricebookEntryRecord
|
pricebookEntry?: SalesforcePricebookEntryRecord
|
||||||
): SimActivationFeeCatalogItem {
|
): SimActivationFeeCatalogItem {
|
||||||
const simProduct = mapSimProduct(product, pricebookEntry);
|
const simProduct = mapSimProduct(product, pricebookEntry);
|
||||||
const isDefault = product.Is_Default__c === true;
|
// Auto_Add__c and Is_Default__c are no longer in the query.
|
||||||
const autoAdd = product.Auto_Add__c === true;
|
// Default status is handled by SimServicesService fallback if not present.
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...simProduct,
|
...simProduct,
|
||||||
catalogMetadata: {
|
catalogMetadata: {
|
||||||
...(simProduct.catalogMetadata ?? {}),
|
...(simProduct.catalogMetadata ?? {}),
|
||||||
isDefault,
|
isDefault: false, // Will be handled by service fallback
|
||||||
autoAdd,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -127,7 +127,6 @@ export const simActivationFeeCatalogItemSchema = simCatalogProductSchema.extend(
|
|||||||
catalogMetadata: z
|
catalogMetadata: z
|
||||||
.object({
|
.object({
|
||||||
isDefault: z.boolean().optional(),
|
isDefault: z.boolean().optional(),
|
||||||
autoAdd: z.boolean().optional(),
|
|
||||||
})
|
})
|
||||||
.optional(),
|
.optional(),
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user