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 };
|
||||
}
|
||||
|
||||
const autoAddFee = activationFees.find(fee => fee.catalogMetadata?.autoAdd);
|
||||
if (autoAddFee) {
|
||||
return { fee: autoAddFee, autoAdded: true };
|
||||
}
|
||||
|
||||
const defaultFee = activationFees.find(fee => fee.catalogMetadata?.isDefault);
|
||||
if (defaultFee) {
|
||||
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/image-types/global" />
|
||||
import "./.next/types/routes.d.ts";
|
||||
import "./.next/dev/types/routes.d.ts";
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// 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) {
|
||||
return undefined;
|
||||
}
|
||||
return (
|
||||
fees.find(fee => fee.catalogMetadata?.autoAdd) ||
|
||||
fees.find(fee => fee.catalogMetadata?.isDefault) ||
|
||||
fees[0]
|
||||
);
|
||||
return fees.find(fee => fee.catalogMetadata?.isDefault) || fees[0];
|
||||
};
|
||||
|
||||
const resolveOneTimeCharge = (value?: {
|
||||
@ -511,8 +507,7 @@ export function SimConfigureView({
|
||||
¥{activationFeeDetails.amount.toLocaleString()}
|
||||
</span>
|
||||
</div>
|
||||
{(requiredActivationFee?.catalogMetadata?.autoAdd ||
|
||||
requiredActivationFee?.catalogMetadata?.isDefault) && (
|
||||
{requiredActivationFee?.catalogMetadata?.isDefault && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Required for all new SIM activations
|
||||
</p>
|
||||
|
||||
@ -186,15 +186,14 @@ export function mapSimActivationFee(
|
||||
pricebookEntry?: SalesforcePricebookEntryRecord
|
||||
): SimActivationFeeCatalogItem {
|
||||
const simProduct = mapSimProduct(product, pricebookEntry);
|
||||
const isDefault = product.Is_Default__c === true;
|
||||
const autoAdd = product.Auto_Add__c === true;
|
||||
// Auto_Add__c and Is_Default__c are no longer in the query.
|
||||
// Default status is handled by SimServicesService fallback if not present.
|
||||
|
||||
return {
|
||||
...simProduct,
|
||||
catalogMetadata: {
|
||||
...(simProduct.catalogMetadata ?? {}),
|
||||
isDefault,
|
||||
autoAdd,
|
||||
isDefault: false, // Will be handled by service fallback
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -127,7 +127,6 @@ export const simActivationFeeCatalogItemSchema = simCatalogProductSchema.extend(
|
||||
catalogMetadata: z
|
||||
.object({
|
||||
isDefault: z.boolean().optional(),
|
||||
autoAdd: z.boolean().optional(),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user