Skip to content

Commit

Permalink
Merge pull request #12990 from transcom/MAIN-B-20093
Browse files Browse the repository at this point in the history
MAIN-B-20083
  • Loading branch information
taeJungCaci authored Jun 7, 2024
2 parents 9dad858 + f5ebb25 commit af398d6
Show file tree
Hide file tree
Showing 17 changed files with 196 additions and 105 deletions.
28 changes: 28 additions & 0 deletions pkg/gen/primeapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions pkg/gen/primemessages/update_m_t_o_shipment.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions pkg/gen/primev3api/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions pkg/gen/primev3messages/update_m_t_o_shipment.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions pkg/handlers/primeapi/payloads/payload_to_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,16 @@ func MTOShipmentModelFromUpdate(mtoShipment *primemessages.UpdateMTOShipment, mt
CounselorRemarks: mtoShipment.CounselorRemarks,
}

if mtoShipment.ActualProGearWeight != nil {
actualProGearWeight := unit.Pound(*mtoShipment.ActualProGearWeight)
model.ActualProGearWeight = &actualProGearWeight
}

if mtoShipment.ActualSpouseProGearWeight != nil {
actualSpouseProGearWeight := unit.Pound(*mtoShipment.ActualSpouseProGearWeight)
model.ActualSpouseProGearWeight = &actualSpouseProGearWeight
}

