Skip to content

Commit

Permalink
fixing changes to match IntegrationBranch
Browse files Browse the repository at this point in the history
  • Loading branch information
taeJungCaci committed Oct 22, 2024
1 parent bfebbf3 commit c0564c6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
2 changes: 2 additions & 0 deletions src/components/Office/ShipmentForm/ShipmentForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ const ShipmentForm = (props) => {
});
} else if (isMobileHome) {
schema = mobileHomeShipmentSchema();
showDeliveryFields = true;
showPickupFields = true;
} else if (isBoat) {
schema = boatShipmentSchema();
showDeliveryFields = true;
Expand Down
1 change: 1 addition & 0 deletions src/components/Office/ShipmentForm/ShipmentForm.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2238,6 +2238,7 @@ describe('ShipmentForm component', () => {
).not.toBeInTheDocument();
});
});

describe('creating a new Mobile Home shipment', () => {
it('renders the Mobile Home shipment form correctly', async () => {
renderWithRouter(<ShipmentForm {...defaultProps} shipmentType={SHIPMENT_OPTIONS.MOBILE_HOME} isCreatePage />);
Expand Down
45 changes: 23 additions & 22 deletions src/utils/formatMtoShipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,10 +519,9 @@ export function convertInchesToFeetAndInches(totalInches) {
return { feet, inches };
}

// Initial values for boat shipment
export function formatBoatShipmentForDisplay(boatShipment, initialValues) {
const { year, make, model, lengthInInches, widthInInches, heightInInches, hasTrailer, isRoadworthy } =
boatShipment || {};
// Initial values for mobile home shipment
export function formatMobileHomeShipmentForDisplay(mobileHomeShipment, initialValues) {
const { year, make, model, lengthInInches, widthInInches, heightInInches } = mobileHomeShipment || {};

const length = convertInchesToFeetAndInches(lengthInInches);
const width = convertInchesToFeetAndInches(widthInInches);
Expand All @@ -538,43 +537,35 @@ export function formatBoatShipmentForDisplay(boatShipment, initialValues) {
widthInches: width.inches,
heightFeet: height.feet,
heightInches: height.inches,
hasTrailer: hasTrailer ? 'true' : 'false',
isRoadworthy: isRoadworthy === null ? '' : isRoadworthy?.toString(),
...initialValues,
};

return displayValues;
}

export function formatBoatShipmentForAPI(values) {
export function formatMobileHomeShipmentForAPI(values) {
const totalLengthInInches = toTotalInches(values.lengthFeet, values.lengthInches);
const totalWidthInInches = toTotalInches(values.widthFeet, values.widthInches);
const totalHeightInInches = toTotalInches(values.heightFeet, values.heightInches);
const hasTrailerBool = values.hasTrailer === 'true';
const isRoadworthyBool = values.isRoadworthy && hasTrailerBool ? values.isRoadworthy === 'true' : null;

const boatShipment = {
type: values.type,
const mobileHomeShipment = {
year: Number(values.year),
make: values.make,
model: values.model,
lengthInInches: totalLengthInInches,
widthInInches: totalWidthInInches,
heightInInches: totalHeightInInches,
hasTrailer: values.hasTrailer === 'true',
isRoadworthy: values.hasTrailer === 'true' ? isRoadworthyBool : null,
};
const mtoShipmentType =
boatShipment.type === boatShipmentTypes.TOW_AWAY ? SHIPMENT_TYPES.BOAT_TOW_AWAY : SHIPMENT_TYPES.BOAT_HAUL_AWAY;

return {
shipmentType: mtoShipmentType,
boatShipment,
mobileHomeShipment,
};
}

export function formatMobileHomeShipmentForDisplay(mobileHomeShipment, initialValues) {
const { year, make, model, lengthInInches, widthInInches, heightInInches } = mobileHomeShipment || {};
// Initial values for boat shipment
export function formatBoatShipmentForDisplay(boatShipment, initialValues) {
const { year, make, model, lengthInInches, widthInInches, heightInInches, hasTrailer, isRoadworthy } =
boatShipment || {};

const length = convertInchesToFeetAndInches(lengthInInches);
const width = convertInchesToFeetAndInches(widthInInches);
Expand All @@ -590,28 +581,38 @@ export function formatMobileHomeShipmentForDisplay(mobileHomeShipment, initialVa
widthInches: width.inches,
heightFeet: height.feet,
heightInches: height.inches,
hasTrailer: hasTrailer ? 'true' : 'false',
isRoadworthy: isRoadworthy === null ? '' : isRoadworthy?.toString(),
...initialValues,
};

return displayValues;
}

export function formatMobileHomeShipmentForAPI(values) {
export function formatBoatShipmentForAPI(values) {
const totalLengthInInches = toTotalInches(values.lengthFeet, values.lengthInches);
const totalWidthInInches = toTotalInches(values.widthFeet, values.widthInches);
const totalHeightInInches = toTotalInches(values.heightFeet, values.heightInches);
const hasTrailerBool = values.hasTrailer === 'true';
const isRoadworthyBool = values.isRoadworthy && hasTrailerBool ? values.isRoadworthy === 'true' : null;

const mobileHomeShipment = {
const boatShipment = {
type: values.type,
year: Number(values.year),
make: values.make,
model: values.model,
lengthInInches: totalLengthInInches,
widthInInches: totalWidthInInches,
heightInInches: totalHeightInInches,
hasTrailer: values.hasTrailer === 'true',
isRoadworthy: values.hasTrailer === 'true' ? isRoadworthyBool : null,
};
const mtoShipmentType =
boatShipment.type === boatShipmentTypes.TOW_AWAY ? SHIPMENT_TYPES.BOAT_TOW_AWAY : SHIPMENT_TYPES.BOAT_HAUL_AWAY;

return {
mobileHomeShipment,
shipmentType: mtoShipmentType,
boatShipment,
};
}

Expand Down

0 comments on commit c0564c6

Please sign in to comment.