Skip to content

Commit

Permalink
Merge branch 'main' into B-21367-B-Block-third-address-if-no-second-a…
Browse files Browse the repository at this point in the history
…ddress-is-present
  • Loading branch information
joeydoyecaci authored Oct 22, 2024
2 parents 5540ac9 + 942fd9a commit d389539
Show file tree
Hide file tree
Showing 9 changed files with 291 additions and 72 deletions.
2 changes: 2 additions & 0 deletions pkg/handlers/ghcapi/internal/payloads/model_to_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -2294,6 +2294,8 @@ func SearchMoves(appCtx appcontext.AppContext, moves models.Moves) *ghcmessages.

if err != nil {
destinationGBLOC = *ghcmessages.NewGBLOC("")
} else if customer.Affiliation.String() == "MARINES" {
destinationGBLOC = ghcmessages.GBLOC("USMC/" + PostalCodeToGBLOC.GBLOC)
} else {
destinationGBLOC = ghcmessages.GBLOC(PostalCodeToGBLOC.GBLOC)
}
Expand Down
22 changes: 22 additions & 0 deletions pkg/handlers/ghcapi/internal/payloads/model_to_payload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/gofrs/uuid"

"github.com/transcom/mymove/pkg/factory"
"github.com/transcom/mymove/pkg/gen/ghcmessages"
"github.com/transcom/mymove/pkg/handlers"
"github.com/transcom/mymove/pkg/models"
Expand Down Expand Up @@ -350,3 +351,24 @@ func (suite *PayloadsSuite) TestCreateCustomer() {
suite.IsType(returnedShipmentAddressUpdate, &ghcmessages.CreatedCustomer{})
})
}

func (suite *PayloadsSuite) TestSearchMoves() {
appCtx := suite.AppContextForTest()

marines := models.AffiliationMARINES
moveUSMC := factory.BuildMove(suite.DB(), []factory.Customization{
{
Model: models.ServiceMember{
Affiliation: &marines,
},
},
}, nil)

moves := models.Moves{moveUSMC}
suite.Run("Success - Returns a ghcmessages Upload payload from Upload Struct", func() {
payload := SearchMoves(appCtx, moves)

suite.IsType(payload, &ghcmessages.SearchMoves{})
suite.NotNil(payload)
})
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import * as PropTypes from 'prop-types';
import { generatePath } from 'react-router-dom';
import { generatePath, useParams, useNavigate } from 'react-router-dom';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

import styles from './RequestedShipments.module.scss';
Expand All @@ -14,6 +14,10 @@ import shipmentCardsStyles from 'styles/shipmentCards.module.scss';
import { MTOServiceItemShape, OrdersInfoShape } from 'types/order';
import { ShipmentShape } from 'types/shipment';
import { formatDateFromIso } from 'utils/formatters';
import ButtonDropdown from 'components/ButtonDropdown/ButtonDropdown';
import { SHIPMENT_OPTIONS_URL } from 'shared/constants';
import Restricted from 'components/Restricted/Restricted';
import { permissionTypes } from 'constants/permissions';

// nts defaults show preferred pickup date and pickup address, flagged items when collapsed
// ntsr defaults shows preferred delivery date, storage facility address, destination address, flagged items when collapsed
Expand Down Expand Up @@ -66,11 +70,54 @@ const ApprovedRequestedShipments = ({
};
};

const { moveCode } = useParams();
const navigate = useNavigate();
const handleButtonDropdownChange = (e) => {
const selectedOption = e.target.value;

const addShipmentPath = `${generatePath(tooRoutes.SHIPMENT_ADD_PATH, {
moveCode,
shipmentType: selectedOption,
})}`;

navigate(addShipmentPath);
};

const dutyLocationPostal = { postalCode: ordersInfo.newDutyLocation?.address?.postalCode };

return (
<div className={styles.RequestedShipments} data-testid="requested-shipments">
<h2>Approved Shipments</h2>
<div className={styles.sectionHeader}>
<h2>Approved Shipments</h2>
<div className={styles.buttonDropdown}>
{!isMoveLocked && (
<Restricted to={permissionTypes.createTxoShipment}>
<ButtonDropdown
ariaLabel="Add a new shipment"
data-testid="addShipmentButton"
onChange={handleButtonDropdownChange}
>
<option value="" label="Add a new shipment">
Add a new shipment
</option>
<option data-testid="hhgOption" value={SHIPMENT_OPTIONS_URL.HHG}>
HHG
</option>
<option value={SHIPMENT_OPTIONS_URL.PPM}>PPM</option>
<option value={SHIPMENT_OPTIONS_URL.NTS}>NTS</option>
<option value={SHIPMENT_OPTIONS_URL.NTSrelease}>NTS-release</option>
<option data-testid="boatOption" value={SHIPMENT_OPTIONS_URL.BOAT}>
Boat
</option>
<option data-testid="mobileHomeOption" value={SHIPMENT_OPTIONS_URL.MOBILE_HOME}>
Mobile Home
</option>
</ButtonDropdown>
</Restricted>
)}
</div>
</div>

<div className={shipmentCardsStyles.shipmentCards}>
{mtoShipments &&
mtoShipments.map((shipment) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@
@include u-padding-x(4);
@include u-padding-y(2);

.sectionHeader {
display: flex;
justify-content: center;
align-items: center;
h2 {
margin-right: auto;
}

.buttonDropdown {
margin-left: auto
}
}

h4 {
@include u-margin(0);
font-weight: bold;
Expand Down
Loading

0 comments on commit d389539

Please sign in to comment.