if mtoShipment.PrimeActualWeight != nil {
actualWeight := unit.Pound(*mtoShipment.PrimeActualWeight)
model.PrimeActualWeight = &actualWeight
Expand Down
10 changes: 10 additions & 0 deletions pkg/handlers/primeapiv2/payloads/payload_to_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,16 @@ func MTOShipmentModelFromUpdate(mtoShipment *primev2messages.UpdateMTOShipment,
ActualSpouseProGearWeight: handlers.PoundPtrFromInt64Ptr(mtoShipment.ActualSpouseProGearWeight),
}

if mtoShipment.ActualProGearWeight != nil {
actualProGearWeight := unit.Pound(*mtoShipment.ActualProGearWeight)
model.ActualProGearWeight = &actualProGearWeight
}

if mtoShipment.ActualSpouseProGearWeight != nil {
actualSpouseProGearWeight := unit.Pound(*mtoShipment.ActualSpouseProGearWeight)
model.ActualSpouseProGearWeight = &actualSpouseProGearWeight
}

if mtoShipment.PrimeActualWeight != nil {
actualWeight := unit.Pound(*mtoShipment.PrimeActualWeight)
model.PrimeActualWeight = &actualWeight
Expand Down
10 changes: 10 additions & 0 deletions pkg/handlers/primeapiv3/payloads/payload_to_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,16 @@ func MTOShipmentModelFromUpdate(mtoShipment *primev3messages.UpdateMTOShipment,
CounselorRemarks: mtoShipment.CounselorRemarks,
}

if mtoShipment.ActualProGearWeight != nil {
actualProGearWeight := unit.Pound(*mtoShipment.ActualProGearWeight)
model.ActualProGearWeight = &actualProGearWeight
}

if mtoShipment.ActualSpouseProGearWeight != nil {
actualSpouseProGearWeight := unit.Pound(*mtoShipment.ActualSpouseProGearWeight)
model.ActualSpouseProGearWeight = &actualSpouseProGearWeight
}

if mtoShipment.PrimeActualWeight != nil {
actualWeight := unit.Pound(*mtoShipment.PrimeActualWeight)
model.PrimeActualWeight = &actualWeight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import { Grid, GridContainer } from '@trussworks/react-uswds';
import { SHIPMENT_OPTIONS } from '../../../../shared/constants';

import ReviewShipmentWeightsTable from './ReviewShipmentWeightsTable';
import {
PPMReviewWeightsTableConfig,
proGearReviewWeightsTableConfig,
nonPPMReviewWeightsTableConfig,
} from './helpers';
import { PPMReviewWeightsTableConfig, nonPPMReviewWeightsTableConfig } from './helpers';

export default {
title: 'Office Components / PPM / Review Shipment Weights Table',
Expand Down Expand Up @@ -102,19 +98,6 @@ PPMShipmentsNoRows.args = {
tableConfig: PPMReviewWeightsTableConfig,
};

export const ProGearWeights = Template.bind({});
ProGearWeights.args = {
tableData: [
{
entitlement: {
proGearWeight: 2000,
spouseProGearWeight: 500,
},
},
],
tableConfig: proGearReviewWeightsTableConfig,
};

export const NonPPMShipments = Template.bind({});
NonPPMShipments.args = {
tableData: [
Expand All @@ -123,6 +106,8 @@ NonPPMShipments.args = {
primeEstimatedWeight: 2500,
calculatedBillableWeight: 3000,
primeActualWeight: 3500,
proGearWeight: 2000,
spouseProGearWeight: 500,
reweigh: {
id: 'rw01',
weight: 3200,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import { render, waitFor, screen } from '@testing-library/react';
import { SHIPMENT_OPTIONS } from '../../../../shared/constants';

import ReviewShipmentWeightsTable from './ReviewShipmentWeightsTable';
import {
nonPPMReviewWeightsTableConfig,
PPMReviewWeightsTableConfig,
proGearReviewWeightsTableConfig,
} from './helpers';
import { nonPPMReviewWeightsTableConfig, PPMReviewWeightsTableConfig } from './helpers';

import { MockProviders } from 'testUtils';

Expand Down Expand Up @@ -40,17 +36,6 @@ const PPMProps = {
],
tableConfig: PPMReviewWeightsTableConfig,
};
const ProGearProps = {
tableData: [
{
entitlement: {
proGearWeight: 2000,
proGearWeightSpouse: 500,
},
},
],
tableConfig: proGearReviewWeightsTableConfig,
};
const NonPPMProps = {
tableData: [
{
Expand Down Expand Up @@ -90,20 +75,6 @@ describe('ReviewShipmentWeight component', () => {
expect(screen.getByText('Apr 01 2023')).toBeInTheDocument();
});
});
it('correctly renders Pro-gear table data', async () => {
render(
<MockProviders>
<ReviewShipmentWeightsTable {...ProGearProps} />
</MockProviders>,
);
await waitFor(async () => {
expect(screen.getByTestId('reviewShipmentWeightsTable')).toBeInTheDocument();
expect(screen.getByText('Pro-gear (lbs)')).toBeInTheDocument();
expect(screen.getByText('2,000 lbs')).toBeInTheDocument();
expect(screen.getByText('Spouse pro-gear (lbs)')).toBeInTheDocument();
expect(screen.getByText('500 lbs')).toBeInTheDocument();
});
});
it('correctly renders non-PPM table data', async () => {
render(
<MockProviders>
Expand Down
55 changes: 15 additions & 40 deletions src/components/Office/PPM/ReviewShipmentWeightsTable/helpers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,50 +183,31 @@ export const PPMReviewWeightsTableColumns = [
),
];

export const proGearTableColumns = [
export const nonPPMTableColumns = [
createHeader('', (row) => <ShipmentTypeCell row={row} />, {
id: 'shipmentType',
isFilterable: false,
}),
createHeader('Estimated weight', (row) => estimatedWeightDisplayHelper(row), {
id: 'estimatedWeight',
isFilterable: false,
}),
createHeader(
'',
() => {
return (
<div
className={`${styles['review-shipment-weights-table-row']} ${styles['review-shipment-weights-table-row-pro-gear']}`}
>
<strong>Pro-gear</strong>{' '}
</div>
);
},
'Pro-gear \n(lbs)',
(row) => (row.actualProGearWeight > 0 ? formatWeight(row.actualProGearWeight) : DASH),
{
id: 'shipmentType',
id: 'actualProGear',
isFilterable: false,
},
),
createHeader(
'Pro-gear (lbs)',
(row) => (row.entitlement.proGearWeight > 0 ? formatWeight(row.entitlement.proGearWeight) : DASH),
{
id: 'proGear',
isFilterable: false,
},
),
createHeader(
'Spouse pro-gear (lbs)',
(row) => (row.entitlement.proGearWeightSpouse > 0 ? formatWeight(row.entitlement.proGearWeightSpouse) : DASH),
'Spouse pro-gear \n(lbs)',
(row) => (row.actualSpouseProGearWeight > 0 ? formatWeight(row.actualSpouseProGearWeight) : DASH),
{
id: 'spouseProGear',
id: 'actualSpouseProGear',
isFilterable: false,
},
),
];

export const nonPPMTableColumns = [
createHeader('', (row) => <ShipmentTypeCell row={row} />, {
id: 'shipmentType',
isFilterable: false,
}),
createHeader('Estimated weight', (row) => estimatedWeightDisplayHelper(row), {
id: 'estimatedWeight',
isFilterable: false,
}),
createHeader('Reweigh requested', (row) => (row.reweigh ? 'Yes' : 'No'), {
id: 'reweighRequested',
isFilterable: false,
Expand Down Expand Up @@ -259,12 +240,6 @@ export const PPMReviewWeightsTableConfig = {
determineShipmentNumbers: true,
};

export const proGearReviewWeightsTableConfig = {
tableColumns: proGearTableColumns,
noRowsMsg: null,
determineShipmentNumbers: false,
};

export const nonPPMReviewWeightsTableConfig = {
tableColumns: nonPPMTableColumns,
noRowsMsg: NO_ROWS_MESSAGES.NonPPM,
Expand Down
Loading

0 comments on commit af398d6

Please sign in to comment.