From 273016e777c902c7ebc2be8304d154cd880bc0ef Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Thu, 1 Aug 2024 04:51:41 +0000 Subject: [PATCH 001/216] zip city lookup template using offices --- pkg/gen/internalapi/configure_mymove.go | 5 + pkg/gen/internalapi/embedded_spec.go | 344 ++++++++++++++++++ .../addresses/get_location_by_zip_city.go | 58 +++ .../get_location_by_zip_city_parameters.go | 71 ++++ .../get_location_by_zip_city_responses.go | 159 ++++++++ .../get_location_by_zip_city_urlbuilder.go | 99 +++++ .../internaloperations/mymove_api.go | 12 + pkg/gen/internalmessages/zip_city_lookup.go | 281 ++++++++++++++ .../ResidentialAddressForm.jsx | 2 + .../LocationSearchBox/LocationSearchBox.jsx | 4 + .../form/AddressFields/AddressFields.jsx | 78 +++- src/components/form/fields/ZipCityInput.jsx | 52 +++ .../MyMove/Profile/ResidentialAddress.jsx | 2 + swagger-def/definitions/ZipCityLookup.yaml | 126 +++++++ swagger-def/internal.yaml | 25 ++ swagger/internal.yaml | 156 ++++++++ 16 files changed, 1458 insertions(+), 16 deletions(-) create mode 100644 pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city.go create mode 100644 pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_parameters.go create mode 100644 pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_responses.go create mode 100644 pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_urlbuilder.go create mode 100644 pkg/gen/internalmessages/zip_city_lookup.go create mode 100644 src/components/form/fields/ZipCityInput.jsx create mode 100644 swagger-def/definitions/ZipCityLookup.yaml diff --git a/pkg/gen/internalapi/configure_mymove.go b/pkg/gen/internalapi/configure_mymove.go index 1295e8d8ac8..28e9bdd4c02 100644 --- a/pkg/gen/internalapi/configure_mymove.go +++ b/pkg/gen/internalapi/configure_mymove.go @@ -195,6 +195,11 @@ func configureAPI(api *internaloperations.MymoveAPI) http.Handler { return middleware.NotImplemented("operation moves.GetAllMoves has not yet been implemented") }) } + if api.AddressesGetLocationByZipCityHandler == nil { + api.AddressesGetLocationByZipCityHandler = addresses.GetLocationByZipCityHandlerFunc(func(params addresses.GetLocationByZipCityParams) middleware.Responder { + return middleware.NotImplemented("operation addresses.GetLocationByZipCity has not yet been implemented") + }) + } if api.TransportationOfficesGetTransportationOfficesHandler == nil { api.TransportationOfficesGetTransportationOfficesHandler = transportation_offices.GetTransportationOfficesHandlerFunc(func(params transportation_offices.GetTransportationOfficesParams) middleware.Responder { return middleware.NotImplemented("operation transportation_offices.GetTransportationOffices has not yet been implemented") diff --git a/pkg/gen/internalapi/embedded_spec.go b/pkg/gen/internalapi/embedded_spec.go index 24f5a4fdd47..aa54c788b89 100644 --- a/pkg/gen/internalapi/embedded_spec.go +++ b/pkg/gen/internalapi/embedded_spec.go @@ -39,6 +39,44 @@ func init() { }, "basePath": "/internal", "paths": { + "/addresses/zip_city_lookup/{zip_city}": { + "get": { + "description": "Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code.", + "tags": [ + "addresses" + ], + "summary": "Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City string", + "operationId": "getLocationByZipCity", + "parameters": [ + { + "type": "string", + "name": "zip_city", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "the requested list of city, state, county, and postal code matches", + "schema": { + "$ref": "#/definitions/ZipCityLookup" + } + }, + "400": { + "description": "invalid request" + }, + "403": { + "description": "not authorized" + }, + "404": { + "description": "not found" + }, + "500": { + "description": "server error" + } + } + } + }, "/addresses/{addressId}": { "get": { "description": "Find by API using address ID that returns an address json object containing address 1, address 2, address 3, city and postal code.", @@ -7511,6 +7549,140 @@ func init() { "$ref": "#/definitions/WeightTicket" }, "x-omitempty": false + }, + "ZipCityLookup": { + "description": "A postal code and city lookup", + "type": "object", + "properties": { + "city": { + "type": "string", + "title": "City", + "example": "Anytown" + }, + "county": { + "type": "string", + "title": "County", + "x-nullable": true, + "example": "LOS ANGELES" + }, + "postalCode": { + "type": "string", + "format": "zip", + "title": "ZIP", + "pattern": "^(\\d{5}([\\-]\\d{4})?)$", + "example": "90210" + }, + "state": { + "type": "string", + "title": "State", + "enum": [ + "AL", + "AK", + "AR", + "AZ", + "CA", + "CO", + "CT", + "DC", + "DE", + "FL", + "GA", + "HI", + "IA", + "ID", + "IL", + "IN", + "KS", + "KY", + "LA", + "MA", + "MD", + "ME", + "MI", + "MN", + "MO", + "MS", + "MT", + "NC", + "ND", + "NE", + "NH", + "NJ", + "NM", + "NV", + "NY", + "OH", + "OK", + "OR", + "PA", + "RI", + "SC", + "SD", + "TN", + "TX", + "UT", + "VA", + "VT", + "WA", + "WI", + "WV", + "WY" + ], + "x-display-value": { + "AK": "AK", + "AL": "AL", + "AR": "AR", + "AZ": "AZ", + "CA": "CA", + "CO": "CO", + "CT": "CT", + "DC": "DC", + "DE": "DE", + "FL": "FL", + "GA": "GA", + "HI": "HI", + "IA": "IA", + "ID": "ID", + "IL": "IL", + "IN": "IN", + "KS": "KS", + "KY": "KY", + "LA": "LA", + "MA": "MA", + "MD": "MD", + "ME": "ME", + "MI": "MI", + "MN": "MN", + "MO": "MO", + "MS": "MS", + "MT": "MT", + "NC": "NC", + "ND": "ND", + "NE": "NE", + "NH": "NH", + "NJ": "NJ", + "NM": "NM", + "NV": "NV", + "NY": "NY", + "OH": "OH", + "OK": "OK", + "OR": "OR", + "PA": "PA", + "RI": "RI", + "SC": "SC", + "SD": "SD", + "TN": "TN", + "TX": "TX", + "UT": "UT", + "VA": "VA", + "VT": "VT", + "WA": "WA", + "WI": "WI", + "WV": "WV", + "WY": "WY" + } + } + } } }, "parameters": { @@ -7689,6 +7861,44 @@ func init() { }, "basePath": "/internal", "paths": { + "/addresses/zip_city_lookup/{zip_city}": { + "get": { + "description": "Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code.", + "tags": [ + "addresses" + ], + "summary": "Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City string", + "operationId": "getLocationByZipCity", + "parameters": [ + { + "type": "string", + "name": "zip_city", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "the requested list of city, state, county, and postal code matches", + "schema": { + "$ref": "#/definitions/ZipCityLookup" + } + }, + "400": { + "description": "invalid request" + }, + "403": { + "description": "not authorized" + }, + "404": { + "description": "not found" + }, + "500": { + "description": "server error" + } + } + } + }, "/addresses/{addressId}": { "get": { "description": "Find by API using address ID that returns an address json object containing address 1, address 2, address 3, city and postal code.", @@ -15622,6 +15832,140 @@ func init() { "$ref": "#/definitions/WeightTicket" }, "x-omitempty": false + }, + "ZipCityLookup": { + "description": "A postal code and city lookup", + "type": "object", + "properties": { + "city": { + "type": "string", + "title": "City", + "example": "Anytown" + }, + "county": { + "type": "string", + "title": "County", + "x-nullable": true, + "example": "LOS ANGELES" + }, + "postalCode": { + "type": "string", + "format": "zip", + "title": "ZIP", + "pattern": "^(\\d{5}([\\-]\\d{4})?)$", + "example": "90210" + }, + "state": { + "type": "string", + "title": "State", + "enum": [ + "AL", + "AK", + "AR", + "AZ", + "CA", + "CO", + "CT", + "DC", + "DE", + "FL", + "GA", + "HI", + "IA", + "ID", + "IL", + "IN", + "KS", + "KY", + "LA", + "MA", + "MD", + "ME", + "MI", + "MN", + "MO", + "MS", + "MT", + "NC", + "ND", + "NE", + "NH", + "NJ", + "NM", + "NV", + "NY", + "OH", + "OK", + "OR", + "PA", + "RI", + "SC", + "SD", + "TN", + "TX", + "UT", + "VA", + "VT", + "WA", + "WI", + "WV", + "WY" + ], + "x-display-value": { + "AK": "AK", + "AL": "AL", + "AR": "AR", + "AZ": "AZ", + "CA": "CA", + "CO": "CO", + "CT": "CT", + "DC": "DC", + "DE": "DE", + "FL": "FL", + "GA": "GA", + "HI": "HI", + "IA": "IA", + "ID": "ID", + "IL": "IL", + "IN": "IN", + "KS": "KS", + "KY": "KY", + "LA": "LA", + "MA": "MA", + "MD": "MD", + "ME": "ME", + "MI": "MI", + "MN": "MN", + "MO": "MO", + "MS": "MS", + "MT": "MT", + "NC": "NC", + "ND": "ND", + "NE": "NE", + "NH": "NH", + "NJ": "NJ", + "NM": "NM", + "NV": "NV", + "NY": "NY", + "OH": "OH", + "OK": "OK", + "OR": "OR", + "PA": "PA", + "RI": "RI", + "SC": "SC", + "SD": "SD", + "TN": "TN", + "TX": "TX", + "UT": "UT", + "VA": "VA", + "VT": "VT", + "WA": "WA", + "WI": "WI", + "WV": "WV", + "WY": "WY" + } + } + } } }, "parameters": { diff --git a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city.go b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city.go new file mode 100644 index 00000000000..7a4842fe465 --- /dev/null +++ b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package addresses + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLocationByZipCityHandlerFunc turns a function with the right signature into a get location by zip city handler +type GetLocationByZipCityHandlerFunc func(GetLocationByZipCityParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLocationByZipCityHandlerFunc) Handle(params GetLocationByZipCityParams) middleware.Responder { + return fn(params) +} + +// GetLocationByZipCityHandler interface for that can handle valid get location by zip city params +type GetLocationByZipCityHandler interface { + Handle(GetLocationByZipCityParams) middleware.Responder +} + +// NewGetLocationByZipCity creates a new http.Handler for the get location by zip city operation +func NewGetLocationByZipCity(ctx *middleware.Context, handler GetLocationByZipCityHandler) *GetLocationByZipCity { + return &GetLocationByZipCity{Context: ctx, Handler: handler} +} + +/* + GetLocationByZipCity swagger:route GET /addresses/zip_city_lookup/{zip_city} addresses getLocationByZipCity + +Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City string + +Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code. +*/ +type GetLocationByZipCity struct { + Context *middleware.Context + Handler GetLocationByZipCityHandler +} + +func (o *GetLocationByZipCity) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetLocationByZipCityParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_parameters.go b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_parameters.go new file mode 100644 index 00000000000..e56e0f520ee --- /dev/null +++ b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_parameters.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package addresses + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetLocationByZipCityParams creates a new GetLocationByZipCityParams object +// +// There are no default values defined in the spec. +func NewGetLocationByZipCityParams() GetLocationByZipCityParams { + + return GetLocationByZipCityParams{} +} + +// GetLocationByZipCityParams contains all the bound params for the get location by zip city operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLocationByZipCity +type GetLocationByZipCityParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + ZipCity string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLocationByZipCityParams() beforehand. +func (o *GetLocationByZipCityParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rZipCity, rhkZipCity, _ := route.Params.GetOK("zip_city") + if err := o.bindZipCity(rZipCity, rhkZipCity, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindZipCity binds and validates parameter ZipCity from path. +func (o *GetLocationByZipCityParams) bindZipCity(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ZipCity = raw + + return nil +} diff --git a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_responses.go b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_responses.go new file mode 100644 index 00000000000..e0039e991cd --- /dev/null +++ b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_responses.go @@ -0,0 +1,159 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package addresses + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/transcom/mymove/pkg/gen/internalmessages" +) + +// GetLocationByZipCityOKCode is the HTTP code returned for type GetLocationByZipCityOK +const GetLocationByZipCityOKCode int = 200 + +/* +GetLocationByZipCityOK the requested list of city, state, county, and postal code matches + +swagger:response getLocationByZipCityOK +*/ +type GetLocationByZipCityOK struct { + + /* + In: Body + */ + Payload *internalmessages.ZipCityLookup `json:"body,omitempty"` +} + +// NewGetLocationByZipCityOK creates GetLocationByZipCityOK with default headers values +func NewGetLocationByZipCityOK() *GetLocationByZipCityOK { + + return &GetLocationByZipCityOK{} +} + +// WithPayload adds the payload to the get location by zip city o k response +func (o *GetLocationByZipCityOK) WithPayload(payload *internalmessages.ZipCityLookup) *GetLocationByZipCityOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get location by zip city o k response +func (o *GetLocationByZipCityOK) SetPayload(payload *internalmessages.ZipCityLookup) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLocationByZipCityOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLocationByZipCityBadRequestCode is the HTTP code returned for type GetLocationByZipCityBadRequest +const GetLocationByZipCityBadRequestCode int = 400 + +/* +GetLocationByZipCityBadRequest invalid request + +swagger:response getLocationByZipCityBadRequest +*/ +type GetLocationByZipCityBadRequest struct { +} + +// NewGetLocationByZipCityBadRequest creates GetLocationByZipCityBadRequest with default headers values +func NewGetLocationByZipCityBadRequest() *GetLocationByZipCityBadRequest { + + return &GetLocationByZipCityBadRequest{} +} + +// WriteResponse to the client +func (o *GetLocationByZipCityBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(400) +} + +// GetLocationByZipCityForbiddenCode is the HTTP code returned for type GetLocationByZipCityForbidden +const GetLocationByZipCityForbiddenCode int = 403 + +/* +GetLocationByZipCityForbidden not authorized + +swagger:response getLocationByZipCityForbidden +*/ +type GetLocationByZipCityForbidden struct { +} + +// NewGetLocationByZipCityForbidden creates GetLocationByZipCityForbidden with default headers values +func NewGetLocationByZipCityForbidden() *GetLocationByZipCityForbidden { + + return &GetLocationByZipCityForbidden{} +} + +// WriteResponse to the client +func (o *GetLocationByZipCityForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(403) +} + +// GetLocationByZipCityNotFoundCode is the HTTP code returned for type GetLocationByZipCityNotFound +const GetLocationByZipCityNotFoundCode int = 404 + +/* +GetLocationByZipCityNotFound not found + +swagger:response getLocationByZipCityNotFound +*/ +type GetLocationByZipCityNotFound struct { +} + +// NewGetLocationByZipCityNotFound creates GetLocationByZipCityNotFound with default headers values +func NewGetLocationByZipCityNotFound() *GetLocationByZipCityNotFound { + + return &GetLocationByZipCityNotFound{} +} + +// WriteResponse to the client +func (o *GetLocationByZipCityNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(404) +} + +// GetLocationByZipCityInternalServerErrorCode is the HTTP code returned for type GetLocationByZipCityInternalServerError +const GetLocationByZipCityInternalServerErrorCode int = 500 + +/* +GetLocationByZipCityInternalServerError server error + +swagger:response getLocationByZipCityInternalServerError +*/ +type GetLocationByZipCityInternalServerError struct { +} + +// NewGetLocationByZipCityInternalServerError creates GetLocationByZipCityInternalServerError with default headers values +func NewGetLocationByZipCityInternalServerError() *GetLocationByZipCityInternalServerError { + + return &GetLocationByZipCityInternalServerError{} +} + +// WriteResponse to the client +func (o *GetLocationByZipCityInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(500) +} diff --git a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_urlbuilder.go b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_urlbuilder.go new file mode 100644 index 00000000000..bc0f0cb3a13 --- /dev/null +++ b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package addresses + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetLocationByZipCityURL generates an URL for the get location by zip city operation +type GetLocationByZipCityURL struct { + ZipCity string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLocationByZipCityURL) WithBasePath(bp string) *GetLocationByZipCityURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLocationByZipCityURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLocationByZipCityURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/addresses/zip_city_lookup/{zip_city}" + + zipCity := o.ZipCity + if zipCity != "" { + _path = strings.Replace(_path, "{zip_city}", zipCity, -1) + } else { + return nil, errors.New("zipCity is required on GetLocationByZipCityURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/internal" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLocationByZipCityURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLocationByZipCityURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLocationByZipCityURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLocationByZipCityURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLocationByZipCityURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLocationByZipCityURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/internalapi/internaloperations/mymove_api.go b/pkg/gen/internalapi/internaloperations/mymove_api.go index dcee8b1e2ca..43e97f62ba7 100644 --- a/pkg/gen/internalapi/internaloperations/mymove_api.go +++ b/pkg/gen/internalapi/internaloperations/mymove_api.go @@ -142,6 +142,9 @@ func NewMymoveAPI(spec *loads.Document) *MymoveAPI { MovesGetAllMovesHandler: moves.GetAllMovesHandlerFunc(func(params moves.GetAllMovesParams) middleware.Responder { return middleware.NotImplemented("operation moves.GetAllMoves has not yet been implemented") }), + AddressesGetLocationByZipCityHandler: addresses.GetLocationByZipCityHandlerFunc(func(params addresses.GetLocationByZipCityParams) middleware.Responder { + return middleware.NotImplemented("operation addresses.GetLocationByZipCity has not yet been implemented") + }), TransportationOfficesGetTransportationOfficesHandler: transportation_offices.GetTransportationOfficesHandlerFunc(func(params transportation_offices.GetTransportationOfficesParams) middleware.Responder { return middleware.NotImplemented("operation transportation_offices.GetTransportationOffices has not yet been implemented") }), @@ -365,6 +368,8 @@ type MymoveAPI struct { PpmDeleteWeightTicketHandler ppm.DeleteWeightTicketHandler // MovesGetAllMovesHandler sets the operation handler for the get all moves operation MovesGetAllMovesHandler moves.GetAllMovesHandler + // AddressesGetLocationByZipCityHandler sets the operation handler for the get location by zip city operation + AddressesGetLocationByZipCityHandler addresses.GetLocationByZipCityHandler // TransportationOfficesGetTransportationOfficesHandler sets the operation handler for the get transportation offices operation TransportationOfficesGetTransportationOfficesHandler transportation_offices.GetTransportationOfficesHandler // EntitlementsIndexEntitlementsHandler sets the operation handler for the index entitlements operation @@ -607,6 +612,9 @@ func (o *MymoveAPI) Validate() error { if o.MovesGetAllMovesHandler == nil { unregistered = append(unregistered, "moves.GetAllMovesHandler") } + if o.AddressesGetLocationByZipCityHandler == nil { + unregistered = append(unregistered, "addresses.GetLocationByZipCityHandler") + } if o.TransportationOfficesGetTransportationOfficesHandler == nil { unregistered = append(unregistered, "transportation_offices.GetTransportationOfficesHandler") } @@ -928,6 +936,10 @@ func (o *MymoveAPI) initHandlerCache() { if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } + o.handlers["GET"]["/addresses/zip_city_lookup/{zip_city}"] = addresses.NewGetLocationByZipCity(o.context, o.AddressesGetLocationByZipCityHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } o.handlers["GET"]["/transportation-offices"] = transportation_offices.NewGetTransportationOffices(o.context, o.TransportationOfficesGetTransportationOfficesHandler) if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) diff --git a/pkg/gen/internalmessages/zip_city_lookup.go b/pkg/gen/internalmessages/zip_city_lookup.go new file mode 100644 index 00000000000..84452ee8787 --- /dev/null +++ b/pkg/gen/internalmessages/zip_city_lookup.go @@ -0,0 +1,281 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package internalmessages + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ZipCityLookup A postal code and city lookup +// +// swagger:model ZipCityLookup +type ZipCityLookup struct { + + // City + // Example: Anytown + City string `json:"city,omitempty"` + + // County + // Example: LOS ANGELES + County *string `json:"county,omitempty"` + + // ZIP + // Example: 90210 + // Pattern: ^(\d{5}([\-]\d{4})?)$ + PostalCode string `json:"postalCode,omitempty"` + + // State + // Enum: [AL AK AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD TN TX UT VA VT WA WI WV WY] + State string `json:"state,omitempty"` +} + +// Validate validates this zip city lookup +func (m *ZipCityLookup) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePostalCode(formats); err != nil { + res = append(res, err) + } + + if err := m.validateState(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ZipCityLookup) validatePostalCode(formats strfmt.Registry) error { + if swag.IsZero(m.PostalCode) { // not required + return nil + } + + if err := validate.Pattern("postalCode", "body", m.PostalCode, `^(\d{5}([\-]\d{4})?)$`); err != nil { + return err + } + + return nil +} + +var zipCityLookupTypeStatePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["AL","AK","AR","AZ","CA","CO","CT","DC","DE","FL","GA","HI","IA","ID","IL","IN","KS","KY","LA","MA","MD","ME","MI","MN","MO","MS","MT","NC","ND","NE","NH","NJ","NM","NV","NY","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VA","VT","WA","WI","WV","WY"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + zipCityLookupTypeStatePropEnum = append(zipCityLookupTypeStatePropEnum, v) + } +} + +const ( + + // ZipCityLookupStateAL captures enum value "AL" + ZipCityLookupStateAL string = "AL" + + // ZipCityLookupStateAK captures enum value "AK" + ZipCityLookupStateAK string = "AK" + + // ZipCityLookupStateAR captures enum value "AR" + ZipCityLookupStateAR string = "AR" + + // ZipCityLookupStateAZ captures enum value "AZ" + ZipCityLookupStateAZ string = "AZ" + + // ZipCityLookupStateCA captures enum value "CA" + ZipCityLookupStateCA string = "CA" + + // ZipCityLookupStateCO captures enum value "CO" + ZipCityLookupStateCO string = "CO" + + // ZipCityLookupStateCT captures enum value "CT" + ZipCityLookupStateCT string = "CT" + + // ZipCityLookupStateDC captures enum value "DC" + ZipCityLookupStateDC string = "DC" + + // ZipCityLookupStateDE captures enum value "DE" + ZipCityLookupStateDE string = "DE" + + // ZipCityLookupStateFL captures enum value "FL" + ZipCityLookupStateFL string = "FL" + + // ZipCityLookupStateGA captures enum value "GA" + ZipCityLookupStateGA string = "GA" + + // ZipCityLookupStateHI captures enum value "HI" + ZipCityLookupStateHI string = "HI" + + // ZipCityLookupStateIA captures enum value "IA" + ZipCityLookupStateIA string = "IA" + + // ZipCityLookupStateID captures enum value "ID" + ZipCityLookupStateID string = "ID" + + // ZipCityLookupStateIL captures enum value "IL" + ZipCityLookupStateIL string = "IL" + + // ZipCityLookupStateIN captures enum value "IN" + ZipCityLookupStateIN string = "IN" + + // ZipCityLookupStateKS captures enum value "KS" + ZipCityLookupStateKS string = "KS" + + // ZipCityLookupStateKY captures enum value "KY" + ZipCityLookupStateKY string = "KY" + + // ZipCityLookupStateLA captures enum value "LA" + ZipCityLookupStateLA string = "LA" + + // ZipCityLookupStateMA captures enum value "MA" + ZipCityLookupStateMA string = "MA" + + // ZipCityLookupStateMD captures enum value "MD" + ZipCityLookupStateMD string = "MD" + + // ZipCityLookupStateME captures enum value "ME" + ZipCityLookupStateME string = "ME" + + // ZipCityLookupStateMI captures enum value "MI" + ZipCityLookupStateMI string = "MI" + + // ZipCityLookupStateMN captures enum value "MN" + ZipCityLookupStateMN string = "MN" + + // ZipCityLookupStateMO captures enum value "MO" + ZipCityLookupStateMO string = "MO" + + // ZipCityLookupStateMS captures enum value "MS" + ZipCityLookupStateMS string = "MS" + + // ZipCityLookupStateMT captures enum value "MT" + ZipCityLookupStateMT string = "MT" + + // ZipCityLookupStateNC captures enum value "NC" + ZipCityLookupStateNC string = "NC" + + // ZipCityLookupStateND captures enum value "ND" + ZipCityLookupStateND string = "ND" + + // ZipCityLookupStateNE captures enum value "NE" + ZipCityLookupStateNE string = "NE" + + // ZipCityLookupStateNH captures enum value "NH" + ZipCityLookupStateNH string = "NH" + + // ZipCityLookupStateNJ captures enum value "NJ" + ZipCityLookupStateNJ string = "NJ" + + // ZipCityLookupStateNM captures enum value "NM" + ZipCityLookupStateNM string = "NM" + + // ZipCityLookupStateNV captures enum value "NV" + ZipCityLookupStateNV string = "NV" + + // ZipCityLookupStateNY captures enum value "NY" + ZipCityLookupStateNY string = "NY" + + // ZipCityLookupStateOH captures enum value "OH" + ZipCityLookupStateOH string = "OH" + + // ZipCityLookupStateOK captures enum value "OK" + ZipCityLookupStateOK string = "OK" + + // ZipCityLookupStateOR captures enum value "OR" + ZipCityLookupStateOR string = "OR" + + // ZipCityLookupStatePA captures enum value "PA" + ZipCityLookupStatePA string = "PA" + + // ZipCityLookupStateRI captures enum value "RI" + ZipCityLookupStateRI string = "RI" + + // ZipCityLookupStateSC captures enum value "SC" + ZipCityLookupStateSC string = "SC" + + // ZipCityLookupStateSD captures enum value "SD" + ZipCityLookupStateSD string = "SD" + + // ZipCityLookupStateTN captures enum value "TN" + ZipCityLookupStateTN string = "TN" + + // ZipCityLookupStateTX captures enum value "TX" + ZipCityLookupStateTX string = "TX" + + // ZipCityLookupStateUT captures enum value "UT" + ZipCityLookupStateUT string = "UT" + + // ZipCityLookupStateVA captures enum value "VA" + ZipCityLookupStateVA string = "VA" + + // ZipCityLookupStateVT captures enum value "VT" + ZipCityLookupStateVT string = "VT" + + // ZipCityLookupStateWA captures enum value "WA" + ZipCityLookupStateWA string = "WA" + + // ZipCityLookupStateWI captures enum value "WI" + ZipCityLookupStateWI string = "WI" + + // ZipCityLookupStateWV captures enum value "WV" + ZipCityLookupStateWV string = "WV" + + // ZipCityLookupStateWY captures enum value "WY" + ZipCityLookupStateWY string = "WY" +) + +// prop value enum +func (m *ZipCityLookup) validateStateEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, zipCityLookupTypeStatePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *ZipCityLookup) validateState(formats strfmt.Registry) error { + if swag.IsZero(m.State) { // not required + return nil + } + + // value enum + if err := m.validateStateEnum("state", "body", m.State); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this zip city lookup based on context it is used +func (m *ZipCityLookup) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ZipCityLookup) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ZipCityLookup) UnmarshalBinary(b []byte) error { + var res ZipCityLookup + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx index dcc3b3c3242..64fae48a609 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx @@ -18,6 +18,7 @@ const ResidentialAddressForm = ({ formFieldsName, initialValues, onSubmit, onBac const validationSchema = Yup.object().shape({ [formFieldsName]: requiredAddressSchema.required(), }); + const zipCityEnabled = true; // TODO: NEED TO DETERMINE WHICH USER/PAGES TO DETERMINE IF THIS IS ENABLED return ( diff --git a/src/components/LocationSearchBox/LocationSearchBox.jsx b/src/components/LocationSearchBox/LocationSearchBox.jsx index c4d0133533c..cb5a3d95899 100644 --- a/src/components/LocationSearchBox/LocationSearchBox.jsx +++ b/src/components/LocationSearchBox/LocationSearchBox.jsx @@ -87,6 +87,7 @@ export const LocationSearchBoxComponent = ({ hint, placeholder, isDisabled, + handleOnChange, }) => { const { value, onChange, name: inputName } = input; @@ -150,6 +151,7 @@ export const LocationSearchBoxComponent = ({ } onChange(selectedValue); + handleOnChange(selectedValue); return selectedValue; }; @@ -238,6 +240,7 @@ LocationSearchBoxContainer.propTypes = { placeholder: PropTypes.string, isDisabled: PropTypes.bool, searchLocations: PropTypes.func, + handleOnChange: PropTypes.func, }; LocationSearchBoxContainer.defaultProps = { @@ -253,6 +256,7 @@ LocationSearchBoxContainer.defaultProps = { placeholder: 'Start typing a duty location...', isDisabled: false, searchLocations: SearchDutyLocations, + handleOnChange: null, }; LocationSearchBoxComponent.propTypes = { diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index 0d26aad4dcc..1f74f935afe 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -7,6 +7,7 @@ import { statesList } from '../../../constants/states'; import TextField from 'components/form/fields/TextField/TextField'; import { DropdownInput } from 'components/form/fields/DropdownInput'; +import ZipCityInput from 'components/form/fields/ZipCityInput'; /** * @param legend @@ -14,6 +15,7 @@ import { DropdownInput } from 'components/form/fields/DropdownInput'; * @param name * @param render * @param validators + * @param zipCity * @param formikFunctionsToValidatePostalCodeOnChange If you are intending to validate the postal code on change, you * will need to pass the handleChange and setFieldTouched Formik functions through in an object here. * See ResidentialAddressForm for an example. @@ -26,13 +28,14 @@ export const AddressFields = ({ name, render, validators, + zipCityEnabled, formikFunctionsToValidatePostalCodeOnChange, }) => { const addressFieldsUUID = useRef(uuidv4()); - let postalCodeField; + let stateField; - if (formikFunctionsToValidatePostalCodeOnChange) { + if (formikFunctionsToValidatePostalCodeOnChange && !zipCityEnabled) { postalCodeField = ( ); } + if (zipCityEnabled) { + stateField = ( + + ); + } else { + stateField = ( + + ); + } + + const handleZipCityChange = (value) => { + console.log(value); + }; + return (
{render( @@ -87,24 +117,38 @@ export const AddressFields = ({ name={`${name}.streetAddress3`} validate={validators?.streetAddress3} /> - - + {zipCityEnabled && ( + + )}
- + {zipCityEnabled && ( + + )} +
+
+ {stateField} + {postalCodeField}
-
{postalCodeField}
, )} @@ -117,6 +161,7 @@ AddressFields.propTypes = { className: PropTypes.string, name: PropTypes.string.isRequired, render: PropTypes.func, + zipCityEnabled: PropTypes.bool, validators: PropTypes.shape({ streetAddress1: PropTypes.func, streetAddress2: PropTypes.func, @@ -134,6 +179,7 @@ AddressFields.defaultProps = { legend: '', className: '', render: (fields) => fields, + zipCityEnabled: false, validators: {}, formikFunctionsToValidatePostalCodeOnChange: null, }; diff --git a/src/components/form/fields/ZipCityInput.jsx b/src/components/form/fields/ZipCityInput.jsx new file mode 100644 index 00000000000..e38c8f4cd12 --- /dev/null +++ b/src/components/form/fields/ZipCityInput.jsx @@ -0,0 +1,52 @@ +import { useField } from 'formik'; +import React from 'react'; +import PropTypes from 'prop-types'; + +import './DropdownInput.module.scss'; +import LocationSearchBox from 'components/LocationSearchBox/LocationSearchBox'; +import { searchTransportationOffices } from 'services/internalApi'; + +export const ZipCityInput = (props) => { + const { label, name, displayAddress, hint, placeholder, isDisabled, handleZipCityChange } = props; + const [field, meta, helpers] = useField(props); + const errorString = meta.value?.name ? meta.error?.name || meta.error : ''; + + return ( + + ); +}; + +ZipCityInput.propTypes = { + // label displayed for input + label: PropTypes.string.isRequired, + // name is for the input + name: PropTypes.string.isRequired, + displayAddress: PropTypes.bool, + hint: PropTypes.node, + placeholder: PropTypes.string, + isDisabled: PropTypes.bool, +}; + +ZipCityInput.defaultProps = { + displayAddress: true, + hint: '', + placeholder: '', + isDisabled: false, +}; + +export default ZipCityInput; diff --git a/src/pages/MyMove/Profile/ResidentialAddress.jsx b/src/pages/MyMove/Profile/ResidentialAddress.jsx index 32884504b62..8c78d52c333 100644 --- a/src/pages/MyMove/Profile/ResidentialAddress.jsx +++ b/src/pages/MyMove/Profile/ResidentialAddress.jsx @@ -48,6 +48,8 @@ export const ResidentialAddress = ({ serviceMember, updateServiceMember }) => { city: serviceMember.residential_address?.city || '', state: serviceMember.residential_address?.state || '', postalCode: serviceMember.residential_address?.postalCode || '', + county: serviceMember.residential_address?.county || '', + zipCity: '', }, }; diff --git a/swagger-def/definitions/ZipCityLookup.yaml b/swagger-def/definitions/ZipCityLookup.yaml new file mode 100644 index 00000000000..e02e4ba8c7c --- /dev/null +++ b/swagger-def/definitions/ZipCityLookup.yaml @@ -0,0 +1,126 @@ +description: A postal code and city lookup +type: object +properties: + city: + type: string + example: Anytown + title: City + state: + title: State + type: string + x-display-value: + AL: AL + AK: AK + AR: AR + AZ: AZ + CA: CA + CO: CO + CT: CT + DC: DC + DE: DE + FL: FL + GA: GA + HI: HI + IA: IA + ID: ID + IL: IL + IN: IN + KS: KS + KY: KY + LA: LA + MA: MA + MD: MD + ME: ME + MI: MI + MN: MN + MO: MO + MS: MS + MT: MT + NC: NC + ND: ND + NE: NE + NH: NH + NJ: NJ + NM: NM + NV: NV + NY: NY + OH: OH + OK: OK + OR: OR + PA: PA + RI: RI + SC: SC + SD: SD + TN: TN + TX: TX + UT: UT + VA: VA + VT: VT + WA: WA + WI: WI + WV: WV + WY: WY + enum: + - AL + - AK + - AR + - AZ + - CA + - CO + - CT + - DC + - DE + - FL + - GA + - HI + - IA + - ID + - IL + - IN + - KS + - KY + - LA + - MA + - MD + - ME + - MI + - MN + - MO + - MS + - MT + - NC + - ND + - NE + - NH + - NJ + - NM + - NV + - NY + - OH + - OK + - OR + - PA + - RI + - SC + - SD + - TN + - TX + - UT + - VA + - VT + - WA + - WI + - WV + - WY + postalCode: + type: string + format: zip + title: ZIP + example: '90210' + pattern: '^(\d{5}([\-]\d{4})?)$' + county: + type: string + title: County + x-nullable: true + example: 'LOS ANGELES' + diff --git a/swagger-def/internal.yaml b/swagger-def/internal.yaml index 8d0c9b4a472..2fddcb75be6 100644 --- a/swagger-def/internal.yaml +++ b/swagger-def/internal.yaml @@ -4148,6 +4148,31 @@ paths: description: not found "500": description: server error + /addresses/zip_city_lookup/{zip_city}: + get: + summary: Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City string + description: Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code. + operationId: getLocationByZipCity + tags: + - addresses + parameters: + - in: path + name: zip_city + type: string + required: true + responses: + "200": + description: the requested list of city, state, county, and postal code matches + schema: + $ref: "definitions/ZipCityLookup.yaml" + "400": + description: invalid request + "403": + description: not authorized + "404": + description: not found + "500": + description: server error "/mto_shipments": post: summary: createMTOShipment diff --git a/swagger/internal.yaml b/swagger/internal.yaml index a06ea2d0352..8d51f87bff4 100644 --- a/swagger/internal.yaml +++ b/swagger/internal.yaml @@ -3580,6 +3580,132 @@ definitions: RENTAL_EQUIPMENT: Rental equipment TOLLS: Tolls WEIGHING_FEE: Weighing fee + ZipCityLookup: + description: A postal code and city lookup + type: object + properties: + city: + type: string + example: Anytown + title: City + state: + title: State + type: string + x-display-value: + AL: AL + AK: AK + AR: AR + AZ: AZ + CA: CA + CO: CO + CT: CT + DC: DC + DE: DE + FL: FL + GA: GA + HI: HI + IA: IA + ID: ID + IL: IL + IN: IN + KS: KS + KY: KY + LA: LA + MA: MA + MD: MD + ME: ME + MI: MI + MN: MN + MO: MO + MS: MS + MT: MT + NC: NC + ND: ND + NE: NE + NH: NH + NJ: NJ + NM: NM + NV: NV + NY: NY + OH: OH + OK: OK + OR: OR + PA: PA + RI: RI + SC: SC + SD: SD + TN: TN + TX: TX + UT: UT + VA: VA + VT: VT + WA: WA + WI: WI + WV: WV + WY: WY + enum: + - AL + - AK + - AR + - AZ + - CA + - CO + - CT + - DC + - DE + - FL + - GA + - HI + - IA + - ID + - IL + - IN + - KS + - KY + - LA + - MA + - MD + - ME + - MI + - MN + - MO + - MS + - MT + - NC + - ND + - NE + - NH + - NJ + - NM + - NV + - NY + - OH + - OK + - OR + - PA + - RI + - SC + - SD + - TN + - TX + - UT + - VA + - VT + - WA + - WI + - WV + - WY + postalCode: + type: string + format: zip + title: ZIP + example: '90210' + pattern: ^(\d{5}([\-]\d{4})?)$ + county: + type: string + title: County + x-nullable: true + example: LOS ANGELES paths: /feature-flags/user-boolean/{key}: post: @@ -5588,6 +5714,36 @@ paths: description: not found '500': description: server error + /addresses/zip_city_lookup/{zip_city}: + get: + summary: >- + Returns City, State, Postal Code, and County associated with the + specified full/partial Postal Code or City string + description: >- + Find by API using full/partial Postal Code or City name that returns an + us_post_region_cities json object containing city, state, county and + postal code. + operationId: getLocationByZipCity + tags: + - addresses + parameters: + - in: path + name: zip_city + type: string + required: true + responses: + '200': + description: the requested list of city, state, county, and postal code matches + schema: + $ref: '#/definitions/ZipCityLookup' + '400': + description: invalid request + '403': + description: not authorized + '404': + description: not found + '500': + description: server error /mto_shipments: post: summary: createMTOShipment From 85787b2b72452170925e525e5ae03240769e9cc1 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Mon, 5 Aug 2024 18:11:12 +0000 Subject: [PATCH 002/216] linter fixes --- pkg/gen/internalapi/embedded_spec.go | 576 +++++++++--------- .../get_location_by_zip_city_responses.go | 19 +- .../internalmessages/us_post_region_cities.go | 78 +++ .../internalmessages/us_post_region_city.go | 281 +++++++++ pkg/gen/internalmessages/zip_city_lookup.go | 281 --------- pkg/handlers/internalapi/addresses.go | 26 + pkg/handlers/internalapi/api.go | 6 + .../internal/payloads/model_to_payload.go | 27 + .../internal/payloads/payload_to_model.go | 14 + pkg/models/us_post_region_city.go | 4 + pkg/services/address.go | 4 + pkg/services/address/address_lookup.go | 77 +++ .../ResidentialAddressForm.jsx | 18 +- .../form/AddressFields/AddressFields.jsx | 7 +- .../MyMove/Profile/ResidentialAddress.jsx | 1 - ...pCityLookup.yaml => UsPostRegionCity.yaml} | 0 swagger-def/internal.yaml | 6 +- swagger/internal.yaml | 8 +- 18 files changed, 851 insertions(+), 582 deletions(-) create mode 100644 pkg/gen/internalmessages/us_post_region_cities.go create mode 100644 pkg/gen/internalmessages/us_post_region_city.go delete mode 100644 pkg/gen/internalmessages/zip_city_lookup.go create mode 100644 pkg/services/address/address_lookup.go rename swagger-def/definitions/{ZipCityLookup.yaml => UsPostRegionCity.yaml} (100%) diff --git a/pkg/gen/internalapi/embedded_spec.go b/pkg/gen/internalapi/embedded_spec.go index aa54c788b89..60a46505405 100644 --- a/pkg/gen/internalapi/embedded_spec.go +++ b/pkg/gen/internalapi/embedded_spec.go @@ -59,7 +59,7 @@ func init() { "200": { "description": "the requested list of city, state, county, and postal code matches", "schema": { - "$ref": "#/definitions/ZipCityLookup" + "$ref": "#/definitions/UsPostRegionCities" } }, "400": { @@ -7287,6 +7287,146 @@ func init() { } } }, + "UsPostRegionCities": { + "type": "array", + "items": { + "$ref": "#/definitions/UsPostRegionCity" + } + }, + "UsPostRegionCity": { + "description": "A postal code and city lookup", + "type": "object", + "properties": { + "city": { + "type": "string", + "title": "City", + "example": "Anytown" + }, + "county": { + "type": "string", + "title": "County", + "x-nullable": true, + "example": "LOS ANGELES" + }, + "postalCode": { + "type": "string", + "format": "zip", + "title": "ZIP", + "pattern": "^(\\d{5}([\\-]\\d{4})?)$", + "example": "90210" + }, + "state": { + "type": "string", + "title": "State", + "enum": [ + "AL", + "AK", + "AR", + "AZ", + "CA", + "CO", + "CT", + "DC", + "DE", + "FL", + "GA", + "HI", + "IA", + "ID", + "IL", + "IN", + "KS", + "KY", + "LA", + "MA", + "MD", + "ME", + "MI", + "MN", + "MO", + "MS", + "MT", + "NC", + "ND", + "NE", + "NH", + "NJ", + "NM", + "NV", + "NY", + "OH", + "OK", + "OR", + "PA", + "RI", + "SC", + "SD", + "TN", + "TX", + "UT", + "VA", + "VT", + "WA", + "WI", + "WV", + "WY" + ], + "x-display-value": { + "AK": "AK", + "AL": "AL", + "AR": "AR", + "AZ": "AZ", + "CA": "CA", + "CO": "CO", + "CT": "CT", + "DC": "DC", + "DE": "DE", + "FL": "FL", + "GA": "GA", + "HI": "HI", + "IA": "IA", + "ID": "ID", + "IL": "IL", + "IN": "IN", + "KS": "KS", + "KY": "KY", + "LA": "LA", + "MA": "MA", + "MD": "MD", + "ME": "ME", + "MI": "MI", + "MN": "MN", + "MO": "MO", + "MS": "MS", + "MT": "MT", + "NC": "NC", + "ND": "ND", + "NE": "NE", + "NH": "NH", + "NJ": "NJ", + "NM": "NM", + "NV": "NV", + "NY": "NY", + "OH": "OH", + "OK": "OK", + "OR": "OR", + "PA": "PA", + "RI": "RI", + "SC": "SC", + "SD": "SD", + "TN": "TN", + "TX": "TX", + "UT": "UT", + "VA": "VA", + "VT": "VT", + "WA": "WA", + "WI": "WI", + "WV": "WV", + "WY": "WY" + } + } + } + }, "ValidationError": { "required": [ "invalidFields" @@ -7549,140 +7689,6 @@ func init() { "$ref": "#/definitions/WeightTicket" }, "x-omitempty": false - }, - "ZipCityLookup": { - "description": "A postal code and city lookup", - "type": "object", - "properties": { - "city": { - "type": "string", - "title": "City", - "example": "Anytown" - }, - "county": { - "type": "string", - "title": "County", - "x-nullable": true, - "example": "LOS ANGELES" - }, - "postalCode": { - "type": "string", - "format": "zip", - "title": "ZIP", - "pattern": "^(\\d{5}([\\-]\\d{4})?)$", - "example": "90210" - }, - "state": { - "type": "string", - "title": "State", - "enum": [ - "AL", - "AK", - "AR", - "AZ", - "CA", - "CO", - "CT", - "DC", - "DE", - "FL", - "GA", - "HI", - "IA", - "ID", - "IL", - "IN", - "KS", - "KY", - "LA", - "MA", - "MD", - "ME", - "MI", - "MN", - "MO", - "MS", - "MT", - "NC", - "ND", - "NE", - "NH", - "NJ", - "NM", - "NV", - "NY", - "OH", - "OK", - "OR", - "PA", - "RI", - "SC", - "SD", - "TN", - "TX", - "UT", - "VA", - "VT", - "WA", - "WI", - "WV", - "WY" - ], - "x-display-value": { - "AK": "AK", - "AL": "AL", - "AR": "AR", - "AZ": "AZ", - "CA": "CA", - "CO": "CO", - "CT": "CT", - "DC": "DC", - "DE": "DE", - "FL": "FL", - "GA": "GA", - "HI": "HI", - "IA": "IA", - "ID": "ID", - "IL": "IL", - "IN": "IN", - "KS": "KS", - "KY": "KY", - "LA": "LA", - "MA": "MA", - "MD": "MD", - "ME": "ME", - "MI": "MI", - "MN": "MN", - "MO": "MO", - "MS": "MS", - "MT": "MT", - "NC": "NC", - "ND": "ND", - "NE": "NE", - "NH": "NH", - "NJ": "NJ", - "NM": "NM", - "NV": "NV", - "NY": "NY", - "OH": "OH", - "OK": "OK", - "OR": "OR", - "PA": "PA", - "RI": "RI", - "SC": "SC", - "SD": "SD", - "TN": "TN", - "TX": "TX", - "UT": "UT", - "VA": "VA", - "VT": "VT", - "WA": "WA", - "WI": "WI", - "WV": "WV", - "WY": "WY" - } - } - } } }, "parameters": { @@ -7881,7 +7887,7 @@ func init() { "200": { "description": "the requested list of city, state, county, and postal code matches", "schema": { - "$ref": "#/definitions/ZipCityLookup" + "$ref": "#/definitions/UsPostRegionCities" } }, "400": { @@ -15543,21 +15549,161 @@ func init() { "format": "date-time", "readOnly": true }, - "uploadType": { + "uploadType": { + "type": "string", + "enum": [ + "USER", + "PRIME", + "OFFICE" + ], + "readOnly": true, + "example": "OFFICE" + }, + "url": { + "type": "string", + "format": "uri", + "readOnly": true, + "example": "https://uploads.domain.test/dir/c56a4180-65aa-42ec-a945-5fd21dec0538" + } + } + }, + "UsPostRegionCities": { + "type": "array", + "items": { + "$ref": "#/definitions/UsPostRegionCity" + } + }, + "UsPostRegionCity": { + "description": "A postal code and city lookup", + "type": "object", + "properties": { + "city": { + "type": "string", + "title": "City", + "example": "Anytown" + }, + "county": { + "type": "string", + "title": "County", + "x-nullable": true, + "example": "LOS ANGELES" + }, + "postalCode": { + "type": "string", + "format": "zip", + "title": "ZIP", + "pattern": "^(\\d{5}([\\-]\\d{4})?)$", + "example": "90210" + }, + "state": { "type": "string", + "title": "State", "enum": [ - "USER", - "PRIME", - "OFFICE" + "AL", + "AK", + "AR", + "AZ", + "CA", + "CO", + "CT", + "DC", + "DE", + "FL", + "GA", + "HI", + "IA", + "ID", + "IL", + "IN", + "KS", + "KY", + "LA", + "MA", + "MD", + "ME", + "MI", + "MN", + "MO", + "MS", + "MT", + "NC", + "ND", + "NE", + "NH", + "NJ", + "NM", + "NV", + "NY", + "OH", + "OK", + "OR", + "PA", + "RI", + "SC", + "SD", + "TN", + "TX", + "UT", + "VA", + "VT", + "WA", + "WI", + "WV", + "WY" ], - "readOnly": true, - "example": "OFFICE" - }, - "url": { - "type": "string", - "format": "uri", - "readOnly": true, - "example": "https://uploads.domain.test/dir/c56a4180-65aa-42ec-a945-5fd21dec0538" + "x-display-value": { + "AK": "AK", + "AL": "AL", + "AR": "AR", + "AZ": "AZ", + "CA": "CA", + "CO": "CO", + "CT": "CT", + "DC": "DC", + "DE": "DE", + "FL": "FL", + "GA": "GA", + "HI": "HI", + "IA": "IA", + "ID": "ID", + "IL": "IL", + "IN": "IN", + "KS": "KS", + "KY": "KY", + "LA": "LA", + "MA": "MA", + "MD": "MD", + "ME": "ME", + "MI": "MI", + "MN": "MN", + "MO": "MO", + "MS": "MS", + "MT": "MT", + "NC": "NC", + "ND": "ND", + "NE": "NE", + "NH": "NH", + "NJ": "NJ", + "NM": "NM", + "NV": "NV", + "NY": "NY", + "OH": "OH", + "OK": "OK", + "OR": "OR", + "PA": "PA", + "RI": "RI", + "SC": "SC", + "SD": "SD", + "TN": "TN", + "TX": "TX", + "UT": "UT", + "VA": "VA", + "VT": "VT", + "WA": "WA", + "WI": "WI", + "WV": "WV", + "WY": "WY" + } } } }, @@ -15832,140 +15978,6 @@ func init() { "$ref": "#/definitions/WeightTicket" }, "x-omitempty": false - }, - "ZipCityLookup": { - "description": "A postal code and city lookup", - "type": "object", - "properties": { - "city": { - "type": "string", - "title": "City", - "example": "Anytown" - }, - "county": { - "type": "string", - "title": "County", - "x-nullable": true, - "example": "LOS ANGELES" - }, - "postalCode": { - "type": "string", - "format": "zip", - "title": "ZIP", - "pattern": "^(\\d{5}([\\-]\\d{4})?)$", - "example": "90210" - }, - "state": { - "type": "string", - "title": "State", - "enum": [ - "AL", - "AK", - "AR", - "AZ", - "CA", - "CO", - "CT", - "DC", - "DE", - "FL", - "GA", - "HI", - "IA", - "ID", - "IL", - "IN", - "KS", - "KY", - "LA", - "MA", - "MD", - "ME", - "MI", - "MN", - "MO", - "MS", - "MT", - "NC", - "ND", - "NE", - "NH", - "NJ", - "NM", - "NV", - "NY", - "OH", - "OK", - "OR", - "PA", - "RI", - "SC", - "SD", - "TN", - "TX", - "UT", - "VA", - "VT", - "WA", - "WI", - "WV", - "WY" - ], - "x-display-value": { - "AK": "AK", - "AL": "AL", - "AR": "AR", - "AZ": "AZ", - "CA": "CA", - "CO": "CO", - "CT": "CT", - "DC": "DC", - "DE": "DE", - "FL": "FL", - "GA": "GA", - "HI": "HI", - "IA": "IA", - "ID": "ID", - "IL": "IL", - "IN": "IN", - "KS": "KS", - "KY": "KY", - "LA": "LA", - "MA": "MA", - "MD": "MD", - "ME": "ME", - "MI": "MI", - "MN": "MN", - "MO": "MO", - "MS": "MS", - "MT": "MT", - "NC": "NC", - "ND": "ND", - "NE": "NE", - "NH": "NH", - "NJ": "NJ", - "NM": "NM", - "NV": "NV", - "NY": "NY", - "OH": "OH", - "OK": "OK", - "OR": "OR", - "PA": "PA", - "RI": "RI", - "SC": "SC", - "SD": "SD", - "TN": "TN", - "TX": "TX", - "UT": "UT", - "VA": "VA", - "VT": "VT", - "WA": "WA", - "WI": "WI", - "WV": "WV", - "WY": "WY" - } - } - } } }, "parameters": { diff --git a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_responses.go b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_responses.go index e0039e991cd..b1b9e4315b7 100644 --- a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_responses.go +++ b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_responses.go @@ -26,7 +26,7 @@ type GetLocationByZipCityOK struct { /* In: Body */ - Payload *internalmessages.ZipCityLookup `json:"body,omitempty"` + Payload internalmessages.UsPostRegionCities `json:"body,omitempty"` } // NewGetLocationByZipCityOK creates GetLocationByZipCityOK with default headers values @@ -36,13 +36,13 @@ func NewGetLocationByZipCityOK() *GetLocationByZipCityOK { } // WithPayload adds the payload to the get location by zip city o k response -func (o *GetLocationByZipCityOK) WithPayload(payload *internalmessages.ZipCityLookup) *GetLocationByZipCityOK { +func (o *GetLocationByZipCityOK) WithPayload(payload internalmessages.UsPostRegionCities) *GetLocationByZipCityOK { o.Payload = payload return o } // SetPayload sets the payload to the get location by zip city o k response -func (o *GetLocationByZipCityOK) SetPayload(payload *internalmessages.ZipCityLookup) { +func (o *GetLocationByZipCityOK) SetPayload(payload internalmessages.UsPostRegionCities) { o.Payload = payload } @@ -50,11 +50,14 @@ func (o *GetLocationByZipCityOK) SetPayload(payload *internalmessages.ZipCityLoo func (o *GetLocationByZipCityOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } + payload := o.Payload + if payload == nil { + // return empty array + payload = internalmessages.UsPostRegionCities{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this } } diff --git a/pkg/gen/internalmessages/us_post_region_cities.go b/pkg/gen/internalmessages/us_post_region_cities.go new file mode 100644 index 00000000000..b8b2177aec5 --- /dev/null +++ b/pkg/gen/internalmessages/us_post_region_cities.go @@ -0,0 +1,78 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package internalmessages + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// UsPostRegionCities us post region cities +// +// swagger:model UsPostRegionCities +type UsPostRegionCities []*UsPostRegionCity + +// Validate validates this us post region cities +func (m UsPostRegionCities) Validate(formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + if swag.IsZero(m[i]) { // not required + continue + } + + if m[i] != nil { + if err := m[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this us post region cities based on the context it is used +func (m UsPostRegionCities) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + + if m[i] != nil { + + if swag.IsZero(m[i]) { // not required + return nil + } + + if err := m[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/gen/internalmessages/us_post_region_city.go b/pkg/gen/internalmessages/us_post_region_city.go new file mode 100644 index 00000000000..d4f71c2c614 --- /dev/null +++ b/pkg/gen/internalmessages/us_post_region_city.go @@ -0,0 +1,281 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package internalmessages + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// UsPostRegionCity A postal code and city lookup +// +// swagger:model UsPostRegionCity +type UsPostRegionCity struct { + + // City + // Example: Anytown + City string `json:"city,omitempty"` + + // County + // Example: LOS ANGELES + County *string `json:"county,omitempty"` + + // ZIP + // Example: 90210 + // Pattern: ^(\d{5}([\-]\d{4})?)$ + PostalCode string `json:"postalCode,omitempty"` + + // State + // Enum: [AL AK AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD TN TX UT VA VT WA WI WV WY] + State string `json:"state,omitempty"` +} + +// Validate validates this us post region city +func (m *UsPostRegionCity) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePostalCode(formats); err != nil { + res = append(res, err) + } + + if err := m.validateState(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UsPostRegionCity) validatePostalCode(formats strfmt.Registry) error { + if swag.IsZero(m.PostalCode) { // not required + return nil + } + + if err := validate.Pattern("postalCode", "body", m.PostalCode, `^(\d{5}([\-]\d{4})?)$`); err != nil { + return err + } + + return nil +} + +var usPostRegionCityTypeStatePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["AL","AK","AR","AZ","CA","CO","CT","DC","DE","FL","GA","HI","IA","ID","IL","IN","KS","KY","LA","MA","MD","ME","MI","MN","MO","MS","MT","NC","ND","NE","NH","NJ","NM","NV","NY","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VA","VT","WA","WI","WV","WY"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + usPostRegionCityTypeStatePropEnum = append(usPostRegionCityTypeStatePropEnum, v) + } +} + +const ( + + // UsPostRegionCityStateAL captures enum value "AL" + UsPostRegionCityStateAL string = "AL" + + // UsPostRegionCityStateAK captures enum value "AK" + UsPostRegionCityStateAK string = "AK" + + // UsPostRegionCityStateAR captures enum value "AR" + UsPostRegionCityStateAR string = "AR" + + // UsPostRegionCityStateAZ captures enum value "AZ" + UsPostRegionCityStateAZ string = "AZ" + + // UsPostRegionCityStateCA captures enum value "CA" + UsPostRegionCityStateCA string = "CA" + + // UsPostRegionCityStateCO captures enum value "CO" + UsPostRegionCityStateCO string = "CO" + + // UsPostRegionCityStateCT captures enum value "CT" + UsPostRegionCityStateCT string = "CT" + + // UsPostRegionCityStateDC captures enum value "DC" + UsPostRegionCityStateDC string = "DC" + + // UsPostRegionCityStateDE captures enum value "DE" + UsPostRegionCityStateDE string = "DE" + + // UsPostRegionCityStateFL captures enum value "FL" + UsPostRegionCityStateFL string = "FL" + + // UsPostRegionCityStateGA captures enum value "GA" + UsPostRegionCityStateGA string = "GA" + + // UsPostRegionCityStateHI captures enum value "HI" + UsPostRegionCityStateHI string = "HI" + + // UsPostRegionCityStateIA captures enum value "IA" + UsPostRegionCityStateIA string = "IA" + + // UsPostRegionCityStateID captures enum value "ID" + UsPostRegionCityStateID string = "ID" + + // UsPostRegionCityStateIL captures enum value "IL" + UsPostRegionCityStateIL string = "IL" + + // UsPostRegionCityStateIN captures enum value "IN" + UsPostRegionCityStateIN string = "IN" + + // UsPostRegionCityStateKS captures enum value "KS" + UsPostRegionCityStateKS string = "KS" + + // UsPostRegionCityStateKY captures enum value "KY" + UsPostRegionCityStateKY string = "KY" + + // UsPostRegionCityStateLA captures enum value "LA" + UsPostRegionCityStateLA string = "LA" + + // UsPostRegionCityStateMA captures enum value "MA" + UsPostRegionCityStateMA string = "MA" + + // UsPostRegionCityStateMD captures enum value "MD" + UsPostRegionCityStateMD string = "MD" + + // UsPostRegionCityStateME captures enum value "ME" + UsPostRegionCityStateME string = "ME" + + // UsPostRegionCityStateMI captures enum value "MI" + UsPostRegionCityStateMI string = "MI" + + // UsPostRegionCityStateMN captures enum value "MN" + UsPostRegionCityStateMN string = "MN" + + // UsPostRegionCityStateMO captures enum value "MO" + UsPostRegionCityStateMO string = "MO" + + // UsPostRegionCityStateMS captures enum value "MS" + UsPostRegionCityStateMS string = "MS" + + // UsPostRegionCityStateMT captures enum value "MT" + UsPostRegionCityStateMT string = "MT" + + // UsPostRegionCityStateNC captures enum value "NC" + UsPostRegionCityStateNC string = "NC" + + // UsPostRegionCityStateND captures enum value "ND" + UsPostRegionCityStateND string = "ND" + + // UsPostRegionCityStateNE captures enum value "NE" + UsPostRegionCityStateNE string = "NE" + + // UsPostRegionCityStateNH captures enum value "NH" + UsPostRegionCityStateNH string = "NH" + + // UsPostRegionCityStateNJ captures enum value "NJ" + UsPostRegionCityStateNJ string = "NJ" + + // UsPostRegionCityStateNM captures enum value "NM" + UsPostRegionCityStateNM string = "NM" + + // UsPostRegionCityStateNV captures enum value "NV" + UsPostRegionCityStateNV string = "NV" + + // UsPostRegionCityStateNY captures enum value "NY" + UsPostRegionCityStateNY string = "NY" + + // UsPostRegionCityStateOH captures enum value "OH" + UsPostRegionCityStateOH string = "OH" + + // UsPostRegionCityStateOK captures enum value "OK" + UsPostRegionCityStateOK string = "OK" + + // UsPostRegionCityStateOR captures enum value "OR" + UsPostRegionCityStateOR string = "OR" + + // UsPostRegionCityStatePA captures enum value "PA" + UsPostRegionCityStatePA string = "PA" + + // UsPostRegionCityStateRI captures enum value "RI" + UsPostRegionCityStateRI string = "RI" + + // UsPostRegionCityStateSC captures enum value "SC" + UsPostRegionCityStateSC string = "SC" + + // UsPostRegionCityStateSD captures enum value "SD" + UsPostRegionCityStateSD string = "SD" + + // UsPostRegionCityStateTN captures enum value "TN" + UsPostRegionCityStateTN string = "TN" + + // UsPostRegionCityStateTX captures enum value "TX" + UsPostRegionCityStateTX string = "TX" + + // UsPostRegionCityStateUT captures enum value "UT" + UsPostRegionCityStateUT string = "UT" + + // UsPostRegionCityStateVA captures enum value "VA" + UsPostRegionCityStateVA string = "VA" + + // UsPostRegionCityStateVT captures enum value "VT" + UsPostRegionCityStateVT string = "VT" + + // UsPostRegionCityStateWA captures enum value "WA" + UsPostRegionCityStateWA string = "WA" + + // UsPostRegionCityStateWI captures enum value "WI" + UsPostRegionCityStateWI string = "WI" + + // UsPostRegionCityStateWV captures enum value "WV" + UsPostRegionCityStateWV string = "WV" + + // UsPostRegionCityStateWY captures enum value "WY" + UsPostRegionCityStateWY string = "WY" +) + +// prop value enum +func (m *UsPostRegionCity) validateStateEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, usPostRegionCityTypeStatePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *UsPostRegionCity) validateState(formats strfmt.Registry) error { + if swag.IsZero(m.State) { // not required + return nil + } + + // value enum + if err := m.validateStateEnum("state", "body", m.State); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this us post region city based on context it is used +func (m *UsPostRegionCity) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *UsPostRegionCity) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UsPostRegionCity) UnmarshalBinary(b []byte) error { + var res UsPostRegionCity + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/internalmessages/zip_city_lookup.go b/pkg/gen/internalmessages/zip_city_lookup.go deleted file mode 100644 index 84452ee8787..00000000000 --- a/pkg/gen/internalmessages/zip_city_lookup.go +++ /dev/null @@ -1,281 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package internalmessages - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "encoding/json" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// ZipCityLookup A postal code and city lookup -// -// swagger:model ZipCityLookup -type ZipCityLookup struct { - - // City - // Example: Anytown - City string `json:"city,omitempty"` - - // County - // Example: LOS ANGELES - County *string `json:"county,omitempty"` - - // ZIP - // Example: 90210 - // Pattern: ^(\d{5}([\-]\d{4})?)$ - PostalCode string `json:"postalCode,omitempty"` - - // State - // Enum: [AL AK AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD TN TX UT VA VT WA WI WV WY] - State string `json:"state,omitempty"` -} - -// Validate validates this zip city lookup -func (m *ZipCityLookup) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validatePostalCode(formats); err != nil { - res = append(res, err) - } - - if err := m.validateState(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ZipCityLookup) validatePostalCode(formats strfmt.Registry) error { - if swag.IsZero(m.PostalCode) { // not required - return nil - } - - if err := validate.Pattern("postalCode", "body", m.PostalCode, `^(\d{5}([\-]\d{4})?)$`); err != nil { - return err - } - - return nil -} - -var zipCityLookupTypeStatePropEnum []interface{} - -func init() { - var res []string - if err := json.Unmarshal([]byte(`["AL","AK","AR","AZ","CA","CO","CT","DC","DE","FL","GA","HI","IA","ID","IL","IN","KS","KY","LA","MA","MD","ME","MI","MN","MO","MS","MT","NC","ND","NE","NH","NJ","NM","NV","NY","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VA","VT","WA","WI","WV","WY"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - zipCityLookupTypeStatePropEnum = append(zipCityLookupTypeStatePropEnum, v) - } -} - -const ( - - // ZipCityLookupStateAL captures enum value "AL" - ZipCityLookupStateAL string = "AL" - - // ZipCityLookupStateAK captures enum value "AK" - ZipCityLookupStateAK string = "AK" - - // ZipCityLookupStateAR captures enum value "AR" - ZipCityLookupStateAR string = "AR" - - // ZipCityLookupStateAZ captures enum value "AZ" - ZipCityLookupStateAZ string = "AZ" - - // ZipCityLookupStateCA captures enum value "CA" - ZipCityLookupStateCA string = "CA" - - // ZipCityLookupStateCO captures enum value "CO" - ZipCityLookupStateCO string = "CO" - - // ZipCityLookupStateCT captures enum value "CT" - ZipCityLookupStateCT string = "CT" - - // ZipCityLookupStateDC captures enum value "DC" - ZipCityLookupStateDC string = "DC" - - // ZipCityLookupStateDE captures enum value "DE" - ZipCityLookupStateDE string = "DE" - - // ZipCityLookupStateFL captures enum value "FL" - ZipCityLookupStateFL string = "FL" - - // ZipCityLookupStateGA captures enum value "GA" - ZipCityLookupStateGA string = "GA" - - // ZipCityLookupStateHI captures enum value "HI" - ZipCityLookupStateHI string = "HI" - - // ZipCityLookupStateIA captures enum value "IA" - ZipCityLookupStateIA string = "IA" - - // ZipCityLookupStateID captures enum value "ID" - ZipCityLookupStateID string = "ID" - - // ZipCityLookupStateIL captures enum value "IL" - ZipCityLookupStateIL string = "IL" - - // ZipCityLookupStateIN captures enum value "IN" - ZipCityLookupStateIN string = "IN" - - // ZipCityLookupStateKS captures enum value "KS" - ZipCityLookupStateKS string = "KS" - - // ZipCityLookupStateKY captures enum value "KY" - ZipCityLookupStateKY string = "KY" - - // ZipCityLookupStateLA captures enum value "LA" - ZipCityLookupStateLA string = "LA" - - // ZipCityLookupStateMA captures enum value "MA" - ZipCityLookupStateMA string = "MA" - - // ZipCityLookupStateMD captures enum value "MD" - ZipCityLookupStateMD string = "MD" - - // ZipCityLookupStateME captures enum value "ME" - ZipCityLookupStateME string = "ME" - - // ZipCityLookupStateMI captures enum value "MI" - ZipCityLookupStateMI string = "MI" - - // ZipCityLookupStateMN captures enum value "MN" - ZipCityLookupStateMN string = "MN" - - // ZipCityLookupStateMO captures enum value "MO" - ZipCityLookupStateMO string = "MO" - - // ZipCityLookupStateMS captures enum value "MS" - ZipCityLookupStateMS string = "MS" - - // ZipCityLookupStateMT captures enum value "MT" - ZipCityLookupStateMT string = "MT" - - // ZipCityLookupStateNC captures enum value "NC" - ZipCityLookupStateNC string = "NC" - - // ZipCityLookupStateND captures enum value "ND" - ZipCityLookupStateND string = "ND" - - // ZipCityLookupStateNE captures enum value "NE" - ZipCityLookupStateNE string = "NE" - - // ZipCityLookupStateNH captures enum value "NH" - ZipCityLookupStateNH string = "NH" - - // ZipCityLookupStateNJ captures enum value "NJ" - ZipCityLookupStateNJ string = "NJ" - - // ZipCityLookupStateNM captures enum value "NM" - ZipCityLookupStateNM string = "NM" - - // ZipCityLookupStateNV captures enum value "NV" - ZipCityLookupStateNV string = "NV" - - // ZipCityLookupStateNY captures enum value "NY" - ZipCityLookupStateNY string = "NY" - - // ZipCityLookupStateOH captures enum value "OH" - ZipCityLookupStateOH string = "OH" - - // ZipCityLookupStateOK captures enum value "OK" - ZipCityLookupStateOK string = "OK" - - // ZipCityLookupStateOR captures enum value "OR" - ZipCityLookupStateOR string = "OR" - - // ZipCityLookupStatePA captures enum value "PA" - ZipCityLookupStatePA string = "PA" - - // ZipCityLookupStateRI captures enum value "RI" - ZipCityLookupStateRI string = "RI" - - // ZipCityLookupStateSC captures enum value "SC" - ZipCityLookupStateSC string = "SC" - - // ZipCityLookupStateSD captures enum value "SD" - ZipCityLookupStateSD string = "SD" - - // ZipCityLookupStateTN captures enum value "TN" - ZipCityLookupStateTN string = "TN" - - // ZipCityLookupStateTX captures enum value "TX" - ZipCityLookupStateTX string = "TX" - - // ZipCityLookupStateUT captures enum value "UT" - ZipCityLookupStateUT string = "UT" - - // ZipCityLookupStateVA captures enum value "VA" - ZipCityLookupStateVA string = "VA" - - // ZipCityLookupStateVT captures enum value "VT" - ZipCityLookupStateVT string = "VT" - - // ZipCityLookupStateWA captures enum value "WA" - ZipCityLookupStateWA string = "WA" - - // ZipCityLookupStateWI captures enum value "WI" - ZipCityLookupStateWI string = "WI" - - // ZipCityLookupStateWV captures enum value "WV" - ZipCityLookupStateWV string = "WV" - - // ZipCityLookupStateWY captures enum value "WY" - ZipCityLookupStateWY string = "WY" -) - -// prop value enum -func (m *ZipCityLookup) validateStateEnum(path, location string, value string) error { - if err := validate.EnumCase(path, location, value, zipCityLookupTypeStatePropEnum, true); err != nil { - return err - } - return nil -} - -func (m *ZipCityLookup) validateState(formats strfmt.Registry) error { - if swag.IsZero(m.State) { // not required - return nil - } - - // value enum - if err := m.validateStateEnum("state", "body", m.State); err != nil { - return err - } - - return nil -} - -// ContextValidate validates this zip city lookup based on context it is used -func (m *ZipCityLookup) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *ZipCityLookup) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ZipCityLookup) UnmarshalBinary(b []byte) error { - var res ZipCityLookup - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/handlers/internalapi/addresses.go b/pkg/handlers/internalapi/addresses.go index 5fdc3eabd14..f08c68b9b64 100644 --- a/pkg/handlers/internalapi/addresses.go +++ b/pkg/handlers/internalapi/addresses.go @@ -6,11 +6,13 @@ import ( "go.uber.org/zap" "github.com/transcom/mymove/pkg/appcontext" + "github.com/transcom/mymove/pkg/apperror" addressop "github.com/transcom/mymove/pkg/gen/internalapi/internaloperations/addresses" "github.com/transcom/mymove/pkg/gen/internalmessages" "github.com/transcom/mymove/pkg/handlers" "github.com/transcom/mymove/pkg/handlers/internalapi/internal/payloads" "github.com/transcom/mymove/pkg/models" + "github.com/transcom/mymove/pkg/services" ) func addressModelFromPayload(rawAddress *internalmessages.Address) *models.Address { @@ -67,3 +69,27 @@ func (h ShowAddressHandler) Handle(params addressop.ShowAddressParams) middlewar return addressop.NewShowAddressOK().WithPayload(addressPayload), nil }) } + +type GetLocationByZipCityHandler struct { + handlers.HandlerConfig + services.UsPostRegionCity +} + +func (h GetLocationByZipCityHandler) Handle(params addressop.GetLocationByZipCityParams) middleware.Responder { + return h.AuditableAppContextFromRequestWithErrors(params.HTTPRequest, + func(appCtx appcontext.AppContext) (middleware.Responder, error) { + if !appCtx.Session().IsMilApp() && appCtx.Session().ServiceMemberID == uuid.Nil { + noServiceMemberIDErr := apperror.NewSessionError("No service member ID") + return addressop.NewGetLocationByZipCityForbidden(), noServiceMemberIDErr + } + + locationList, err := h.GetLocationsByZipCity(appCtx, params.ZipCity) + if err != nil { + appCtx.Logger().Error("Error searching for Transportation Offices: ", zap.Error(err)) + return addressop.NewGetLocationByZipCityInternalServerError(), err + } + + returnPayload := payloads.UsPostRegionCities(*locationList) + return addressop.NewGetLocationByZipCityOK().WithPayload(returnPayload), nil + }) +} diff --git a/pkg/handlers/internalapi/api.go b/pkg/handlers/internalapi/api.go index 058cfc049d2..334011fb167 100644 --- a/pkg/handlers/internalapi/api.go +++ b/pkg/handlers/internalapi/api.go @@ -87,6 +87,7 @@ func NewInternalAPI(handlerConfig handlers.HandlerConfig) *internalops.MymoveAPI closeoutOfficeUpdater := move.NewCloseoutOfficeUpdater(move.NewMoveFetcher(), transportationOfficeFetcher) addressCreator := address.NewAddressCreator() addressUpdater := address.NewAddressUpdater() + usPostRegionCity := address.NewUsPostRegionCity() ppmShipmentUpdater := ppmshipment.NewPPMShipmentUpdater(ppmEstimator, addressCreator, addressUpdater) @@ -259,6 +260,11 @@ func NewInternalAPI(handlerConfig handlers.HandlerConfig) *internalops.MymoveAPI transportationOfficeFetcher, } + internalAPI.AddressesGetLocationByZipCityHandler = GetLocationByZipCityHandler{ + handlerConfig, + usPostRegionCity, + } + paymentPacketCreator := ppmshipment.NewPaymentPacketCreator(ppmShipmentFetcher, pdfGenerator, AOAPacketCreator) internalAPI.PpmShowPaymentPacketHandler = ShowPaymentPacketHandler{handlerConfig, paymentPacketCreator} diff --git a/pkg/handlers/internalapi/internal/payloads/model_to_payload.go b/pkg/handlers/internalapi/internal/payloads/model_to_payload.go index 6fefd884c93..d219b23211f 100644 --- a/pkg/handlers/internalapi/internal/payloads/model_to_payload.go +++ b/pkg/handlers/internalapi/internal/payloads/model_to_payload.go @@ -553,3 +553,30 @@ func SignedCertification(signedCertification *models.SignedCertification) *inter return model } + +// UsPostRegionCity payload +func UsPostRegionCity(usPostRegionCity *models.UsPostRegionCity) *internalmessages.UsPostRegionCity { + if usPostRegionCity == nil { + return nil + } + if *usPostRegionCity == (models.UsPostRegionCity{}) { + return nil + } + + return &internalmessages.UsPostRegionCity{ + City: usPostRegionCity.USPostRegionCityNm, + State: usPostRegionCity.State, + PostalCode: usPostRegionCity.UsprZipID, + County: &usPostRegionCity.UsprcCountyNm, + } +} + +// UsPostRegionCities payload +func UsPostRegionCities(usPostRegionCities models.UsPostRegionCities) internalmessages.UsPostRegionCities { + payload := make(internalmessages.UsPostRegionCities, len(usPostRegionCities)) + for i, usPostRegionCity := range usPostRegionCities { + copyOfUsPostRegionCity := usPostRegionCity + payload[i] = UsPostRegionCity(©OfUsPostRegionCity) + } + return payload +} diff --git a/pkg/handlers/internalapi/internal/payloads/payload_to_model.go b/pkg/handlers/internalapi/internal/payloads/payload_to_model.go index 7f9d8f7c4c5..afa85e8cd50 100644 --- a/pkg/handlers/internalapi/internal/payloads/payload_to_model.go +++ b/pkg/handlers/internalapi/internal/payloads/payload_to_model.go @@ -32,6 +32,20 @@ func AddressModel(address *internalmessages.Address) *models.Address { } } +// UsPostRegionCityModel model +func UsPostRegionCityModel(usPostRegionCity *internalmessages.UsPostRegionCity) *models.UsPostRegionCity { + if usPostRegionCity == nil { + return nil + } + + return &models.UsPostRegionCity{ + USPostRegionCityNm: usPostRegionCity.City, + State: usPostRegionCity.State, + UsprZipID: usPostRegionCity.PostalCode, + UsprcCountyNm: *usPostRegionCity.County, + } +} + // MTOAgentModel model func MTOAgentModel(mtoAgent *internalmessages.MTOAgent) *models.MTOAgent { if mtoAgent == nil { diff --git a/pkg/models/us_post_region_city.go b/pkg/models/us_post_region_city.go index 1b3126947fa..89f88788deb 100644 --- a/pkg/models/us_post_region_city.go +++ b/pkg/models/us_post_region_city.go @@ -29,8 +29,11 @@ type UsPostRegionCity struct { CtryGencDgphCd string `db:"ctry_genc_dgph_cd" json:"ctry_genc_dgph_cd"` CreatedAt time.Time `db:"created_at" json:"created_at"` UpdatedAt time.Time `db:"updated_at" json:"updated_at"` + State string `db:"state" json:"state"` } +type UsPostRegionCities []UsPostRegionCity + // Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method. func (usprc *UsPostRegionCity) Validate(_ *pop.Connection) (*validate.Errors, error) { return validate.Validate( @@ -39,6 +42,7 @@ func (usprc *UsPostRegionCity) Validate(_ *pop.Connection) (*validate.Errors, er &validators.StringIsPresent{Field: usprc.USPostRegionCityNm, Name: "USPostRegionCityNm"}, &validators.StringIsPresent{Field: usprc.UsprcPrfdLstLineCtystNm, Name: "UsprcPrfdLstLineCtystNm"}, &validators.StringIsPresent{Field: usprc.UsprcCountyNm, Name: "UsprcCountyNm"}, + &validators.StringIsPresent{Field: usprc.State, Name: "State"}, ), nil } diff --git a/pkg/services/address.go b/pkg/services/address.go index d2905922b3d..90432ebb76b 100644 --- a/pkg/services/address.go +++ b/pkg/services/address.go @@ -12,3 +12,7 @@ type AddressCreator interface { type AddressUpdater interface { UpdateAddress(appCtx appcontext.AppContext, address *models.Address, eTag string) (*models.Address, error) } + +type UsPostRegionCity interface { + GetLocationsByZipCity(appCtx appcontext.AppContext, search string) (*models.UsPostRegionCities, error) +} diff --git a/pkg/services/address/address_lookup.go b/pkg/services/address/address_lookup.go new file mode 100644 index 00000000000..0f6a341ba88 --- /dev/null +++ b/pkg/services/address/address_lookup.go @@ -0,0 +1,77 @@ +package address + +import ( + "database/sql" + + "github.com/gofrs/uuid" + "github.com/pkg/errors" + + "github.com/transcom/mymove/pkg/appcontext" + "github.com/transcom/mymove/pkg/apperror" + "github.com/transcom/mymove/pkg/models" + "github.com/transcom/mymove/pkg/services" +) + +type usPostRegionCity struct { +} + +func NewUsPostRegionCity() services.UsPostRegionCity { + return &usPostRegionCity{} +} + +func (o usPostRegionCity) GetLocationsByZipCity(appCtx appcontext.AppContext, search string) (*models.UsPostRegionCities, error) { + locationList, err := FindLocationsByZipCity(appCtx, search) + + if err != nil { + switch err { + case sql.ErrNoRows: + return &locationList, apperror.NewNotFoundError(uuid.Nil, "Search string: "+search) + default: + return &locationList, err + } + } + + return &locationList, nil +} + +func FindLocationsByZipCity(appCtx appcontext.AppContext, search string) (models.UsPostRegionCities, error) { + var locationList []models.UsPostRegionCity + + // The % operator filters out strings that are below this similarity threshold + err := appCtx.DB().Q().RawQuery("SET pg_trgm.similarity_threshold = 0.03").Exec() + if err != nil { + return locationList, err + } + + // sqlQuery := ` + // with locations as (select office.id as transportation_office_id, office.name, similarity(office.name, $1) as sim + // from transportation_offices as office + // where name % $1 ` + + // sqlQuery += ` + // order by sim desc + // limit 5) + // select office.* + // from names n inner join transportation_offices office on n.transportation_office_id = office.id + // group by office.id + // order by max(n.sim) desc, office.name + // limit 5` + sqlQuery := ` + select uprc.u_s_post_region_city_nm, uprc.state, uprc.usprc_county_nm, uprc.uspr_zip_id + from us_post_region_cities uprc where position(upper($1) in uprc.uspr_zip_id) > 0 or + position(upper($1) in uprc.u_s_post_region_city_nm) > 0 + limit 5` + query := appCtx.DB().Q().RawQuery(sqlQuery, search) + if err := query.All(&locationList); err != nil { + if errors.Cause(err).Error() != models.RecordNotFoundErrorString { + return locationList, err + } + } + for i := range locationList { + err := appCtx.DB().Load(&locationList[i], "Address") + if err != nil { + return locationList, err + } + } + return locationList, nil +} diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx index 64fae48a609..2115e306c2c 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx @@ -18,7 +18,6 @@ const ResidentialAddressForm = ({ formFieldsName, initialValues, onSubmit, onBac const validationSchema = Yup.object().shape({ [formFieldsName]: requiredAddressSchema.required(), }); - const zipCityEnabled = true; // TODO: NEED TO DETERMINE WHICH USER/PAGES TO DETERMINE IF THIS IS ENABLED return ( - {({ isValid, isSubmitting, handleChange, handleSubmit, setFieldTouched }) => { + {({ isValid, isSubmitting, handleChange, handleSubmit, setFieldTouched, values, setValues }) => { + const handleZipCityChange = (value) => { + setValues({ + ...values, + current_residence: { + city: value.address.city, + state: value.address.state, + county: value.address.county, + postalCode: value.address.postalCode, + }, + }); + }; + return (

Current address

@@ -38,7 +49,8 @@ const ResidentialAddressForm = ({ formFieldsName, initialValues, onSubmit, onBac name={formFieldsName} validators={validators} formikFunctionsToValidatePostalCodeOnChange={{ handleChange, setFieldTouched }} - zipCityEnabled={zipCityEnabled} + zipCityEnabled + handleZipCityChange={handleZipCityChange} /> diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index 1f74f935afe..8e4ad8ad53c 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -29,6 +29,7 @@ export const AddressFields = ({ render, validators, zipCityEnabled, + handleZipCityChange, formikFunctionsToValidatePostalCodeOnChange, }) => { const addressFieldsUUID = useRef(uuidv4()); @@ -89,10 +90,6 @@ export const AddressFields = ({ ); } - const handleZipCityChange = (value) => { - console.log(value); - }; - return (
{render( @@ -162,6 +159,7 @@ AddressFields.propTypes = { name: PropTypes.string.isRequired, render: PropTypes.func, zipCityEnabled: PropTypes.bool, + handleZipCityChange: PropTypes.func, validators: PropTypes.shape({ streetAddress1: PropTypes.func, streetAddress2: PropTypes.func, @@ -180,6 +178,7 @@ AddressFields.defaultProps = { className: '', render: (fields) => fields, zipCityEnabled: false, + handleZipCityChange: null, validators: {}, formikFunctionsToValidatePostalCodeOnChange: null, }; diff --git a/src/pages/MyMove/Profile/ResidentialAddress.jsx b/src/pages/MyMove/Profile/ResidentialAddress.jsx index 8c78d52c333..76bad8693cd 100644 --- a/src/pages/MyMove/Profile/ResidentialAddress.jsx +++ b/src/pages/MyMove/Profile/ResidentialAddress.jsx @@ -49,7 +49,6 @@ export const ResidentialAddress = ({ serviceMember, updateServiceMember }) => { state: serviceMember.residential_address?.state || '', postalCode: serviceMember.residential_address?.postalCode || '', county: serviceMember.residential_address?.county || '', - zipCity: '', }, }; diff --git a/swagger-def/definitions/ZipCityLookup.yaml b/swagger-def/definitions/UsPostRegionCity.yaml similarity index 100% rename from swagger-def/definitions/ZipCityLookup.yaml rename to swagger-def/definitions/UsPostRegionCity.yaml diff --git a/swagger-def/internal.yaml b/swagger-def/internal.yaml index 2fddcb75be6..99218646edf 100644 --- a/swagger-def/internal.yaml +++ b/swagger-def/internal.yaml @@ -589,6 +589,10 @@ definitions: type: array items: $ref: "definitions/TransportationOffice.yaml" + UsPostRegionCities: + type: array + items: + $ref: "definitions/UsPostRegionCity.yaml" OfficeUser: type: object properties: @@ -4164,7 +4168,7 @@ paths: "200": description: the requested list of city, state, county, and postal code matches schema: - $ref: "definitions/ZipCityLookup.yaml" + $ref: "#/definitions/UsPostRegionCities" "400": description: invalid request "403": diff --git a/swagger/internal.yaml b/swagger/internal.yaml index 8d51f87bff4..42775220e59 100644 --- a/swagger/internal.yaml +++ b/swagger/internal.yaml @@ -610,6 +610,10 @@ definitions: type: array items: $ref: '#/definitions/TransportationOffice' + UsPostRegionCities: + type: array + items: + $ref: '#/definitions/UsPostRegionCity' OfficeUser: type: object properties: @@ -3580,7 +3584,7 @@ definitions: RENTAL_EQUIPMENT: Rental equipment TOLLS: Tolls WEIGHING_FEE: Weighing fee - ZipCityLookup: + UsPostRegionCity: description: A postal code and city lookup type: object properties: @@ -5735,7 +5739,7 @@ paths: '200': description: the requested list of city, state, county, and postal code matches schema: - $ref: '#/definitions/ZipCityLookup' + $ref: '#/definitions/UsPostRegionCities' '400': description: invalid request '403': From f88f93d71d22c777c5cbdd5c5b2f9760190e0240 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Mon, 5 Aug 2024 23:45:47 +0000 Subject: [PATCH 003/216] fix null string for state --- migrations/app/migrations_manifest.txt | 1 + ..._update_us_post_region_cities_state.up.sql | 2 ++ pkg/handlers/internalapi/addresses.go | 2 +- pkg/services/address/address_lookup.go | 25 +++---------------- 4 files changed, 7 insertions(+), 23 deletions(-) create mode 100644 migrations/app/schema/20240805234231_update_us_post_region_cities_state.up.sql diff --git a/migrations/app/migrations_manifest.txt b/migrations/app/migrations_manifest.txt index 70554ba54c6..a703b4a89fe 100644 --- a/migrations/app/migrations_manifest.txt +++ b/migrations/app/migrations_manifest.txt @@ -970,3 +970,4 @@ 20240725190050_update_payment_request_status_tpps_received.up.sql 20240729162353_joseph_doye_cn_cac.up.sql 20240729164930_mai_do_cac.up.sql +20240805234231_update_us_post_region_cities_state.up.sql diff --git a/migrations/app/schema/20240805234231_update_us_post_region_cities_state.up.sql b/migrations/app/schema/20240805234231_update_us_post_region_cities_state.up.sql new file mode 100644 index 00000000000..b462e3ab960 --- /dev/null +++ b/migrations/app/schema/20240805234231_update_us_post_region_cities_state.up.sql @@ -0,0 +1,2 @@ +UPDATE us_post_region_cities SET state = '' WHERE state IS null; +ALTER TABLE public.us_post_region_cities ALTER COLUMN state SET NOT NULL; \ No newline at end of file diff --git a/pkg/handlers/internalapi/addresses.go b/pkg/handlers/internalapi/addresses.go index f08c68b9b64..27a02e3b880 100644 --- a/pkg/handlers/internalapi/addresses.go +++ b/pkg/handlers/internalapi/addresses.go @@ -85,7 +85,7 @@ func (h GetLocationByZipCityHandler) Handle(params addressop.GetLocationByZipCit locationList, err := h.GetLocationsByZipCity(appCtx, params.ZipCity) if err != nil { - appCtx.Logger().Error("Error searching for Transportation Offices: ", zap.Error(err)) + appCtx.Logger().Error("Error searching for Zip/City: ", zap.Error(err)) return addressop.NewGetLocationByZipCityInternalServerError(), err } diff --git a/pkg/services/address/address_lookup.go b/pkg/services/address/address_lookup.go index 0f6a341ba88..e8fa5c58111 100644 --- a/pkg/services/address/address_lookup.go +++ b/pkg/services/address/address_lookup.go @@ -37,38 +37,19 @@ func (o usPostRegionCity) GetLocationsByZipCity(appCtx appcontext.AppContext, se func FindLocationsByZipCity(appCtx appcontext.AppContext, search string) (models.UsPostRegionCities, error) { var locationList []models.UsPostRegionCity - // The % operator filters out strings that are below this similarity threshold - err := appCtx.DB().Q().RawQuery("SET pg_trgm.similarity_threshold = 0.03").Exec() - if err != nil { - return locationList, err - } - - // sqlQuery := ` - // with locations as (select office.id as transportation_office_id, office.name, similarity(office.name, $1) as sim - // from transportation_offices as office - // where name % $1 ` - - // sqlQuery += ` - // order by sim desc - // limit 5) - // select office.* - // from names n inner join transportation_offices office on n.transportation_office_id = office.id - // group by office.id - // order by max(n.sim) desc, office.name - // limit 5` sqlQuery := ` select uprc.u_s_post_region_city_nm, uprc.state, uprc.usprc_county_nm, uprc.uspr_zip_id from us_post_region_cities uprc where position(upper($1) in uprc.uspr_zip_id) > 0 or position(upper($1) in uprc.u_s_post_region_city_nm) > 0 - limit 5` - query := appCtx.DB().Q().RawQuery(sqlQuery, search) + limit 10` + query := appCtx.DB().Q().RawQuery(sqlQuery, &search) if err := query.All(&locationList); err != nil { if errors.Cause(err).Error() != models.RecordNotFoundErrorString { return locationList, err } } for i := range locationList { - err := appCtx.DB().Load(&locationList[i], "Address") + err := appCtx.DB().Load(&locationList[i], "State") if err != nil { return locationList, err } From ed12e77467377b83ac4ee97141a2ba97ab893d32 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Tue, 6 Aug 2024 19:53:01 +0000 Subject: [PATCH 004/216] call get location from UI --- pkg/gen/internalapi/embedded_spec.go | 8 ++--- .../addresses/get_location_by_zip_city.go | 2 +- .../get_location_by_zip_city_parameters.go | 12 +++---- .../get_location_by_zip_city_urlbuilder.go | 12 +++---- .../internaloperations/mymove_api.go | 2 +- pkg/handlers/internalapi/addresses.go | 2 +- .../ResidentialAddressForm.jsx | 8 ++--- .../LocationSearchBox/LocationSearchBox.jsx | 31 ++++++++++++++++--- src/components/form/fields/ZipCityInput.jsx | 4 +-- src/services/internalApi.js | 4 +++ swagger-def/internal.yaml | 4 +-- swagger/internal.yaml | 4 +-- 12 files changed, 60 insertions(+), 33 deletions(-) diff --git a/pkg/gen/internalapi/embedded_spec.go b/pkg/gen/internalapi/embedded_spec.go index 60a46505405..f141a72bf08 100644 --- a/pkg/gen/internalapi/embedded_spec.go +++ b/pkg/gen/internalapi/embedded_spec.go @@ -39,7 +39,7 @@ func init() { }, "basePath": "/internal", "paths": { - "/addresses/zip_city_lookup/{zip_city}": { + "/addresses/zip_city_lookup/{search}": { "get": { "description": "Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code.", "tags": [ @@ -50,7 +50,7 @@ func init() { "parameters": [ { "type": "string", - "name": "zip_city", + "name": "search", "in": "path", "required": true } @@ -7867,7 +7867,7 @@ func init() { }, "basePath": "/internal", "paths": { - "/addresses/zip_city_lookup/{zip_city}": { + "/addresses/zip_city_lookup/{search}": { "get": { "description": "Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code.", "tags": [ @@ -7878,7 +7878,7 @@ func init() { "parameters": [ { "type": "string", - "name": "zip_city", + "name": "search", "in": "path", "required": true } diff --git a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city.go b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city.go index 7a4842fe465..288f11ae2d1 100644 --- a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city.go +++ b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city.go @@ -30,7 +30,7 @@ func NewGetLocationByZipCity(ctx *middleware.Context, handler GetLocationByZipCi } /* - GetLocationByZipCity swagger:route GET /addresses/zip_city_lookup/{zip_city} addresses getLocationByZipCity + GetLocationByZipCity swagger:route GET /addresses/zip_city_lookup/{search} addresses getLocationByZipCity Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City string diff --git a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_parameters.go b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_parameters.go index e56e0f520ee..17f92305b63 100644 --- a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_parameters.go +++ b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_parameters.go @@ -34,7 +34,7 @@ type GetLocationByZipCityParams struct { Required: true In: path */ - ZipCity string + Search string } // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface @@ -46,8 +46,8 @@ func (o *GetLocationByZipCityParams) BindRequest(r *http.Request, route *middlew o.HTTPRequest = r - rZipCity, rhkZipCity, _ := route.Params.GetOK("zip_city") - if err := o.bindZipCity(rZipCity, rhkZipCity, route.Formats); err != nil { + rSearch, rhkSearch, _ := route.Params.GetOK("search") + if err := o.bindSearch(rSearch, rhkSearch, route.Formats); err != nil { res = append(res, err) } if len(res) > 0 { @@ -56,8 +56,8 @@ func (o *GetLocationByZipCityParams) BindRequest(r *http.Request, route *middlew return nil } -// bindZipCity binds and validates parameter ZipCity from path. -func (o *GetLocationByZipCityParams) bindZipCity(rawData []string, hasKey bool, formats strfmt.Registry) error { +// bindSearch binds and validates parameter Search from path. +func (o *GetLocationByZipCityParams) bindSearch(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] @@ -65,7 +65,7 @@ func (o *GetLocationByZipCityParams) bindZipCity(rawData []string, hasKey bool, // Required: true // Parameter is provided by construction from the route - o.ZipCity = raw + o.Search = raw return nil } diff --git a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_urlbuilder.go b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_urlbuilder.go index bc0f0cb3a13..9d57f272323 100644 --- a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_urlbuilder.go +++ b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_urlbuilder.go @@ -14,7 +14,7 @@ import ( // GetLocationByZipCityURL generates an URL for the get location by zip city operation type GetLocationByZipCityURL struct { - ZipCity string + Search string _basePath string // avoid unkeyed usage @@ -40,13 +40,13 @@ func (o *GetLocationByZipCityURL) SetBasePath(bp string) { func (o *GetLocationByZipCityURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/addresses/zip_city_lookup/{zip_city}" + var _path = "/addresses/zip_city_lookup/{search}" - zipCity := o.ZipCity - if zipCity != "" { - _path = strings.Replace(_path, "{zip_city}", zipCity, -1) + search := o.Search + if search != "" { + _path = strings.Replace(_path, "{search}", search, -1) } else { - return nil, errors.New("zipCity is required on GetLocationByZipCityURL") + return nil, errors.New("search is required on GetLocationByZipCityURL") } _basePath := o._basePath diff --git a/pkg/gen/internalapi/internaloperations/mymove_api.go b/pkg/gen/internalapi/internaloperations/mymove_api.go index 43e97f62ba7..ebeb2ba19ab 100644 --- a/pkg/gen/internalapi/internaloperations/mymove_api.go +++ b/pkg/gen/internalapi/internaloperations/mymove_api.go @@ -936,7 +936,7 @@ func (o *MymoveAPI) initHandlerCache() { if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } - o.handlers["GET"]["/addresses/zip_city_lookup/{zip_city}"] = addresses.NewGetLocationByZipCity(o.context, o.AddressesGetLocationByZipCityHandler) + o.handlers["GET"]["/addresses/zip_city_lookup/{search}"] = addresses.NewGetLocationByZipCity(o.context, o.AddressesGetLocationByZipCityHandler) if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } diff --git a/pkg/handlers/internalapi/addresses.go b/pkg/handlers/internalapi/addresses.go index 27a02e3b880..d6504ac63b9 100644 --- a/pkg/handlers/internalapi/addresses.go +++ b/pkg/handlers/internalapi/addresses.go @@ -83,7 +83,7 @@ func (h GetLocationByZipCityHandler) Handle(params addressop.GetLocationByZipCit return addressop.NewGetLocationByZipCityForbidden(), noServiceMemberIDErr } - locationList, err := h.GetLocationsByZipCity(appCtx, params.ZipCity) + locationList, err := h.GetLocationsByZipCity(appCtx, params.Search) if err != nil { appCtx.Logger().Error("Error searching for Zip/City: ", zap.Error(err)) return addressop.NewGetLocationByZipCityInternalServerError(), err diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx index 2115e306c2c..a141f584a1b 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx @@ -32,10 +32,10 @@ const ResidentialAddressForm = ({ formFieldsName, initialValues, onSubmit, onBac setValues({ ...values, current_residence: { - city: value.address.city, - state: value.address.state, - county: value.address.county, - postalCode: value.address.postalCode, + city: value.city, + state: value.state, + county: value.county, + postalCode: value.postalCode, }, }); }; diff --git a/src/components/LocationSearchBox/LocationSearchBox.jsx b/src/components/LocationSearchBox/LocationSearchBox.jsx index cb5a3d95899..cc3ded504e1 100644 --- a/src/components/LocationSearchBox/LocationSearchBox.jsx +++ b/src/components/LocationSearchBox/LocationSearchBox.jsx @@ -24,7 +24,7 @@ const formatOptionLabel = (option, input) => { const searchIndex = optionLabel.toLowerCase().indexOf(inputText.toLowerCase()); if (searchIndex === -1) { - return {optionLabel}; + return {option.city}; } return ( @@ -36,6 +36,26 @@ const formatOptionLabel = (option, input) => { ); }; +const formatZipCity = (option, input) => { + const { inputValue } = input; + const outputLabel = `${option.city}, ${option.state} ${option.postalCode} (${option.county})`; + const inputText = inputValue || ''; + + const searchIndex = outputLabel.toLowerCase().indexOf(inputText.toLowerCase()); + + if (searchIndex === -1) { + return {outputLabel}; + } + + return ( + + {outputLabel.substr(0, searchIndex)} + {outputLabel.substr(searchIndex, inputText.length)} + {outputLabel.substr(searchIndex + inputText.length)} + + ); +}; + const uswdsBlack = '#565c65'; const uswdsBlue = '#2491ff'; @@ -139,7 +159,7 @@ export const LocationSearchBoxComponent = ({ }, DEBOUNCE_TIMER_MS); const selectOption = async (selectedValue) => { - if (!selectedValue.address) { + if (!selectedValue.address && !handleOnChange) { const address = await showAddress(selectedValue.address_id); const newValue = { ...selectedValue, @@ -151,7 +171,10 @@ export const LocationSearchBoxComponent = ({ } onChange(selectedValue); - handleOnChange(selectedValue); + + if (handleOnChange !== null) { + handleOnChange(selectedValue); + } return selectedValue; }; @@ -197,7 +220,7 @@ export const LocationSearchBoxComponent = ({ inputId={inputId} className={dutyInputClasses} cacheOptions - formatOptionLabel={formatOptionLabel} + formatOptionLabel={handleOnChange ? formatZipCity : formatOptionLabel} getOptionValue={getOptionName} loadOptions={loadOptions} onChange={selectOption} diff --git a/src/components/form/fields/ZipCityInput.jsx b/src/components/form/fields/ZipCityInput.jsx index e38c8f4cd12..f88d8ad84af 100644 --- a/src/components/form/fields/ZipCityInput.jsx +++ b/src/components/form/fields/ZipCityInput.jsx @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import './DropdownInput.module.scss'; import LocationSearchBox from 'components/LocationSearchBox/LocationSearchBox'; -import { searchTransportationOffices } from 'services/internalApi'; +import { searchLocationByZipCity } from 'services/internalApi'; export const ZipCityInput = (props) => { const { label, name, displayAddress, hint, placeholder, isDisabled, handleZipCityChange } = props; @@ -25,7 +25,7 @@ export const ZipCityInput = (props) => { hint={hint} placeholder={placeholder} isDisabled={isDisabled} - searchLocations={searchTransportationOffices} + searchLocations={searchLocationByZipCity} handleOnChange={handleZipCityChange} /> ); diff --git a/src/services/internalApi.js b/src/services/internalApi.js index 501917b4d64..444d35724ca 100644 --- a/src/services/internalApi.js +++ b/src/services/internalApi.js @@ -537,3 +537,7 @@ export async function downloadPPMAOAPacket(ppmShipmentId) { export async function downloadPPMPaymentPacket(ppmShipmentId) { return makeInternalRequestRaw('ppm.showPaymentPacket', { ppmShipmentId }); } + +export async function searchLocationByZipCity(search) { + return makeInternalRequest('addresses.getLocationByZipCity', { search }, { normalize: false }); +} diff --git a/swagger-def/internal.yaml b/swagger-def/internal.yaml index 99218646edf..217b0c4e86b 100644 --- a/swagger-def/internal.yaml +++ b/swagger-def/internal.yaml @@ -4152,7 +4152,7 @@ paths: description: not found "500": description: server error - /addresses/zip_city_lookup/{zip_city}: + /addresses/zip_city_lookup/{search}: get: summary: Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City string description: Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code. @@ -4161,7 +4161,7 @@ paths: - addresses parameters: - in: path - name: zip_city + name: search type: string required: true responses: diff --git a/swagger/internal.yaml b/swagger/internal.yaml index 42775220e59..e1f892e9f5e 100644 --- a/swagger/internal.yaml +++ b/swagger/internal.yaml @@ -5718,7 +5718,7 @@ paths: description: not found '500': description: server error - /addresses/zip_city_lookup/{zip_city}: + /addresses/zip_city_lookup/{search}: get: summary: >- Returns City, State, Postal Code, and County associated with the @@ -5732,7 +5732,7 @@ paths: - addresses parameters: - in: path - name: zip_city + name: search type: string required: true responses: From d5fec66953ae07616e8214446c20a3d3aa879a7f Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 9 Aug 2024 01:05:15 +0000 Subject: [PATCH 005/216] updated tests --- pkg/services/address/address_lookup.go | 2 +- .../ResidentialAddressForm.jsx | 4 +- .../ResidentialAddressForm.test.jsx | 56 +++++------ .../LocationSearchBox/LocationSearchBox.jsx | 1 + .../form/AddressFields/AddressFields.jsx | 4 +- .../MyMove/Profile/ResidentialAddress.jsx | 1 - .../Profile/ResidentialAddress.test.jsx | 95 ++----------------- 7 files changed, 39 insertions(+), 124 deletions(-) diff --git a/pkg/services/address/address_lookup.go b/pkg/services/address/address_lookup.go index e8fa5c58111..b6a8b08ff42 100644 --- a/pkg/services/address/address_lookup.go +++ b/pkg/services/address/address_lookup.go @@ -41,7 +41,7 @@ func FindLocationsByZipCity(appCtx appcontext.AppContext, search string) (models select uprc.u_s_post_region_city_nm, uprc.state, uprc.usprc_county_nm, uprc.uspr_zip_id from us_post_region_cities uprc where position(upper($1) in uprc.uspr_zip_id) > 0 or position(upper($1) in uprc.u_s_post_region_city_nm) > 0 - limit 10` + limit 20` query := appCtx.DB().Q().RawQuery(sqlQuery, &search) if err := query.All(&locationList); err != nil { if errors.Cause(err).Error() != models.RecordNotFoundErrorString { diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx index a141f584a1b..2375f209669 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx @@ -32,8 +32,9 @@ const ResidentialAddressForm = ({ formFieldsName, initialValues, onSubmit, onBac setValues({ ...values, current_residence: { + ...values.current_residence, city: value.city, - state: value.state, + state: value.state ? value.state : '', county: value.county, postalCode: value.postalCode, }, @@ -48,7 +49,6 @@ const ResidentialAddressForm = ({ formFieldsName, initialValues, onSubmit, onBac diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx index ffc56a38674..5575b2b78c8 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx @@ -1,8 +1,9 @@ import React from 'react'; -import { render, waitFor } from '@testing-library/react'; +import { render, screen, waitFor, fireEvent } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import ResidentialAddressForm from './ResidentialAddressForm'; +import addressFactory from 'utils/test/factories/address'; describe('ResidentialAddressForm component', () => { const formFieldsName = 'current_residence'; @@ -16,6 +17,7 @@ describe('ResidentialAddressForm component', () => { city: '', state: '', postalCode: '', + county: '', }, }, onSubmit: jest.fn().mockImplementation(() => Promise.resolve()), @@ -28,8 +30,11 @@ describe('ResidentialAddressForm component', () => { city: 'El Paso', state: 'TX', postalCode: '79912', + county: 'El Paso', }; + const mockAddress = addressFactory(); + it('renders the form inputs and help text', async () => { const { getByLabelText, getByText } = render(); @@ -42,48 +47,30 @@ describe('ResidentialAddressForm component', () => { expect(getByLabelText('State')).toBeInstanceOf(HTMLSelectElement); + expect(getByLabelText('County')).toBeInstanceOf(HTMLSelectElement); + expect(getByLabelText('ZIP')).toBeInstanceOf(HTMLInputElement); expect(getByText('Must be a physical address.')).toBeInTheDocument(); }); }); - it('passes custom validators to fields', async () => { - const postalCodeValidator = jest.fn().mockImplementation(() => undefined); - - const { findByLabelText } = render( - , - ); - - const postalCodeInput = await findByLabelText('ZIP'); - - const postalCode = '99999'; - - await userEvent.type(postalCodeInput, postalCode); - - await waitFor(() => { - // We expect this to be called 6 times. - // 1 - validate on mount - // 5 - once for each 9 that was typed, since we are validating on change - expect(postalCodeValidator).toHaveBeenCalledTimes(6); - expect(postalCodeValidator).toHaveBeenCalledWith(postalCode); - }); - }); - it('shows an error message if trying to submit an invalid form', async () => { const { getByRole, findAllByRole, getByLabelText } = render(); await userEvent.click(getByLabelText('Address 1')); await userEvent.click(getByLabelText(/Address 2/)); - await userEvent.click(getByLabelText('City')); - await userEvent.click(getByLabelText('State')); - await userEvent.click(getByLabelText('ZIP')); + const postalCodeInput = await screen.findByLabelText('Zip/City Lookup'); + + const postalCode = '79912'; + await userEvent.type(postalCodeInput, postalCode); + await userEvent.click(await screen.findByText('79912')); const submitBtn = getByRole('button', { name: 'Next' }); await userEvent.click(submitBtn); const alerts = await findAllByRole('alert'); - expect(alerts.length).toBe(4); + expect(alerts.length).toBe(1); alerts.forEach((alert) => { expect(alert).toHaveTextContent('Required'); @@ -96,12 +83,15 @@ describe('ResidentialAddressForm component', () => { const { getByRole, getByLabelText } = render(); const submitBtn = getByRole('button', { name: 'Next' }); - await userEvent.type(getByLabelText('Address 1'), fakeAddress.streetAddress1); - await userEvent.type(getByLabelText(/Address 2/), fakeAddress.streetAddress2); - await userEvent.type(getByLabelText('City'), fakeAddress.city); - await userEvent.selectOptions(getByLabelText('State'), [fakeAddress.state]); - await userEvent.type(getByLabelText('ZIP'), fakeAddress.postalCode); - await userEvent.tab(); + await userEvent.type(getByLabelText('Address 1'), mockAddress.streetAddress1); + await userEvent.type(getByLabelText(/Address 2/), mockAddress.streetAddress2); + const input = getByRole('combobox', { id: 'zipCity-input' }); + await userEvent.type(input, mockAddress.postalCode); + await waitFor(() => { + expect(screen.getByText(mockAddress.city)).toBeInTheDocument(); + }); + + fireEvent.keyPress(input, { key: 'Enter', code: 13 }); await waitFor(() => { expect(submitBtn).toBeEnabled(); diff --git a/src/components/LocationSearchBox/LocationSearchBox.jsx b/src/components/LocationSearchBox/LocationSearchBox.jsx index cc3ded504e1..bc6be42697f 100644 --- a/src/components/LocationSearchBox/LocationSearchBox.jsx +++ b/src/components/LocationSearchBox/LocationSearchBox.jsx @@ -217,6 +217,7 @@ export const LocationSearchBoxComponent = ({
{ // If we are validating on change we need to also set the field to touched when it is changed. // Formik, by default, only sets the field to touched on blur. @@ -166,6 +167,7 @@ AddressFields.propTypes = { city: PropTypes.func, state: PropTypes.func, postalCode: PropTypes.func, + county: PropTypes.func, }), formikFunctionsToValidatePostalCodeOnChange: PropTypes.shape({ handleChange: PropTypes.func, diff --git a/src/pages/MyMove/Profile/ResidentialAddress.jsx b/src/pages/MyMove/Profile/ResidentialAddress.jsx index 76bad8693cd..ad0265dfbfa 100644 --- a/src/pages/MyMove/Profile/ResidentialAddress.jsx +++ b/src/pages/MyMove/Profile/ResidentialAddress.jsx @@ -99,7 +99,6 @@ export const ResidentialAddress = ({ serviceMember, updateServiceMember }) => { initialValues={initialValues} onBack={handleBack} onSubmit={handleSubmit} - validators={{ postalCode: validatePostalCode }} /> diff --git a/src/pages/MyMove/Profile/ResidentialAddress.test.jsx b/src/pages/MyMove/Profile/ResidentialAddress.test.jsx index a5da6e02ea8..3b1a44fc996 100644 --- a/src/pages/MyMove/Profile/ResidentialAddress.test.jsx +++ b/src/pages/MyMove/Profile/ResidentialAddress.test.jsx @@ -35,6 +35,7 @@ describe('ResidentialAddress page', () => { city: 'El Paso', state: 'TX', postalCode: '79912', + county: 'El Paso', }; const blankAddress = Object.fromEntries(Object.keys(fakeAddress).map((k) => [k, ''])); @@ -58,27 +59,6 @@ describe('ResidentialAddress page', () => { }); }); - it('validates zip code using api endpoint', async () => { - const testProps = generateTestProps(blankAddress); - - ValidateZipRateData.mockImplementation(() => ({ - valid: true, - })); - - render(); - - const postalCodeInput = await screen.findByLabelText('ZIP'); - - const postalCode = '99999'; - - await userEvent.type(postalCodeInput, postalCode); - await userEvent.tab(); - - await waitFor(() => { - expect(ValidateZipRateData).toHaveBeenCalledWith(postalCode, 'origin'); - }); - }); - it('back button goes to the contact info step', async () => { const testProps = generateTestProps(blankAddress); @@ -91,40 +71,6 @@ describe('ResidentialAddress page', () => { expect(mockNavigate).toHaveBeenCalledWith(customerRoutes.CONTACT_INFO_PATH); }); - it('Selecting an unsupported state should display an unsupported state message', async () => { - const testProps = generateTestProps(blankAddress); - - const expectedServiceMemberPayload = { ...testProps.serviceMember, residential_address: fakeAddress }; - - ValidateZipRateData.mockImplementation(() => ({ - valid: true, - })); - patchServiceMember.mockImplementation(() => Promise.resolve(expectedServiceMemberPayload)); - - const { getByLabelText, getByText } = render(); - - await userEvent.type(screen.getByLabelText('Address 1'), fakeAddress.streetAddress1); - await userEvent.type(screen.getByLabelText(/Address 2/), fakeAddress.streetAddress2); - await userEvent.type(screen.getByLabelText('City'), fakeAddress.city); - await userEvent.selectOptions(screen.getByLabelText('State'), 'AK'); - await userEvent.type(screen.getByLabelText('ZIP'), fakeAddress.postalCode); - await userEvent.tab(); - - let msg = getByText('Moves to this state are not supported at this time.'); - expect(msg).toBeVisible(); - - await userEvent.selectOptions(getByLabelText('State'), 'AL'); - await userEvent.type(getByLabelText('ZIP'), fakeAddress.postalCode); - await userEvent.tab(); - expect(msg).not.toBeVisible(); - - await userEvent.selectOptions(getByLabelText('State'), 'HI'); - await userEvent.type(getByLabelText('ZIP'), fakeAddress.postalCode); - await userEvent.tab(); - msg = getByText('Moves to this state are not supported at this time.'); - expect(msg).toBeVisible(); - }); - it('next button submits the form and goes to the Backup address step', async () => { const testProps = generateTestProps(blankAddress); @@ -136,12 +82,16 @@ describe('ResidentialAddress page', () => { patchServiceMember.mockImplementation(() => Promise.resolve(expectedServiceMemberPayload)); render(); - + const postalCode = '79912'; + const testLocation = 'EL PASO, TX 79912 (EL PASO)'; + const optionName = testLocation.split(' 79912')[0]; await userEvent.type(screen.getByLabelText('Address 1'), fakeAddress.streetAddress1); await userEvent.type(screen.getByLabelText(/Address 2/), fakeAddress.streetAddress2); - await userEvent.type(screen.getByLabelText('City'), fakeAddress.city); - await userEvent.selectOptions(screen.getByLabelText('State'), [fakeAddress.state]); - await userEvent.type(screen.getByLabelText('ZIP'), fakeAddress.postalCode); + await userEvent.type(screen.getByLabelText('Zip/City Lookup'), '79912'); + await userEvent.click(await screen.findByText(optionName)); + // const postalCodeInput = await findByLabelText('Zip/City Lookup'); + // await userEvent.type(postalCodeInput, postalCode); + // await userEvent.click(await screen.findByText('79912')); await userEvent.tab(); const submitButton = screen.getByRole('button', { name: 'Next' }); @@ -156,33 +106,6 @@ describe('ResidentialAddress page', () => { expect(mockNavigate).toHaveBeenCalledWith(customerRoutes.BACKUP_ADDRESS_PATH); }); - it('shows an error if the ValidateZipRateData API returns an error', async () => { - const testProps = generateTestProps(fakeAddress); - - ValidateZipRateData.mockImplementation(() => ({ - valid: false, - })); - patchServiceMember.mockImplementation(() => Promise.resolve(testProps.serviceMember)); - - render(); - - // Touch field so that error message can be displayed - await userEvent.click(screen.getByLabelText('ZIP')); - - const submitButton = screen.getByRole('button', { name: 'Next' }); - expect(submitButton).toBeInTheDocument(); - await userEvent.click(submitButton); - - const alert = await screen.findByRole('alert'); - - expect(alert).toHaveTextContent( - 'Sorry, we don’t support that zip code yet. Please contact your local PPPO for assistance.', - ); - expect(patchServiceMember).not.toHaveBeenCalled(); - expect(testProps.updateServiceMember).not.toHaveBeenCalled(); - expect(mockNavigate).not.toHaveBeenCalled(); - }); - it('shows an error if the patchServiceMember API returns an error', async () => { const testProps = generateTestProps(fakeAddress); From efd5b4cb7af09bcb5cfb3c12de8ca4b11abf48c9 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 9 Aug 2024 07:01:59 +0000 Subject: [PATCH 006/216] test updates --- pkg/factory/us_post_region_city_factory.go | 1 + .../us_post_region_city_factory_test.go | 1 + pkg/handlers/internalapi/addresses_test.go | 34 +++++++++++++++++++ pkg/models/us_post_region_city_test.go | 3 ++ 4 files changed, 39 insertions(+) diff --git a/pkg/factory/us_post_region_city_factory.go b/pkg/factory/us_post_region_city_factory.go index 64b99cfda24..0791cf8d2b8 100644 --- a/pkg/factory/us_post_region_city_factory.go +++ b/pkg/factory/us_post_region_city_factory.go @@ -25,6 +25,7 @@ func BuildUsPostRegionCity(db *pop.Connection, customs []Customization, traits [ UsprcPrfdLstLineCtystNm: "MacDill", UsprcCountyNm: "Hillsborough", CtryGencDgphCd: "US", + State: "FL", } testdatagen.MergeModels(&usPostRegionCity, cUsPostRegionCity) diff --git a/pkg/factory/us_post_region_city_factory_test.go b/pkg/factory/us_post_region_city_factory_test.go index 117f1c14a29..07dea63be91 100644 --- a/pkg/factory/us_post_region_city_factory_test.go +++ b/pkg/factory/us_post_region_city_factory_test.go @@ -11,6 +11,7 @@ func (suite *FactorySuite) TestBuildUsPostRegionCity() { UsprcPrfdLstLineCtystNm: "MacDill", UsprcCountyNm: "Hillsborough", CtryGencDgphCd: "US", + State: "FL", } suite.Run("Successful creation of default UsPostRegionCity", func() { diff --git a/pkg/handlers/internalapi/addresses_test.go b/pkg/handlers/internalapi/addresses_test.go index ee14909386a..c844d0a151d 100644 --- a/pkg/handlers/internalapi/addresses_test.go +++ b/pkg/handlers/internalapi/addresses_test.go @@ -3,6 +3,7 @@ package internalapi import ( "net/http/httptest" + "github.com/go-openapi/strfmt" "github.com/gofrs/uuid" "github.com/transcom/mymove/pkg/factory" @@ -10,6 +11,7 @@ import ( "github.com/transcom/mymove/pkg/gen/internalmessages" "github.com/transcom/mymove/pkg/handlers" "github.com/transcom/mymove/pkg/models" + "github.com/transcom/mymove/pkg/services/address" ) func fakeAddressPayload() *internalmessages.Address { @@ -74,3 +76,35 @@ func (suite *HandlerSuite) TestShowAddressHandler() { }) } + +func (suite *HandlerSuite) TestGetLocationByZipCityHandler() { + suite.Run("successful zip city lookup", func() { + usPostRegionCity := factory.BuildDefaultUsPostRegionCity(suite.DB()) + suite.MustSave(&usPostRegionCity) + + var fetchedUsPostRegionCity models.UsPostRegionCity + err := suite.DB().Where("uspr_zip_id = $1", usPostRegionCity.UsprZipID).First(&fetchedUsPostRegionCity) + + suite.NoError(err) + suite.Equal(usPostRegionCity.UsprZipID, fetchedUsPostRegionCity.UsprZipID) + + usPostRegionCityService := address.NewUsPostRegionCity() + move := factory.BuildMove(suite.DB(), nil, nil) + req := httptest.NewRequest("GET", "/addresses/zip_city_lookup/"+usPostRegionCity.UsprZipID, nil) + req = suite.AuthenticateRequest(req, move.Orders.ServiceMember) + params := addressop.GetLocationByZipCityParams{ + HTTPRequest: req, + Search: usPostRegionCity.UsprZipID, + } + + handler := GetLocationByZipCityHandler{ + HandlerConfig: suite.HandlerConfig(), + UsPostRegionCity: usPostRegionCityService} + + response := handler.Handle(params) + suite.Assertions.IsType(&addressop.GetLocationByZipCityOK{}, response) + responsePayload := response.(*addressop.GetLocationByZipCityOK) + suite.NoError(responsePayload.Payload.Validate(strfmt.Default)) + suite.Equal(usPostRegionCity.UsprZipID, responsePayload.Payload[0].PostalCode) + }) +} diff --git a/pkg/models/us_post_region_city_test.go b/pkg/models/us_post_region_city_test.go index 1f3daff9034..990d07a1060 100644 --- a/pkg/models/us_post_region_city_test.go +++ b/pkg/models/us_post_region_city_test.go @@ -12,6 +12,7 @@ func (suite *ModelSuite) TestCanSaveValidUsPostRegionCity() { UsprcPrfdLstLineCtystNm: "USPRC Preferred City Name", UsprcCountyNm: "USPRC County", CtryGencDgphCd: "US", + State: "CA", } suite.MustCreate(&usPostRegionCity) @@ -26,6 +27,7 @@ func (suite *ModelSuite) TestInvalidUsPostRegionCity() { "uspost_region_city_nm": {"USPostRegionCityNm can not be blank."}, "usprc_prfd_lst_line_ctyst_nm": {"UsprcPrfdLstLineCtystNm can not be blank."}, "usprc_county_nm": {"UsprcCountyNm can not be blank."}, + "state": {"State can not be blank"}, } suite.verifyValidationErrors(&usPostRegionCity, expErrors) @@ -52,6 +54,7 @@ func (suite *ModelSuite) TestFindCountyByZipCode() { UsprcPrfdLstLineCtystNm: "00000 Preferred City Name", UsprcCountyNm: "00000's County", CtryGencDgphCd: "US", + State: "CA", } suite.MustCreate(&usPostRegionCity) From 357417b67d9f3a2ac7401bd21897eb28b0290e38 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 9 Aug 2024 07:13:57 +0000 Subject: [PATCH 007/216] more test updates --- pkg/models/us_post_region_city_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/models/us_post_region_city_test.go b/pkg/models/us_post_region_city_test.go index 990d07a1060..3f02573b403 100644 --- a/pkg/models/us_post_region_city_test.go +++ b/pkg/models/us_post_region_city_test.go @@ -27,7 +27,7 @@ func (suite *ModelSuite) TestInvalidUsPostRegionCity() { "uspost_region_city_nm": {"USPostRegionCityNm can not be blank."}, "usprc_prfd_lst_line_ctyst_nm": {"UsprcPrfdLstLineCtystNm can not be blank."}, "usprc_county_nm": {"UsprcCountyNm can not be blank."}, - "state": {"State can not be blank"}, + "state": {"State can not be blank."}, } suite.verifyValidationErrors(&usPostRegionCity, expErrors) From a79271c59bc8ea09e8d1de4f028f0caa77735f74 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Thu, 15 Aug 2024 16:44:34 +0000 Subject: [PATCH 008/216] trying to fix tests --- .../ResidentialAddressForm.jsx | 2 +- .../ResidentialAddressForm.test.jsx | 86 ++++++++++++++----- src/components/form/fields/ZipCityInput.jsx | 2 + .../Profile/ResidentialAddress.test.jsx | 4 +- 4 files changed, 68 insertions(+), 26 deletions(-) diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx index 2375f209669..15caced9b39 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx @@ -27,7 +27,7 @@ const ResidentialAddressForm = ({ formFieldsName, initialValues, onSubmit, onBac validateOnMount validationSchema={validationSchema} > - {({ isValid, isSubmitting, handleChange, handleSubmit, setFieldTouched, values, setValues }) => { + {({ isValid, isSubmitting, handleSubmit, values, setValues }) => { const handleZipCityChange = (value) => { setValues({ ...values, diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx index 5575b2b78c8..0e60f58fee2 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx @@ -1,9 +1,23 @@ import React from 'react'; import { render, screen, waitFor, fireEvent } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; +import { act } from 'react-dom/test-utils'; +import selectEvent from 'react-select-event'; +import { renderWithRouter } from 'testUtils'; import ResidentialAddressForm from './ResidentialAddressForm'; -import addressFactory from 'utils/test/factories/address'; +import { searchLocationByZipCity } from 'services/internalApi'; + +const mockNavigate = jest.fn(); +jest.mock('react-router-dom', () => ({ + ...jest.requireActual('react-router-dom'), + useNavigate: () => mockNavigate, +})); + +jest.mock('services/internalApi', () => ({ + ...jest.requireActual('services/internalApi'), + searchLocationByZipCity: jest.fn(), +})); describe('ResidentialAddressForm component', () => { const formFieldsName = 'current_residence'; @@ -33,21 +47,21 @@ describe('ResidentialAddressForm component', () => { county: 'El Paso', }; - const mockAddress = addressFactory(); - it('renders the form inputs and help text', async () => { - const { getByLabelText, getByText } = render(); + const { getByRole, getByLabelText, getByText } = render(); await waitFor(() => { expect(getByLabelText('Address 1')).toBeInstanceOf(HTMLInputElement); expect(getByLabelText(/Address 2/)).toBeInstanceOf(HTMLInputElement); + expect(getByRole('combobox', { id: 'zipCity-input' })).toBeInstanceOf(HTMLInputElement); + expect(getByLabelText('City')).toBeInstanceOf(HTMLInputElement); - expect(getByLabelText('State')).toBeInstanceOf(HTMLSelectElement); + expect(getByLabelText('State')).toBeInstanceOf(HTMLInputElement); - expect(getByLabelText('County')).toBeInstanceOf(HTMLSelectElement); + expect(getByLabelText('County')).toBeInstanceOf(HTMLInputElement); expect(getByLabelText('ZIP')).toBeInstanceOf(HTMLInputElement); @@ -56,15 +70,31 @@ describe('ResidentialAddressForm component', () => { }); it('shows an error message if trying to submit an invalid form', async () => { + const mockAddress = { + city: 'El Paso', + state: 'TX', + postalCode: '79912', + county: 'El Paso', + }; + const mockSearchLocationByZipCity= () => Promise.resolve(mockAddress); + searchLocationByZipCity.mockImplementation(mockSearchLocationByZipCity); + const { getByRole, findAllByRole, getByLabelText } = render(); await userEvent.click(getByLabelText('Address 1')); await userEvent.click(getByLabelText(/Address 2/)); - const postalCodeInput = await screen.findByLabelText('Zip/City Lookup'); + const input = getByRole('combobox', { id: 'zipCity-input' }); + fireEvent.change(input, {target: {value: mockAddress.postalCode} }); + await act(() => selectEvent.select(input, 79912)); + + await waitFor(() => { + expect(screen.getByText(mockAddress.postalCode)).toBeInTheDocument(); + }); - const postalCode = '79912'; + // fireEvent.keyPress(input, { key: 'Enter', code: 13 }); - await userEvent.type(postalCodeInput, postalCode); - await userEvent.click(await screen.findByText('79912')); + await waitFor(() => { + expect(searchLocationByZipCity).toHaveBeenCalledTimes(1); + }); const submitBtn = getByRole('button', { name: 'Next' }); await userEvent.click(submitBtn); @@ -80,19 +110,29 @@ describe('ResidentialAddressForm component', () => { }); it('submits the form when its valid', async () => { - const { getByRole, getByLabelText } = render(); - const submitBtn = getByRole('button', { name: 'Next' }); - - await userEvent.type(getByLabelText('Address 1'), mockAddress.streetAddress1); - await userEvent.type(getByLabelText(/Address 2/), mockAddress.streetAddress2); - const input = getByRole('combobox', { id: 'zipCity-input' }); - await userEvent.type(input, mockAddress.postalCode); - await waitFor(() => { - expect(screen.getByText(mockAddress.city)).toBeInTheDocument(); - }); - - fireEvent.keyPress(input, { key: 'Enter', code: 13 }); - + const mockAddress = { + city: 'El Paso', + state: 'TX', + postalCode: '79912', + county: 'El Paso', + }; + const mockSearchLocationByZipCity= () => Promise.resolve(mockAddress); + searchLocationByZipCity.mockImplementation(mockSearchLocationByZipCity); + + // const { getByRole, getByLabelText } = render(); + renderWithRouter(); + const submitBtn = screen.getByRole('button', { name: 'Next' }); + + await userEvent.type(screen.getByLabelText('Address 1'), fakeAddress.streetAddress1); + await userEvent.type(screen.getByLabelText(/Address 2/), fakeAddress.streetAddress2); + const input = screen.getByLabelText('Zip/City Lookup'); + await userEvent.type(input, '79912'); + fireEvent.change(input, {target: {value: mockAddress.postalCode} }); + // await waitFor(() => { + // expect(screen.getByText(mockAddress.state)).toBeInTheDocument(); + // }); + await act(() => selectEvent.select(input, mockAddress.postalCode)); + expect(screen.getByLabelText('State')).toHaveValue(mockAddress.state); await waitFor(() => { expect(submitBtn).toBeEnabled(); }); diff --git a/src/components/form/fields/ZipCityInput.jsx b/src/components/form/fields/ZipCityInput.jsx index f88d8ad84af..0d2eecd14db 100644 --- a/src/components/form/fields/ZipCityInput.jsx +++ b/src/components/form/fields/ZipCityInput.jsx @@ -40,6 +40,7 @@ ZipCityInput.propTypes = { hint: PropTypes.node, placeholder: PropTypes.string, isDisabled: PropTypes.bool, + handleZipCityChange: PropTypes.func, }; ZipCityInput.defaultProps = { @@ -47,6 +48,7 @@ ZipCityInput.defaultProps = { hint: '', placeholder: '', isDisabled: false, + handleZipCityChange: undefined, }; export default ZipCityInput; diff --git a/src/pages/MyMove/Profile/ResidentialAddress.test.jsx b/src/pages/MyMove/Profile/ResidentialAddress.test.jsx index 3b1a44fc996..8b2f412876c 100644 --- a/src/pages/MyMove/Profile/ResidentialAddress.test.jsx +++ b/src/pages/MyMove/Profile/ResidentialAddress.test.jsx @@ -84,10 +84,10 @@ describe('ResidentialAddress page', () => { render(); const postalCode = '79912'; const testLocation = 'EL PASO, TX 79912 (EL PASO)'; - const optionName = testLocation.split(' 79912')[0]; + const optionName = testLocation.split(' 79')[0]; await userEvent.type(screen.getByLabelText('Address 1'), fakeAddress.streetAddress1); await userEvent.type(screen.getByLabelText(/Address 2/), fakeAddress.streetAddress2); - await userEvent.type(screen.getByLabelText('Zip/City Lookup'), '79912'); + await userEvent.type(screen.getByLabelText('Zip/City Lookup'), '79'); await userEvent.click(await screen.findByText(optionName)); // const postalCodeInput = await findByLabelText('Zip/City Lookup'); // await userEvent.type(postalCodeInput, postalCode); From a868a918132f0e21928e9b8323db6de05429ad16 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Thu, 15 Aug 2024 20:59:00 +0000 Subject: [PATCH 009/216] fixed client tests --- .../ResidentialAddressForm.test.jsx | 97 ++++++------------- .../Profile/ResidentialAddress.test.jsx | 13 +-- 2 files changed, 29 insertions(+), 81 deletions(-) diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx index 0e60f58fee2..afb18b3d15a 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx @@ -1,23 +1,8 @@ import React from 'react'; -import { render, screen, waitFor, fireEvent } from '@testing-library/react'; +import { render, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { act } from 'react-dom/test-utils'; -import selectEvent from 'react-select-event'; -import { renderWithRouter } from 'testUtils'; import ResidentialAddressForm from './ResidentialAddressForm'; -import { searchLocationByZipCity } from 'services/internalApi'; - -const mockNavigate = jest.fn(); -jest.mock('react-router-dom', () => ({ - ...jest.requireActual('react-router-dom'), - useNavigate: () => mockNavigate, -})); - -jest.mock('services/internalApi', () => ({ - ...jest.requireActual('services/internalApi'), - searchLocationByZipCity: jest.fn(), -})); describe('ResidentialAddressForm component', () => { const formFieldsName = 'current_residence'; @@ -31,7 +16,6 @@ describe('ResidentialAddressForm component', () => { city: '', state: '', postalCode: '', - county: '', }, }, onSubmit: jest.fn().mockImplementation(() => Promise.resolve()), @@ -44,25 +28,37 @@ describe('ResidentialAddressForm component', () => { city: 'El Paso', state: 'TX', postalCode: '79912', - county: 'El Paso', }; + const dataProps = { + formFieldsName, + initialValues: { + [formFieldsName]: { + streetAddress1: '', + streetAddress2: '', + city: fakeAddress.city, + state: fakeAddress.state, + postalCode: fakeAddress.postalCode, + county: fakeAddress.county, + }, + }, + onSubmit: jest.fn().mockImplementation(() => Promise.resolve()), + onBack: jest.fn(), + }; + + it('renders the form inputs and help text', async () => { - const { getByRole, getByLabelText, getByText } = render(); + const { getByLabelText, getByText } = render(); await waitFor(() => { expect(getByLabelText('Address 1')).toBeInstanceOf(HTMLInputElement); expect(getByLabelText(/Address 2/)).toBeInstanceOf(HTMLInputElement); - expect(getByRole('combobox', { id: 'zipCity-input' })).toBeInstanceOf(HTMLInputElement); - expect(getByLabelText('City')).toBeInstanceOf(HTMLInputElement); expect(getByLabelText('State')).toBeInstanceOf(HTMLInputElement); - expect(getByLabelText('County')).toBeInstanceOf(HTMLInputElement); - expect(getByLabelText('ZIP')).toBeInstanceOf(HTMLInputElement); expect(getByText('Must be a physical address.')).toBeInTheDocument(); @@ -70,31 +66,10 @@ describe('ResidentialAddressForm component', () => { }); it('shows an error message if trying to submit an invalid form', async () => { - const mockAddress = { - city: 'El Paso', - state: 'TX', - postalCode: '79912', - county: 'El Paso', - }; - const mockSearchLocationByZipCity= () => Promise.resolve(mockAddress); - searchLocationByZipCity.mockImplementation(mockSearchLocationByZipCity); - const { getByRole, findAllByRole, getByLabelText } = render(); await userEvent.click(getByLabelText('Address 1')); await userEvent.click(getByLabelText(/Address 2/)); - const input = getByRole('combobox', { id: 'zipCity-input' }); - fireEvent.change(input, {target: {value: mockAddress.postalCode} }); - await act(() => selectEvent.select(input, 79912)); - - await waitFor(() => { - expect(screen.getByText(mockAddress.postalCode)).toBeInTheDocument(); - }); - // fireEvent.keyPress(input, { key: 'Enter', code: 13 }); - - await waitFor(() => { - expect(searchLocationByZipCity).toHaveBeenCalledTimes(1); - }); const submitBtn = getByRole('button', { name: 'Next' }); await userEvent.click(submitBtn); @@ -110,29 +85,13 @@ describe('ResidentialAddressForm component', () => { }); it('submits the form when its valid', async () => { - const mockAddress = { - city: 'El Paso', - state: 'TX', - postalCode: '79912', - county: 'El Paso', - }; - const mockSearchLocationByZipCity= () => Promise.resolve(mockAddress); - searchLocationByZipCity.mockImplementation(mockSearchLocationByZipCity); - - // const { getByRole, getByLabelText } = render(); - renderWithRouter(); - const submitBtn = screen.getByRole('button', { name: 'Next' }); - - await userEvent.type(screen.getByLabelText('Address 1'), fakeAddress.streetAddress1); - await userEvent.type(screen.getByLabelText(/Address 2/), fakeAddress.streetAddress2); - const input = screen.getByLabelText('Zip/City Lookup'); - await userEvent.type(input, '79912'); - fireEvent.change(input, {target: {value: mockAddress.postalCode} }); - // await waitFor(() => { - // expect(screen.getByText(mockAddress.state)).toBeInTheDocument(); - // }); - await act(() => selectEvent.select(input, mockAddress.postalCode)); - expect(screen.getByLabelText('State')).toHaveValue(mockAddress.state); + const { getByRole, getByLabelText } = render(); + const submitBtn = getByRole('button', { name: 'Next' }); + + await userEvent.type(getByLabelText('Address 1'), fakeAddress.streetAddress1); + await userEvent.type(getByLabelText(/Address 2/), fakeAddress.streetAddress2); + await userEvent.tab(); + await waitFor(() => { expect(submitBtn).toBeEnabled(); }); @@ -143,7 +102,7 @@ describe('ResidentialAddressForm component', () => { }; await waitFor(() => { - expect(testProps.onSubmit).toHaveBeenCalledWith(expectedParams, expect.anything()); + expect(dataProps.onSubmit).toHaveBeenCalledWith(expectedParams, expect.anything()); }); }); @@ -159,4 +118,4 @@ describe('ResidentialAddressForm component', () => { }); afterEach(jest.resetAllMocks); -}); +}); \ No newline at end of file diff --git a/src/pages/MyMove/Profile/ResidentialAddress.test.jsx b/src/pages/MyMove/Profile/ResidentialAddress.test.jsx index 8b2f412876c..92450d9f08b 100644 --- a/src/pages/MyMove/Profile/ResidentialAddress.test.jsx +++ b/src/pages/MyMove/Profile/ResidentialAddress.test.jsx @@ -72,7 +72,7 @@ describe('ResidentialAddress page', () => { }); it('next button submits the form and goes to the Backup address step', async () => { - const testProps = generateTestProps(blankAddress); + const testProps = generateTestProps(fakeAddress); const expectedServiceMemberPayload = { ...testProps.serviceMember, residential_address: fakeAddress }; @@ -82,17 +82,6 @@ describe('ResidentialAddress page', () => { patchServiceMember.mockImplementation(() => Promise.resolve(expectedServiceMemberPayload)); render(); - const postalCode = '79912'; - const testLocation = 'EL PASO, TX 79912 (EL PASO)'; - const optionName = testLocation.split(' 79')[0]; - await userEvent.type(screen.getByLabelText('Address 1'), fakeAddress.streetAddress1); - await userEvent.type(screen.getByLabelText(/Address 2/), fakeAddress.streetAddress2); - await userEvent.type(screen.getByLabelText('Zip/City Lookup'), '79'); - await userEvent.click(await screen.findByText(optionName)); - // const postalCodeInput = await findByLabelText('Zip/City Lookup'); - // await userEvent.type(postalCodeInput, postalCode); - // await userEvent.click(await screen.findByText('79912')); - await userEvent.tab(); const submitButton = screen.getByRole('button', { name: 'Next' }); expect(submitButton).toBeInTheDocument(); From be2e1eb903b5719661682839f0c88d5412a1be04 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Thu, 15 Aug 2024 22:29:43 +0000 Subject: [PATCH 010/216] test fixes --- .../ResidentialAddressForm.test.jsx | 97 ++++++------------- .../Profile/ResidentialAddress.test.jsx | 13 +-- yarn.lock | 26 +---- 3 files changed, 30 insertions(+), 106 deletions(-) diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx index 0e60f58fee2..afb18b3d15a 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx @@ -1,23 +1,8 @@ import React from 'react'; -import { render, screen, waitFor, fireEvent } from '@testing-library/react'; +import { render, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { act } from 'react-dom/test-utils'; -import selectEvent from 'react-select-event'; -import { renderWithRouter } from 'testUtils'; import ResidentialAddressForm from './ResidentialAddressForm'; -import { searchLocationByZipCity } from 'services/internalApi'; - -const mockNavigate = jest.fn(); -jest.mock('react-router-dom', () => ({ - ...jest.requireActual('react-router-dom'), - useNavigate: () => mockNavigate, -})); - -jest.mock('services/internalApi', () => ({ - ...jest.requireActual('services/internalApi'), - searchLocationByZipCity: jest.fn(), -})); describe('ResidentialAddressForm component', () => { const formFieldsName = 'current_residence'; @@ -31,7 +16,6 @@ describe('ResidentialAddressForm component', () => { city: '', state: '', postalCode: '', - county: '', }, }, onSubmit: jest.fn().mockImplementation(() => Promise.resolve()), @@ -44,25 +28,37 @@ describe('ResidentialAddressForm component', () => { city: 'El Paso', state: 'TX', postalCode: '79912', - county: 'El Paso', }; + const dataProps = { + formFieldsName, + initialValues: { + [formFieldsName]: { + streetAddress1: '', + streetAddress2: '', + city: fakeAddress.city, + state: fakeAddress.state, + postalCode: fakeAddress.postalCode, + county: fakeAddress.county, + }, + }, + onSubmit: jest.fn().mockImplementation(() => Promise.resolve()), + onBack: jest.fn(), + }; + + it('renders the form inputs and help text', async () => { - const { getByRole, getByLabelText, getByText } = render(); + const { getByLabelText, getByText } = render(); await waitFor(() => { expect(getByLabelText('Address 1')).toBeInstanceOf(HTMLInputElement); expect(getByLabelText(/Address 2/)).toBeInstanceOf(HTMLInputElement); - expect(getByRole('combobox', { id: 'zipCity-input' })).toBeInstanceOf(HTMLInputElement); - expect(getByLabelText('City')).toBeInstanceOf(HTMLInputElement); expect(getByLabelText('State')).toBeInstanceOf(HTMLInputElement); - expect(getByLabelText('County')).toBeInstanceOf(HTMLInputElement); - expect(getByLabelText('ZIP')).toBeInstanceOf(HTMLInputElement); expect(getByText('Must be a physical address.')).toBeInTheDocument(); @@ -70,31 +66,10 @@ describe('ResidentialAddressForm component', () => { }); it('shows an error message if trying to submit an invalid form', async () => { - const mockAddress = { - city: 'El Paso', - state: 'TX', - postalCode: '79912', - county: 'El Paso', - }; - const mockSearchLocationByZipCity= () => Promise.resolve(mockAddress); - searchLocationByZipCity.mockImplementation(mockSearchLocationByZipCity); - const { getByRole, findAllByRole, getByLabelText } = render(); await userEvent.click(getByLabelText('Address 1')); await userEvent.click(getByLabelText(/Address 2/)); - const input = getByRole('combobox', { id: 'zipCity-input' }); - fireEvent.change(input, {target: {value: mockAddress.postalCode} }); - await act(() => selectEvent.select(input, 79912)); - - await waitFor(() => { - expect(screen.getByText(mockAddress.postalCode)).toBeInTheDocument(); - }); - // fireEvent.keyPress(input, { key: 'Enter', code: 13 }); - - await waitFor(() => { - expect(searchLocationByZipCity).toHaveBeenCalledTimes(1); - }); const submitBtn = getByRole('button', { name: 'Next' }); await userEvent.click(submitBtn); @@ -110,29 +85,13 @@ describe('ResidentialAddressForm component', () => { }); it('submits the form when its valid', async () => { - const mockAddress = { - city: 'El Paso', - state: 'TX', - postalCode: '79912', - county: 'El Paso', - }; - const mockSearchLocationByZipCity= () => Promise.resolve(mockAddress); - searchLocationByZipCity.mockImplementation(mockSearchLocationByZipCity); - - // const { getByRole, getByLabelText } = render(); - renderWithRouter(); - const submitBtn = screen.getByRole('button', { name: 'Next' }); - - await userEvent.type(screen.getByLabelText('Address 1'), fakeAddress.streetAddress1); - await userEvent.type(screen.getByLabelText(/Address 2/), fakeAddress.streetAddress2); - const input = screen.getByLabelText('Zip/City Lookup'); - await userEvent.type(input, '79912'); - fireEvent.change(input, {target: {value: mockAddress.postalCode} }); - // await waitFor(() => { - // expect(screen.getByText(mockAddress.state)).toBeInTheDocument(); - // }); - await act(() => selectEvent.select(input, mockAddress.postalCode)); - expect(screen.getByLabelText('State')).toHaveValue(mockAddress.state); + const { getByRole, getByLabelText } = render(); + const submitBtn = getByRole('button', { name: 'Next' }); + + await userEvent.type(getByLabelText('Address 1'), fakeAddress.streetAddress1); + await userEvent.type(getByLabelText(/Address 2/), fakeAddress.streetAddress2); + await userEvent.tab(); + await waitFor(() => { expect(submitBtn).toBeEnabled(); }); @@ -143,7 +102,7 @@ describe('ResidentialAddressForm component', () => { }; await waitFor(() => { - expect(testProps.onSubmit).toHaveBeenCalledWith(expectedParams, expect.anything()); + expect(dataProps.onSubmit).toHaveBeenCalledWith(expectedParams, expect.anything()); }); }); @@ -159,4 +118,4 @@ describe('ResidentialAddressForm component', () => { }); afterEach(jest.resetAllMocks); -}); +}); \ No newline at end of file diff --git a/src/pages/MyMove/Profile/ResidentialAddress.test.jsx b/src/pages/MyMove/Profile/ResidentialAddress.test.jsx index 8b2f412876c..92450d9f08b 100644 --- a/src/pages/MyMove/Profile/ResidentialAddress.test.jsx +++ b/src/pages/MyMove/Profile/ResidentialAddress.test.jsx @@ -72,7 +72,7 @@ describe('ResidentialAddress page', () => { }); it('next button submits the form and goes to the Backup address step', async () => { - const testProps = generateTestProps(blankAddress); + const testProps = generateTestProps(fakeAddress); const expectedServiceMemberPayload = { ...testProps.serviceMember, residential_address: fakeAddress }; @@ -82,17 +82,6 @@ describe('ResidentialAddress page', () => { patchServiceMember.mockImplementation(() => Promise.resolve(expectedServiceMemberPayload)); render(); - const postalCode = '79912'; - const testLocation = 'EL PASO, TX 79912 (EL PASO)'; - const optionName = testLocation.split(' 79')[0]; - await userEvent.type(screen.getByLabelText('Address 1'), fakeAddress.streetAddress1); - await userEvent.type(screen.getByLabelText(/Address 2/), fakeAddress.streetAddress2); - await userEvent.type(screen.getByLabelText('Zip/City Lookup'), '79'); - await userEvent.click(await screen.findByText(optionName)); - // const postalCodeInput = await findByLabelText('Zip/City Lookup'); - // await userEvent.type(postalCodeInput, postalCode); - // await userEvent.click(await screen.findByText('79912')); - await userEvent.tab(); const submitButton = screen.getByRole('button', { name: 'Next' }); expect(submitButton).toBeInTheDocument(); diff --git a/yarn.lock b/yarn.lock index 3117d58fb44..037527e22da 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8350,11 +8350,6 @@ es-to-primitive@^1.2.1: is-date-object "^1.0.1" is-symbol "^1.0.2" -es6-error@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d" - integrity sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg== - es6-object-assign@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/es6-object-assign/-/es6-object-assign-1.1.0.tgz#c2c3582656247c39ea107cb1e6652b6f9f24523c" @@ -10518,11 +10513,6 @@ is-potential-custom-element-name@^1.0.1: resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz#171ed6f19e3ac554394edf78caa05784a45bebb5" integrity sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ== -is-promise@^2.1.0: - version "2.2.2" - resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.2.2.tgz#39ab959ccbf9a774cf079f7b40c7a26f763135f1" - integrity sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ== - is-reference@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/is-reference/-/is-reference-1.2.1.tgz#8b2dac0b371f4bc994fdeaba9eb542d03002d0b7" @@ -14507,7 +14497,7 @@ react-is@18.1.0: resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== -react-is@^16.13.1, react-is@^16.4.2, react-is@^16.7.0: +react-is@^16.13.1, react-is@^16.7.0: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== @@ -14888,20 +14878,6 @@ redux-devtools-extension@^2.13.2: resolved "https://registry.yarnpkg.com/redux-devtools-extension/-/redux-devtools-extension-2.13.9.tgz#6b764e8028b507adcb75a1cae790f71e6be08ae7" integrity sha512-cNJ8Q/EtjhQaZ71c8I9+BPySIBVEKssbPpskBfsXqb8HJ002A3KRVHfeRzwRo6mGPqsm7XuHTqNSNeS1Khig0A== -redux-form@^8.3.10: - version "8.3.10" - resolved "https://registry.yarnpkg.com/redux-form/-/redux-form-8.3.10.tgz#335657fafd4b26b91b4ce65371cd9dabe3648158" - integrity sha512-Eeog8dJYUxCSZI/oBoy7VkprvMjj1lpUnHa3LwjVNZvYDNeiRZMoZoaAT+6nlK2YQ4aiBopKUMiLe4ihUOHCGg== - dependencies: - "@babel/runtime" "^7.9.2" - es6-error "^4.1.1" - hoist-non-react-statics "^3.3.2" - invariant "^2.2.4" - is-promise "^2.1.0" - lodash "^4.17.15" - prop-types "^15.6.1" - react-is "^16.4.2" - redux-mock-store@1.5.4: version "1.5.4" resolved "https://registry.yarnpkg.com/redux-mock-store/-/redux-mock-store-1.5.4.tgz#90d02495fd918ddbaa96b83aef626287c9ab5872" From a4b5fdc0c5a6482b766fbf9408fbb16f1ae0fc90 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 16 Aug 2024 02:36:33 +0000 Subject: [PATCH 011/216] added input test --- .../form/fields/ZipCityInput.test.jsx | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/components/form/fields/ZipCityInput.test.jsx diff --git a/src/components/form/fields/ZipCityInput.test.jsx b/src/components/form/fields/ZipCityInput.test.jsx new file mode 100644 index 00000000000..f863fb96d59 --- /dev/null +++ b/src/components/form/fields/ZipCityInput.test.jsx @@ -0,0 +1,64 @@ +import React from 'react'; +import { mount, shallow } from 'enzyme'; +import { act } from 'react-dom/test-utils'; +import AsyncSelect from 'react-select/async'; + +import { ZipCityInput } from './ZipCityInput'; + +import { LocationSearchBoxComponent, LocationSearchBoxContainer } from 'components/LocationSearchBox/LocationSearchBox'; + +const mockOnChange = jest.fn(); +const mockSetValue = jest.fn(); +// mock out formik hook as we are not testing formik +// needs to be before first describe +jest.mock('formik', () => { + return { + ...jest.requireActual('formik'), + useField: () => [ + { + onChange: mockOnChange, + }, + { touched: true, error: 'sample error' }, + { setValue: mockSetValue }, + ], + }; +}); + +jest.mock('services/internalapi', () => { + return { + searchLocationByZipCity: () => + new Promise((resolve) => { + resolve(["El Paso"]); + }), + }; +}); + +const handleZipCityChange = jest.fn(); + +describe('ZipCityInput', () => { + describe('with all required props', () => { + const wrapper = shallow( + + ); + + it('renders a Zip City search input', () => { + const input = wrapper.find(LocationSearchBoxContainer); + expect(input.length).toBe(1); + }); + + it('triggers onChange properly', async () => { + const container = wrapper.find(LocationSearchBoxContainer).dive(); + const component = container.find(LocationSearchBoxComponent).dive(); + const select = component.find(AsyncSelect); + await select.simulate('change', { city: "El Paso" }); + expect(mockSetValue).toHaveBeenCalledWith({ city: "El Paso"}); + }); + }); + + afterEach(jest.resetAllMocks); +}); From e2f426f31be884214808e80ac62582fbd48c615e Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 16 Aug 2024 05:03:55 +0000 Subject: [PATCH 012/216] fix playwright test, formik validation --- playwright/tests/my/mymove/onboarding.spec.js | 10 ++++----- .../ResidentialAddressForm.jsx | 21 +++++++++++-------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/playwright/tests/my/mymove/onboarding.spec.js b/playwright/tests/my/mymove/onboarding.spec.js index c9aa3203b96..b8e78c39be9 100644 --- a/playwright/tests/my/mymove/onboarding.spec.js +++ b/playwright/tests/my/mymove/onboarding.spec.js @@ -1,6 +1,6 @@ // @ts-check // import { test, expect } from '../../utils/my/customerTest'; -import { test } from '../../utils/my/customerTest'; +import { test, expect } from '../../utils/my/customerTest'; const multiMoveEnabled = process.env.FEATURE_FLAG_MULTI_MOVE; @@ -105,10 +105,10 @@ test.describe('(MultiMove) Onboarding', () => { // Current address section await customerPage.waitForPage.onboardingCurrentAddress(); await page.getByLabel('Address 1').fill('7 Q St'); - await page.getByLabel('City').fill('Atco'); - await page.getByLabel('State').selectOption({ label: 'NJ' }); - await page.getByLabel('ZIP').fill('08004'); - await page.getByLabel('ZIP').blur(); + await page.getByLabel('Address 1').blur(); + await page.getByLabel('Zip/City Lookup').fill('08004'); + await expect(page.getByText('ATCO, NJ 08004 (CAMDEN)', { exact: true })).toBeVisible(); + await page.keyboard.press('Enter'); await customerPage.navigateForward(); // Backup mailing address section diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx index 15caced9b39..200ba55bdbc 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx @@ -29,16 +29,19 @@ const ResidentialAddressForm = ({ formFieldsName, initialValues, onSubmit, onBac > {({ isValid, isSubmitting, handleSubmit, values, setValues }) => { const handleZipCityChange = (value) => { - setValues({ - ...values, - current_residence: { - ...values.current_residence, - city: value.city, - state: value.state ? value.state : '', - county: value.county, - postalCode: value.postalCode, + setValues( + { + ...values, + current_residence: { + ...values.current_residence, + city: value.city, + state: value.state ? value.state : '', + county: value.county, + postalCode: value.postalCode, + }, }, - }); + { shouldValidate: true }, + ); }; return ( From 315724ca436274aec81e50f7069d787145444020 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 16 Aug 2024 05:23:27 +0000 Subject: [PATCH 013/216] code cleanup --- playwright/tests/my/mymove/onboarding.spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/playwright/tests/my/mymove/onboarding.spec.js b/playwright/tests/my/mymove/onboarding.spec.js index b8e78c39be9..ecc3a847278 100644 --- a/playwright/tests/my/mymove/onboarding.spec.js +++ b/playwright/tests/my/mymove/onboarding.spec.js @@ -3,6 +3,7 @@ import { test, expect } from '../../utils/my/customerTest'; const multiMoveEnabled = process.env.FEATURE_FLAG_MULTI_MOVE; +const zipCityLookup = 'ATCO, NJ 08004 (CAMDEN)'; test.describe('Onboarding', () => { test.skip(multiMoveEnabled === 'true', 'Skip if MultiMove workflow is enabled.'); @@ -107,7 +108,7 @@ test.describe('(MultiMove) Onboarding', () => { await page.getByLabel('Address 1').fill('7 Q St'); await page.getByLabel('Address 1').blur(); await page.getByLabel('Zip/City Lookup').fill('08004'); - await expect(page.getByText('ATCO, NJ 08004 (CAMDEN)', { exact: true })).toBeVisible(); + await expect(page.getByText(zipCityLookup, { exact: true })).toBeVisible(); await page.keyboard.press('Enter'); await customerPage.navigateForward(); From 2560a7aa8b075d01a17cea7743a4fcf962e93927 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 16 Aug 2024 14:32:07 +0000 Subject: [PATCH 014/216] fix blank locations --- .../ResidentialAddressForm.test.jsx | 1 + .../LocationSearchBox/LocationSearchBox.jsx | 2 +- .../LocationSearchBox/LocationSearchBox.stories.jsx | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx index afb18b3d15a..645a60c63e4 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx @@ -28,6 +28,7 @@ describe('ResidentialAddressForm component', () => { city: 'El Paso', state: 'TX', postalCode: '79912', + county: 'El Paso', }; const dataProps = { diff --git a/src/components/LocationSearchBox/LocationSearchBox.jsx b/src/components/LocationSearchBox/LocationSearchBox.jsx index bc6be42697f..ef1e1cd05fa 100644 --- a/src/components/LocationSearchBox/LocationSearchBox.jsx +++ b/src/components/LocationSearchBox/LocationSearchBox.jsx @@ -24,7 +24,7 @@ const formatOptionLabel = (option, input) => { const searchIndex = optionLabel.toLowerCase().indexOf(inputText.toLowerCase()); if (searchIndex === -1) { - return {option.city}; + return {optionLabel}; } return ( diff --git a/src/components/LocationSearchBox/LocationSearchBox.stories.jsx b/src/components/LocationSearchBox/LocationSearchBox.stories.jsx index 8067f599b7d..d271ed7929c 100644 --- a/src/components/LocationSearchBox/LocationSearchBox.stories.jsx +++ b/src/components/LocationSearchBox/LocationSearchBox.stories.jsx @@ -7,6 +7,13 @@ export default { component: LocationSearchBoxComponent, }; +const testZipCity = { + city: 'El Paso', + state: 'TX', + postalCode: '79912', + county: 'El Paso', +}; + const testAddress = { city: 'Glendale Luke AFB', country: 'United States', @@ -129,6 +136,10 @@ const baseValue = { address: { ...testAddress }, }; +const mockSearchLocationByZipCity = async () => { + return testZipCity; +}; + const mockSearchLocations = async () => { return testLocations; }; From b5308be520af59e2ae224662ce35f6040a99569e Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 16 Aug 2024 22:13:38 +0000 Subject: [PATCH 015/216] adding storybook --- .../ResidentialAddressForm.test.jsx | 1 - .../LocationSearchBox.stories.jsx | 52 +++++++++++++++---- .../AddressFields/AddressFields.stories.jsx | 21 ++++++++ 3 files changed, 63 insertions(+), 11 deletions(-) diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx index 645a60c63e4..1f4a94b0356 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx @@ -47,7 +47,6 @@ describe('ResidentialAddressForm component', () => { onBack: jest.fn(), }; - it('renders the form inputs and help text', async () => { const { getByLabelText, getByText } = render(); diff --git a/src/components/LocationSearchBox/LocationSearchBox.stories.jsx b/src/components/LocationSearchBox/LocationSearchBox.stories.jsx index d271ed7929c..c2fc98b5459 100644 --- a/src/components/LocationSearchBox/LocationSearchBox.stories.jsx +++ b/src/components/LocationSearchBox/LocationSearchBox.stories.jsx @@ -7,12 +7,20 @@ export default { component: LocationSearchBoxComponent, }; -const testZipCity = { - city: 'El Paso', - state: 'TX', - postalCode: '79912', - county: 'El Paso', -}; +const testZipCity = [ + { + city: 'Glendale Luke AFB', + county: 'Maricopa', + postalCode: '85309', + state: 'AZ', + }, + { + city: 'El Paso', + county: 'El Paso', + postalCode: '79912', + state: 'TX', + }, +]; const testAddress = { city: 'Glendale Luke AFB', @@ -136,10 +144,6 @@ const baseValue = { address: { ...testAddress }, }; -const mockSearchLocationByZipCity = async () => { - return testZipCity; -}; - const mockSearchLocations = async () => { return testLocations; }; @@ -148,6 +152,10 @@ const mockShowAddress = async () => { return testAddress; }; +const mockZipCity = async () => { + return testZipCity; +}; + export const DutyStationBasic = () => { const [value, setValue] = useState(); @@ -277,3 +285,27 @@ export const TransportationLocationWithValue = () => { /> ); }; + +export const ZipCityLocationBasic = () => { + const [value, setValue] = useState(); + + const onChange = (newValue) => { + setValue(newValue); + }; + + const handleOnChange = (newValue) => { + setValue(newValue); + }; + + return ( + + ); +}; diff --git a/src/components/form/AddressFields/AddressFields.stories.jsx b/src/components/form/AddressFields/AddressFields.stories.jsx index 61730cab606..33476511fd2 100644 --- a/src/components/form/AddressFields/AddressFields.stories.jsx +++ b/src/components/form/AddressFields/AddressFields.stories.jsx @@ -125,3 +125,24 @@ export const InsideSectionWrapper = () => ( )} ); + +export const ZipCityAddress = () => ( + + {() => ( + + + + )} + +); From 9727135e4c406d214b54f4a71e60f2d30de9c152 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Sat, 17 Aug 2024 00:14:45 +0000 Subject: [PATCH 016/216] add zip lookup for backup address --- .../BackupAddressForm/BackupAddressForm.jsx | 23 +++++++--- .../BackupAddressForm.test.jsx | 33 +++++++++----- .../form/AddressFields/AddressFields.jsx | 19 +++++--- src/pages/MyMove/Profile/BackupAddress.jsx | 1 + .../MyMove/Profile/BackupAddress.test.jsx | 43 ++----------------- .../MyMove/Profile/ResidentialAddress.jsx | 21 --------- 6 files changed, 56 insertions(+), 84 deletions(-) diff --git a/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx b/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx index e745afa9b2d..44c828bc15e 100644 --- a/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx +++ b/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx @@ -24,7 +24,23 @@ const BackupAddressForm = ({ formFieldsName, initialValues, onSubmit, onBack }) validateOnMount validationSchema={validationSchema} > - {({ isValid, isSubmitting, handleChange, handleSubmit, setFieldTouched }) => { + {({ isValid, isSubmitting, handleSubmit, values, setValues }) => { + const handleZipCityChange = (value) => { + setValues( + { + ...values, + backup_mailing_address: { + ...values.backup_mailing_address, + city: value.city, + state: value.state ? value.state : '', + county: value.county, + postalCode: value.postalCode, + }, + }, + { shouldValidate: true }, + ); + }; + return (

Backup address

@@ -35,10 +51,7 @@ const BackupAddressForm = ({ formFieldsName, initialValues, onSubmit, onBack })

- +
diff --git a/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx b/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx index e1e77805f51..136b4b2460d 100644 --- a/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx +++ b/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx @@ -28,6 +28,23 @@ describe('BackupAddressForm component', () => { city: 'El Paso', state: 'TX', postalCode: '79912', + county: 'El Paso', + }; + + const dataProps = { + formFieldsName, + initialValues: { + [formFieldsName]: { + streetAddress1: '', + streetAddress2: '', + city: fakeAddress.city, + state: fakeAddress.state, + postalCode: fakeAddress.postalCode, + county: fakeAddress.county, + }, + }, + onSubmit: jest.fn().mockImplementation(() => Promise.resolve()), + onBack: jest.fn(), }; it('renders the form inputs', async () => { @@ -40,7 +57,7 @@ describe('BackupAddressForm component', () => { expect(getByLabelText('City')).toBeInstanceOf(HTMLInputElement); - expect(getByLabelText('State')).toBeInstanceOf(HTMLSelectElement); + expect(getByLabelText('State')).toBeInstanceOf(HTMLInputElement); expect(getByLabelText('ZIP')).toBeInstanceOf(HTMLInputElement); }); @@ -50,15 +67,12 @@ describe('BackupAddressForm component', () => { const { getByRole, findAllByRole, getByLabelText } = render(); await userEvent.click(getByLabelText('Address 1')); await userEvent.click(getByLabelText(/Address 2/)); - await userEvent.click(getByLabelText('City')); - await userEvent.click(getByLabelText('ZIP')); - await userEvent.click(getByLabelText('State')); - + const submitBtn = getByRole('button', { name: 'Next' }); await userEvent.click(submitBtn); const alerts = await findAllByRole('alert'); - expect(alerts.length).toBe(4); + expect(alerts.length).toBe(1); alerts.forEach((alert) => { expect(alert).toHaveTextContent('Required'); @@ -68,14 +82,11 @@ describe('BackupAddressForm component', () => { }); it('submits the form when its valid', async () => { - const { getByRole, getByLabelText } = render(); + const { getByRole, getByLabelText } = render(); const submitBtn = getByRole('button', { name: 'Next' }); await userEvent.type(getByLabelText('Address 1'), fakeAddress.streetAddress1); await userEvent.type(getByLabelText(/Address 2/), fakeAddress.streetAddress2); - await userEvent.type(getByLabelText('City'), fakeAddress.city); - await userEvent.selectOptions(getByLabelText('State'), [fakeAddress.state]); - await userEvent.type(getByLabelText('ZIP'), fakeAddress.postalCode); await userEvent.tab(); await waitFor(() => { @@ -88,7 +99,7 @@ describe('BackupAddressForm component', () => { }; await waitFor(() => { - expect(testProps.onSubmit).toHaveBeenCalledWith(expectedParams, expect.anything()); + expect(dataProps.onSubmit).toHaveBeenCalledWith(expectedParams, expect.anything()); }); }); diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index a896656f19a..2f5eb9a62fc 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -116,13 +116,18 @@ export const AddressFields = ({ validate={validators?.streetAddress3} /> {zipCityEnabled && ( - + <> + +

+ If you encounter any inaccurate lookup information please contact the Help Desk for further assistance. +

+ )}
diff --git a/src/pages/MyMove/Profile/BackupAddress.jsx b/src/pages/MyMove/Profile/BackupAddress.jsx index 193d9624626..bc573125458 100644 --- a/src/pages/MyMove/Profile/BackupAddress.jsx +++ b/src/pages/MyMove/Profile/BackupAddress.jsx @@ -28,6 +28,7 @@ export const BackupAddress = ({ serviceMember, updateServiceMember }) => { city: serviceMember.backup_mailing_address?.city || '', state: serviceMember.backup_mailing_address?.state || '', postalCode: serviceMember.backup_mailing_address?.postalCode || '', + county: serviceMember.backup_mailing_address?.county || '', }, }; diff --git a/src/pages/MyMove/Profile/BackupAddress.test.jsx b/src/pages/MyMove/Profile/BackupAddress.test.jsx index 378c5102a73..5ac4d41469c 100644 --- a/src/pages/MyMove/Profile/BackupAddress.test.jsx +++ b/src/pages/MyMove/Profile/BackupAddress.test.jsx @@ -29,6 +29,7 @@ describe('BackupAddress page', () => { city: 'El Paso', state: 'TX', postalCode: '79912', + county: 'El Paso', }; const blankAddress = Object.fromEntries(Object.keys(fakeAddress).map((k) => [k, ''])); @@ -64,20 +65,13 @@ describe('BackupAddress page', () => { }); it('next button submits the form and goes to the Backup contact step', async () => { - const testProps = generateTestProps(blankAddress); + const testProps = generateTestProps(fakeAddress); const expectedServiceMemberPayload = { ...testProps.serviceMember, backup_mailing_address: fakeAddress }; patchServiceMember.mockImplementation(() => Promise.resolve(expectedServiceMemberPayload)); - const { getByRole, getByLabelText } = render(); - - await userEvent.type(getByLabelText('Address 1'), fakeAddress.streetAddress1); - await userEvent.type(getByLabelText(/Address 2/), fakeAddress.streetAddress2); - await userEvent.type(getByLabelText('City'), fakeAddress.city); - await userEvent.selectOptions(getByLabelText('State'), [fakeAddress.state]); - await userEvent.type(getByLabelText('ZIP'), fakeAddress.postalCode); - await userEvent.tab(); + const { getByRole } = render(); const submitButton = getByRole('button', { name: 'Next' }); expect(submitButton).toBeInTheDocument(); @@ -95,37 +89,6 @@ describe('BackupAddress page', () => { expect(mockNavigate).toHaveBeenCalledWith(customerRoutes.BACKUP_CONTACTS_PATH); }); - it('Selecting an unsupported state should display an unsupported state message', async () => { - const testProps = generateTestProps(blankAddress); - - const expectedServiceMemberPayload = { ...testProps.serviceMember, backup_mailing_address: fakeAddress }; - - patchServiceMember.mockImplementation(() => Promise.resolve(expectedServiceMemberPayload)); - - const { getByLabelText, getByText } = render(); - - await userEvent.type(getByLabelText('Address 1'), fakeAddress.streetAddress1); - await userEvent.type(getByLabelText(/Address 2/), fakeAddress.streetAddress2); - await userEvent.type(getByLabelText('City'), fakeAddress.city); - await userEvent.selectOptions(getByLabelText('State'), 'AK'); - await userEvent.type(getByLabelText('ZIP'), fakeAddress.postalCode); - await userEvent.tab(); - - let msg = getByText('Moves to this state are not supported at this time.'); - expect(msg).toBeVisible(); - - await userEvent.selectOptions(getByLabelText('State'), 'AL'); - await userEvent.type(getByLabelText('ZIP'), fakeAddress.postalCode); - await userEvent.tab(); - expect(msg).not.toBeVisible(); - - await userEvent.selectOptions(getByLabelText('State'), 'HI'); - await userEvent.type(getByLabelText('ZIP'), fakeAddress.postalCode); - await userEvent.tab(); - msg = getByText('Moves to this state are not supported at this time.'); - expect(msg).toBeVisible(); - }); - it('shows an error if the patchServiceMember API returns an error', async () => { const testProps = generateTestProps(fakeAddress); diff --git a/src/pages/MyMove/Profile/ResidentialAddress.jsx b/src/pages/MyMove/Profile/ResidentialAddress.jsx index ad0265dfbfa..c97b8a4835b 100644 --- a/src/pages/MyMove/Profile/ResidentialAddress.jsx +++ b/src/pages/MyMove/Profile/ResidentialAddress.jsx @@ -7,33 +7,12 @@ import { useNavigate } from 'react-router-dom'; import NotificationScrollToTop from 'components/NotificationScrollToTop'; import { getResponseError, patchServiceMember } from 'services/internalApi'; import { updateServiceMember as updateServiceMemberAction } from 'store/entities/actions'; -import { ValidateZipRateData } from 'shared/api'; import { selectServiceMemberFromLoggedInUser } from 'store/entities/selectors'; import requireCustomerState from 'containers/requireCustomerState/requireCustomerState'; import { profileStates } from 'constants/customerStates'; import { customerRoutes } from 'constants/routes'; import ResidentialAddressForm from 'components/Customer/ResidentialAddressForm/ResidentialAddressForm'; import { ResidentialAddressShape } from 'types/address'; -import { ZIP_CODE_REGEX } from 'utils/validation'; - -const UnsupportedZipCodeErrorMsg = - 'Sorry, we don’t support that zip code yet. Please contact your local PPPO for assistance.'; - -const validatePostalCode = async (value) => { - // Since we are validating the postal code on change, we want to only make this validation check - // when we know the value could possibly be valid. - if (!ZIP_CODE_REGEX.test(value)) { - return 'Must be valid zip code'; - } - let responseBody; - try { - responseBody = await ValidateZipRateData(value, 'origin'); - } catch (e) { - return 'Error checking ZIP'; - } - - return responseBody.valid ? undefined : UnsupportedZipCodeErrorMsg; -}; export const ResidentialAddress = ({ serviceMember, updateServiceMember }) => { const navigate = useNavigate(); From 88da3b9de47b85be276a54e02db88122932a5ba6 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Mon, 19 Aug 2024 17:20:00 +0000 Subject: [PATCH 017/216] test fixes --- playwright/tests/my/mymove/onboarding.spec.js | 8 ++--- .../form/fields/ZipCityInput.test.jsx | 35 +++++++++---------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/playwright/tests/my/mymove/onboarding.spec.js b/playwright/tests/my/mymove/onboarding.spec.js index ecc3a847278..ccbd536c286 100644 --- a/playwright/tests/my/mymove/onboarding.spec.js +++ b/playwright/tests/my/mymove/onboarding.spec.js @@ -115,10 +115,10 @@ test.describe('(MultiMove) Onboarding', () => { // Backup mailing address section await customerPage.waitForPage.onboardingBackupAddress(); await page.getByLabel('Address 1').fill('7 Q St'); - await page.getByLabel('City').fill('Atco'); - await page.getByLabel('State').selectOption({ label: 'NJ' }); - await page.getByLabel('ZIP').fill('08004'); - await page.getByLabel('ZIP').blur(); + await page.getByLabel('Address 1').blur(); + await page.getByLabel('Zip/City Lookup').fill('08004'); + await expect(page.getByText(zipCityLookup, { exact: true })).toBeVisible(); + await page.keyboard.press('Enter'); await customerPage.navigateForward(); // Backup contact info section diff --git a/src/components/form/fields/ZipCityInput.test.jsx b/src/components/form/fields/ZipCityInput.test.jsx index f863fb96d59..587e6a8a239 100644 --- a/src/components/form/fields/ZipCityInput.test.jsx +++ b/src/components/form/fields/ZipCityInput.test.jsx @@ -1,11 +1,11 @@ import React from 'react'; -import { mount, shallow } from 'enzyme'; -import { act } from 'react-dom/test-utils'; +import { shallow } from 'enzyme'; import AsyncSelect from 'react-select/async'; import { ZipCityInput } from './ZipCityInput'; import { LocationSearchBoxComponent, LocationSearchBoxContainer } from 'components/LocationSearchBox/LocationSearchBox'; +import { searchLocationByZipCity } from 'services/internalApi'; const mockOnChange = jest.fn(); const mockSetValue = jest.fn(); @@ -24,26 +24,23 @@ jest.mock('formik', () => { }; }); -jest.mock('services/internalapi', () => { - return { - searchLocationByZipCity: () => - new Promise((resolve) => { - resolve(["El Paso"]); - }), - }; -}); +jest.mock('services/internalApi', () => ({ + ...jest.requireActual('services/internalApi'), + searchLocationByZipCity: jest.fn(), +})); const handleZipCityChange = jest.fn(); describe('ZipCityInput', () => { describe('with all required props', () => { const wrapper = shallow( - + , ); it('renders a Zip City search input', () => { @@ -52,11 +49,13 @@ describe('ZipCityInput', () => { }); it('triggers onChange properly', async () => { + const cityName = 'El Paso'; + searchLocationByZipCity.mockImplementation(() => Promise.resolve(cityName)); const container = wrapper.find(LocationSearchBoxContainer).dive(); const component = container.find(LocationSearchBoxComponent).dive(); const select = component.find(AsyncSelect); - await select.simulate('change', { city: "El Paso" }); - expect(mockSetValue).toHaveBeenCalledWith({ city: "El Paso"}); + await select.simulate('change', { city: cityName }); + expect(mockSetValue).toHaveBeenCalledWith({ city: cityName }); }); }); From e4df45ebbb133eaf5f834f942a4fbcdaf755be75 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Mon, 19 Aug 2024 20:01:35 +0000 Subject: [PATCH 018/216] prettier fixes --- .../Customer/BackupAddressForm/BackupAddressForm.test.jsx | 2 +- .../ResidentialAddressForm/ResidentialAddressForm.test.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx b/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx index 136b4b2460d..7f11de937ef 100644 --- a/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx +++ b/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx @@ -67,7 +67,7 @@ describe('BackupAddressForm component', () => { const { getByRole, findAllByRole, getByLabelText } = render(); await userEvent.click(getByLabelText('Address 1')); await userEvent.click(getByLabelText(/Address 2/)); - + const submitBtn = getByRole('button', { name: 'Next' }); await userEvent.click(submitBtn); diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx index 1f4a94b0356..15c3e22b49b 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx @@ -118,4 +118,4 @@ describe('ResidentialAddressForm component', () => { }); afterEach(jest.resetAllMocks); -}); \ No newline at end of file +}); From bb2acfdec74e463f0be32b4da86588bee9ee0718 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Mon, 19 Aug 2024 21:54:35 +0000 Subject: [PATCH 019/216] adding mocks --- pkg/services/address.go | 1 + pkg/services/mocks/UsPostRegionCity.go | 55 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 pkg/services/mocks/UsPostRegionCity.go diff --git a/pkg/services/address.go b/pkg/services/address.go index 90432ebb76b..0f515aa7e8f 100644 --- a/pkg/services/address.go +++ b/pkg/services/address.go @@ -13,6 +13,7 @@ type AddressUpdater interface { UpdateAddress(appCtx appcontext.AppContext, address *models.Address, eTag string) (*models.Address, error) } +//go:generate mockery --name UsPostRegionCity type UsPostRegionCity interface { GetLocationsByZipCity(appCtx appcontext.AppContext, search string) (*models.UsPostRegionCities, error) } diff --git a/pkg/services/mocks/UsPostRegionCity.go b/pkg/services/mocks/UsPostRegionCity.go new file mode 100644 index 00000000000..410e7007ed7 --- /dev/null +++ b/pkg/services/mocks/UsPostRegionCity.go @@ -0,0 +1,55 @@ +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + appcontext "github.com/transcom/mymove/pkg/appcontext" + + models "github.com/transcom/mymove/pkg/models" +) + +// UsPostRegionCity is an autogenerated mock type for the UsPostRegionCity type +type UsPostRegionCity struct { + mock.Mock +} + +// GetLocationsByZipCity provides a mock function with given fields: appCtx, search +func (_m *UsPostRegionCity) GetLocationsByZipCity(appCtx appcontext.AppContext, search string) (*models.UsPostRegionCities, error) { + ret := _m.Called(appCtx, search) + + var r0 *models.UsPostRegionCities + var r1 error + if rf, ok := ret.Get(0).(func(appcontext.AppContext, string) (*models.UsPostRegionCities, error)); ok { + return rf(appCtx, search) + } + if rf, ok := ret.Get(0).(func(appcontext.AppContext, string) *models.UsPostRegionCities); ok { + r0 = rf(appCtx, search) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*models.UsPostRegionCities) + } + } + + if rf, ok := ret.Get(1).(func(appcontext.AppContext, string) error); ok { + r1 = rf(appCtx, search) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewUsPostRegionCity creates a new instance of UsPostRegionCity. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewUsPostRegionCity(t interface { + mock.TestingT + Cleanup(func()) +}) *UsPostRegionCity { + mock := &UsPostRegionCity{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} From de21889b7d9ae4b56880b68f4d29e43ec430e7d0 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Mon, 19 Aug 2024 22:10:48 +0000 Subject: [PATCH 020/216] renaming handleOnChange --- .../LocationSearchBox/LocationSearchBox.jsx | 14 +++++++------- .../LocationSearchBox.stories.jsx | 4 ++-- src/components/form/fields/ZipCityInput.jsx | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/LocationSearchBox/LocationSearchBox.jsx b/src/components/LocationSearchBox/LocationSearchBox.jsx index ef1e1cd05fa..6d65fae0cc5 100644 --- a/src/components/LocationSearchBox/LocationSearchBox.jsx +++ b/src/components/LocationSearchBox/LocationSearchBox.jsx @@ -107,7 +107,7 @@ export const LocationSearchBoxComponent = ({ hint, placeholder, isDisabled, - handleOnChange, + handleZipCityOnChange, }) => { const { value, onChange, name: inputName } = input; @@ -159,7 +159,7 @@ export const LocationSearchBoxComponent = ({ }, DEBOUNCE_TIMER_MS); const selectOption = async (selectedValue) => { - if (!selectedValue.address && !handleOnChange) { + if (!selectedValue.address && !handleZipCityOnChange) { const address = await showAddress(selectedValue.address_id); const newValue = { ...selectedValue, @@ -172,8 +172,8 @@ export const LocationSearchBoxComponent = ({ onChange(selectedValue); - if (handleOnChange !== null) { - handleOnChange(selectedValue); + if (handleZipCityOnChange !== null) { + handleZipCityOnChange(selectedValue); } return selectedValue; }; @@ -221,7 +221,7 @@ export const LocationSearchBoxComponent = ({ inputId={inputId} className={dutyInputClasses} cacheOptions - formatOptionLabel={handleOnChange ? formatZipCity : formatOptionLabel} + formatOptionLabel={handleZipCityOnChange ? formatZipCity : formatOptionLabel} getOptionValue={getOptionName} loadOptions={loadOptions} onChange={selectOption} @@ -264,7 +264,7 @@ LocationSearchBoxContainer.propTypes = { placeholder: PropTypes.string, isDisabled: PropTypes.bool, searchLocations: PropTypes.func, - handleOnChange: PropTypes.func, + handleZipCityOnChange: PropTypes.func, }; LocationSearchBoxContainer.defaultProps = { @@ -280,7 +280,7 @@ LocationSearchBoxContainer.defaultProps = { placeholder: 'Start typing a duty location...', isDisabled: false, searchLocations: SearchDutyLocations, - handleOnChange: null, + handleZipCityOnChange: null, }; LocationSearchBoxComponent.propTypes = { diff --git a/src/components/LocationSearchBox/LocationSearchBox.stories.jsx b/src/components/LocationSearchBox/LocationSearchBox.stories.jsx index c2fc98b5459..c19250b69cc 100644 --- a/src/components/LocationSearchBox/LocationSearchBox.stories.jsx +++ b/src/components/LocationSearchBox/LocationSearchBox.stories.jsx @@ -293,7 +293,7 @@ export const ZipCityLocationBasic = () => { setValue(newValue); }; - const handleOnChange = (newValue) => { + const handleZipCityOnChange = (newValue) => { setValue(newValue); }; @@ -305,7 +305,7 @@ export const ZipCityLocationBasic = () => { name="test_component" searchLocations={mockZipCity} displayAddress={false} - handleOnChange={handleOnChange} + handleZipCityOnChange={handleZipCityOnChange} /> ); }; diff --git a/src/components/form/fields/ZipCityInput.jsx b/src/components/form/fields/ZipCityInput.jsx index 0d2eecd14db..9df98ceecaa 100644 --- a/src/components/form/fields/ZipCityInput.jsx +++ b/src/components/form/fields/ZipCityInput.jsx @@ -26,7 +26,7 @@ export const ZipCityInput = (props) => { placeholder={placeholder} isDisabled={isDisabled} searchLocations={searchLocationByZipCity} - handleOnChange={handleZipCityChange} + handleZipCityOnChange={handleZipCityChange} /> ); }; From bdb34bf24ffb05e7638b4dada63f24c63d8ff448 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Mon, 19 Aug 2024 22:30:03 +0000 Subject: [PATCH 021/216] make on change required --- src/components/form/fields/ZipCityInput.jsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/form/fields/ZipCityInput.jsx b/src/components/form/fields/ZipCityInput.jsx index 9df98ceecaa..8f48bf2ed8f 100644 --- a/src/components/form/fields/ZipCityInput.jsx +++ b/src/components/form/fields/ZipCityInput.jsx @@ -40,7 +40,7 @@ ZipCityInput.propTypes = { hint: PropTypes.node, placeholder: PropTypes.string, isDisabled: PropTypes.bool, - handleZipCityChange: PropTypes.func, + handleZipCityChange: PropTypes.func.isRequired, }; ZipCityInput.defaultProps = { @@ -48,7 +48,6 @@ ZipCityInput.defaultProps = { hint: '', placeholder: '', isDisabled: false, - handleZipCityChange: undefined, }; export default ZipCityInput; From 15597aefbdb5ae99e502a83cb13e2900c9b9168d Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 21 Aug 2024 00:45:59 +0000 Subject: [PATCH 022/216] added zipcity for office --- pkg/gen/ghcapi/configure_mymove.go | 6 + pkg/gen/ghcapi/embedded_spec.go | 362 ++++++++++++++++++ .../addresses/get_location_by_zip_city.go | 58 +++ .../get_location_by_zip_city_parameters.go | 71 ++++ .../get_location_by_zip_city_responses.go | 162 ++++++++ .../get_location_by_zip_city_urlbuilder.go | 99 +++++ pkg/gen/ghcapi/ghcoperations/mymove_api.go | 13 + pkg/gen/ghcmessages/us_post_region_cities.go | 78 ++++ pkg/gen/ghcmessages/us_post_region_city.go | 281 ++++++++++++++ pkg/handlers/ghcapi/addresses.go | 38 ++ pkg/handlers/ghcapi/api.go | 6 + .../internal/payloads/model_to_payload.go | 27 ++ .../internal/payloads/payload_to_model.go | 14 + .../CustomerContactInfoForm.jsx | 44 ++- src/components/form/fields/ZipCityInput.jsx | 22 +- src/services/ghcApi.js | 4 + swagger-def/ghc.yaml | 30 ++ swagger/ghc.yaml | 161 ++++++++ 18 files changed, 1470 insertions(+), 6 deletions(-) create mode 100644 pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city.go create mode 100644 pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_parameters.go create mode 100644 pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_responses.go create mode 100644 pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_urlbuilder.go create mode 100644 pkg/gen/ghcmessages/us_post_region_cities.go create mode 100644 pkg/gen/ghcmessages/us_post_region_city.go create mode 100644 pkg/handlers/ghcapi/addresses.go diff --git a/pkg/gen/ghcapi/configure_mymove.go b/pkg/gen/ghcapi/configure_mymove.go index 780c3432a1d..94e72d2ce18 100644 --- a/pkg/gen/ghcapi/configure_mymove.go +++ b/pkg/gen/ghcapi/configure_mymove.go @@ -11,6 +11,7 @@ import ( "github.com/go-openapi/runtime/middleware" "github.com/transcom/mymove/pkg/gen/ghcapi/ghcoperations" + "github.com/transcom/mymove/pkg/gen/ghcapi/ghcoperations/addresses" "github.com/transcom/mymove/pkg/gen/ghcapi/ghcoperations/application_parameters" "github.com/transcom/mymove/pkg/gen/ghcapi/ghcoperations/customer" "github.com/transcom/mymove/pkg/gen/ghcapi/ghcoperations/customer_support_remarks" @@ -214,6 +215,11 @@ func configureAPI(api *ghcoperations.MymoveAPI) http.Handler { return middleware.NotImplemented("operation evaluation_reports.GetEvaluationReport has not yet been implemented") }) } + if api.AddressesGetLocationByZipCityHandler == nil { + api.AddressesGetLocationByZipCityHandler = addresses.GetLocationByZipCityHandlerFunc(func(params addresses.GetLocationByZipCityParams) middleware.Responder { + return middleware.NotImplemented("operation addresses.GetLocationByZipCity has not yet been implemented") + }) + } if api.MtoServiceItemGetMTOServiceItemHandler == nil { api.MtoServiceItemGetMTOServiceItemHandler = mto_service_item.GetMTOServiceItemHandlerFunc(func(params mto_service_item.GetMTOServiceItemParams) middleware.Responder { return middleware.NotImplemented("operation mto_service_item.GetMTOServiceItem has not yet been implemented") diff --git a/pkg/gen/ghcapi/embedded_spec.go b/pkg/gen/ghcapi/embedded_spec.go index bdbfc90f34c..0adfa8e2d0b 100644 --- a/pkg/gen/ghcapi/embedded_spec.go +++ b/pkg/gen/ghcapi/embedded_spec.go @@ -36,6 +36,44 @@ func init() { }, "basePath": "/ghc/v1", "paths": { + "/addresses/zip_city_lookup/{search}": { + "get": { + "description": "Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code.", + "tags": [ + "addresses" + ], + "summary": "Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City string", + "operationId": "getLocationByZipCity", + "parameters": [ + { + "type": "string", + "name": "search", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "the requested list of city, state, county, and postal code matches", + "schema": { + "$ref": "#/definitions/UsPostRegionCities" + } + }, + "400": { + "description": "invalid request" + }, + "403": { + "description": "not authorized" + }, + "404": { + "description": "not found" + }, + "500": { + "description": "server error" + } + } + } + }, "/application_parameters/{parameterName}": { "get": { "description": "Searches for an application parameter by name, returns nil if not found", @@ -13187,6 +13225,146 @@ func init() { } } }, + "UsPostRegionCities": { + "type": "array", + "items": { + "$ref": "#/definitions/UsPostRegionCity" + } + }, + "UsPostRegionCity": { + "description": "A postal code and city lookup", + "type": "object", + "properties": { + "city": { + "type": "string", + "title": "City", + "example": "Anytown" + }, + "county": { + "type": "string", + "title": "County", + "x-nullable": true, + "example": "LOS ANGELES" + }, + "postalCode": { + "type": "string", + "format": "zip", + "title": "ZIP", + "pattern": "^(\\d{5}([\\-]\\d{4})?)$", + "example": "90210" + }, + "state": { + "type": "string", + "title": "State", + "enum": [ + "AL", + "AK", + "AR", + "AZ", + "CA", + "CO", + "CT", + "DC", + "DE", + "FL", + "GA", + "HI", + "IA", + "ID", + "IL", + "IN", + "KS", + "KY", + "LA", + "MA", + "MD", + "ME", + "MI", + "MN", + "MO", + "MS", + "MT", + "NC", + "ND", + "NE", + "NH", + "NJ", + "NM", + "NV", + "NY", + "OH", + "OK", + "OR", + "PA", + "RI", + "SC", + "SD", + "TN", + "TX", + "UT", + "VA", + "VT", + "WA", + "WI", + "WV", + "WY" + ], + "x-display-value": { + "AK": "AK", + "AL": "AL", + "AR": "AR", + "AZ": "AZ", + "CA": "CA", + "CO": "CO", + "CT": "CT", + "DC": "DC", + "DE": "DE", + "FL": "FL", + "GA": "GA", + "HI": "HI", + "IA": "IA", + "ID": "ID", + "IL": "IL", + "IN": "IN", + "KS": "KS", + "KY": "KY", + "LA": "LA", + "MA": "MA", + "MD": "MD", + "ME": "ME", + "MI": "MI", + "MN": "MN", + "MO": "MO", + "MS": "MS", + "MT": "MT", + "NC": "NC", + "ND": "ND", + "NE": "NE", + "NH": "NH", + "NJ": "NJ", + "NM": "NM", + "NV": "NV", + "NY": "NY", + "OH": "OH", + "OK": "OK", + "OR": "OR", + "PA": "PA", + "RI": "RI", + "SC": "SC", + "SD": "SD", + "TN": "TN", + "TX": "TX", + "UT": "UT", + "VA": "VA", + "VT": "VT", + "WA": "WA", + "WI": "WI", + "WV": "WV", + "WY": "WY" + } + } + } + }, "ValidationError": { "required": [ "invalid_fields" @@ -13529,6 +13707,9 @@ func init() { { "name": "transportationOffice" }, + { + "name": "addresses" + }, { "name": "uploads" }, @@ -13556,6 +13737,44 @@ func init() { }, "basePath": "/ghc/v1", "paths": { + "/addresses/zip_city_lookup/{search}": { + "get": { + "description": "Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code.", + "tags": [ + "addresses" + ], + "summary": "Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City string", + "operationId": "getLocationByZipCity", + "parameters": [ + { + "type": "string", + "name": "search", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "the requested list of city, state, county, and postal code matches", + "schema": { + "$ref": "#/definitions/UsPostRegionCities" + } + }, + "400": { + "description": "invalid request" + }, + "403": { + "description": "not authorized" + }, + "404": { + "description": "not found" + }, + "500": { + "description": "server error" + } + } + } + }, "/application_parameters/{parameterName}": { "get": { "description": "Searches for an application parameter by name, returns nil if not found", @@ -28266,6 +28485,146 @@ func init() { } } }, + "UsPostRegionCities": { + "type": "array", + "items": { + "$ref": "#/definitions/UsPostRegionCity" + } + }, + "UsPostRegionCity": { + "description": "A postal code and city lookup", + "type": "object", + "properties": { + "city": { + "type": "string", + "title": "City", + "example": "Anytown" + }, + "county": { + "type": "string", + "title": "County", + "x-nullable": true, + "example": "LOS ANGELES" + }, + "postalCode": { + "type": "string", + "format": "zip", + "title": "ZIP", + "pattern": "^(\\d{5}([\\-]\\d{4})?)$", + "example": "90210" + }, + "state": { + "type": "string", + "title": "State", + "enum": [ + "AL", + "AK", + "AR", + "AZ", + "CA", + "CO", + "CT", + "DC", + "DE", + "FL", + "GA", + "HI", + "IA", + "ID", + "IL", + "IN", + "KS", + "KY", + "LA", + "MA", + "MD", + "ME", + "MI", + "MN", + "MO", + "MS", + "MT", + "NC", + "ND", + "NE", + "NH", + "NJ", + "NM", + "NV", + "NY", + "OH", + "OK", + "OR", + "PA", + "RI", + "SC", + "SD", + "TN", + "TX", + "UT", + "VA", + "VT", + "WA", + "WI", + "WV", + "WY" + ], + "x-display-value": { + "AK": "AK", + "AL": "AL", + "AR": "AR", + "AZ": "AZ", + "CA": "CA", + "CO": "CO", + "CT": "CT", + "DC": "DC", + "DE": "DE", + "FL": "FL", + "GA": "GA", + "HI": "HI", + "IA": "IA", + "ID": "ID", + "IL": "IL", + "IN": "IN", + "KS": "KS", + "KY": "KY", + "LA": "LA", + "MA": "MA", + "MD": "MD", + "ME": "ME", + "MI": "MI", + "MN": "MN", + "MO": "MO", + "MS": "MS", + "MT": "MT", + "NC": "NC", + "ND": "ND", + "NE": "NE", + "NH": "NH", + "NJ": "NJ", + "NM": "NM", + "NV": "NV", + "NY": "NY", + "OH": "OH", + "OK": "OK", + "OR": "OR", + "PA": "PA", + "RI": "RI", + "SC": "SC", + "SD": "SD", + "TN": "TN", + "TX": "TX", + "UT": "UT", + "VA": "VA", + "VT": "VT", + "WA": "WA", + "WI": "WI", + "WV": "WV", + "WY": "WY" + } + } + } + }, "ValidationError": { "required": [ "invalid_fields" @@ -28617,6 +28976,9 @@ func init() { { "name": "transportationOffice" }, + { + "name": "addresses" + }, { "name": "uploads" }, diff --git a/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city.go b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city.go new file mode 100644 index 00000000000..288f11ae2d1 --- /dev/null +++ b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package addresses + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLocationByZipCityHandlerFunc turns a function with the right signature into a get location by zip city handler +type GetLocationByZipCityHandlerFunc func(GetLocationByZipCityParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLocationByZipCityHandlerFunc) Handle(params GetLocationByZipCityParams) middleware.Responder { + return fn(params) +} + +// GetLocationByZipCityHandler interface for that can handle valid get location by zip city params +type GetLocationByZipCityHandler interface { + Handle(GetLocationByZipCityParams) middleware.Responder +} + +// NewGetLocationByZipCity creates a new http.Handler for the get location by zip city operation +func NewGetLocationByZipCity(ctx *middleware.Context, handler GetLocationByZipCityHandler) *GetLocationByZipCity { + return &GetLocationByZipCity{Context: ctx, Handler: handler} +} + +/* + GetLocationByZipCity swagger:route GET /addresses/zip_city_lookup/{search} addresses getLocationByZipCity + +Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City string + +Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code. +*/ +type GetLocationByZipCity struct { + Context *middleware.Context + Handler GetLocationByZipCityHandler +} + +func (o *GetLocationByZipCity) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetLocationByZipCityParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_parameters.go b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_parameters.go new file mode 100644 index 00000000000..17f92305b63 --- /dev/null +++ b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_parameters.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package addresses + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetLocationByZipCityParams creates a new GetLocationByZipCityParams object +// +// There are no default values defined in the spec. +func NewGetLocationByZipCityParams() GetLocationByZipCityParams { + + return GetLocationByZipCityParams{} +} + +// GetLocationByZipCityParams contains all the bound params for the get location by zip city operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLocationByZipCity +type GetLocationByZipCityParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + Search string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLocationByZipCityParams() beforehand. +func (o *GetLocationByZipCityParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rSearch, rhkSearch, _ := route.Params.GetOK("search") + if err := o.bindSearch(rSearch, rhkSearch, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindSearch binds and validates parameter Search from path. +func (o *GetLocationByZipCityParams) bindSearch(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Search = raw + + return nil +} diff --git a/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_responses.go b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_responses.go new file mode 100644 index 00000000000..abfd0c3b7f9 --- /dev/null +++ b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_responses.go @@ -0,0 +1,162 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package addresses + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/transcom/mymove/pkg/gen/ghcmessages" +) + +// GetLocationByZipCityOKCode is the HTTP code returned for type GetLocationByZipCityOK +const GetLocationByZipCityOKCode int = 200 + +/* +GetLocationByZipCityOK the requested list of city, state, county, and postal code matches + +swagger:response getLocationByZipCityOK +*/ +type GetLocationByZipCityOK struct { + + /* + In: Body + */ + Payload ghcmessages.UsPostRegionCities `json:"body,omitempty"` +} + +// NewGetLocationByZipCityOK creates GetLocationByZipCityOK with default headers values +func NewGetLocationByZipCityOK() *GetLocationByZipCityOK { + + return &GetLocationByZipCityOK{} +} + +// WithPayload adds the payload to the get location by zip city o k response +func (o *GetLocationByZipCityOK) WithPayload(payload ghcmessages.UsPostRegionCities) *GetLocationByZipCityOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get location by zip city o k response +func (o *GetLocationByZipCityOK) SetPayload(payload ghcmessages.UsPostRegionCities) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLocationByZipCityOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = ghcmessages.UsPostRegionCities{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetLocationByZipCityBadRequestCode is the HTTP code returned for type GetLocationByZipCityBadRequest +const GetLocationByZipCityBadRequestCode int = 400 + +/* +GetLocationByZipCityBadRequest invalid request + +swagger:response getLocationByZipCityBadRequest +*/ +type GetLocationByZipCityBadRequest struct { +} + +// NewGetLocationByZipCityBadRequest creates GetLocationByZipCityBadRequest with default headers values +func NewGetLocationByZipCityBadRequest() *GetLocationByZipCityBadRequest { + + return &GetLocationByZipCityBadRequest{} +} + +// WriteResponse to the client +func (o *GetLocationByZipCityBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(400) +} + +// GetLocationByZipCityForbiddenCode is the HTTP code returned for type GetLocationByZipCityForbidden +const GetLocationByZipCityForbiddenCode int = 403 + +/* +GetLocationByZipCityForbidden not authorized + +swagger:response getLocationByZipCityForbidden +*/ +type GetLocationByZipCityForbidden struct { +} + +// NewGetLocationByZipCityForbidden creates GetLocationByZipCityForbidden with default headers values +func NewGetLocationByZipCityForbidden() *GetLocationByZipCityForbidden { + + return &GetLocationByZipCityForbidden{} +} + +// WriteResponse to the client +func (o *GetLocationByZipCityForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(403) +} + +// GetLocationByZipCityNotFoundCode is the HTTP code returned for type GetLocationByZipCityNotFound +const GetLocationByZipCityNotFoundCode int = 404 + +/* +GetLocationByZipCityNotFound not found + +swagger:response getLocationByZipCityNotFound +*/ +type GetLocationByZipCityNotFound struct { +} + +// NewGetLocationByZipCityNotFound creates GetLocationByZipCityNotFound with default headers values +func NewGetLocationByZipCityNotFound() *GetLocationByZipCityNotFound { + + return &GetLocationByZipCityNotFound{} +} + +// WriteResponse to the client +func (o *GetLocationByZipCityNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(404) +} + +// GetLocationByZipCityInternalServerErrorCode is the HTTP code returned for type GetLocationByZipCityInternalServerError +const GetLocationByZipCityInternalServerErrorCode int = 500 + +/* +GetLocationByZipCityInternalServerError server error + +swagger:response getLocationByZipCityInternalServerError +*/ +type GetLocationByZipCityInternalServerError struct { +} + +// NewGetLocationByZipCityInternalServerError creates GetLocationByZipCityInternalServerError with default headers values +func NewGetLocationByZipCityInternalServerError() *GetLocationByZipCityInternalServerError { + + return &GetLocationByZipCityInternalServerError{} +} + +// WriteResponse to the client +func (o *GetLocationByZipCityInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(500) +} diff --git a/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_urlbuilder.go b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_urlbuilder.go new file mode 100644 index 00000000000..4a00f0c4e66 --- /dev/null +++ b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package addresses + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetLocationByZipCityURL generates an URL for the get location by zip city operation +type GetLocationByZipCityURL struct { + Search string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLocationByZipCityURL) WithBasePath(bp string) *GetLocationByZipCityURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLocationByZipCityURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLocationByZipCityURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/addresses/zip_city_lookup/{search}" + + search := o.Search + if search != "" { + _path = strings.Replace(_path, "{search}", search, -1) + } else { + return nil, errors.New("search is required on GetLocationByZipCityURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/ghc/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLocationByZipCityURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLocationByZipCityURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLocationByZipCityURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLocationByZipCityURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLocationByZipCityURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLocationByZipCityURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/ghcapi/ghcoperations/mymove_api.go b/pkg/gen/ghcapi/ghcoperations/mymove_api.go index f5368032656..48d5ee249aa 100644 --- a/pkg/gen/ghcapi/ghcoperations/mymove_api.go +++ b/pkg/gen/ghcapi/ghcoperations/mymove_api.go @@ -19,6 +19,7 @@ import ( "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" + "github.com/transcom/mymove/pkg/gen/ghcapi/ghcoperations/addresses" "github.com/transcom/mymove/pkg/gen/ghcapi/ghcoperations/application_parameters" "github.com/transcom/mymove/pkg/gen/ghcapi/ghcoperations/customer" "github.com/transcom/mymove/pkg/gen/ghcapi/ghcoperations/customer_support_remarks" @@ -155,6 +156,9 @@ func NewMymoveAPI(spec *loads.Document) *MymoveAPI { EvaluationReportsGetEvaluationReportHandler: evaluation_reports.GetEvaluationReportHandlerFunc(func(params evaluation_reports.GetEvaluationReportParams) middleware.Responder { return middleware.NotImplemented("operation evaluation_reports.GetEvaluationReport has not yet been implemented") }), + AddressesGetLocationByZipCityHandler: addresses.GetLocationByZipCityHandlerFunc(func(params addresses.GetLocationByZipCityParams) middleware.Responder { + return middleware.NotImplemented("operation addresses.GetLocationByZipCity has not yet been implemented") + }), MtoServiceItemGetMTOServiceItemHandler: mto_service_item.GetMTOServiceItemHandlerFunc(func(params mto_service_item.GetMTOServiceItemParams) middleware.Responder { return middleware.NotImplemented("operation mto_service_item.GetMTOServiceItem has not yet been implemented") }), @@ -454,6 +458,8 @@ type MymoveAPI struct { MoveTaskOrderGetEntitlementsHandler move_task_order.GetEntitlementsHandler // EvaluationReportsGetEvaluationReportHandler sets the operation handler for the get evaluation report operation EvaluationReportsGetEvaluationReportHandler evaluation_reports.GetEvaluationReportHandler + // AddressesGetLocationByZipCityHandler sets the operation handler for the get location by zip city operation + AddressesGetLocationByZipCityHandler addresses.GetLocationByZipCityHandler // MtoServiceItemGetMTOServiceItemHandler sets the operation handler for the get m t o service item operation MtoServiceItemGetMTOServiceItemHandler mto_service_item.GetMTOServiceItemHandler // MoveGetMoveHandler sets the operation handler for the get move operation @@ -754,6 +760,9 @@ func (o *MymoveAPI) Validate() error { if o.EvaluationReportsGetEvaluationReportHandler == nil { unregistered = append(unregistered, "evaluation_reports.GetEvaluationReportHandler") } + if o.AddressesGetLocationByZipCityHandler == nil { + unregistered = append(unregistered, "addresses.GetLocationByZipCityHandler") + } if o.MtoServiceItemGetMTOServiceItemHandler == nil { unregistered = append(unregistered, "mto_service_item.GetMTOServiceItemHandler") } @@ -1160,6 +1169,10 @@ func (o *MymoveAPI) initHandlerCache() { if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } + o.handlers["GET"]["/addresses/zip_city_lookup/{search}"] = addresses.NewGetLocationByZipCity(o.context, o.AddressesGetLocationByZipCityHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } o.handlers["GET"]["/move-task-orders/{moveTaskOrderID}/service-items/{mtoServiceItemID}"] = mto_service_item.NewGetMTOServiceItem(o.context, o.MtoServiceItemGetMTOServiceItemHandler) if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) diff --git a/pkg/gen/ghcmessages/us_post_region_cities.go b/pkg/gen/ghcmessages/us_post_region_cities.go new file mode 100644 index 00000000000..2256a1f3035 --- /dev/null +++ b/pkg/gen/ghcmessages/us_post_region_cities.go @@ -0,0 +1,78 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ghcmessages + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// UsPostRegionCities us post region cities +// +// swagger:model UsPostRegionCities +type UsPostRegionCities []*UsPostRegionCity + +// Validate validates this us post region cities +func (m UsPostRegionCities) Validate(formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + if swag.IsZero(m[i]) { // not required + continue + } + + if m[i] != nil { + if err := m[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// ContextValidate validate this us post region cities based on the context it is used +func (m UsPostRegionCities) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + + if m[i] != nil { + + if swag.IsZero(m[i]) { // not required + return nil + } + + if err := m[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/gen/ghcmessages/us_post_region_city.go b/pkg/gen/ghcmessages/us_post_region_city.go new file mode 100644 index 00000000000..ad9ed32d27d --- /dev/null +++ b/pkg/gen/ghcmessages/us_post_region_city.go @@ -0,0 +1,281 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ghcmessages + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// UsPostRegionCity A postal code and city lookup +// +// swagger:model UsPostRegionCity +type UsPostRegionCity struct { + + // City + // Example: Anytown + City string `json:"city,omitempty"` + + // County + // Example: LOS ANGELES + County *string `json:"county,omitempty"` + + // ZIP + // Example: 90210 + // Pattern: ^(\d{5}([\-]\d{4})?)$ + PostalCode string `json:"postalCode,omitempty"` + + // State + // Enum: [AL AK AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD TN TX UT VA VT WA WI WV WY] + State string `json:"state,omitempty"` +} + +// Validate validates this us post region city +func (m *UsPostRegionCity) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePostalCode(formats); err != nil { + res = append(res, err) + } + + if err := m.validateState(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UsPostRegionCity) validatePostalCode(formats strfmt.Registry) error { + if swag.IsZero(m.PostalCode) { // not required + return nil + } + + if err := validate.Pattern("postalCode", "body", m.PostalCode, `^(\d{5}([\-]\d{4})?)$`); err != nil { + return err + } + + return nil +} + +var usPostRegionCityTypeStatePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["AL","AK","AR","AZ","CA","CO","CT","DC","DE","FL","GA","HI","IA","ID","IL","IN","KS","KY","LA","MA","MD","ME","MI","MN","MO","MS","MT","NC","ND","NE","NH","NJ","NM","NV","NY","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VA","VT","WA","WI","WV","WY"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + usPostRegionCityTypeStatePropEnum = append(usPostRegionCityTypeStatePropEnum, v) + } +} + +const ( + + // UsPostRegionCityStateAL captures enum value "AL" + UsPostRegionCityStateAL string = "AL" + + // UsPostRegionCityStateAK captures enum value "AK" + UsPostRegionCityStateAK string = "AK" + + // UsPostRegionCityStateAR captures enum value "AR" + UsPostRegionCityStateAR string = "AR" + + // UsPostRegionCityStateAZ captures enum value "AZ" + UsPostRegionCityStateAZ string = "AZ" + + // UsPostRegionCityStateCA captures enum value "CA" + UsPostRegionCityStateCA string = "CA" + + // UsPostRegionCityStateCO captures enum value "CO" + UsPostRegionCityStateCO string = "CO" + + // UsPostRegionCityStateCT captures enum value "CT" + UsPostRegionCityStateCT string = "CT" + + // UsPostRegionCityStateDC captures enum value "DC" + UsPostRegionCityStateDC string = "DC" + + // UsPostRegionCityStateDE captures enum value "DE" + UsPostRegionCityStateDE string = "DE" + + // UsPostRegionCityStateFL captures enum value "FL" + UsPostRegionCityStateFL string = "FL" + + // UsPostRegionCityStateGA captures enum value "GA" + UsPostRegionCityStateGA string = "GA" + + // UsPostRegionCityStateHI captures enum value "HI" + UsPostRegionCityStateHI string = "HI" + + // UsPostRegionCityStateIA captures enum value "IA" + UsPostRegionCityStateIA string = "IA" + + // UsPostRegionCityStateID captures enum value "ID" + UsPostRegionCityStateID string = "ID" + + // UsPostRegionCityStateIL captures enum value "IL" + UsPostRegionCityStateIL string = "IL" + + // UsPostRegionCityStateIN captures enum value "IN" + UsPostRegionCityStateIN string = "IN" + + // UsPostRegionCityStateKS captures enum value "KS" + UsPostRegionCityStateKS string = "KS" + + // UsPostRegionCityStateKY captures enum value "KY" + UsPostRegionCityStateKY string = "KY" + + // UsPostRegionCityStateLA captures enum value "LA" + UsPostRegionCityStateLA string = "LA" + + // UsPostRegionCityStateMA captures enum value "MA" + UsPostRegionCityStateMA string = "MA" + + // UsPostRegionCityStateMD captures enum value "MD" + UsPostRegionCityStateMD string = "MD" + + // UsPostRegionCityStateME captures enum value "ME" + UsPostRegionCityStateME string = "ME" + + // UsPostRegionCityStateMI captures enum value "MI" + UsPostRegionCityStateMI string = "MI" + + // UsPostRegionCityStateMN captures enum value "MN" + UsPostRegionCityStateMN string = "MN" + + // UsPostRegionCityStateMO captures enum value "MO" + UsPostRegionCityStateMO string = "MO" + + // UsPostRegionCityStateMS captures enum value "MS" + UsPostRegionCityStateMS string = "MS" + + // UsPostRegionCityStateMT captures enum value "MT" + UsPostRegionCityStateMT string = "MT" + + // UsPostRegionCityStateNC captures enum value "NC" + UsPostRegionCityStateNC string = "NC" + + // UsPostRegionCityStateND captures enum value "ND" + UsPostRegionCityStateND string = "ND" + + // UsPostRegionCityStateNE captures enum value "NE" + UsPostRegionCityStateNE string = "NE" + + // UsPostRegionCityStateNH captures enum value "NH" + UsPostRegionCityStateNH string = "NH" + + // UsPostRegionCityStateNJ captures enum value "NJ" + UsPostRegionCityStateNJ string = "NJ" + + // UsPostRegionCityStateNM captures enum value "NM" + UsPostRegionCityStateNM string = "NM" + + // UsPostRegionCityStateNV captures enum value "NV" + UsPostRegionCityStateNV string = "NV" + + // UsPostRegionCityStateNY captures enum value "NY" + UsPostRegionCityStateNY string = "NY" + + // UsPostRegionCityStateOH captures enum value "OH" + UsPostRegionCityStateOH string = "OH" + + // UsPostRegionCityStateOK captures enum value "OK" + UsPostRegionCityStateOK string = "OK" + + // UsPostRegionCityStateOR captures enum value "OR" + UsPostRegionCityStateOR string = "OR" + + // UsPostRegionCityStatePA captures enum value "PA" + UsPostRegionCityStatePA string = "PA" + + // UsPostRegionCityStateRI captures enum value "RI" + UsPostRegionCityStateRI string = "RI" + + // UsPostRegionCityStateSC captures enum value "SC" + UsPostRegionCityStateSC string = "SC" + + // UsPostRegionCityStateSD captures enum value "SD" + UsPostRegionCityStateSD string = "SD" + + // UsPostRegionCityStateTN captures enum value "TN" + UsPostRegionCityStateTN string = "TN" + + // UsPostRegionCityStateTX captures enum value "TX" + UsPostRegionCityStateTX string = "TX" + + // UsPostRegionCityStateUT captures enum value "UT" + UsPostRegionCityStateUT string = "UT" + + // UsPostRegionCityStateVA captures enum value "VA" + UsPostRegionCityStateVA string = "VA" + + // UsPostRegionCityStateVT captures enum value "VT" + UsPostRegionCityStateVT string = "VT" + + // UsPostRegionCityStateWA captures enum value "WA" + UsPostRegionCityStateWA string = "WA" + + // UsPostRegionCityStateWI captures enum value "WI" + UsPostRegionCityStateWI string = "WI" + + // UsPostRegionCityStateWV captures enum value "WV" + UsPostRegionCityStateWV string = "WV" + + // UsPostRegionCityStateWY captures enum value "WY" + UsPostRegionCityStateWY string = "WY" +) + +// prop value enum +func (m *UsPostRegionCity) validateStateEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, usPostRegionCityTypeStatePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *UsPostRegionCity) validateState(formats strfmt.Registry) error { + if swag.IsZero(m.State) { // not required + return nil + } + + // value enum + if err := m.validateStateEnum("state", "body", m.State); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this us post region city based on context it is used +func (m *UsPostRegionCity) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *UsPostRegionCity) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UsPostRegionCity) UnmarshalBinary(b []byte) error { + var res UsPostRegionCity + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/handlers/ghcapi/addresses.go b/pkg/handlers/ghcapi/addresses.go new file mode 100644 index 00000000000..cd1c4c3d8d2 --- /dev/null +++ b/pkg/handlers/ghcapi/addresses.go @@ -0,0 +1,38 @@ +package ghcapi + +import ( + "github.com/go-openapi/runtime/middleware" + "github.com/gofrs/uuid" + "go.uber.org/zap" + + "github.com/transcom/mymove/pkg/appcontext" + "github.com/transcom/mymove/pkg/apperror" + addressop "github.com/transcom/mymove/pkg/gen/ghcapi/ghcoperations/addresses" + "github.com/transcom/mymove/pkg/handlers" + "github.com/transcom/mymove/pkg/handlers/ghcapi/internal/payloads" + "github.com/transcom/mymove/pkg/services" +) + +type GetLocationByZipCityHandler struct { + handlers.HandlerConfig + services.UsPostRegionCity +} + +func (h GetLocationByZipCityHandler) Handle(params addressop.GetLocationByZipCityParams) middleware.Responder { + return h.AuditableAppContextFromRequestWithErrors(params.HTTPRequest, + func(appCtx appcontext.AppContext) (middleware.Responder, error) { + if !appCtx.Session().IsOfficeApp() && appCtx.Session().OfficeUserID == uuid.Nil { + noOfficeUserIDErr := apperror.NewSessionError("No office user ID") + return addressop.NewGetLocationByZipCityForbidden(), noOfficeUserIDErr + } + + locationList, err := h.GetLocationsByZipCity(appCtx, params.Search) + if err != nil { + appCtx.Logger().Error("Error searching for Zip/City: ", zap.Error(err)) + return addressop.NewGetLocationByZipCityInternalServerError(), err + } + + returnPayload := payloads.UsPostRegionCities(*locationList) + return addressop.NewGetLocationByZipCityOK().WithPayload(returnPayload), nil + }) +} diff --git a/pkg/handlers/ghcapi/api.go b/pkg/handlers/ghcapi/api.go index f123495eb4d..d93a820001c 100644 --- a/pkg/handlers/ghcapi/api.go +++ b/pkg/handlers/ghcapi/api.go @@ -99,6 +99,7 @@ func NewGhcAPIHandler(handlerConfig handlers.HandlerConfig) *ghcops.MymoveAPI { transportationOfficeFetcher := transportationoffice.NewTransportationOfficesFetcher() closeoutOfficeUpdater := move.NewCloseoutOfficeUpdater(move.NewMoveFetcher(), transportationOfficeFetcher) + usPostRegionCity := address.NewUsPostRegionCity() shipmentSITStatus := sitstatus.NewShipmentSITStatus() @@ -628,6 +629,11 @@ func NewGhcAPIHandler(handlerConfig handlers.HandlerConfig) *ghcops.MymoveAPI { closeoutOfficeUpdater, } + ghcAPI.AddressesGetLocationByZipCityHandler = GetLocationByZipCityHandler{ + handlerConfig, + usPostRegionCity, + } + ghcAPI.OfficeUsersCreateRequestedOfficeUserHandler = RequestOfficeUserHandler{ handlerConfig, officerUserCreator, diff --git a/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go b/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go index fbd58138930..9775a46c165 100644 --- a/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go +++ b/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go @@ -2251,3 +2251,30 @@ func SearchCustomers(customers models.ServiceMemberSearchResults) *ghcmessages.S } return &searchCustomers } + +// UsPostRegionCity payload +func UsPostRegionCity(usPostRegionCity *models.UsPostRegionCity) *ghcmessages.UsPostRegionCity { + if usPostRegionCity == nil { + return nil + } + if *usPostRegionCity == (models.UsPostRegionCity{}) { + return nil + } + + return &ghcmessages.UsPostRegionCity{ + City: usPostRegionCity.USPostRegionCityNm, + State: usPostRegionCity.State, + PostalCode: usPostRegionCity.UsprZipID, + County: &usPostRegionCity.UsprcCountyNm, + } +} + +// UsPostRegionCities payload +func UsPostRegionCities(usPostRegionCities models.UsPostRegionCities) ghcmessages.UsPostRegionCities { + payload := make(ghcmessages.UsPostRegionCities, len(usPostRegionCities)) + for i, usPostRegionCity := range usPostRegionCities { + copyOfUsPostRegionCity := usPostRegionCity + payload[i] = UsPostRegionCity(©OfUsPostRegionCity) + } + return payload +} diff --git a/pkg/handlers/ghcapi/internal/payloads/payload_to_model.go b/pkg/handlers/ghcapi/internal/payloads/payload_to_model.go index 2e50c7724f4..f9a90828129 100644 --- a/pkg/handlers/ghcapi/internal/payloads/payload_to_model.go +++ b/pkg/handlers/ghcapi/internal/payloads/payload_to_model.go @@ -718,3 +718,17 @@ func EvaluationReportFromUpdate(evaluationReport *ghcmessages.EvaluationReport) } return &model, nil } + +// UsPostRegionCityModel model +func UsPostRegionCityModel(usPostRegionCity *ghcmessages.UsPostRegionCity) *models.UsPostRegionCity { + if usPostRegionCity == nil { + return nil + } + + return &models.UsPostRegionCity{ + USPostRegionCityNm: usPostRegionCity.City, + State: usPostRegionCity.State, + UsprZipID: usPostRegionCity.PostalCode, + UsprcCountyNm: *usPostRegionCity.County, + } +} diff --git a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx index f54dbcc2e7b..6fe6115bd4f 100644 --- a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx +++ b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx @@ -46,7 +46,37 @@ const CustomerContactInfoForm = ({ initialValues, onSubmit, onBack }) => {
- {({ isValid, handleSubmit }) => { + {({ isValid, handleSubmit, values, setValues }) => { + const handleCurrentZipCityChange = (value) => { + setValues( + { + ...values, + customerAddress: { + ...values.customerAddress, + city: value.city, + state: value.state ? value.state : '', + county: value.county, + postalCode: value.postalCode, + }, + }, + { shouldValidate: true }, + ); + }; + const handleBackupZipCityChange = (value) => { + setValues( + { + ...values, + backupAddress: { + ...values.backupAddress, + city: value.city, + state: value.state ? value.state : '', + county: value.county, + postalCode: value.postalCode, + }, + }, + { shouldValidate: true }, + ); + }; return ( @@ -65,9 +95,17 @@ const CustomerContactInfoForm = ({ initialValues, onSubmit, onBack }) => { )} />

Current Address

- +

Backup Address

- +

Backup contact

diff --git a/src/components/form/fields/ZipCityInput.jsx b/src/components/form/fields/ZipCityInput.jsx index 0d2eecd14db..a64d20f7663 100644 --- a/src/components/form/fields/ZipCityInput.jsx +++ b/src/components/form/fields/ZipCityInput.jsx @@ -1,13 +1,17 @@ import { useField } from 'formik'; import React from 'react'; +import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import './DropdownInput.module.scss'; import LocationSearchBox from 'components/LocationSearchBox/LocationSearchBox'; import { searchLocationByZipCity } from 'services/internalApi'; +import { searchLocationByZipCity as ghcSearchLocationByZipCity } from 'services/ghcApi'; +import { selectLoggedInUser } from 'store/entities/selectors'; +import { OfficeUserInfoShape } from 'types/index'; export const ZipCityInput = (props) => { - const { label, name, displayAddress, hint, placeholder, isDisabled, handleZipCityChange } = props; + const { label, name, displayAddress, hint, placeholder, isDisabled, handleZipCityChange, officeUser } = props; const [field, meta, helpers] = useField(props); const errorString = meta.value?.name ? meta.error?.name || meta.error : ''; @@ -25,7 +29,7 @@ export const ZipCityInput = (props) => { hint={hint} placeholder={placeholder} isDisabled={isDisabled} - searchLocations={searchLocationByZipCity} + searchLocations={officeUser?.id ? ghcSearchLocationByZipCity : searchLocationByZipCity} handleOnChange={handleZipCityChange} /> ); @@ -41,6 +45,7 @@ ZipCityInput.propTypes = { placeholder: PropTypes.string, isDisabled: PropTypes.bool, handleZipCityChange: PropTypes.func, + officeUser: OfficeUserInfoShape, }; ZipCityInput.defaultProps = { @@ -49,6 +54,17 @@ ZipCityInput.defaultProps = { placeholder: '', isDisabled: false, handleZipCityChange: undefined, + officeUser: {}, }; -export default ZipCityInput; +const mapStateToProps = (state) => { + const user = selectLoggedInUser(state); + + return { + officeUser: user?.office_user || {}, + }; +}; + +const mapDispatchToProps = {}; + +export default connect(mapStateToProps, mapDispatchToProps)(ZipCityInput); diff --git a/src/services/ghcApi.js b/src/services/ghcApi.js index 034206adc75..f7819a14135 100644 --- a/src/services/ghcApi.js +++ b/src/services/ghcApi.js @@ -842,3 +842,7 @@ export async function patchPPMSIT({ ppmShipmentId, payload, eTag }) { }, ); } + +export async function searchLocationByZipCity(search) { + return makeGHCRequest('addresses.getLocationByZipCity', { search }, { normalize: false }); +} diff --git a/swagger-def/ghc.yaml b/swagger-def/ghc.yaml index 965b04f6aa3..17041012964 100644 --- a/swagger-def/ghc.yaml +++ b/swagger-def/ghc.yaml @@ -26,6 +26,7 @@ tags: - name: ppm - name: tac - name: transportationOffice + - name: addresses - name: uploads - name: paymentRequests paths: @@ -3838,6 +3839,31 @@ paths: $ref: '#/responses/NotFound' '500': $ref: '#/responses/ServerError' + /addresses/zip_city_lookup/{search}: + get: + summary: Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City string + description: Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code. + operationId: getLocationByZipCity + tags: + - addresses + parameters: + - in: path + name: search + type: string + required: true + responses: + "200": + description: the requested list of city, state, county, and postal code matches + schema: + $ref: "#/definitions/UsPostRegionCities" + "400": + description: invalid request + "403": + description: not authorized + "404": + description: not found + "500": + description: server error /uploads: post: summary: Create a new upload @@ -6889,6 +6915,10 @@ definitions: type: array items: $ref: 'definitions/TransportationOffice.yaml' + UsPostRegionCities: + type: array + items: + $ref: "definitions/UsPostRegionCity.yaml" GBLOCs: type: array items: diff --git a/swagger/ghc.yaml b/swagger/ghc.yaml index 8aba9933867..f47a2f33415 100644 --- a/swagger/ghc.yaml +++ b/swagger/ghc.yaml @@ -38,6 +38,7 @@ tags: - name: ppm - name: tac - name: transportationOffice + - name: addresses - name: uploads - name: paymentRequests paths: @@ -4020,6 +4021,36 @@ paths: $ref: '#/responses/NotFound' '500': $ref: '#/responses/ServerError' + /addresses/zip_city_lookup/{search}: + get: + summary: >- + Returns City, State, Postal Code, and County associated with the + specified full/partial Postal Code or City string + description: >- + Find by API using full/partial Postal Code or City name that returns an + us_post_region_cities json object containing city, state, county and + postal code. + operationId: getLocationByZipCity + tags: + - addresses + parameters: + - in: path + name: search + type: string + required: true + responses: + '200': + description: the requested list of city, state, county, and postal code matches + schema: + $ref: '#/definitions/UsPostRegionCities' + '400': + description: invalid request + '403': + description: not authorized + '404': + description: not found + '500': + description: server error /uploads: post: summary: Create a new upload @@ -7168,6 +7199,10 @@ definitions: type: array items: $ref: '#/definitions/TransportationOffice' + UsPostRegionCities: + type: array + items: + $ref: '#/definitions/UsPostRegionCity' GBLOCs: type: array items: @@ -10282,6 +10317,132 @@ definitions: validHhgProgramCodeForLoa: type: boolean x-nullable: true + UsPostRegionCity: + description: A postal code and city lookup + type: object + properties: + city: + type: string + example: Anytown + title: City + state: + title: State + type: string + x-display-value: + AL: AL + AK: AK + AR: AR + AZ: AZ + CA: CA + CO: CO + CT: CT + DC: DC + DE: DE + FL: FL + GA: GA + HI: HI + IA: IA + ID: ID + IL: IL + IN: IN + KS: KS + KY: KY + LA: LA + MA: MA + MD: MD + ME: ME + MI: MI + MN: MN + MO: MO + MS: MS + MT: MT + NC: NC + ND: ND + NE: NE + NH: NH + NJ: NJ + NM: NM + NV: NV + NY: NY + OH: OH + OK: OK + OR: OR + PA: PA + RI: RI + SC: SC + SD: SD + TN: TN + TX: TX + UT: UT + VA: VA + VT: VT + WA: WA + WI: WI + WV: WV + WY: WY + enum: + - AL + - AK + - AR + - AZ + - CA + - CO + - CT + - DC + - DE + - FL + - GA + - HI + - IA + - ID + - IL + - IN + - KS + - KY + - LA + - MA + - MD + - ME + - MI + - MN + - MO + - MS + - MT + - NC + - ND + - NE + - NH + - NJ + - NM + - NV + - NY + - OH + - OK + - OR + - PA + - RI + - SC + - SD + - TN + - TX + - UT + - VA + - VT + - WA + - WI + - WV + - WY + postalCode: + type: string + format: zip + title: ZIP + example: '90210' + pattern: ^(\d{5}([\-]\d{4})?)$ + county: + type: string + title: County + x-nullable: true + example: LOS ANGELES responses: InvalidRequest: description: The request payload is invalid From 3c20c914cc9eba8eedf8021f7e23ad2a64076800 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 21 Aug 2024 17:20:56 +0000 Subject: [PATCH 023/216] don't display undefined in results --- pkg/services/address/address_lookup.go | 2 +- src/components/LocationSearchBox/LocationSearchBox.jsx | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/services/address/address_lookup.go b/pkg/services/address/address_lookup.go index b6a8b08ff42..57fb6c60fd6 100644 --- a/pkg/services/address/address_lookup.go +++ b/pkg/services/address/address_lookup.go @@ -41,7 +41,7 @@ func FindLocationsByZipCity(appCtx appcontext.AppContext, search string) (models select uprc.u_s_post_region_city_nm, uprc.state, uprc.usprc_county_nm, uprc.uspr_zip_id from us_post_region_cities uprc where position(upper($1) in uprc.uspr_zip_id) > 0 or position(upper($1) in uprc.u_s_post_region_city_nm) > 0 - limit 20` + limit 30` query := appCtx.DB().Q().RawQuery(sqlQuery, &search) if err := query.All(&locationList); err != nil { if errors.Cause(err).Error() != models.RecordNotFoundErrorString { diff --git a/src/components/LocationSearchBox/LocationSearchBox.jsx b/src/components/LocationSearchBox/LocationSearchBox.jsx index 6d65fae0cc5..65713946d53 100644 --- a/src/components/LocationSearchBox/LocationSearchBox.jsx +++ b/src/components/LocationSearchBox/LocationSearchBox.jsx @@ -38,7 +38,9 @@ const formatOptionLabel = (option, input) => { const formatZipCity = (option, input) => { const { inputValue } = input; - const outputLabel = `${option.city}, ${option.state} ${option.postalCode} (${option.county})`; + const outputLabel = `${option?.city || ''}, ${option?.state || ''} ${option?.postalCode || ''} (${ + option?.county || '' + })`; const inputText = inputValue || ''; const searchIndex = outputLabel.toLowerCase().indexOf(inputText.toLowerCase()); From 286b8141b9d4c83d9e5c9a85285eb5ca914948ef Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Thu, 22 Aug 2024 00:43:59 +0000 Subject: [PATCH 024/216] match at beginning --- pkg/services/address/address_lookup.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/services/address/address_lookup.go b/pkg/services/address/address_lookup.go index 57fb6c60fd6..69d1f8781ff 100644 --- a/pkg/services/address/address_lookup.go +++ b/pkg/services/address/address_lookup.go @@ -2,6 +2,7 @@ package address import ( "database/sql" + "fmt" "github.com/gofrs/uuid" "github.com/pkg/errors" @@ -36,13 +37,11 @@ func (o usPostRegionCity) GetLocationsByZipCity(appCtx appcontext.AppContext, se func FindLocationsByZipCity(appCtx appcontext.AppContext, search string) (models.UsPostRegionCities, error) { var locationList []models.UsPostRegionCity - - sqlQuery := ` + sqlQuery := fmt.Sprintf(` select uprc.u_s_post_region_city_nm, uprc.state, uprc.usprc_county_nm, uprc.uspr_zip_id - from us_post_region_cities uprc where position(upper($1) in uprc.uspr_zip_id) > 0 or - position(upper($1) in uprc.u_s_post_region_city_nm) > 0 - limit 30` - query := appCtx.DB().Q().RawQuery(sqlQuery, &search) + from us_post_region_cities uprc where uprc.uspr_zip_id like '%[1]s%%' or + uprc.u_s_post_region_city_nm like upper('%[1]s%%') limit 30`, search) + query := appCtx.DB().Q().RawQuery(sqlQuery) if err := query.All(&locationList); err != nil { if errors.Cause(err).Error() != models.RecordNotFoundErrorString { return locationList, err From 23b61bca292ff909f5b881d0df1815419988f46b Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Thu, 22 Aug 2024 01:52:42 +0000 Subject: [PATCH 025/216] updating props --- src/components/form/AddressFields/AddressFields.jsx | 1 - src/components/form/fields/ZipCityInput.jsx | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index 2f5eb9a62fc..e0770495a5f 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -121,7 +121,6 @@ export const AddressFields = ({ name="zipCity" placeholder="Start typing a Zip Code or City..." label="Zip/City Lookup" - displayAddress={false} handleZipCityChange={handleZipCityChange} />

diff --git a/src/components/form/fields/ZipCityInput.jsx b/src/components/form/fields/ZipCityInput.jsx index 86edd913a1f..c27d92b6f19 100644 --- a/src/components/form/fields/ZipCityInput.jsx +++ b/src/components/form/fields/ZipCityInput.jsx @@ -49,7 +49,7 @@ ZipCityInput.propTypes = { }; ZipCityInput.defaultProps = { - displayAddress: true, + displayAddress: false, hint: '', placeholder: '', isDisabled: false, From 7e8cb9d1373fcad6d22a2936b8c4dad9d05da9b5 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Thu, 22 Aug 2024 01:55:21 +0000 Subject: [PATCH 026/216] fix handler name --- src/components/form/fields/ZipCityInput.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/form/fields/ZipCityInput.jsx b/src/components/form/fields/ZipCityInput.jsx index c27d92b6f19..d1b3873f344 100644 --- a/src/components/form/fields/ZipCityInput.jsx +++ b/src/components/form/fields/ZipCityInput.jsx @@ -30,7 +30,7 @@ export const ZipCityInput = (props) => { placeholder={placeholder} isDisabled={isDisabled} searchLocations={officeUser?.id ? ghcSearchLocationByZipCity : searchLocationByZipCity} - handleOnChange={handleZipCityChange} + handleZipCityOnChange={handleZipCityChange} /> ); }; From d23db6bcc4a134e06c2c409e8103f809be020f76 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Thu, 22 Aug 2024 15:21:54 +0000 Subject: [PATCH 027/216] adding zip/city to other addresses --- .../CustomerContactInfoForm.jsx | 6 +- .../Office/ShipmentForm/ShipmentForm.jsx | 284 ++++++++++++++++-- 2 files changed, 262 insertions(+), 28 deletions(-) diff --git a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx index 6fe6115bd4f..7e6e15f3aee 100644 --- a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx +++ b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx @@ -68,10 +68,10 @@ const CustomerContactInfoForm = ({ initialValues, onSubmit, onBack }) => { ...values, backupAddress: { ...values.backupAddress, - city: value.city, + city: value.city ? value.city : '', state: value.state ? value.state : '', - county: value.county, - postalCode: value.postalCode, + county: value.county ? value.county : '', + postalCode: value.postalCode ? value.postalCode : '', }, }, { shouldValidate: true }, diff --git a/src/components/Office/ShipmentForm/ShipmentForm.jsx b/src/components/Office/ShipmentForm/ShipmentForm.jsx index 23ee524d471..f77cad6bf67 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.jsx @@ -545,30 +545,208 @@ const ShipmentForm = (props) => { const { checked } = e.target; if (checked) { // use current residence - setValues({ - ...values, - pickup: { - ...values.pickup, - address: currentResidence, + setValues( + { + ...values, + pickup: { + ...values.pickup, + address: currentResidence, + }, }, - }); + { shouldValidate: true }, + ); } else { // Revert address - setValues({ + setValues( + { + ...values, + pickup: { + ...values.pickup, + address: { + streetAddress1: '', + streetAddress2: '', + streetAddress3: '', + city: '', + state: '', + postalCode: '', + county: '', + }, + }, + }, + { shouldValidate: true }, + ); + } + }; + + const handlePickupZipCityChange = (value) => { + setValues( + { ...values, pickup: { ...values.pickup, address: { - streetAddress1: '', - streetAddress2: '', - streetAddress3: '', - city: '', - state: '', - postalCode: '', + ...values.pickup.address, + city: value.city ? value.city : '', + state: value.state ? value.state : '', + county: value.county ? value.county : '', + postalCode: value.postalCode ? value.postalCode : '', }, }, - }); - } + }, + { shouldValidate: true }, + ); + }; + + const handleSecondaryPickupZipCityChange = (value) => { + setValues( + { + ...values, + secondaryPickup: { + ...values.secondaryPickup, + address: { + ...values.secondaryPickup.address, + city: value.city ? value.city : '', + state: value.state ? value.state : '', + county: value.county ? value.county : '', + postalCode: value.postalCode ? value.postalCode : '', + }, + }, + }, + { shouldValidate: true }, + ); + }; + + const handleTertiaryPickupZipCityChange = (value) => { + setValues( + { + ...values, + tertiaryPickup: { + ...values.tertiaryPickup, + address: { + ...values.tertiaryPickup.address, + city: value.city ? value.city : '', + state: value.state ? value.state : '', + county: value.county ? value.county : '', + postalCode: value.postalCode ? value.postalCode : '', + }, + }, + }, + { shouldValidate: true }, + ); + }; + + const handleDeliveryZipCityChange = (value) => { + setValues( + { + ...values, + delivery: { + ...values.delivery, + address: { + ...values.delivery.address, + city: value.city ? value.city : '', + state: value.state ? value.state : '', + county: value.county ? value.county : '', + postalCode: value.postalCode ? value.postalCode : '', + }, + }, + }, + { shouldValidate: true }, + ); + }; + + const handleSecondaryDeliveryZipCityChange = (value) => { + setValues( + { + ...values, + secondaryDelivery: { + ...values.secondaryDelivery, + address: { + ...values.secondaryDelivery.address, + city: value.city ? value.city : '', + state: value.state ? value.state : '', + county: value.county ? value.county : '', + postalCode: value.postalCode ? value.postalCode : '', + }, + }, + }, + { shouldValidate: true }, + ); + }; + + const handleTertiaryDeliveryZipCityChange = (value) => { + setValues( + { + ...values, + tertiaryDelivery: { + ...values.tertiaryDelivery, + address: { + ...values.tertiaryDelivery.address, + city: value.city ? value.city : '', + state: value.state ? value.state : '', + county: value.county ? value.county : '', + postalCode: value.postalCode ? value.postalCode : '', + }, + }, + }, + { shouldValidate: true }, + ); + }; + + const handleDestinationZipCityChange = (value) => { + setValues( + { + ...values, + destination: { + ...values.destination, + address: { + ...values.destination.address, + city: value.city ? value.city : '', + state: value.state ? value.state : '', + county: value.county ? value.county : '', + postalCode: value.postalCode ? value.postalCode : '', + }, + }, + }, + { shouldValidate: true }, + ); + }; + + const handleSecondaryDestinationZipCityChange = (value) => { + setValues( + { + ...values, + secondaryDestination: { + ...values.secondaryDestination, + address: { + ...values.secondaryDestination.address, + city: value.city ? value.city : '', + state: value.state ? value.state : '', + county: value.county ? value.county : '', + postalCode: value.postalCode ? value.postalCode : '', + }, + }, + }, + { shouldValidate: true }, + ); + }; + + const handleTertiaryDestinationZipCityChange = (value) => { + setValues( + { + ...values, + tertiaryDestination: { + ...values.tertiaryDestination, + address: { + ...values.tertiaryDestination.address, + city: value.city ? value.city : '', + state: value.state ? value.state : '', + county: value.county ? value.county : '', + postalCode: value.postalCode ? value.postalCode : '', + }, + }, + }, + { shouldValidate: true }, + ); }; return ( @@ -677,6 +855,8 @@ const ShipmentForm = (props) => { ( <>

What address are the movers picking up from?

@@ -716,7 +896,11 @@ const ShipmentForm = (props) => { {hasSecondaryPickup === 'yes' && ( <> - + {isTertiaryAddressEnabled && ( <>

Third pickup location

@@ -745,7 +929,13 @@ const ShipmentForm = (props) => { />
- {hasTertiaryPickup === 'yes' && } + {hasTertiaryPickup === 'yes' && ( + + )} )} @@ -816,6 +1006,8 @@ const ShipmentForm = (props) => { > { return fields; }} @@ -848,7 +1040,11 @@ const ShipmentForm = (props) => { {hasSecondaryDelivery === 'yes' && ( <> - + {isTertiaryAddressEnabled && ( <>

Third delivery location

@@ -877,7 +1073,13 @@ const ShipmentForm = (props) => { />
- {hasTertiaryDelivery === 'yes' && } + {hasTertiaryDelivery === 'yes' && ( + + )} )} @@ -945,6 +1147,8 @@ const ShipmentForm = (props) => { {hasDeliveryAddress === 'yes' ? ( ( <> {fields} @@ -984,7 +1188,11 @@ const ShipmentForm = (props) => { {hasSecondaryDelivery === 'yes' && ( <> - + {isTertiaryAddressEnabled && ( <>

Third delivery location

@@ -1016,7 +1224,11 @@ const ShipmentForm = (props) => {
{hasTertiaryDelivery === 'yes' && ( - + )} )} @@ -1074,6 +1286,8 @@ const ShipmentForm = (props) => { ( <>

What address are the movers picking up from?

@@ -1116,7 +1330,11 @@ const ShipmentForm = (props) => { {hasSecondaryPickup === 'true' && ( <> - + {isTertiaryAddressEnabled && ( <>

Third pickup location

@@ -1148,7 +1366,13 @@ const ShipmentForm = (props) => { />
- {hasTertiaryPickup === 'true' && } + {hasTertiaryPickup === 'true' && ( + + )} )} @@ -1159,6 +1383,8 @@ const ShipmentForm = (props) => { ( <> {fields} @@ -1193,7 +1419,11 @@ const ShipmentForm = (props) => { {hasSecondaryDestination === 'true' && ( <> - + {isTertiaryAddressEnabled && ( <>

Third destination address

@@ -1226,7 +1456,11 @@ const ShipmentForm = (props) => {
{hasTertiaryDestination === 'true' && ( - + )} )} From 4bd5ad2e3877f107c659a1f98bfde84368f6c9ab Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Thu, 22 Aug 2024 19:08:04 +0000 Subject: [PATCH 028/216] add error message for lookup --- .../ResidentialAddressForm.jsx | 16 ++++++++++++---- .../form/AddressFields/AddressFields.jsx | 19 +++++++++++++++---- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx index 200ba55bdbc..be3920ac460 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import { React, useState } from 'react'; import PropTypes from 'prop-types'; import { Formik } from 'formik'; import classnames from 'classnames'; @@ -18,6 +18,7 @@ const ResidentialAddressForm = ({ formFieldsName, initialValues, onSubmit, onBac const validationSchema = Yup.object().shape({ [formFieldsName]: requiredAddressSchema.required(), }); + const [isLookupErrorVisible, setIsLookupErrorVisible] = useState(false); return ( diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index 2f5eb9a62fc..2242849d066 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -1,7 +1,7 @@ import React, { useRef } from 'react'; import PropTypes from 'prop-types'; import { v4 as uuidv4 } from 'uuid'; -import { Fieldset } from '@trussworks/react-uswds'; +import { Fieldset, Alert } from '@trussworks/react-uswds'; import { statesList } from '../../../constants/states'; @@ -29,6 +29,7 @@ export const AddressFields = ({ render, validators, zipCityEnabled, + zipCityError, handleZipCityChange, formikFunctionsToValidatePostalCodeOnChange, }) => { @@ -124,9 +125,17 @@ export const AddressFields = ({ displayAddress={false} handleZipCityChange={handleZipCityChange} /> -

- If you encounter any inaccurate lookup information please contact the Help Desk for further assistance. -

+ {!zipCityError && ( + + If you encounter any inaccurate lookup information please contact the Help Desk for further + assistance. + + )} + {zipCityError && ( + + Not all data was able to populate successfully. Contact the Help Desk for further assistance. + + )} )}
@@ -165,6 +174,7 @@ AddressFields.propTypes = { name: PropTypes.string.isRequired, render: PropTypes.func, zipCityEnabled: PropTypes.bool, + zipCityError: PropTypes.bool, handleZipCityChange: PropTypes.func, validators: PropTypes.shape({ streetAddress1: PropTypes.func, @@ -185,6 +195,7 @@ AddressFields.defaultProps = { className: '', render: (fields) => fields, zipCityEnabled: false, + zipCityError: false, handleZipCityChange: null, validators: {}, formikFunctionsToValidatePostalCodeOnChange: null, From 07bd12d37aa1b4f172bb9558df44638d42eec0d3 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Thu, 22 Aug 2024 19:10:57 +0000 Subject: [PATCH 029/216] adding error to backup address --- .../BackupAddressForm/BackupAddressForm.jsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx b/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx index 44c828bc15e..f6593c3466b 100644 --- a/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx +++ b/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import { React, useState } from 'react'; import PropTypes from 'prop-types'; import { Formik } from 'formik'; import * as Yup from 'yup'; @@ -15,6 +15,7 @@ const BackupAddressForm = ({ formFieldsName, initialValues, onSubmit, onBack }) const validationSchema = Yup.object().shape({ [formFieldsName]: requiredAddressSchema.required(), }); + const [isLookupErrorVisible, setIsLookupErrorVisible] = useState(false); return ( - +
From e263fc2b0ecb4571e9e54afefd99ed3758833037 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Thu, 22 Aug 2024 16:02:40 -0500 Subject: [PATCH 030/216] add hyperlink for help desk --- src/components/form/AddressFields/AddressFields.jsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index 2242849d066..4bc6086c309 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -127,13 +127,16 @@ export const AddressFields = ({ /> {!zipCityError && ( - If you encounter any inaccurate lookup information please contact the Help Desk for further - assistance. + If you encounter any inaccurate lookup information please contact the + Help Desk + for further assistance. )} {zipCityError && ( - Not all data was able to populate successfully. Contact the Help Desk for further assistance. + Not all data was able to populate successfully. Contact the + Help Desk + for further assistance. )} From c05fa8d8d9f0ea1a9cb8523cfde71adffa80624a Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 23 Aug 2024 02:46:53 +0000 Subject: [PATCH 031/216] add zip city to edit shipment and update tests --- .../BackupAddressForm.test.jsx | 31 ++++++++-- .../ResidentialAddressForm.test.jsx | 30 ++++++++-- .../CustomerContactInfoForm.jsx | 12 +--- .../CustomerContactInfoForm.test.jsx | 38 +++++++++++- .../Office/ShipmentForm/ShipmentForm.jsx | 15 ----- .../Office/ShipmentForm/ShipmentForm.test.jsx | 17 ++++++ .../form/AddressFields/AddressFields.jsx | 8 +-- .../MyMove/Profile/BackupAddress.test.jsx | 59 ++++++++++++++++--- .../Profile/ResidentialAddress.test.jsx | 30 ++++++++-- 9 files changed, 188 insertions(+), 52 deletions(-) diff --git a/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx b/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx index 7f11de937ef..2c9763efc44 100644 --- a/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx +++ b/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx @@ -1,8 +1,10 @@ import React from 'react'; import { render, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; +import { Provider } from 'react-redux'; import BackupAddressForm from './BackupAddressForm'; +import { configureStore } from 'shared/store'; describe('BackupAddressForm component', () => { const formFieldsName = 'backup_mailing_residence'; @@ -48,7 +50,13 @@ describe('BackupAddressForm component', () => { }; it('renders the form inputs', async () => { - const { getByLabelText } = render(); + const mockStore = configureStore({}); + + const { getByLabelText } = render( + + + + ); await waitFor(() => { expect(getByLabelText('Address 1')).toBeInstanceOf(HTMLInputElement); @@ -64,7 +72,12 @@ describe('BackupAddressForm component', () => { }); it('shows an error message if trying to submit an invalid form', async () => { - const { getByRole, findAllByRole, getByLabelText } = render(); + const mockStore = configureStore({}); + const { getByRole, findAllByRole, getByLabelText } = render( + + + + ); await userEvent.click(getByLabelText('Address 1')); await userEvent.click(getByLabelText(/Address 2/)); @@ -82,7 +95,12 @@ describe('BackupAddressForm component', () => { }); it('submits the form when its valid', async () => { - const { getByRole, getByLabelText } = render(); + const mockStore = configureStore({}); + const { getByRole, getByLabelText } = render( + + + + ); const submitBtn = getByRole('button', { name: 'Next' }); await userEvent.type(getByLabelText('Address 1'), fakeAddress.streetAddress1); @@ -104,7 +122,12 @@ describe('BackupAddressForm component', () => { }); it('implements the onBack handler when the Back button is clicked', async () => { - const { getByRole } = render(); + const mockStore = configureStore({}); + const { getByRole } = render( + + + + ); const backBtn = getByRole('button', { name: 'Back' }); await userEvent.click(backBtn); diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx index 15c3e22b49b..2a882163010 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx @@ -1,8 +1,10 @@ import React from 'react'; import { render, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; +import { Provider } from 'react-redux'; import ResidentialAddressForm from './ResidentialAddressForm'; +import { configureStore } from 'shared/store'; describe('ResidentialAddressForm component', () => { const formFieldsName = 'current_residence'; @@ -48,7 +50,12 @@ describe('ResidentialAddressForm component', () => { }; it('renders the form inputs and help text', async () => { - const { getByLabelText, getByText } = render(); + const mockStore = configureStore({}); + const { getByLabelText, getByText } = render( + + + + ); await waitFor(() => { expect(getByLabelText('Address 1')).toBeInstanceOf(HTMLInputElement); @@ -66,7 +73,12 @@ describe('ResidentialAddressForm component', () => { }); it('shows an error message if trying to submit an invalid form', async () => { - const { getByRole, findAllByRole, getByLabelText } = render(); + const mockStore = configureStore({}); + const { getByRole, findAllByRole, getByLabelText } = render( + + + + ); await userEvent.click(getByLabelText('Address 1')); await userEvent.click(getByLabelText(/Address 2/)); @@ -85,7 +97,12 @@ describe('ResidentialAddressForm component', () => { }); it('submits the form when its valid', async () => { - const { getByRole, getByLabelText } = render(); + const mockStore = configureStore({}); + const { getByRole, getByLabelText } = render( + + + + ); const submitBtn = getByRole('button', { name: 'Next' }); await userEvent.type(getByLabelText('Address 1'), fakeAddress.streetAddress1); @@ -107,7 +124,12 @@ describe('ResidentialAddressForm component', () => { }); it('implements the onBack handler when the Back button is clicked', async () => { - const { getByRole } = render(); + const mockStore = configureStore({}); + const { getByRole } = render( + + + + ); const backBtn = getByRole('button', { name: 'Back' }); await userEvent.click(backBtn); diff --git a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx index 7e6e15f3aee..ee50c953a05 100644 --- a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx +++ b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx @@ -95,17 +95,9 @@ const CustomerContactInfoForm = ({ initialValues, onSubmit, onBack }) => { )} />

Current Address

- +

Backup Address

- +

Backup contact

diff --git a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.test.jsx b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.test.jsx index 99566b44b8e..521ad141be7 100644 --- a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.test.jsx +++ b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.test.jsx @@ -1,10 +1,27 @@ import React from 'react'; import { render, waitFor, screen } from '@testing-library/react'; -// import userEvent from '@testing-library/user-event'; +import { Provider } from 'react-redux'; import CustomerContactInfoForm from './CustomerContactInfoForm'; +import { roleTypes } from 'constants/userRoles'; +import { configureStore } from 'shared/store'; describe('CustomerContactInfoForm Component', () => { + const loggedInTOOState = { + auth: { + activeRole: roleTypes.TOO, + isLoading: false, + isLoggedIn: true, + }, + entities: { + user: { + userId234: { + id: 'userId234', + roles: [{ roleType: roleTypes.TIO }], + }, + }, + }, + }; const initialValues = { firstName: '', middleName: '', @@ -43,6 +60,7 @@ describe('CustomerContactInfoForm Component', () => { city: 'Missoula', state: 'MT', postalCode: '59802', + county: 'MISSOULA', }, name: 'joe bob', telephone: '855-222-1111', @@ -56,7 +74,14 @@ describe('CustomerContactInfoForm Component', () => { }; it('renders the form inputs', async () => { - render(); + const mockStore = configureStore({ + ...loggedInTOOState + }); + render( + + + + ); await waitFor(() => { expect(screen.getByText('Contact info')).toBeInstanceOf(HTMLHeadingElement); @@ -105,7 +130,14 @@ describe('CustomerContactInfoForm Component', () => { }); it('does not allow submission without cac_validated value', async () => { - render(); + const mockStore = configureStore({ + ...loggedInTOOState + }); + render( + + + + ); await waitFor(() => { expect(screen.getByText('CAC Validation')).toBeInstanceOf(HTMLHeadingElement); diff --git a/src/components/Office/ShipmentForm/ShipmentForm.jsx b/src/components/Office/ShipmentForm/ShipmentForm.jsx index f77cad6bf67..0c28740eca5 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.jsx @@ -855,7 +855,6 @@ const ShipmentForm = (props) => { ( <> @@ -898,7 +897,6 @@ const ShipmentForm = (props) => { <> {isTertiaryAddressEnabled && ( @@ -932,7 +930,6 @@ const ShipmentForm = (props) => { {hasTertiaryPickup === 'yes' && ( )} @@ -1006,7 +1003,6 @@ const ShipmentForm = (props) => { > { return fields; @@ -1042,7 +1038,6 @@ const ShipmentForm = (props) => { <> {isTertiaryAddressEnabled && ( @@ -1076,7 +1071,6 @@ const ShipmentForm = (props) => { {hasTertiaryDelivery === 'yes' && ( )} @@ -1147,7 +1141,6 @@ const ShipmentForm = (props) => { {hasDeliveryAddress === 'yes' ? ( ( <> @@ -1190,7 +1183,6 @@ const ShipmentForm = (props) => { <> {isTertiaryAddressEnabled && ( @@ -1226,7 +1218,6 @@ const ShipmentForm = (props) => { {hasTertiaryDelivery === 'yes' && ( )} @@ -1286,7 +1277,6 @@ const ShipmentForm = (props) => { ( <> @@ -1332,7 +1322,6 @@ const ShipmentForm = (props) => { <> {isTertiaryAddressEnabled && ( @@ -1369,7 +1358,6 @@ const ShipmentForm = (props) => { {hasTertiaryPickup === 'true' && ( )} @@ -1383,7 +1371,6 @@ const ShipmentForm = (props) => { ( <> @@ -1421,7 +1408,6 @@ const ShipmentForm = (props) => { <> {isTertiaryAddressEnabled && ( @@ -1458,7 +1444,6 @@ const ShipmentForm = (props) => { {hasTertiaryDestination === 'true' && ( )} diff --git a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx index d12835dfb2c..926d29dec57 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx @@ -45,12 +45,14 @@ const mockMtoShipment = { city: 'San Antonio', state: 'TX', postalCode: '78234', + county: 'BEXAR', }, destinationAddress: { streetAddress1: '441 SW Rio de la Plata Drive', city: 'Tacoma', state: 'WA', postalCode: '98421', + county: 'PIERCE', }, mtoAgents: [ { @@ -176,6 +178,7 @@ const defaultProps = { postalCode: '31905', streetAddress1: '123 Main', streetAddress2: '', + county: 'MUSCOGEE', }, originDutyLocationAddress: { city: 'Fort Benning', @@ -183,6 +186,7 @@ const defaultProps = { postalCode: '31905', streetAddress1: '123 Main', streetAddress2: '', + county: 'MUSCOGEE', }, serviceMember: { weightAllotment: { @@ -220,6 +224,7 @@ const mockPPMShipment = { city: 'Test City', state: 'KY', postalCode: '42701', + county: 'HARDIN', }, secondaryPickupAddress: { streetAddress1: '777 Test Street', @@ -228,6 +233,7 @@ const mockPPMShipment = { city: 'Test City', state: 'KY', postalCode: '42702', + county: 'HARDIN', }, destinationAddress: { streetAddress1: '222 Test Street', @@ -236,6 +242,7 @@ const mockPPMShipment = { city: 'Test City', state: 'KY', postalCode: '42703', + county: 'HARDIN', }, secondaryDestinationAddress: { streetAddress1: '444 Test Street', @@ -244,6 +251,7 @@ const mockPPMShipment = { city: 'Test City', state: 'KY', postalCode: '42701', + county: 'HARDIN', }, sitExpected: false, estimatedWeight: 4999, @@ -271,6 +279,7 @@ const mockRejectedPPMShipment = { city: 'Test City', state: 'KY', postalCode: '42701', + county: 'HARDIN', }, secondaryPickupAddress: { streetAddress1: '777 Test Street', @@ -287,6 +296,7 @@ const mockRejectedPPMShipment = { city: 'Test City', state: 'KY', postalCode: '42703', + county: 'HARDIN', }, secondaryDestinationAddress: { streetAddress1: '444 Test Street', @@ -295,6 +305,7 @@ const mockRejectedPPMShipment = { city: 'Test City', state: 'KY', postalCode: '42701', + county: 'HARDIN', }, sitExpected: false, estimatedWeight: 4999, @@ -320,6 +331,7 @@ const mockDeliveryAddressUpdate = { streetAddress1: '123 Any Street', streetAddress2: 'P.O. Box 12345', streetAddress3: 'c/o Some Person', + county: 'LOS ANGELES', }, originalAddress: { city: 'Fairfield', @@ -331,6 +343,7 @@ const mockDeliveryAddressUpdate = { streetAddress1: '987 Any Avenue', streetAddress2: 'P.O. Box 9876', streetAddress3: 'c/o Some Person', + county: 'SOLANO', }, shipmentID: '5c84bcf3-92f7-448f-b0e1-e5378b6806df', status: 'REQUESTED', @@ -1109,6 +1122,7 @@ describe('ShipmentForm component', () => { state: 'WA', postalCode: '98421', streetAddress2: '', + county: 'PIERCE', }, pickupAddress: { streetAddress1: '812 S 129th St', @@ -1116,6 +1130,7 @@ describe('ShipmentForm component', () => { state: 'TX', postalCode: '78234', streetAddress2: '', + county: 'BEXAR', }, agents: [ { @@ -1736,6 +1751,7 @@ describe('ShipmentForm component', () => { city: 'Test City', state: 'KY', postalCode: '42701', + county: 'HARDIN', }, destinationAddress: { streetAddress1: '222 Test Street', @@ -1744,6 +1760,7 @@ describe('ShipmentForm component', () => { city: 'Test City', state: 'KY', postalCode: '42703', + county: 'HARDIN', }, }; diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index 183f55a42e3..cc140d643fb 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -116,7 +116,7 @@ export const AddressFields = ({ name={`${name}.streetAddress3`} validate={validators?.streetAddress3} /> - {zipCityEnabled && ( + {handleZipCityChange && ( <> {!zipCityError && ( - + If you encounter any inaccurate lookup information please contact the Help Desk for further assistance. )} {zipCityError && ( - + Not all data was able to populate successfully. Contact the Help Desk for further assistance. @@ -149,7 +149,7 @@ export const AddressFields = ({ validate={validators?.city} isDisabled={zipCityEnabled} /> - {zipCityEnabled && ( + {handleZipCityChange && ( ({ @@ -22,6 +25,22 @@ beforeEach(() => { jest.resetAllMocks(); }); +const loggedInTOOState = { + auth: { + activeRole: roleTypes.TOO, + isLoading: false, + isLoggedIn: true, + }, + entities: { + user: { + userId234: { + id: 'userId234', + roles: [{ roleType: roleTypes.TIO }], + }, + }, + }, +}; + describe('BackupAddress page', () => { const fakeAddress = { streetAddress1: '235 Prospect Valley Road SE', @@ -44,8 +63,14 @@ describe('BackupAddress page', () => { it('renders the BackupAddressForm', async () => { const testProps = generateTestProps(blankAddress); - - const { queryByRole } = render(); + const mockStore = configureStore({ + ...loggedInTOOState + }); + const { queryByRole } = render( + + + + ); await waitFor(() => { expect(queryByRole('heading', { name: 'Backup address', level: 1 })).toBeInTheDocument(); @@ -54,8 +79,14 @@ describe('BackupAddress page', () => { it('back button goes to the Residential address step', async () => { const testProps = generateTestProps(blankAddress); - - const { findByRole } = render(); + const mockStore = configureStore({ + ...loggedInTOOState + }); + const { findByRole } = render( + + + + ); const backButton = await findByRole('button', { name: 'Back' }); expect(backButton).toBeInTheDocument(); @@ -66,12 +97,18 @@ describe('BackupAddress page', () => { it('next button submits the form and goes to the Backup contact step', async () => { const testProps = generateTestProps(fakeAddress); - + const mockStore = configureStore({ + ...loggedInTOOState + }); const expectedServiceMemberPayload = { ...testProps.serviceMember, backup_mailing_address: fakeAddress }; patchServiceMember.mockImplementation(() => Promise.resolve(expectedServiceMemberPayload)); - const { getByRole } = render(); + const { getByRole } = render( + + + + ); const submitButton = getByRole('button', { name: 'Next' }); expect(submitButton).toBeInTheDocument(); @@ -91,7 +128,9 @@ describe('BackupAddress page', () => { it('shows an error if the patchServiceMember API returns an error', async () => { const testProps = generateTestProps(fakeAddress); - + const mockStore = configureStore({ + ...loggedInTOOState + }); patchServiceMember.mockImplementation(() => // Disable this rule because makeSwaggerRequest does not throw an error if the API call fails // eslint-disable-next-line prefer-promise-reject-errors @@ -105,7 +144,11 @@ describe('BackupAddress page', () => { }), ); - const { getByRole, queryByText } = render(); + const { getByRole, queryByText } = render( + + + + ); const submitButton = getByRole('button', { name: 'Next' }); expect(submitButton).toBeInTheDocument(); diff --git a/src/pages/MyMove/Profile/ResidentialAddress.test.jsx b/src/pages/MyMove/Profile/ResidentialAddress.test.jsx index 92450d9f08b..670b4316a45 100644 --- a/src/pages/MyMove/Profile/ResidentialAddress.test.jsx +++ b/src/pages/MyMove/Profile/ResidentialAddress.test.jsx @@ -1,9 +1,11 @@ import React from 'react'; import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; +import { Provider } from 'react-redux'; import { MockProviders } from 'testUtils'; import ConnectedResidentialAddress, { ResidentialAddress } from 'pages/MyMove/Profile/ResidentialAddress'; +import { configureStore } from 'shared/store'; import { customerRoutes } from 'constants/routes'; import { patchServiceMember } from 'services/internalApi'; import { ValidateZipRateData } from 'shared/api'; @@ -51,8 +53,13 @@ describe('ResidentialAddress page', () => { it('renders the ResidentialAddressForm', async () => { const testProps = generateTestProps(blankAddress); + const mockStore = configureStore({}); - render(); + render( + + + + ); await waitFor(() => { expect(screen.getByRole('heading', { name: 'Current address', level: 1 })).toBeInTheDocument(); @@ -61,8 +68,13 @@ describe('ResidentialAddress page', () => { it('back button goes to the contact info step', async () => { const testProps = generateTestProps(blankAddress); + const mockStore = configureStore({}); - render(); + render( + + + + ); const backButton = await screen.findByRole('button', { name: 'Back' }); expect(backButton).toBeInTheDocument(); @@ -73,6 +85,7 @@ describe('ResidentialAddress page', () => { it('next button submits the form and goes to the Backup address step', async () => { const testProps = generateTestProps(fakeAddress); + const mockStore = configureStore({}); const expectedServiceMemberPayload = { ...testProps.serviceMember, residential_address: fakeAddress }; @@ -81,7 +94,11 @@ describe('ResidentialAddress page', () => { })); patchServiceMember.mockImplementation(() => Promise.resolve(expectedServiceMemberPayload)); - render(); + render( + + + + ); const submitButton = screen.getByRole('button', { name: 'Next' }); expect(submitButton).toBeInTheDocument(); @@ -97,6 +114,7 @@ describe('ResidentialAddress page', () => { it('shows an error if the patchServiceMember API returns an error', async () => { const testProps = generateTestProps(fakeAddress); + const mockStore = configureStore({}); ValidateZipRateData.mockImplementation(() => ({ valid: true, @@ -114,7 +132,11 @@ describe('ResidentialAddress page', () => { }), ); - render(); + render( + + + + ); const submitButton = screen.getByRole('button', { name: 'Next' }); expect(submitButton).toBeInTheDocument(); From d43c4d3ea047b59ff8a4154dd2e0ebe06bfc525f Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 23 Aug 2024 03:00:00 +0000 Subject: [PATCH 032/216] adding ghc api test --- pkg/handlers/ghcapi/addresses_test.go | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 pkg/handlers/ghcapi/addresses_test.go diff --git a/pkg/handlers/ghcapi/addresses_test.go b/pkg/handlers/ghcapi/addresses_test.go new file mode 100644 index 00000000000..763c4933c79 --- /dev/null +++ b/pkg/handlers/ghcapi/addresses_test.go @@ -0,0 +1,44 @@ +package ghcapi + +import ( + "net/http/httptest" + + "github.com/go-openapi/strfmt" + + "github.com/transcom/mymove/pkg/factory" + addressop "github.com/transcom/mymove/pkg/gen/ghcapi/ghcoperations/addresses" + "github.com/transcom/mymove/pkg/models" + "github.com/transcom/mymove/pkg/services/address" +) + +func (suite *HandlerSuite) TestGetLocationByZipCityHandler() { + suite.Run("successful zip city lookup", func() { + usPostRegionCity := factory.BuildDefaultUsPostRegionCity(suite.DB()) + suite.MustSave(&usPostRegionCity) + + var fetchedUsPostRegionCity models.UsPostRegionCity + err := suite.DB().Where("uspr_zip_id = $1", usPostRegionCity.UsprZipID).First(&fetchedUsPostRegionCity) + + suite.NoError(err) + suite.Equal(usPostRegionCity.UsprZipID, fetchedUsPostRegionCity.UsprZipID) + + usPostRegionCityService := address.NewUsPostRegionCity() + move := factory.BuildMove(suite.DB(), nil, nil) + req := httptest.NewRequest("GET", "/addresses/zip_city_lookup/"+usPostRegionCity.UsprZipID, nil) + req = suite.AuthenticateRequest(req, move.Orders.ServiceMember) + params := addressop.GetLocationByZipCityParams{ + HTTPRequest: req, + Search: usPostRegionCity.UsprZipID, + } + + handler := GetLocationByZipCityHandler{ + HandlerConfig: suite.HandlerConfig(), + UsPostRegionCity: usPostRegionCityService} + + response := handler.Handle(params) + suite.Assertions.IsType(&addressop.GetLocationByZipCityOK{}, response) + responsePayload := response.(*addressop.GetLocationByZipCityOK) + suite.NoError(responsePayload.Payload.Validate(strfmt.Default)) + suite.Equal(usPostRegionCity.UsprZipID, responsePayload.Payload[0].PostalCode) + }) +} From bc650bc9438b351a539cd8da300248822a376209 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 23 Aug 2024 15:08:24 +0000 Subject: [PATCH 033/216] changed url, open in new tab --- src/components/form/AddressFields/AddressFields.jsx | 9 +++++++-- src/shared/constants.js | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index 4bc6086c309..2da00582915 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -5,6 +5,7 @@ import { Fieldset, Alert } from '@trussworks/react-uswds'; import { statesList } from '../../../constants/states'; +import { technicalHelpDeskURL } from 'shared/constants'; import TextField from 'components/form/fields/TextField/TextField'; import { DropdownInput } from 'components/form/fields/DropdownInput'; import ZipCityInput from 'components/form/fields/ZipCityInput'; @@ -128,14 +129,18 @@ export const AddressFields = ({ {!zipCityError && ( If you encounter any inaccurate lookup information please contact the - Help Desk + + Technical Help Desk + for further assistance. )} {zipCityError && ( Not all data was able to populate successfully. Contact the - Help Desk + + Technical Help Desk + for further assistance. )} diff --git a/src/shared/constants.js b/src/shared/constants.js index 4fb0ab134a8..ad10847e50f 100644 --- a/src/shared/constants.js +++ b/src/shared/constants.js @@ -16,6 +16,8 @@ export const hostname = window && window.location && window.location.hostname; export const isMilmoveSite = hostname.startsWith('my') || hostname.startsWith('mil') || ''; export const isOfficeSite = hostname.startsWith('office') || ''; export const isAdminSite = hostname.startsWith('admin') || ''; +export const technicalHelpDeskURL = + 'https://www.militaryonesource.mil/resources/gov/customer-service-contacts-for-military-pcs/#technical-help-desk'; export function serviceName() { if (isAdminSite) { From c8ef4fc6219a649f4f8f05e39909c3b8ce899407 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 23 Aug 2024 19:02:37 +0000 Subject: [PATCH 034/216] sytling adjustments --- .../internal/payloads/model_to_payload.go | 5 +--- .../LocationSearchBox/LocationSearchBox.jsx | 7 ++++-- .../form/AddressFields/AddressFields.jsx | 24 ++++++++++++------- .../AddressFields/AddressFields.module.scss | 24 +++++++++++++++++++ 4 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 src/components/form/AddressFields/AddressFields.module.scss diff --git a/pkg/handlers/internalapi/internal/payloads/model_to_payload.go b/pkg/handlers/internalapi/internal/payloads/model_to_payload.go index b369d9c9dbb..438be3e5d43 100644 --- a/pkg/handlers/internalapi/internal/payloads/model_to_payload.go +++ b/pkg/handlers/internalapi/internal/payloads/model_to_payload.go @@ -607,10 +607,7 @@ func SignedCertification(signedCertification *models.SignedCertification) *inter // UsPostRegionCity payload func UsPostRegionCity(usPostRegionCity *models.UsPostRegionCity) *internalmessages.UsPostRegionCity { - if usPostRegionCity == nil { - return nil - } - if *usPostRegionCity == (models.UsPostRegionCity{}) { + if usPostRegionCity == nil || *usPostRegionCity == (models.UsPostRegionCity{}) { return nil } diff --git a/src/components/LocationSearchBox/LocationSearchBox.jsx b/src/components/LocationSearchBox/LocationSearchBox.jsx index 65713946d53..68faeb6869d 100644 --- a/src/components/LocationSearchBox/LocationSearchBox.jsx +++ b/src/components/LocationSearchBox/LocationSearchBox.jsx @@ -70,7 +70,10 @@ const customStyles = { borderRadius: '0px', borderColor: uswdsBlack, padding: '0.1rem', - maxWidth: '32rem', + maxWidth: '100%', + '@media (max-width: 768px)': { + maxWidth: '32em', + }, ':hover': { ...styles[':hover'], borderColor: uswdsBlack, @@ -206,7 +209,7 @@ export const LocationSearchBoxComponent = ({ onChange(null); }; - const noOptionsMessage = () => (inputValue.length ? 'No Options' : ''); + const noOptionsMessage = () => (inputValue.length ? 'No Options' : null); const hasLocation = !!value && !!value.address; return ( diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index 2da00582915..78e518c33b3 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -1,10 +1,12 @@ import React, { useRef } from 'react'; import PropTypes from 'prop-types'; import { v4 as uuidv4 } from 'uuid'; -import { Fieldset, Alert } from '@trussworks/react-uswds'; +import { Fieldset } from '@trussworks/react-uswds'; import { statesList } from '../../../constants/states'; +import Hint from 'components/Hint/index'; +import styles from 'components/form/AddressFields/AddressFields.module.scss'; import { technicalHelpDeskURL } from 'shared/constants'; import TextField from 'components/form/fields/TextField/TextField'; import { DropdownInput } from 'components/form/fields/DropdownInput'; @@ -37,6 +39,9 @@ export const AddressFields = ({ const addressFieldsUUID = useRef(uuidv4()); let postalCodeField; let stateField; + const infoStr = 'If you encounter any inaccurate lookup information please contact the '; + const errorStr = 'Not all data was able to populate successfully. Contact the '; + const assistanceStr = ' for further assistance.'; if (formikFunctionsToValidatePostalCodeOnChange) { postalCodeField = ( @@ -127,22 +132,22 @@ export const AddressFields = ({ handleZipCityChange={handleZipCityChange} /> {!zipCityError && ( - - If you encounter any inaccurate lookup information please contact the + + {infoStr} Technical Help Desk - for further assistance. - + {assistanceStr} + )} {zipCityError && ( - - Not all data was able to populate successfully. Contact the + + {errorStr} Technical Help Desk - for further assistance. - + {assistanceStr} + )} )} @@ -157,6 +162,7 @@ export const AddressFields = ({ /> {zipCityEnabled && ( Date: Fri, 23 Aug 2024 19:26:16 +0000 Subject: [PATCH 035/216] refactor, add lookup to edit profile --- .../EditContactInfoForm.jsx | 62 ++++++++++- .../ResidentialAddressForm.jsx | 1 + .../form/AddressFields/AddressFields.jsx | 100 ++++++++---------- src/pages/MyMove/Profile/EditContactInfo.jsx | 2 + 4 files changed, 106 insertions(+), 59 deletions(-) diff --git a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx index 4ffc3b0c0e5..2ca3e7027b5 100644 --- a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx +++ b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx @@ -1,5 +1,5 @@ import classnames from 'classnames'; -import React from 'react'; +import { React, useState } from 'react'; import PropTypes from 'prop-types'; import { Formik } from 'formik'; import * as Yup from 'yup'; @@ -30,10 +30,54 @@ const EditContactInfoForm = ({ initialValues, onSubmit, onCancel }) => { }); const sectionStyles = classnames(formStyles.formSection, editContactInfoFormStyle.formSection); + const [isCurrentLookupErrorVisible, setIsCurrentLookupErrorVisible] = useState(false); + const [isBackupLookupErrorVisible, setIsBackupLookupErrorVisible] = useState(false); return ( - {({ isValid, isSubmitting, handleSubmit }) => { + {({ isValid, isSubmitting, handleSubmit, values, setValues }) => { + const handleCurrentZipCityChange = (value) => { + setValues( + { + ...values, + residential_address: { + ...values.residential_address, + city: value.city ? value.city : '', + state: value.state ? value.state : '', + county: value.county ? value.county : '', + postalCode: value.postalCode ? value.postalCode : '', + }, + }, + { shouldValidate: true }, + ); + + if (!value.city || !value.state || !value.county || !value.postalCode) { + setIsCurrentLookupErrorVisible(true); + } else { + setIsCurrentLookupErrorVisible(false); + } + }; + const handleBackupZipCityChange = (value) => { + setValues( + { + ...values, + backup_mailing_address: { + ...values.backup_mailing_address, + city: value.city ? value.city : '', + state: value.state ? value.state : '', + county: value.county ? value.county : '', + postalCode: value.postalCode ? value.postalCode : '', + }, + }, + { shouldValidate: true }, + ); + + if (!value.city || !value.state || !value.county || !value.postalCode) { + setIsBackupLookupErrorVisible(true); + } else { + setIsBackupLookupErrorVisible(false); + } + }; return (

Edit contact info

@@ -47,7 +91,12 @@ const EditContactInfoForm = ({ initialValues, onSubmit, onCancel }) => {

Current address

- +
@@ -57,7 +106,12 @@ const EditContactInfoForm = ({ initialValues, onSubmit, onCancel }) => { transit during your move.

- +
diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx index be3920ac460..798bc0b7f96 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx @@ -90,6 +90,7 @@ ResidentialAddressForm.propTypes = { city: PropTypes.func, state: PropTypes.func, postalCode: PropTypes.func, + county: PropTypes.func, }), }; diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index 78e518c33b3..fd5de5aec4e 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -37,66 +37,56 @@ export const AddressFields = ({ formikFunctionsToValidatePostalCodeOnChange, }) => { const addressFieldsUUID = useRef(uuidv4()); - let postalCodeField; - let stateField; const infoStr = 'If you encounter any inaccurate lookup information please contact the '; const errorStr = 'Not all data was able to populate successfully. Contact the '; const assistanceStr = ' for further assistance.'; - if (formikFunctionsToValidatePostalCodeOnChange) { - postalCodeField = ( - { - // If we are validating on change we need to also set the field to touched when it is changed. - // Formik, by default, only sets the field to touched on blur. - // The validation errors will not show unless the field has been touched. We await the handleChange event, - // then we set the field to touched. - // We send true for the shouldValidate arg to validate the field at the same time. - await formikFunctionsToValidatePostalCodeOnChange.handleChange(e); - formikFunctionsToValidatePostalCodeOnChange.setFieldTouched(`${name}.postalCode`, true, true); - }} - /> - ); - } else { - postalCodeField = ( - - ); - } + const postalCodeField = formikFunctionsToValidatePostalCodeOnChange ? ( + { + // If we are validating on change we need to also set the field to touched when it is changed. + // Formik, by default, only sets the field to touched on blur. + // The validation errors will not show unless the field has been touched. We await the handleChange event, + // then we set the field to touched. + // We send true for the shouldValidate arg to validate the field at the same time. + await formikFunctionsToValidatePostalCodeOnChange.handleChange(e); + formikFunctionsToValidatePostalCodeOnChange.setFieldTouched(`${name}.postalCode`, true, true); + }} + /> + ) : ( + + ); - if (zipCityEnabled) { - stateField = ( - - ); - } else { - stateField = ( - - ); - } + const stateField = zipCityEnabled ? ( + + ) : ( + + ); return (
diff --git a/src/pages/MyMove/Profile/EditContactInfo.jsx b/src/pages/MyMove/Profile/EditContactInfo.jsx index aa27b30eae0..06d36de9394 100644 --- a/src/pages/MyMove/Profile/EditContactInfo.jsx +++ b/src/pages/MyMove/Profile/EditContactInfo.jsx @@ -43,6 +43,7 @@ export const EditContactInfo = ({ city: serviceMember.residential_address?.city || '', state: serviceMember.residential_address?.state || '', postalCode: serviceMember.residential_address?.postalCode || '', + county: serviceMember.residential_address?.county || '', }, [backupAddressName]: { streetAddress1: serviceMember.backup_mailing_address?.streetAddress1 || '', @@ -50,6 +51,7 @@ export const EditContactInfo = ({ city: serviceMember.backup_mailing_address?.city || '', state: serviceMember.backup_mailing_address?.state || '', postalCode: serviceMember.backup_mailing_address?.postalCode || '', + county: serviceMember.backup_mailing_address?.county || '', }, [backupContactName]: { name: currentBackupContacts[0]?.name || '', From ce219553eb6a21db3893ad62af1ac6f8829d143a Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 23 Aug 2024 19:30:49 +0000 Subject: [PATCH 036/216] code cleanup --- src/components/form/fields/ZipCityInput.jsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/form/fields/ZipCityInput.jsx b/src/components/form/fields/ZipCityInput.jsx index 8f48bf2ed8f..90747b9c688 100644 --- a/src/components/form/fields/ZipCityInput.jsx +++ b/src/components/form/fields/ZipCityInput.jsx @@ -32,9 +32,7 @@ export const ZipCityInput = (props) => { }; ZipCityInput.propTypes = { - // label displayed for input label: PropTypes.string.isRequired, - // name is for the input name: PropTypes.string.isRequired, displayAddress: PropTypes.bool, hint: PropTypes.node, From acdadb5171851b1eda139c7a28695508aaa0173f Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 23 Aug 2024 22:47:27 +0000 Subject: [PATCH 037/216] updated tests --- .../Customer/EditContactInfoForm/EditContactInfoForm.test.jsx | 4 ++-- src/components/LocationSearchBox/LocationSearchBox.jsx | 2 +- src/pages/MyMove/Profile/EditContactInfo.test.jsx | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.test.jsx b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.test.jsx index 22d8a2d6115..fbd23cf2b53 100644 --- a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.test.jsx +++ b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.test.jsx @@ -106,10 +106,10 @@ describe('EditContactInfoForm component', () => { const [residentialState, backupState] = stateInputs; - expect(residentialState).toBeInstanceOf(HTMLSelectElement); + expect(residentialState).toBeInstanceOf(HTMLInputElement); expect(residentialState).toHaveValue(testProps.initialValues.residential_address.state); - expect(backupState).toBeInstanceOf(HTMLSelectElement); + expect(backupState).toBeInstanceOf(HTMLInputElement); expect(backupState).toHaveValue(testProps.initialValues.backup_mailing_address.state); const zipInputs = await screen.findAllByLabelText('ZIP'); diff --git a/src/components/LocationSearchBox/LocationSearchBox.jsx b/src/components/LocationSearchBox/LocationSearchBox.jsx index 68faeb6869d..d836f3a8a9b 100644 --- a/src/components/LocationSearchBox/LocationSearchBox.jsx +++ b/src/components/LocationSearchBox/LocationSearchBox.jsx @@ -209,7 +209,7 @@ export const LocationSearchBoxComponent = ({ onChange(null); }; - const noOptionsMessage = () => (inputValue.length ? 'No Options' : null); + const noOptionsMessage = () => (inputValue.length ? 'No Options' : 'No Options'); const hasLocation = !!value && !!value.address; return ( diff --git a/src/pages/MyMove/Profile/EditContactInfo.test.jsx b/src/pages/MyMove/Profile/EditContactInfo.test.jsx index 2ef1a74120b..f06a3b40855 100644 --- a/src/pages/MyMove/Profile/EditContactInfo.test.jsx +++ b/src/pages/MyMove/Profile/EditContactInfo.test.jsx @@ -48,6 +48,7 @@ describe('EditContactInfo page', () => { city: 'Fake City', state: 'TX', postalCode: '79936', + county: 'EL PASO', }, backup_mailing_address: { streetAddress1: '10642 N Second Ave', @@ -55,6 +56,7 @@ describe('EditContactInfo page', () => { city: 'Fake City', state: 'TX', postalCode: '79936', + county: 'EL PASO', }, }, setFlashMessage: jest.fn(), From e1f59f077a9f65b2f1c97fa7159ac3ac344db186 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Mon, 26 Aug 2024 19:28:20 +0000 Subject: [PATCH 038/216] linter --- .../form/AddressFields/AddressFields.test.jsx | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/components/form/AddressFields/AddressFields.test.jsx b/src/components/form/AddressFields/AddressFields.test.jsx index b3f0dc17fa7..dbdb59c6c36 100644 --- a/src/components/form/AddressFields/AddressFields.test.jsx +++ b/src/components/form/AddressFields/AddressFields.test.jsx @@ -120,4 +120,55 @@ describe('AddressFields component', () => { expect(postalCodeError).toHaveTextContent(postalCodeErrorText); }); }); + + describe('zip city enabled with pre-filled values', () => { + it('renders zip city lookup with info', () => { + const initialValues = { + address: { + streetAddress1: '123 Main St', + streetAddress2: 'Apt 3A', + city: 'New York', + state: 'NY', + postalCode: '10002', + county: 'NEW YORK', + }, + }; + + const { getByLabelText, getByTestId } = render( + + + , + ); + expect(getByLabelText('Address 1')).toHaveValue(initialValues.address.streetAddress1); + expect(getByLabelText(/Address 2/)).toHaveValue(initialValues.address.streetAddress2); + expect(getByLabelText('City')).toHaveValue(initialValues.address.city); + expect(getByLabelText('State')).toHaveValue(initialValues.address.state); + expect(getByLabelText('ZIP')).toHaveValue(initialValues.address.postalCode); + expect(getByTestId('zipCityInfo')).toBeInTheDocument(); + }); + it('renders zip city lookup with error', () => { + const initialValues = { + address: { + streetAddress1: '123 Main St', + streetAddress2: 'Apt 3A', + city: 'New York', + state: 'NY', + postalCode: '10002', + county: 'NEW YORK', + }, + }; + + const { getByLabelText, getByTestId } = render( + + + , + ); + expect(getByLabelText('Address 1')).toHaveValue(initialValues.address.streetAddress1); + expect(getByLabelText(/Address 2/)).toHaveValue(initialValues.address.streetAddress2); + expect(getByLabelText('City')).toHaveValue(initialValues.address.city); + expect(getByLabelText('State')).toHaveValue(initialValues.address.state); + expect(getByLabelText('ZIP')).toHaveValue(initialValues.address.postalCode); + expect(getByTestId('zipCityError')).toBeInTheDocument(); + }); + }); }); From 6d5fbfdc9ca069db1d68d877a8d007b77280aa0c Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Mon, 26 Aug 2024 20:52:36 +0000 Subject: [PATCH 039/216] test fixes --- playwright/tests/office/ppms/ppmTestFixture.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/playwright/tests/office/ppms/ppmTestFixture.js b/playwright/tests/office/ppms/ppmTestFixture.js index f23467c32b4..2be71cc0a1f 100644 --- a/playwright/tests/office/ppms/ppmTestFixture.js +++ b/playwright/tests/office/ppms/ppmTestFixture.js @@ -90,6 +90,7 @@ export class PpmPage extends ServiceCounselorPage { await this.page.locator('input[name="pickup.address.city"]').fill('SomeCity - Secondary'); await this.page.locator('select[name="pickup.address.state"]').selectOption({ label: 'CA' }); await this.page.locator('input[name="pickup.address.postalCode"]').fill('90210'); + await this.page.locator('input[name="pickup.address.county"]').fill('LOS ANGELES'); } /** @@ -104,6 +105,7 @@ export class PpmPage extends ServiceCounselorPage { await this.page.locator('input[name="destination.address.streetAddress1"]').fill('123 Street'); await this.page.locator('input[name="destination.address.city"]').fill('SomeCity'); await this.page.locator('select[name="destination.address.state"]').selectOption({ label: 'TX' }); + await this.page.locator('input[name="destination.address.county"]').fill('TARRANT'); } /** From 570654c548f836278fe459c7241ab0c8b9c63068 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Tue, 27 Aug 2024 15:11:18 +0000 Subject: [PATCH 040/216] update tests --- .../BackupAddressForm.test.jsx | 11 +++++---- .../ResidentialAddressForm.test.jsx | 9 +++---- .../CustomerContactInfoForm.test.jsx | 9 +++---- .../form/AddressFields/AddressFields.test.jsx | 24 ++++++++++++++----- .../MyMove/Profile/BackupAddress.test.jsx | 16 ++++++------- .../Profile/ResidentialAddress.test.jsx | 12 +++++----- 6 files changed, 48 insertions(+), 33 deletions(-) diff --git a/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx b/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx index 2c9763efc44..3d6d35c8905 100644 --- a/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx +++ b/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx @@ -4,6 +4,7 @@ import userEvent from '@testing-library/user-event'; import { Provider } from 'react-redux'; import BackupAddressForm from './BackupAddressForm'; + import { configureStore } from 'shared/store'; describe('BackupAddressForm component', () => { @@ -55,7 +56,7 @@ describe('BackupAddressForm component', () => { const { getByLabelText } = render( - + , ); await waitFor(() => { @@ -74,9 +75,9 @@ describe('BackupAddressForm component', () => { it('shows an error message if trying to submit an invalid form', async () => { const mockStore = configureStore({}); const { getByRole, findAllByRole, getByLabelText } = render( - + - + , ); await userEvent.click(getByLabelText('Address 1')); await userEvent.click(getByLabelText(/Address 2/)); @@ -99,7 +100,7 @@ describe('BackupAddressForm component', () => { const { getByRole, getByLabelText } = render( - + , ); const submitBtn = getByRole('button', { name: 'Next' }); @@ -126,7 +127,7 @@ describe('BackupAddressForm component', () => { const { getByRole } = render( - + , ); const backBtn = getByRole('button', { name: 'Back' }); diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx index 2a882163010..ead5e95c42c 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx @@ -4,6 +4,7 @@ import userEvent from '@testing-library/user-event'; import { Provider } from 'react-redux'; import ResidentialAddressForm from './ResidentialAddressForm'; + import { configureStore } from 'shared/store'; describe('ResidentialAddressForm component', () => { @@ -54,7 +55,7 @@ describe('ResidentialAddressForm component', () => { const { getByLabelText, getByText } = render( - + , ); await waitFor(() => { @@ -77,7 +78,7 @@ describe('ResidentialAddressForm component', () => { const { getByRole, findAllByRole, getByLabelText } = render( - + , ); await userEvent.click(getByLabelText('Address 1')); await userEvent.click(getByLabelText(/Address 2/)); @@ -101,7 +102,7 @@ describe('ResidentialAddressForm component', () => { const { getByRole, getByLabelText } = render( - + , ); const submitBtn = getByRole('button', { name: 'Next' }); @@ -128,7 +129,7 @@ describe('ResidentialAddressForm component', () => { const { getByRole } = render( - + , ); const backBtn = getByRole('button', { name: 'Back' }); diff --git a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.test.jsx b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.test.jsx index 521ad141be7..f3c7d50093b 100644 --- a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.test.jsx +++ b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.test.jsx @@ -3,6 +3,7 @@ import { render, waitFor, screen } from '@testing-library/react'; import { Provider } from 'react-redux'; import CustomerContactInfoForm from './CustomerContactInfoForm'; + import { roleTypes } from 'constants/userRoles'; import { configureStore } from 'shared/store'; @@ -75,12 +76,12 @@ describe('CustomerContactInfoForm Component', () => { it('renders the form inputs', async () => { const mockStore = configureStore({ - ...loggedInTOOState + ...loggedInTOOState, }); render( - + , ); await waitFor(() => { @@ -131,12 +132,12 @@ describe('CustomerContactInfoForm Component', () => { it('does not allow submission without cac_validated value', async () => { const mockStore = configureStore({ - ...loggedInTOOState + ...loggedInTOOState, }); render( - + , ); await waitFor(() => { diff --git a/src/components/form/AddressFields/AddressFields.test.jsx b/src/components/form/AddressFields/AddressFields.test.jsx index dbdb59c6c36..185b59a8d7c 100644 --- a/src/components/form/AddressFields/AddressFields.test.jsx +++ b/src/components/form/AddressFields/AddressFields.test.jsx @@ -2,9 +2,15 @@ import React from 'react'; import { render, fireEvent } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { Formik } from 'formik'; +import { Provider } from 'react-redux'; import { AddressFields } from './AddressFields'; +import { configureStore } from 'shared/store'; + + +const handleZipCityChange = {}; + describe('AddressFields component', () => { it('renders a legend and all address inputs', () => { const { getByText, getByLabelText } = render( @@ -133,11 +139,14 @@ describe('AddressFields component', () => { county: 'NEW YORK', }, }; + const mockStore = configureStore({}); const { getByLabelText, getByTestId } = render( - - - , + + + + + , ); expect(getByLabelText('Address 1')).toHaveValue(initialValues.address.streetAddress1); expect(getByLabelText(/Address 2/)).toHaveValue(initialValues.address.streetAddress2); @@ -157,11 +166,14 @@ describe('AddressFields component', () => { county: 'NEW YORK', }, }; + const mockStore = configureStore({}); const { getByLabelText, getByTestId } = render( - - - , + + + + + , ); expect(getByLabelText('Address 1')).toHaveValue(initialValues.address.streetAddress1); expect(getByLabelText(/Address 2/)).toHaveValue(initialValues.address.streetAddress2); diff --git a/src/pages/MyMove/Profile/BackupAddress.test.jsx b/src/pages/MyMove/Profile/BackupAddress.test.jsx index 4f2a33572a2..fb3890bd840 100644 --- a/src/pages/MyMove/Profile/BackupAddress.test.jsx +++ b/src/pages/MyMove/Profile/BackupAddress.test.jsx @@ -64,12 +64,12 @@ describe('BackupAddress page', () => { it('renders the BackupAddressForm', async () => { const testProps = generateTestProps(blankAddress); const mockStore = configureStore({ - ...loggedInTOOState + ...loggedInTOOState, }); const { queryByRole } = render( - + , ); await waitFor(() => { @@ -80,12 +80,12 @@ describe('BackupAddress page', () => { it('back button goes to the Residential address step', async () => { const testProps = generateTestProps(blankAddress); const mockStore = configureStore({ - ...loggedInTOOState + ...loggedInTOOState, }); const { findByRole } = render( - + , ); const backButton = await findByRole('button', { name: 'Back' }); @@ -98,7 +98,7 @@ describe('BackupAddress page', () => { it('next button submits the form and goes to the Backup contact step', async () => { const testProps = generateTestProps(fakeAddress); const mockStore = configureStore({ - ...loggedInTOOState + ...loggedInTOOState, }); const expectedServiceMemberPayload = { ...testProps.serviceMember, backup_mailing_address: fakeAddress }; @@ -107,7 +107,7 @@ describe('BackupAddress page', () => { const { getByRole } = render( - + , ); const submitButton = getByRole('button', { name: 'Next' }); @@ -129,7 +129,7 @@ describe('BackupAddress page', () => { it('shows an error if the patchServiceMember API returns an error', async () => { const testProps = generateTestProps(fakeAddress); const mockStore = configureStore({ - ...loggedInTOOState + ...loggedInTOOState, }); patchServiceMember.mockImplementation(() => // Disable this rule because makeSwaggerRequest does not throw an error if the API call fails @@ -147,7 +147,7 @@ describe('BackupAddress page', () => { const { getByRole, queryByText } = render( - + , ); const submitButton = getByRole('button', { name: 'Next' }); diff --git a/src/pages/MyMove/Profile/ResidentialAddress.test.jsx b/src/pages/MyMove/Profile/ResidentialAddress.test.jsx index 670b4316a45..a8ff7bfc0ff 100644 --- a/src/pages/MyMove/Profile/ResidentialAddress.test.jsx +++ b/src/pages/MyMove/Profile/ResidentialAddress.test.jsx @@ -58,8 +58,8 @@ describe('ResidentialAddress page', () => { render( - - ); + , + ); await waitFor(() => { expect(screen.getByRole('heading', { name: 'Current address', level: 1 })).toBeInTheDocument(); @@ -73,7 +73,7 @@ describe('ResidentialAddress page', () => { render( - + , ); const backButton = await screen.findByRole('button', { name: 'Back' }); @@ -97,7 +97,7 @@ describe('ResidentialAddress page', () => { render( - + , ); const submitButton = screen.getByRole('button', { name: 'Next' }); @@ -135,8 +135,8 @@ describe('ResidentialAddress page', () => { render( - - ); + , + ); const submitButton = screen.getByRole('button', { name: 'Next' }); expect(submitButton).toBeInTheDocument(); From 9c5495958e90a1a4591f563bfdbfd45a78a013e7 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Tue, 27 Aug 2024 19:15:42 +0000 Subject: [PATCH 041/216] client test fixes --- .../EditContactInfoForm.test.jsx | 35 ++++++++++++++++--- .../form/AddressFields/AddressFields.test.jsx | 16 +++++++-- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.test.jsx b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.test.jsx index fbd23cf2b53..94b35f00b36 100644 --- a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.test.jsx +++ b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.test.jsx @@ -1,9 +1,12 @@ import React from 'react'; import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; +import { Provider } from 'react-redux'; import EditContactInfoForm from './EditContactInfoForm'; +import { configureStore } from 'shared/store'; + describe('EditContactInfoForm component', () => { const testProps = { initialValues: { @@ -37,7 +40,13 @@ describe('EditContactInfoForm component', () => { }; it('renders the form inputs', async () => { - render(); + const mockStore = configureStore({}); + + render( + + + + ); const telephoneInput = await screen.findByLabelText('Best contact phone'); @@ -159,7 +168,13 @@ describe('EditContactInfoForm component', () => { }); it('shows an error message if trying to submit an invalid form', async () => { - render(); + const mockStore = configureStore({}); + + render( + + + + ); const saveButton = await screen.findByRole('button', { name: 'Save' }); @@ -180,7 +195,13 @@ describe('EditContactInfoForm component', () => { }); it('submits the form when its valid', async () => { - render(); + const mockStore = configureStore({}); + + render( + + + + ); const saveButton = screen.getByRole('button', { name: 'Save' }); @@ -196,7 +217,13 @@ describe('EditContactInfoForm component', () => { }); it('implements the onCancel handler when the Cancel button is clicked', async () => { - render(); + const mockStore = configureStore({}); + + render( + + + + ); const cancelButton = screen.getByRole('button', { name: 'Cancel' }); diff --git a/src/components/form/AddressFields/AddressFields.test.jsx b/src/components/form/AddressFields/AddressFields.test.jsx index 185b59a8d7c..dc9f2cb6c73 100644 --- a/src/components/form/AddressFields/AddressFields.test.jsx +++ b/src/components/form/AddressFields/AddressFields.test.jsx @@ -8,7 +8,6 @@ import { AddressFields } from './AddressFields'; import { configureStore } from 'shared/store'; - const handleZipCityChange = {}; describe('AddressFields component', () => { @@ -144,7 +143,12 @@ describe('AddressFields component', () => { const { getByLabelText, getByTestId } = render( - + , ); @@ -171,7 +175,13 @@ describe('AddressFields component', () => { const { getByLabelText, getByTestId } = render( - + , ); From a725a924f2fdc813d2de3372cb868db41a0272af Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Tue, 27 Aug 2024 19:30:11 +0000 Subject: [PATCH 042/216] tests... --- .../ServicesCounselingEditShipmentDetails.test.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pages/Office/ServicesCounselingEditShipmentDetails/ServicesCounselingEditShipmentDetails.test.jsx b/src/pages/Office/ServicesCounselingEditShipmentDetails/ServicesCounselingEditShipmentDetails.test.jsx index de1ac1b0ead..148cc0f04e2 100644 --- a/src/pages/Office/ServicesCounselingEditShipmentDetails/ServicesCounselingEditShipmentDetails.test.jsx +++ b/src/pages/Office/ServicesCounselingEditShipmentDetails/ServicesCounselingEditShipmentDetails.test.jsx @@ -108,6 +108,7 @@ const useEditShipmentQueriesReturnValue = { streetAddress1: '123 Any Street', streetAddress2: 'P.O. Box 12345', streetAddress3: 'c/o Some Person', + county: 'LOS ANGELES', }, dodID: '6833908165', eTag: 'MjAyMS0wMS0yMVQxNTo0MTozNS41NjAzNTJa', @@ -147,6 +148,7 @@ const useEditShipmentQueriesReturnValue = { streetAddress1: '987 Any Avenue', streetAddress2: 'P.O. Box 9876', streetAddress3: 'c/o Some Person', + county: 'SOLANO', }, eTag: 'MjAyMC0wNi0xMFQxNTo1ODowMi40MDQwMzFa', id: 'shipment123', @@ -161,6 +163,7 @@ const useEditShipmentQueriesReturnValue = { streetAddress1: '123 Any Street', streetAddress2: 'P.O. Box 12345', streetAddress3: 'c/o Some Person', + county: 'LOS ANGELES', }, requestedPickupDate: '2018-03-15', scheduledPickupDate: '2018-03-16', @@ -193,6 +196,7 @@ const ppmShipment = { city: 'Test City', state: 'KY', postalCode: '42701', + county: 'HARDIN', }, secondaryPickupAddress: { streetAddress1: '777 Test Street', @@ -201,6 +205,7 @@ const ppmShipment = { city: 'Test City', state: 'KY', postalCode: '42702', + county: 'HARDIN', }, destinationAddress: { streetAddress1: '222 Test Street', @@ -209,6 +214,7 @@ const ppmShipment = { city: 'Test City', state: 'KY', postalCode: '42703', + county: 'HARDIN', }, secondaryDestinationAddress: { streetAddress1: '444 Test Street', @@ -217,6 +223,7 @@ const ppmShipment = { city: 'Test City', state: 'KY', postalCode: '42701', + county: 'HARDIN', }, sitExpected: false, estimatedWeight: 1111, From 72490df37d26c463429c7a139a4aa774051d5a08 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Tue, 27 Aug 2024 23:35:28 +0000 Subject: [PATCH 043/216] tests --- src/components/Office/ShipmentForm/ShipmentForm.test.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx index d134b4b4b9b..1ee9a49e59c 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx @@ -288,6 +288,7 @@ const mockRejectedPPMShipment = { city: 'Test City', state: 'KY', postalCode: '42702', + county: 'HARDIN', }, destinationAddress: { streetAddress1: '222 Test Street', From 2d8a8d571ca6b2088aa33a766ae98aece04d1937 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 28 Aug 2024 01:48:26 +0000 Subject: [PATCH 044/216] playwright test --- .../servicescounseling/servicesCounselingTestFixture.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/playwright/tests/office/servicescounseling/servicesCounselingTestFixture.js b/playwright/tests/office/servicescounseling/servicesCounselingTestFixture.js index 78b60200a20..8afc247e924 100644 --- a/playwright/tests/office/servicescounseling/servicesCounselingTestFixture.js +++ b/playwright/tests/office/servicescounseling/servicesCounselingTestFixture.js @@ -161,8 +161,9 @@ export class ServiceCounselorPage extends OfficePage { await storageAddress.getByLabel('Address 1').fill('148 S East St'); await storageAddress.getByLabel('Address 2').fill('Suite 7A'); await storageAddress.getByLabel('City').fill('Sample City'); - await storageAddress.getByLabel('State').selectOption({ label: 'GA' }); + await storageAddress.getByLabel('State').fill('GA'); await storageAddress.getByLabel('ZIP').fill('30301'); + await storageAddress.getByLabel('County').fill('FULTON'); await storageAddress.getByLabel('Lot number').fill('1111111'); // Requested delivery date @@ -174,8 +175,9 @@ export class ServiceCounselorPage extends OfficePage { await deliveryLocation.getByLabel('Address 1').fill('448 Washington Blvd NE'); await deliveryLocation.getByLabel('Address 2').fill('Apt D3'); await deliveryLocation.getByLabel('City').fill('Another City'); - await deliveryLocation.getByLabel('State').selectOption({ label: 'AL' }); + await deliveryLocation.getByLabel('State').fill('AL'); await deliveryLocation.getByLabel('ZIP').fill('36101'); + await deliveryLocation.getByLabel('County').fill('MONTGOMERY'); // Remarks await this.page.getByLabel('Counselor remarks').fill('NTS-release counselor remarks'); From 52b4c8540c48671a9a59f73cc8f9a69a66a757e1 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 28 Aug 2024 03:16:52 +0000 Subject: [PATCH 045/216] server test fix --- pkg/handlers/ghcapi/addresses_test.go | 4 ++-- .../EditContactInfoForm/EditContactInfoForm.test.jsx | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/handlers/ghcapi/addresses_test.go b/pkg/handlers/ghcapi/addresses_test.go index 763c4933c79..0a8b18d8fd9 100644 --- a/pkg/handlers/ghcapi/addresses_test.go +++ b/pkg/handlers/ghcapi/addresses_test.go @@ -23,9 +23,9 @@ func (suite *HandlerSuite) TestGetLocationByZipCityHandler() { suite.Equal(usPostRegionCity.UsprZipID, fetchedUsPostRegionCity.UsprZipID) usPostRegionCityService := address.NewUsPostRegionCity() - move := factory.BuildMove(suite.DB(), nil, nil) + officeUser := factory.BuildOfficeUser(nil, nil, nil) req := httptest.NewRequest("GET", "/addresses/zip_city_lookup/"+usPostRegionCity.UsprZipID, nil) - req = suite.AuthenticateRequest(req, move.Orders.ServiceMember) + req = suite.AuthenticateOfficeRequest(req, officeUser) params := addressop.GetLocationByZipCityParams{ HTTPRequest: req, Search: usPostRegionCity.UsprZipID, diff --git a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.test.jsx b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.test.jsx index 94b35f00b36..9998c5cafc1 100644 --- a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.test.jsx +++ b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.test.jsx @@ -45,7 +45,7 @@ describe('EditContactInfoForm component', () => { render( - + , ); const telephoneInput = await screen.findByLabelText('Best contact phone'); @@ -173,7 +173,7 @@ describe('EditContactInfoForm component', () => { render( - + , ); const saveButton = await screen.findByRole('button', { name: 'Save' }); @@ -200,7 +200,7 @@ describe('EditContactInfoForm component', () => { render( - + , ); const saveButton = screen.getByRole('button', { name: 'Save' }); @@ -222,7 +222,7 @@ describe('EditContactInfoForm component', () => { render( - + , ); const cancelButton = screen.getByRole('button', { name: 'Cancel' }); From 78197e585f1f234973b901a27f721957f1214ac2 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 28 Aug 2024 03:58:48 +0000 Subject: [PATCH 046/216] playwright fix --- .../office/servicescounseling/servicesCounselingTestFixture.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/playwright/tests/office/servicescounseling/servicesCounselingTestFixture.js b/playwright/tests/office/servicescounseling/servicesCounselingTestFixture.js index 8afc247e924..ed665a487a4 100644 --- a/playwright/tests/office/servicescounseling/servicesCounselingTestFixture.js +++ b/playwright/tests/office/servicescounseling/servicesCounselingTestFixture.js @@ -161,9 +161,8 @@ export class ServiceCounselorPage extends OfficePage { await storageAddress.getByLabel('Address 1').fill('148 S East St'); await storageAddress.getByLabel('Address 2').fill('Suite 7A'); await storageAddress.getByLabel('City').fill('Sample City'); - await storageAddress.getByLabel('State').fill('GA'); + await storageAddress.getByLabel('State').selectOption({ label: 'GA' }); await storageAddress.getByLabel('ZIP').fill('30301'); - await storageAddress.getByLabel('County').fill('FULTON'); await storageAddress.getByLabel('Lot number').fill('1111111'); // Requested delivery date From 39f9ccd0a5f9b39b94da9daa9399f131d04c7d00 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 28 Aug 2024 06:59:55 +0000 Subject: [PATCH 047/216] fix playwright, add zip/city to modals --- .../servicesCounselingTestFixture.js | 6 +-- .../EditPPMHeaderSummaryModal.jsx | 51 ++++++++++++++++++- .../form/AddressFields/AddressFields.jsx | 2 + 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/playwright/tests/office/servicescounseling/servicesCounselingTestFixture.js b/playwright/tests/office/servicescounseling/servicesCounselingTestFixture.js index ed665a487a4..08bc3343bc2 100644 --- a/playwright/tests/office/servicescounseling/servicesCounselingTestFixture.js +++ b/playwright/tests/office/servicescounseling/servicesCounselingTestFixture.js @@ -173,9 +173,9 @@ export class ServiceCounselorPage extends OfficePage { const deliveryLocation = await this.page.getByRole('group', { name: 'Delivery location' }); await deliveryLocation.getByLabel('Address 1').fill('448 Washington Blvd NE'); await deliveryLocation.getByLabel('Address 2').fill('Apt D3'); - await deliveryLocation.getByLabel('City').fill('Another City'); - await deliveryLocation.getByLabel('State').fill('AL'); - await deliveryLocation.getByLabel('ZIP').fill('36101'); + await deliveryLocation.getByTestId('delivery.address.city').fill('Another City'); + await deliveryLocation.getByLabel('State').selectOption({ label: 'AL' }); + await deliveryLocation.getByLabel('ZIP', { exact: true }).fill('36101'); await deliveryLocation.getByLabel('County').fill('MONTGOMERY'); // Remarks diff --git a/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx b/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx index 6efd78f282f..918106c34e3 100644 --- a/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx +++ b/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import { React, useState } from 'react'; import { Formik } from 'formik'; import PropTypes from 'prop-types'; import * as Yup from 'yup'; @@ -53,6 +53,7 @@ const EditPPMHeaderSummaryModal = ({ sectionType, sectionInfo, onClose, onSubmit otherwise: (schema) => schema, }), }); + const [isLookupErrorVisible, setIsLookupErrorVisible] = useState(false); return (
@@ -64,7 +65,49 @@ const EditPPMHeaderSummaryModal = ({ sectionType, sectionInfo, onClose, onSubmit

{title}

- {({ isValid, handleChange, setFieldTouched }) => { + {({ isValid, handleChange, setFieldTouched, values, setValues }) => { + const handlePickupZipCityChange = (value) => { + setValues( + { + ...values, + pickupAddress: { + ...values.pickupAddress, + city: value.city, + state: value.state ? value.state : '', + county: value.county, + postalCode: value.postalCode, + }, + }, + { shouldValidate: true }, + ); + + if (!value.city || !value.state || !value.county || !value.postalCode) { + setIsLookupErrorVisible(true); + } else { + setIsLookupErrorVisible(false); + } + }; + const handleDestinationZipCityChange = (value) => { + setValues( + { + ...values, + destinationAddress: { + ...values.destinationAddress, + city: value.city, + state: value.state ? value.state : '', + county: value.county, + postalCode: value.postalCode, + }, + }, + { shouldValidate: true }, + ); + + if (!value.city || !value.state || !value.county || !value.postalCode) { + setIsLookupErrorVisible(true); + } else { + setIsLookupErrorVisible(false); + } + }; return (
@@ -96,6 +139,8 @@ const EditPPMHeaderSummaryModal = ({ sectionType, sectionInfo, onClose, onSubmit legend="Pickup Address" className={styles.AddressFieldSet} formikFunctionsToValidatePostalCodeOnChange={{ handleChange, setFieldTouched }} + zipCityError={isLookupErrorVisible} + handleZipCityChange={handlePickupZipCityChange} /> )} {editItemName === 'destinationAddress' && ( @@ -104,6 +149,8 @@ const EditPPMHeaderSummaryModal = ({ sectionType, sectionInfo, onClose, onSubmit legend="Destination Address" className={styles.AddressFieldSet} formikFunctionsToValidatePostalCodeOnChange={{ handleChange, setFieldTouched }} + zipCityError={isLookupErrorVisible} + handleZipCityChange={handleDestinationZipCityChange} /> )}
diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index 072b4fe0080..db8fda704f1 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -146,6 +146,7 @@ export const AddressFields = ({ label="City" id={`city_${addressFieldsUUID.current}`} name={`${name}.city`} + data-testid={`${name}.city`} validate={validators?.city} isDisabled={zipCityEnabled} /> @@ -155,6 +156,7 @@ export const AddressFields = ({ label="County" id={`county_${addressFieldsUUID.current}`} name={`${name}.county`} + data-testid={`${name}.county`} validate={validators?.county} isDisabled={zipCityEnabled} /> From ecaf9a706c2a6b058b465799ead24a1069b29480 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 28 Aug 2024 15:26:53 +0000 Subject: [PATCH 048/216] fix edit tests --- .../EditPPMHeaderSummaryModal.test.jsx | 41 ++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.test.jsx b/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.test.jsx index 71f30bc1f8c..c5efef00e1a 100644 --- a/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.test.jsx +++ b/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.test.jsx @@ -1,9 +1,12 @@ import React from 'react'; import { render, screen, waitFor, act } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; +import { Provider } from 'react-redux'; import EditPPMHeaderSummaryModal from './EditPPMHeaderSummaryModal'; +import { configureStore } from 'shared/store'; + let onClose; let onSubmit; beforeEach(() => { @@ -28,6 +31,7 @@ describe('EditPPMHeaderSummaryModal', () => { streetAddress1: '987 Any Avenue', streetAddress2: 'P.O. Box 9876', streetAddress3: 'c/o Some Person', + county: 'SOLANO', }, pickupAddressObj: { city: 'Beverly Hills', @@ -39,6 +43,7 @@ describe('EditPPMHeaderSummaryModal', () => { streetAddress1: '123 Any Street', streetAddress2: 'P.O. Box 12345', streetAddress3: 'c/o Some Person', + county: 'LOS ANGELES', }, }; @@ -63,15 +68,19 @@ describe('EditPPMHeaderSummaryModal', () => { }); it('renders pickup address', async () => { + const mockStore = configureStore({}); + await act(async () => { render( - , + + + , ); }); @@ -83,15 +92,19 @@ describe('EditPPMHeaderSummaryModal', () => { }); it('renders destination address', async () => { + const mockStore = configureStore({}); + await act(async () => { render( - , + + + , ); }); From aa917f814a64ac70b3233a2b4fa90d9b6a386464 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 28 Aug 2024 20:24:09 +0000 Subject: [PATCH 049/216] linter fix --- .../Office/ShipmentForm/ShipmentForm.test.jsx | 134 ++++++++++-------- .../form/AddressFields/AddressFields.jsx | 7 + ...icesCounselingEditShipmentDetails.test.jsx | 4 + 3 files changed, 82 insertions(+), 63 deletions(-) diff --git a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx index 1ee9a49e59c..605c2da4e13 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx @@ -446,14 +446,14 @@ describe('ShipmentForm component', () => { await user.click(screen.getByLabelText('Use current address')); }); - expect((await screen.findAllByLabelText('Address 1'))[0]).toHaveValue( + expect(await screen.getByTestId('pickup.address.streetAddress1')).toHaveValue( defaultProps.currentResidence.streetAddress1, ); - expect(screen.getAllByLabelText(/Address 2/)[0]).toHaveValue(''); - expect(screen.getAllByLabelText('City')[0]).toHaveValue(defaultProps.currentResidence.city); - expect(screen.getAllByLabelText('State')[0]).toHaveValue(defaultProps.currentResidence.state); - expect(screen.getAllByLabelText('ZIP')[0]).toHaveValue(defaultProps.currentResidence.postalCode); + expect(screen.getByTestId('pickup.address.streetAddress2')).toHaveValue(''); + expect(screen.getByTestId('pickup.address.city')).toHaveValue(defaultProps.currentResidence.city); + expect(screen.getByTestId('pickup.address.state')).toHaveValue(defaultProps.currentResidence.state); + expect(screen.getByTestId('pickup.address.postalCode')).toHaveValue(defaultProps.currentResidence.postalCode); }); it('renders a second address fieldset when the user has a delivery address', async () => { @@ -543,11 +543,11 @@ describe('ShipmentForm component', () => { expect(await screen.findByLabelText('Requested pickup date')).toHaveValue('01 Mar 2020'); expect(screen.getByLabelText('Use current address')).not.toBeChecked(); - expect(screen.getAllByLabelText('Address 1')[0]).toHaveValue('812 S 129th St'); - expect(screen.getAllByLabelText(/Address 2/)[0]).toHaveValue(''); - expect(screen.getAllByLabelText('City')[0]).toHaveValue('San Antonio'); - expect(screen.getAllByLabelText('State')[0]).toHaveValue('TX'); - expect(screen.getAllByLabelText('ZIP')[0]).toHaveValue('78234'); + expect(screen.getByTestId('pickup.address.streetAddress1')).toHaveValue('812 S 129th St'); + expect(screen.getByTestId('pickup.address.streetAddress2')).toHaveValue(''); + expect(screen.getByTestId('pickup.address.city')).toHaveValue('San Antonio'); + expect(screen.getByTestId('pickup.address.state')).toHaveValue('TX'); + expect(screen.getByTestId('pickup.address.postalCode')).toHaveValue('78234'); expect(screen.getAllByLabelText('First name')[0]).toHaveValue('Jason'); expect(screen.getAllByLabelText('Last name')[0]).toHaveValue('Ash'); expect(screen.getAllByLabelText('Phone')[0]).toHaveValue('999-999-9999'); @@ -591,11 +591,11 @@ describe('ShipmentForm component', () => { expect(await screen.findByLabelText('Requested pickup date')).toHaveValue('01 Mar 2020'); expect(screen.getByLabelText('Use current address')).not.toBeChecked(); - expect(screen.getAllByLabelText('Address 1')[0]).toHaveValue('812 S 129th St'); - expect(screen.getAllByLabelText(/Address 2/)[0]).toHaveValue(''); - expect(screen.getAllByLabelText('City')[0]).toHaveValue('San Antonio'); - expect(screen.getAllByLabelText('State')[0]).toHaveValue('TX'); - expect(screen.getAllByLabelText('ZIP')[0]).toHaveValue('78234'); + expect(screen.getByTestId('pickup.address.streetAddress1')).toHaveValue('812 S 129th St'); + expect(screen.getByTestId('pickup.address.streetAddress2')).toHaveValue(''); + expect(screen.getByTestId('pickup.address.city')).toHaveValue('San Antonio'); + expect(screen.getByTestId('pickup.address.state')).toHaveValue('TX'); + expect(screen.getByTestId('pickup.address.postalCode')).toHaveValue('78234'); expect(screen.getAllByLabelText('First name')[0]).toHaveValue('Jason'); expect(screen.getAllByLabelText('Last name')[0]).toHaveValue('Ash'); expect(screen.getAllByLabelText('Phone')[0]).toHaveValue('999-999-9999'); @@ -1080,17 +1080,17 @@ describe('ShipmentForm component', () => { await act(async () => { await userEvent.type(screen.getByLabelText('Planned Departure Date'), '26 Mar 2022'); - await userEvent.type(screen.getAllByLabelText('Address 1')[0], 'Test Street 1'); - await userEvent.type(screen.getAllByLabelText('City')[0], 'TestOne City'); - const pickupStateInput = screen.getAllByLabelText('State')[0]; + await userEvent.type(screen.getByTestId('pickup.address.streetAddress1'), 'Test Street 1'); + await userEvent.type(screen.getByTestId('pickup.address.city'), 'TestOne City'); + const pickupStateInput = screen.getByTestId('pickup.address.state'); await userEvent.selectOptions(pickupStateInput, 'CA'); - await userEvent.type(screen.getAllByLabelText('ZIP')[0], '90210'); + await userEvent.type(screen.getByTestId('pickup.address.postalCode'), '90210'); - await userEvent.type(screen.getAllByLabelText('Address 1')[1], 'Test Street 3'); - await userEvent.type(screen.getAllByLabelText('City')[1], 'TestTwo City'); - const destinationStateInput = screen.getAllByLabelText('State')[1]; + await userEvent.type(screen.getByTestId('destination.address.streetAddress1'), 'Test Street 3'); + await userEvent.type(screen.getByTestId('destination.address.city'), 'TestTwo City'); + const destinationStateInput = screen.getByTestId('destination.address.state'); await userEvent.selectOptions(destinationStateInput, 'CA'); - await userEvent.type(screen.getAllByLabelText('ZIP')[1], '90210'); + await userEvent.type(screen.getByTestId('destination.address.postalCode'), '90210'); await userEvent.type(screen.getByLabelText('Estimated PPM weight'), '1000'); @@ -1266,63 +1266,67 @@ describe('ShipmentForm component', () => { expect(await screen.getByLabelText('Planned Departure Date')).toHaveValue('01 Apr 2022'); - expect(await screen.getAllByLabelText('Address 1')[0]).toHaveValue( + expect(await screen.getByTestId('pickup.address.streetAddress1')).toHaveValue( mockPPMShipment.ppmShipment.pickupAddress.streetAddress1, ); - expect(await screen.getAllByLabelText(/Address 2/)[0]).toHaveValue( + expect(await screen.getByTestId('pickup.address.streetAddress2')).toHaveValue( mockPPMShipment.ppmShipment.pickupAddress.streetAddress2, ); - expect(await screen.getAllByLabelText('City')[0]).toHaveValue(mockPPMShipment.ppmShipment.pickupAddress.city); - expect(await screen.getAllByLabelText('State')[0]).toHaveValue(mockPPMShipment.ppmShipment.pickupAddress.state); - expect(await screen.getAllByLabelText('ZIP')[0]).toHaveValue( + expect(await screen.getByTestId('pickup.address.city')).toHaveValue( + mockPPMShipment.ppmShipment.pickupAddress.city, + ); + expect(await screen.getByTestId('pickup.address.state')).toHaveValue( + mockPPMShipment.ppmShipment.pickupAddress.state, + ); + expect(await screen.getByTestId('pickup.address.postalCode')).toHaveValue( mockPPMShipment.ppmShipment.pickupAddress.postalCode, ); - expect(await screen.getAllByLabelText('Address 1')[1]).toHaveValue( + expect(await screen.getByTestId('secondaryPickup.address.streetAddress1')).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.streetAddress1, ); - expect(await screen.getAllByLabelText(/Address 2/)[1]).toHaveValue( + expect(await screen.getByTestId('secondaryPickup.address.streetAddress2')).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.streetAddress2, ); - expect(await screen.getAllByLabelText('City')[1]).toHaveValue( + expect(await screen.getByTestId('secondaryPickup.address.city')).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.city, ); - expect(await screen.getAllByLabelText('State')[1]).toHaveValue( + expect(await screen.getByTestId('secondaryPickup.address.state')).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.state, ); - expect(await screen.getAllByLabelText('ZIP')[1]).toHaveValue( + expect(await screen.getByTestId('secondaryPickup.address.postalCode')).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.postalCode, ); - expect(await screen.getAllByLabelText('Address 1')[2]).toHaveValue( + expect(await screen.getByTestId('destination.address.streetAddress1')).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.streetAddress1, ); - expect(await screen.getAllByLabelText(/Address 2/)[2]).toHaveValue( + expect(await screen.getByTestId('destination.address.streetAddress2')).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.streetAddress2, ); - expect(await screen.getAllByLabelText('City')[2]).toHaveValue( + expect(await screen.getByTestId('destination.address.city')).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.city, ); - expect(await screen.getAllByLabelText('State')[2]).toHaveValue( + expect(await screen.getByTestId('destination.address.state')).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.state, ); - expect(await screen.getAllByLabelText('ZIP')[2]).toHaveValue( + expect(await screen.getByTestId('destination.address.postalCode')).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.postalCode, ); - expect(await screen.getAllByLabelText('Address 1')[3]).toHaveValue( + expect(await screen.getByTestId('secondaryDestination.address.streetAddress1')).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.streetAddress1, ); - expect(await screen.getAllByLabelText(/Address 2/)[3]).toHaveValue( + expect(await screen.getByTestId('secondaryDestination.address.streetAddress2')).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.streetAddress2, ); - expect(await screen.getAllByLabelText('City')[3]).toHaveValue( + expect(await screen.getByTestId('secondaryDestination.address.city')).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.city, ); - expect(await screen.getAllByLabelText('State')[3]).toHaveValue( + expect(await screen.getByTestId('secondaryDestination.address.state')).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.state, ); - expect(await screen.getAllByLabelText('ZIP')[3]).toHaveValue( + expect(await screen.getByTestId('secondaryDestination.address.postalCode')).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.postalCode, ); @@ -1389,63 +1393,67 @@ describe('ShipmentForm component', () => { expect(await screen.getByLabelText('Planned Departure Date')).toHaveValue('01 Apr 2022'); - expect(await screen.getAllByLabelText('Address 1')[0]).toHaveValue( + expect(await screen.getByTestId('pickup.address.streetAddress1')).toHaveValue( mockPPMShipment.ppmShipment.pickupAddress.streetAddress1, ); - expect(await screen.getAllByLabelText(/Address 2/)[0]).toHaveValue( + expect(await screen.getByTestId('pickup.address.streetAddress2')).toHaveValue( mockPPMShipment.ppmShipment.pickupAddress.streetAddress2, ); - expect(await screen.getAllByLabelText('City')[0]).toHaveValue(mockPPMShipment.ppmShipment.pickupAddress.city); - expect(await screen.getAllByLabelText('State')[0]).toHaveValue(mockPPMShipment.ppmShipment.pickupAddress.state); - expect(await screen.getAllByLabelText('ZIP')[0]).toHaveValue( + expect(await screen.getByTestId('pickup.address.city')).toHaveValue( + mockPPMShipment.ppmShipment.pickupAddress.city, + ); + expect(await screen.getByTestId('pickup.address.state')).toHaveValue( + mockPPMShipment.ppmShipment.pickupAddress.state, + ); + expect(await screen.getByTestId('pickup.address.postalCode')).toHaveValue( mockPPMShipment.ppmShipment.pickupAddress.postalCode, ); - expect(await screen.getAllByLabelText('Address 1')[1]).toHaveValue( + expect(await screen.getByTestId('secondaryPickup.address.streetAddress1')).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.streetAddress1, ); - expect(await screen.getAllByLabelText(/Address 2/)[1]).toHaveValue( + expect(await screen.getByTestId('secondaryPickup.address.streetAddress2')).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.streetAddress2, ); - expect(await screen.getAllByLabelText('City')[1]).toHaveValue( + expect(await screen.getByTestId('secondaryPickup.address.city')).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.city, ); - expect(await screen.getAllByLabelText('State')[1]).toHaveValue( + expect(await screen.getByTestId('secondaryPickup.address.state')).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.state, ); - expect(await screen.getAllByLabelText('ZIP')[1]).toHaveValue( + expect(await screen.getByTestId('secondaryPickup.address.postalCode')).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.postalCode, ); - expect(await screen.getAllByLabelText('Address 1')[2]).toHaveValue( + expect(await screen.getByTestId('destination.address.streetAddress1')).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.streetAddress1, ); - expect(await screen.getAllByLabelText(/Address 2/)[2]).toHaveValue( + expect(await screen.getByTestId('destination.address.streetAddress2')).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.streetAddress2, ); - expect(await screen.getAllByLabelText('City')[2]).toHaveValue( + expect(await screen.getByTestId('destination.address.city')).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.city, ); - expect(await screen.getAllByLabelText('State')[2]).toHaveValue( + expect(screen.getByTestId('destination.address.state')).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.state, ); - expect(await screen.getAllByLabelText('ZIP')[2]).toHaveValue( + expect(await screen.getByTestId('destination.address.postalCode')).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.postalCode, ); - expect(await screen.getAllByLabelText('Address 1')[3]).toHaveValue( + expect(await screen.getByTestId('secondaryDestination.address.streetAddress1')).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.streetAddress1, ); - expect(await screen.getAllByLabelText(/Address 2/)[3]).toHaveValue( + expect(await screen.getByTestId('secondaryDestination.address.streetAddress2')).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.streetAddress2, ); - expect(await screen.getAllByLabelText('City')[3]).toHaveValue( + expect(await screen.getByTestId('secondaryDestination.address.city')).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.city, ); - expect(await screen.getAllByLabelText('State')[3]).toHaveValue( + expect(await screen.getByTestId('secondaryDestination.address.state')).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.state, ); - expect(await screen.getAllByLabelText('ZIP')[3]).toHaveValue( + expect(await screen.getByTestId('secondaryDestination.address.postalCode')).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.postalCode, ); diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index db8fda704f1..9212b048141 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -46,6 +46,7 @@ export const AddressFields = ({ label="ZIP" id={`zip_${addressFieldsUUID.current}`} name={`${name}.postalCode`} + data-testid={`${name}.postalCode`} maxLength={10} validate={validators?.postalCode} isDisabled={zipCityEnabled} @@ -64,6 +65,7 @@ export const AddressFields = ({ label="ZIP" id={`zip_${addressFieldsUUID.current}`} name={`${name}.postalCode`} + data-testid={`${name}.postalCode`} maxLength={10} validate={validators?.postalCode} isDisabled={zipCityEnabled} @@ -73,6 +75,7 @@ export const AddressFields = ({ const stateField = zipCityEnabled ? ( {handleZipCityChange && ( diff --git a/src/pages/Office/ServicesCounselingEditShipmentDetails/ServicesCounselingEditShipmentDetails.test.jsx b/src/pages/Office/ServicesCounselingEditShipmentDetails/ServicesCounselingEditShipmentDetails.test.jsx index 148cc0f04e2..f1e6a658f90 100644 --- a/src/pages/Office/ServicesCounselingEditShipmentDetails/ServicesCounselingEditShipmentDetails.test.jsx +++ b/src/pages/Office/ServicesCounselingEditShipmentDetails/ServicesCounselingEditShipmentDetails.test.jsx @@ -27,6 +27,7 @@ const mockTransportationOffice = [ postalCode: '', state: '', streetAddress1: '', + county: '', }, address_id: '46c4640b-c35e-4293-a2f1-36c7b629f903', affiliation: 'AIR_FORCE', @@ -63,6 +64,7 @@ jest.mock('components/LocationSearchBox/api', () => ({ postalCode: '85309', state: 'AZ', streetAddress1: 'n/a', + county: 'MARICOPA', }), ), })); @@ -81,6 +83,7 @@ const useEditShipmentQueriesReturnValue = { city: 'Fort Knox', state: 'KY', postalCode: '40121', + county: 'HARDIN', }, }, destinationDutyLocation: { @@ -89,6 +92,7 @@ const useEditShipmentQueriesReturnValue = { city: 'Fort Irwin', state: 'CA', postalCode: '92310', + county: 'SAN BERNARDINO', }, }, customer: { From 00ff654b0bc75f09f957181edbffb885bf7bb34d Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 28 Aug 2024 21:48:22 +0000 Subject: [PATCH 050/216] unique id for zip city input --- src/components/form/AddressFields/AddressFields.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index 9212b048141..e809baac043 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -122,7 +122,7 @@ export const AddressFields = ({ {handleZipCityChange && ( <> Date: Thu, 29 Aug 2024 00:36:38 +0000 Subject: [PATCH 051/216] playwright fixes --- .../primeSimulatorFlows.spec.js | 2 +- playwright/tests/office/txo/tooFlows.spec.js | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/playwright/tests/office/primesimulator/primeSimulatorFlows.spec.js b/playwright/tests/office/primesimulator/primeSimulatorFlows.spec.js index 5b6f56fbb57..fdbacb180b2 100644 --- a/playwright/tests/office/primesimulator/primeSimulatorFlows.spec.js +++ b/playwright/tests/office/primesimulator/primeSimulatorFlows.spec.js @@ -148,7 +148,7 @@ test.describe('Prime simulator user', () => { await page.locator('input[name="destinationAddress.city"]').fill('Joshua Tree'); await page.locator('select[name="destinationAddress.state"]').selectOption({ label: 'CA' }); await page.locator('input[name="destinationAddress.postalCode"]').fill('92252'); - await page.getByTestId('dropdown').nth(1).selectOption('Home of record (HOR)'); + await page.locator('select[name="destinationType"]').selectOption({ label: 'Home of record (HOR)' }); await page.getByText('Save').click(); await expect(page.getByText('Successfully updated shipment')).toHaveCount(1); diff --git a/playwright/tests/office/txo/tooFlows.spec.js b/playwright/tests/office/txo/tooFlows.spec.js index f857428c732..a83b5f6d175 100644 --- a/playwright/tests/office/txo/tooFlows.spec.js +++ b/playwright/tests/office/txo/tooFlows.spec.js @@ -745,12 +745,12 @@ test.describe('TOO user', () => { await expect(page.getByText('Changes sent to contractor.')).toBeVisible(); - const destinationAddress = page.getByRole('group', { name: 'Delivery location' }); - await expect(destinationAddress.getByLabel('Address 1')).toHaveValue('123 Any Street'); - await expect(destinationAddress.getByLabel('Address 2')).toHaveValue('P.O. Box 12345'); - await expect(destinationAddress.getByLabel('City')).toHaveValue('Beverly Hills'); - await expect(destinationAddress.getByLabel('State')).toHaveValue('CA'); - await expect(destinationAddress.getByLabel('ZIP')).toHaveValue('90210'); + const deliveryAddress = page.getByRole('group', { name: 'Delivery location' }); + await expect(deliveryAddress.getByTestId('delivery.address.streetAddress1')).toHaveValue('123 Any Street'); + await expect(deliveryAddress.getByTestId('delivery.address.streetAddress2')).toHaveValue('P.O. Box 12345'); + await expect(deliveryAddress.getByTestId('delivery.address.city')).toHaveValue('Beverly Hills'); + await expect(deliveryAddress.getByTestId('delivery.address.state')).toHaveValue('CA'); + await expect(deliveryAddress.getByTestId('delivery.address.postalCode')).toHaveValue('90210'); // Click save on the page await page.getByRole('button', { name: 'Save' }).click(); @@ -796,12 +796,12 @@ test.describe('TOO user', () => { await expect(page.getByTestId('modal')).not.toBeVisible(); await expect(page.getByText('Changes sent to contractor.')).toBeVisible(); - const destinationAddress = page.getByRole('group', { name: 'Delivery location' }); - await expect(destinationAddress.getByLabel('Address 1')).toHaveValue('123 Any Street'); - await expect(destinationAddress.getByLabel('Address 2')).toHaveValue('P.O. Box 12345'); - await expect(destinationAddress.getByLabel('City')).toHaveValue('Beverly Hills'); - await expect(destinationAddress.getByLabel('State')).toHaveValue('CA'); - await expect(destinationAddress.getByLabel('ZIP')).toHaveValue('90210'); + const deliveryAddress = page.getByRole('group', { name: 'Delivery location' }); + await expect(deliveryAddress.getByTestId('delivery.address.streetAddress1')).toHaveValue('123 Any Street'); + await expect(deliveryAddress.getByTestId('delivery.address.streetAddress2')).toHaveValue('P.O. Box 12345'); + await expect(deliveryAddress.getByTestId('delivery.address.city')).toHaveValue('Beverly Hills'); + await expect(deliveryAddress.getByTestId('delivery.address.state')).toHaveValue('CA'); + await expect(deliveryAddress.getByTestId('delivery.address.postalCode')).toHaveValue('90210'); // Save the approved destination address change await page.getByRole('button', { name: 'Save' }).click(); From 0c25f05c349dbbc1a2aace90b08b66eff5d40f7b Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Thu, 29 Aug 2024 13:36:49 +0000 Subject: [PATCH 052/216] shipment form test --- src/components/Office/ShipmentForm/ShipmentForm.test.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx index c448a8b3cb5..1203cb0905d 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx @@ -195,7 +195,6 @@ const defaultProps = { postalCode: '31905', streetAddress1: '123 Main', streetAddress2: '', - county: 'MUSCOGEE', }, serviceMember: { weightAllotment: { From ca45dea6c894ff599b7178e2514b84310d3a020f Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 30 Aug 2024 00:49:48 +0000 Subject: [PATCH 053/216] =?UTF-8?q?freaking=20tests...(=E2=95=AF=C2=B0?= =?UTF-8?q?=E2=96=A1=C2=B0)=E2=95=AF=EF=B8=B5=20=E2=94=BB=E2=94=81?= =?UTF-8?q?=E2=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Office/ShipmentForm/ShipmentForm.test.jsx | 221 +++++++++--------- .../Office/ShipmentWeight/ShipmentWeight.jsx | 1 + 2 files changed, 118 insertions(+), 104 deletions(-) diff --git a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx index 1203cb0905d..1aff79da08d 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx @@ -1,6 +1,7 @@ /* eslint-disable react/jsx-props-no-spreading */ import React from 'react'; -import { render, screen, waitFor, within, act } from '@testing-library/react'; +import { Formik } from 'formik'; +import { render, screen, waitFor, within, act, fireEvent } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import ShipmentForm from './ShipmentForm'; @@ -1360,35 +1361,47 @@ describe('ShipmentForm component', () => { validatePostalCode.mockImplementation(() => Promise.resolve(false)); renderWithRouter( - , + + + , ); await act(async () => { - await userEvent.type(screen.getByLabelText('Planned Departure Date'), '26 Mar 2022'); + await fireEvent.change(screen.getByLabelText('Planned Departure Date'), { target: { value: '26 Mar 2022' } }); - await userEvent.type(screen.getByTestId('pickup.address.streetAddress1'), 'Test Street 1'); - await userEvent.type(screen.getByTestId('pickup.address.city'), 'TestOne City'); + await fireEvent.change(screen.getByTestId('pickup.address.streetAddress1'), { + target: { value: 'Test Street 1' }, + }); + await fireEvent.change(screen.getByTestId('pickup.address.city'), { target: { value: 'TestOne City' } }); const pickupStateInput = screen.getByTestId('pickup.address.state'); await userEvent.selectOptions(pickupStateInput, 'CA'); - await userEvent.type(screen.getByTestId('pickup.address.postalCode'), '90210'); + await fireEvent.change(screen.getByTestId('pickup.address.postalCode'), { target: { value: '90210' } }); + await fireEvent.change(screen.getByTestId('pickup.address.county'), { target: { value: 'LOS ANGELES' } }); - await userEvent.type(screen.getByTestId('destination.address.streetAddress1'), 'Test Street 3'); - await userEvent.type(screen.getByTestId('destination.address.city'), 'TestTwo City'); + await fireEvent.change(screen.getByTestId('destination.address.streetAddress1'), { + target: { value: 'Test Street 3' }, + }); + await fireEvent.change(screen.getByTestId('destination.address.city'), { target: { value: 'TestTwo City' } }); const destinationStateInput = screen.getByTestId('destination.address.state'); await userEvent.selectOptions(destinationStateInput, 'CA'); - await userEvent.type(screen.getByTestId('destination.address.postalCode'), '90210'); - - await userEvent.type(screen.getByLabelText('Estimated PPM weight'), '1000'); + await fireEvent.change(screen.getByTestId('destination.address.postalCode'), { target: { value: '90210' } }); + await fireEvent.change(screen.getByTestId('destination.address.county'), { target: { value: 'LOS ANGELES' } }); + await fireEvent.change(screen.getByTestId('estimatedWeight'), { target: { value: '1000' } }); + await fireEvent.blur(screen.getByTestId('destination.address.county')); const saveButton = screen.getByRole('button', { name: 'Save and Continue' }); - expect(saveButton).not.toBeDisabled(); - await userEvent.click(saveButton); + + await waitFor(() => { + expect(saveButton).not.toBeDisabled(); + }); + + await fireEvent.click(saveButton); }); await waitFor(() => { @@ -1401,91 +1414,91 @@ describe('ShipmentForm component', () => { expect(mockNavigate).not.toHaveBeenCalled(); }); - it('saves the update to the counselor remarks when the save button is clicked', async () => { - const newCounselorRemarks = 'Counselor remarks'; - - const expectedPayload = { - body: { - customerRemarks: 'mock customer remarks', - counselorRemarks: newCounselorRemarks, - hasSecondaryDeliveryAddress: false, - hasSecondaryPickupAddress: false, - hasTertiaryDeliveryAddress: false, - hasTertiaryPickupAddress: false, - destinationAddress: { - streetAddress1: '441 SW Rio de la Plata Drive', - city: 'Tacoma', - state: 'WA', - postalCode: '98421', - streetAddress2: '', - county: 'PIERCE', - }, - pickupAddress: { - streetAddress1: '812 S 129th St', - city: 'San Antonio', - state: 'TX', - postalCode: '78234', - streetAddress2: '', - county: 'BEXAR', - }, - agents: [ - { - agentType: 'RELEASING_AGENT', - email: 'jasn@email.com', - firstName: 'Jason', - lastName: 'Ash', - phone: '999-999-9999', - }, - { - agentType: 'RECEIVING_AGENT', - email: 'rbaker@email.com', - firstName: 'Riley', - lastName: 'Baker', - phone: '863-555-9664', - }, - ], - requestedDeliveryDate: '2020-03-30', - requestedPickupDate: '2020-03-01', - shipmentType: SHIPMENT_OPTIONS.HHG, - }, - shipmentID: 'shipment123', - moveTaskOrderID: 'mock move id', - normalize: false, - }; - - const patchResponse = { - ...expectedPayload, - created_at: '2021-02-08T16:48:04.117Z', - updated_at: '2021-02-11T16:48:04.117Z', - }; - - const mockSubmitHandler = jest.fn(() => Promise.resolve(patchResponse)); - - renderWithRouter( - , - ); - const counselorRemarks = await screen.findByLabelText('Counselor remarks'); - - await act(async () => { - await userEvent.clear(counselorRemarks); - await userEvent.type(counselorRemarks, newCounselorRemarks); - const saveButton = screen.getByRole('button', { name: 'Save' }); - expect(saveButton).not.toBeDisabled(); - await userEvent.click(saveButton); - }); - - await waitFor(() => { - expect(mockSubmitHandler).toHaveBeenCalledWith(expectedPayload, { - onSuccess: expect.any(Function), - onError: expect.any(Function), - }); - }); - }); + // it('saves the update to the counselor remarks when the save button is clicked', async () => { + // const newCounselorRemarks = 'Counselor remarks'; + + // const expectedPayload = { + // body: { + // customerRemarks: 'mock customer remarks', + // counselorRemarks: newCounselorRemarks, + // hasSecondaryDeliveryAddress: false, + // hasSecondaryPickupAddress: false, + // hasTertiaryDeliveryAddress: false, + // hasTertiaryPickupAddress: false, + // destinationAddress: { + // streetAddress1: '441 SW Rio de la Plata Drive', + // city: 'Tacoma', + // state: 'WA', + // postalCode: '98421', + // streetAddress2: '', + // county: 'PIERCE', + // }, + // pickupAddress: { + // streetAddress1: '812 S 129th St', + // city: 'San Antonio', + // state: 'TX', + // postalCode: '78234', + // streetAddress2: '', + // county: 'BEXAR', + // }, + // agents: [ + // { + // agentType: 'RELEASING_AGENT', + // email: 'jasn@email.com', + // firstName: 'Jason', + // lastName: 'Ash', + // phone: '999-999-9999', + // }, + // { + // agentType: 'RECEIVING_AGENT', + // email: 'rbaker@email.com', + // firstName: 'Riley', + // lastName: 'Baker', + // phone: '863-555-9664', + // }, + // ], + // requestedDeliveryDate: '2020-03-30', + // requestedPickupDate: '2020-03-01', + // shipmentType: SHIPMENT_OPTIONS.HHG, + // }, + // shipmentID: 'shipment123', + // moveTaskOrderID: 'mock move id', + // normalize: false, + // }; + + // const patchResponse = { + // ...expectedPayload, + // created_at: '2021-02-08T16:48:04.117Z', + // updated_at: '2021-02-11T16:48:04.117Z', + // }; + + // const mockSubmitHandler = jest.fn(() => Promise.resolve(patchResponse)); + + // renderWithRouter( + // , + // ); + // const counselorRemarks = await screen.findByLabelText('Counselor remarks'); + + // await act(async () => { + // await userEvent.clear(counselorRemarks); + // await userEvent.type(counselorRemarks, newCounselorRemarks); + // const saveButton = screen.getByRole('button', { name: 'Save' }); + // expect(saveButton).not.toBeDisabled(); + // await userEvent.click(saveButton); + // }); + + // await waitFor(() => { + // expect(mockSubmitHandler).toHaveBeenCalledWith(expectedPayload, { + // onSuccess: expect.any(Function), + // onError: expect.any(Function), + // }); + // }); + // }); }); describe('external vendor shipment', () => { diff --git a/src/components/Office/ShipmentWeight/ShipmentWeight.jsx b/src/components/Office/ShipmentWeight/ShipmentWeight.jsx index 172e2b1a71f..b6b1f531b43 100644 --- a/src/components/Office/ShipmentWeight/ShipmentWeight.jsx +++ b/src/components/Office/ShipmentWeight/ShipmentWeight.jsx @@ -38,6 +38,7 @@ const ShipmentWeight = ({ onEstimatedWeightChange }) => { Date: Fri, 30 Aug 2024 19:58:08 +0000 Subject: [PATCH 054/216] restoring shipmentform test --- .../Office/ShipmentForm/ShipmentForm.test.jsx | 637 +++++------------- 1 file changed, 162 insertions(+), 475 deletions(-) diff --git a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx index 1aff79da08d..1ee9a49e59c 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx @@ -1,7 +1,6 @@ /* eslint-disable react/jsx-props-no-spreading */ import React from 'react'; -import { Formik } from 'formik'; -import { render, screen, waitFor, within, act, fireEvent } from '@testing-library/react'; +import { render, screen, waitFor, within, act } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import ShipmentForm from './ShipmentForm'; @@ -14,7 +13,6 @@ import { tooRoutes } from 'constants/routes'; import { MockProviders } from 'testUtils'; import { validatePostalCode } from 'utils/validation'; import { isBooleanFlagEnabled } from 'utils/featureFlags'; -import { dateSelectionIsWeekendHoliday } from 'services/ghcApi'; jest.mock('utils/featureFlags', () => ({ ...jest.requireActual('utils/featureFlags'), @@ -33,11 +31,6 @@ jest.mock('react-router-dom', () => ({ useNavigate: () => mockNavigate, })); -jest.mock('services/ghcApi', () => ({ - ...jest.requireActual('services/ghcApi'), - dateSelectionIsWeekendHoliday: jest.fn().mockImplementation(() => Promise.resolve()), -})); - const mockMtoShipment = { id: 'shipment123', moveTaskOrderId: 'mock move id', @@ -45,8 +38,6 @@ const mockMtoShipment = { counselorRemarks: 'mock counselor remarks', requestedPickupDate: '2020-03-01', requestedDeliveryDate: '2020-03-30', - // requestedPickupDate: '2021-06-07', - // requestedDeliveryDate: '2021-06-14', hasSecondaryDeliveryAddress: false, hasSecondaryPickupAddress: false, pickupAddress: { @@ -176,7 +167,6 @@ const mockMtoShipment = { const defaultProps = { isCreatePage: true, submitHandler: jest.fn(), - dateSelectionIsWeekendHoliday: jest.fn().mockImplementation(() => Promise.resolve()), newDutyLocationAddress: { city: 'Fort Benning', state: 'GA', @@ -196,6 +186,7 @@ const defaultProps = { postalCode: '31905', streetAddress1: '123 Main', streetAddress2: '', + county: 'MUSCOGEE', }, serviceMember: { weightAllotment: { @@ -447,35 +438,6 @@ describe('ShipmentForm component', () => { expect(screen.getByLabelText('Counselor remarks')).toBeInstanceOf(HTMLTextAreaElement); }); - it('Service Counselor - renders date alert warnings for pickup/delivery on date picker selection', async () => { - const expectedDateSelectionIsWeekendHolidayResponse = { - country_code: 'US', - country_name: 'United States', - is_weekend: true, - is_holiday: false, - }; - dateSelectionIsWeekendHoliday.mockImplementation(() => - Promise.resolve({ data: JSON.stringify(expectedDateSelectionIsWeekendHolidayResponse) }), - ); - renderWithRouter(); - expect(await screen.findByText('HHG')).toHaveClass('usa-tag'); - - await userEvent.type(screen.getByLabelText('Requested pickup date'), '26 Mar 2024'); - await userEvent.type(screen.getByLabelText('Requested delivery date'), '30 Mar 2024'); - await waitFor(() => { - expect( - screen.getByText( - /Requested pickup date 26 Mar 2024 is on a weekend in the United States. This date may not be accepted. A government representative may not be available to provide assistance on this date./, - ), - ).toHaveClass('usa-alert__text'); - expect( - screen.getByText( - /Requested delivery date 30 Mar 2024 is on a weekend in the United States. This date may not be accepted. A government representative may not be available to provide assistance on this date./, - ), - ).toHaveClass('usa-alert__text'); - }); - }); - it('uses the current residence address for pickup address when checked', async () => { const user = userEvent.setup(); renderWithRouter(); @@ -484,14 +446,14 @@ describe('ShipmentForm component', () => { await user.click(screen.getByLabelText('Use current address')); }); - expect(await screen.getByTestId('pickup.address.streetAddress1')).toHaveValue( + expect((await screen.findAllByLabelText('Address 1'))[0]).toHaveValue( defaultProps.currentResidence.streetAddress1, ); - expect(screen.getByTestId('pickup.address.streetAddress2')).toHaveValue(''); - expect(screen.getByTestId('pickup.address.city')).toHaveValue(defaultProps.currentResidence.city); - expect(screen.getByTestId('pickup.address.state')).toHaveValue(defaultProps.currentResidence.state); - expect(screen.getByTestId('pickup.address.postalCode')).toHaveValue(defaultProps.currentResidence.postalCode); + expect(screen.getAllByLabelText(/Address 2/)[0]).toHaveValue(''); + expect(screen.getAllByLabelText('City')[0]).toHaveValue(defaultProps.currentResidence.city); + expect(screen.getAllByLabelText('State')[0]).toHaveValue(defaultProps.currentResidence.state); + expect(screen.getAllByLabelText('ZIP')[0]).toHaveValue(defaultProps.currentResidence.postalCode); }); it('renders a second address fieldset when the user has a delivery address', async () => { @@ -570,17 +532,6 @@ describe('ShipmentForm component', () => { describe('editing an already existing HHG shipment', () => { it('renders the HHG shipment form with pre-filled values', async () => { - // For some reason need this mock here. - const expectedDateSelectionIsWeekendHolidayResponse = { - country_code: 'US', - country_name: 'United States', - is_weekend: false, - is_holiday: false, - }; - dateSelectionIsWeekendHoliday.mockImplementation(() => - Promise.resolve({ data: JSON.stringify(expectedDateSelectionIsWeekendHolidayResponse) }), - ); - renderWithRouter( { expect(await screen.findByLabelText('Requested pickup date')).toHaveValue('01 Mar 2020'); expect(screen.getByLabelText('Use current address')).not.toBeChecked(); - expect(screen.getByTestId('pickup.address.streetAddress1')).toHaveValue('812 S 129th St'); - expect(screen.getByTestId('pickup.address.streetAddress2')).toHaveValue(''); - expect(screen.getByTestId('pickup.address.city')).toHaveValue('San Antonio'); - expect(screen.getByTestId('pickup.address.state')).toHaveValue('TX'); - expect(screen.getByTestId('pickup.address.postalCode')).toHaveValue('78234'); + expect(screen.getAllByLabelText('Address 1')[0]).toHaveValue('812 S 129th St'); + expect(screen.getAllByLabelText(/Address 2/)[0]).toHaveValue(''); + expect(screen.getAllByLabelText('City')[0]).toHaveValue('San Antonio'); + expect(screen.getAllByLabelText('State')[0]).toHaveValue('TX'); + expect(screen.getAllByLabelText('ZIP')[0]).toHaveValue('78234'); expect(screen.getAllByLabelText('First name')[0]).toHaveValue('Jason'); expect(screen.getAllByLabelText('Last name')[0]).toHaveValue('Ash'); expect(screen.getAllByLabelText('Phone')[0]).toHaveValue('999-999-9999'); @@ -640,11 +591,11 @@ describe('ShipmentForm component', () => { expect(await screen.findByLabelText('Requested pickup date')).toHaveValue('01 Mar 2020'); expect(screen.getByLabelText('Use current address')).not.toBeChecked(); - expect(screen.getByTestId('pickup.address.streetAddress1')).toHaveValue('812 S 129th St'); - expect(screen.getByTestId('pickup.address.streetAddress2')).toHaveValue(''); - expect(screen.getByTestId('pickup.address.city')).toHaveValue('San Antonio'); - expect(screen.getByTestId('pickup.address.state')).toHaveValue('TX'); - expect(screen.getByTestId('pickup.address.postalCode')).toHaveValue('78234'); + expect(screen.getAllByLabelText('Address 1')[0]).toHaveValue('812 S 129th St'); + expect(screen.getAllByLabelText(/Address 2/)[0]).toHaveValue(''); + expect(screen.getAllByLabelText('City')[0]).toHaveValue('San Antonio'); + expect(screen.getAllByLabelText('State')[0]).toHaveValue('TX'); + expect(screen.getAllByLabelText('ZIP')[0]).toHaveValue('78234'); expect(screen.getAllByLabelText('First name')[0]).toHaveValue('Jason'); expect(screen.getAllByLabelText('Last name')[0]).toHaveValue('Ash'); expect(screen.getAllByLabelText('Phone')[0]).toHaveValue('999-999-9999'); @@ -1005,138 +956,6 @@ describe('ShipmentForm component', () => { }); describe('as a TOO', () => { - it('create new - HHG: displays date alerts for pickup/delivery for weekends', async () => { - const expectedDateSelectionIsWeekendHolidayResponse = { - country_code: 'US', - country_name: 'United States', - is_weekend: true, - is_holiday: false, - }; - dateSelectionIsWeekendHoliday.mockImplementation(() => - Promise.resolve({ data: JSON.stringify(expectedDateSelectionIsWeekendHolidayResponse) }), - ); - renderWithRouter( - , - ); - expect(await screen.findByText('HHG')).toHaveClass('usa-tag'); - await userEvent.type(screen.getByLabelText('Requested pickup date'), '26 Mar 2024'); - await userEvent.type(screen.getByLabelText('Requested delivery date'), '30 Mar 2024'); - await waitFor(() => { - expect( - screen.getByText( - /Requested pickup date 26 Mar 2024 is on a weekend in the United States. This date may not be accepted. A government representative may not be available to provide assistance on this date./, - ), - ).toHaveClass('usa-alert__text'); - expect( - screen.getByText( - /Requested delivery date 30 Mar 2024 is on a weekend in the United States. This date may not be accepted. A government representative may not be available to provide assistance on this date./, - ), - ).toHaveClass('usa-alert__text'); - }); - }); - - it('edit-HHG: pageload displays date alerts for pickup/delivery for weekends', async () => { - const expectedDateSelectionIsWeekendHolidayResponse = { - country_code: 'US', - country_name: 'United States', - is_weekend: true, - is_holiday: false, - }; - dateSelectionIsWeekendHoliday.mockImplementation(() => - Promise.resolve({ data: JSON.stringify(expectedDateSelectionIsWeekendHolidayResponse) }), - ); - renderWithRouter( - , - ); - expect(await screen.findByText('HHG')).toHaveClass('usa-tag'); - expect(screen.queryByRole('heading', { level: 2, name: 'Vendor' })).not.toBeInTheDocument(); - expect(await screen.findByLabelText('Requested pickup date')).toHaveValue('01 Mar 2020'); - expect(await screen.findByLabelText('Requested delivery date')).toHaveValue('30 Mar 2020'); - await waitFor(() => { - expect( - screen.getByText( - /Requested pickup date 01 Mar 2020 is on a weekend in the United States. This date may not be accepted. A government representative may not be available to provide assistance on this date./, - ), - ).toHaveClass('usa-alert__text'); - expect( - screen.getByText( - /Requested delivery date 30 Mar 2020 is on a weekend in the United States. This date may not be accepted. A government representative may not be available to provide assistance on this date./, - ), - ).toHaveClass('usa-alert__text'); - }); - }); - - it('edit-HHG: pageload displays date alerts for pickup/delivery for holiday', async () => { - const expectedDateSelectionIsWeekendHolidayResponse = { - country_code: 'US', - country_name: 'United States', - is_weekend: false, - is_holiday: true, - }; - dateSelectionIsWeekendHoliday.mockImplementation(() => - Promise.resolve({ data: JSON.stringify(expectedDateSelectionIsWeekendHolidayResponse) }), - ); - renderWithRouter( - , - ); - expect(await screen.findByText('HHG')).toHaveClass('usa-tag'); - await waitFor(() => { - expect( - screen.getByText( - /Requested pickup date 01 Mar 2020 is on a holiday in the United States. This date may not be accepted. A government representative may not be available to provide assistance on this date./, - ), - ).toHaveClass('usa-alert__text'); - expect( - screen.getByText( - /Requested delivery date 30 Mar 2020 is on a holiday in the United States. This date may not be accepted. A government representative may not be available to provide assistance on this date./, - ), - ).toHaveClass('usa-alert__text'); - }); - }); - - it('edit-HHG: pageload displays date alerts for pickup/delivery for weekend and holiday', async () => { - const expectedDateSelectionIsWeekendHolidayResponse = { - country_code: 'US', - country_name: 'United States', - is_weekend: true, - is_holiday: true, - }; - dateSelectionIsWeekendHoliday.mockImplementation(() => - Promise.resolve({ data: JSON.stringify(expectedDateSelectionIsWeekendHolidayResponse) }), - ); - renderWithRouter( - , - ); - expect(await screen.findByText('HHG')).toHaveClass('usa-tag'); - await waitFor(() => { - expect( - screen.getByText( - /Requested pickup date 01 Mar 2020 is on a holiday and weekend in the United States. This date may not be accepted. A government representative may not be available to provide assistance on this date./, - ), - ).toHaveClass('usa-alert__text'); - expect( - screen.getByText( - /Requested delivery date 30 Mar 2020 is on a holiday and weekend in the United States. This date may not be accepted. A government representative may not be available to provide assistance on this date./, - ), - ).toHaveClass('usa-alert__text'); - }); - }); - it('renders the HHG shipment form', async () => { renderWithRouter(); @@ -1161,63 +980,6 @@ describe('ShipmentForm component', () => { expect(screen.getByRole('heading', { level: 2, name: 'Storage facility address' })).toBeInTheDocument(); }); - it('create new - NTS: displays date alerts for pickup/delivery for weekends', async () => { - const expectedDateSelectionIsWeekendHolidayResponse = { - country_code: 'US', - country_name: 'United States', - is_weekend: true, - is_holiday: false, - }; - dateSelectionIsWeekendHoliday.mockImplementation(() => - Promise.resolve({ data: JSON.stringify(expectedDateSelectionIsWeekendHolidayResponse) }), - ); - renderWithRouter( - , - ); - expect(await screen.findByText('NTS')).toHaveClass('usa-tag'); - await userEvent.type(screen.getByLabelText('Requested pickup date'), '26 Mar 2024'); - await waitFor(() => { - expect( - screen.getByText( - /Requested pickup date 26 Mar 2024 is on a weekend in the United States. This date may not be accepted. A government representative may not be available to provide assistance on this date./, - ), - ).toHaveClass('usa-alert__text'); - }); - }); - - it('edit-NTS: pageload displays date alerts for pickup/delivery for weekend and holiday', async () => { - const expectedDateSelectionIsWeekendHolidayResponse = { - country_code: 'US', - country_name: 'United States', - is_weekend: true, - is_holiday: true, - }; - dateSelectionIsWeekendHoliday.mockImplementation(() => - Promise.resolve({ data: JSON.stringify(expectedDateSelectionIsWeekendHolidayResponse) }), - ); - renderWithRouter( - , - ); - expect(await screen.findByText('NTS')).toHaveClass('usa-tag'); - await waitFor(() => { - expect( - screen.getByText( - /Requested pickup date 01 Mar 2020 is on a holiday and weekend in the United States. This date may not be accepted. A government representative may not be available to provide assistance on this date./, - ), - ).toHaveClass('usa-alert__text'); - expect( - screen.getByText( - /Requested delivery date 30 Mar 2020 is on a holiday and weekend in the United States. This date may not be accepted. A government representative may not be available to provide assistance on this date./, - ), - ).toHaveClass('usa-alert__text'); - }); - }); - it('renders the NTS release shipment form', async () => { renderWithRouter( , @@ -1231,61 +993,6 @@ describe('ShipmentForm component', () => { }); }); - it('edit-NTSR: pageload displays date alerts for pickup/delivery for weekend and holiday', async () => { - const expectedDateSelectionIsWeekendHolidayResponse = { - country_code: 'US', - country_name: 'United States', - is_weekend: true, - is_holiday: true, - }; - dateSelectionIsWeekendHoliday.mockImplementation(() => - Promise.resolve({ data: JSON.stringify(expectedDateSelectionIsWeekendHolidayResponse) }), - ); - renderWithRouter( - , - ); - expect(await screen.findByText('NTS-release')).toHaveClass('usa-tag'); - expect( - screen.getByText( - 'Requested pickup date 01 Mar 2020 is on a holiday and weekend in the United States. This date may not be accepted. A government representative may not be available to provide assistance on this date.', - ), - ).toHaveClass('usa-alert__text'); - expect( - screen.getByText( - /Requested delivery date 30 Mar 2020 is on a holiday and weekend in the United States. This date may not be accepted. A government representative may not be available to provide assistance on this date./, - ), - ).toHaveClass('usa-alert__text'); - }); - - it('create new - NTSR: displays date alerts for pickup/delivery for weekends', async () => { - const expectedDateSelectionIsWeekendHolidayResponse = { - country_code: 'US', - country_name: 'United States', - is_weekend: true, - is_holiday: false, - }; - dateSelectionIsWeekendHoliday.mockImplementation(() => - Promise.resolve({ data: JSON.stringify(expectedDateSelectionIsWeekendHolidayResponse) }), - ); - renderWithRouter( - , - ); - expect(await screen.findByText('NTS-release')).toHaveClass('usa-tag'); - await userEvent.type(screen.getByLabelText('Requested delivery date'), '01 Mar 2024'); - await waitFor(() => { - expect( - screen.getByText( - /Requested delivery date 01 Mar 2024 is on a weekend in the United States. This date may not be accepted. A government representative may not be available to provide assistance on this date./, - ), - ).toHaveClass('usa-alert__text'); - }); - }); - describe('filling the form', () => { it('shows an error if the submitHandler returns an error', async () => { const mockSubmitHandler = jest.fn((payload, { onError }) => { @@ -1361,47 +1068,35 @@ describe('ShipmentForm component', () => { validatePostalCode.mockImplementation(() => Promise.resolve(false)); renderWithRouter( - - - , + , ); await act(async () => { - await fireEvent.change(screen.getByLabelText('Planned Departure Date'), { target: { value: '26 Mar 2022' } }); + await userEvent.type(screen.getByLabelText('Planned Departure Date'), '26 Mar 2022'); - await fireEvent.change(screen.getByTestId('pickup.address.streetAddress1'), { - target: { value: 'Test Street 1' }, - }); - await fireEvent.change(screen.getByTestId('pickup.address.city'), { target: { value: 'TestOne City' } }); - const pickupStateInput = screen.getByTestId('pickup.address.state'); + await userEvent.type(screen.getAllByLabelText('Address 1')[0], 'Test Street 1'); + await userEvent.type(screen.getAllByLabelText('City')[0], 'TestOne City'); + const pickupStateInput = screen.getAllByLabelText('State')[0]; await userEvent.selectOptions(pickupStateInput, 'CA'); - await fireEvent.change(screen.getByTestId('pickup.address.postalCode'), { target: { value: '90210' } }); - await fireEvent.change(screen.getByTestId('pickup.address.county'), { target: { value: 'LOS ANGELES' } }); + await userEvent.type(screen.getAllByLabelText('ZIP')[0], '90210'); - await fireEvent.change(screen.getByTestId('destination.address.streetAddress1'), { - target: { value: 'Test Street 3' }, - }); - await fireEvent.change(screen.getByTestId('destination.address.city'), { target: { value: 'TestTwo City' } }); - const destinationStateInput = screen.getByTestId('destination.address.state'); + await userEvent.type(screen.getAllByLabelText('Address 1')[1], 'Test Street 3'); + await userEvent.type(screen.getAllByLabelText('City')[1], 'TestTwo City'); + const destinationStateInput = screen.getAllByLabelText('State')[1]; await userEvent.selectOptions(destinationStateInput, 'CA'); - await fireEvent.change(screen.getByTestId('destination.address.postalCode'), { target: { value: '90210' } }); - await fireEvent.change(screen.getByTestId('destination.address.county'), { target: { value: 'LOS ANGELES' } }); - - await fireEvent.change(screen.getByTestId('estimatedWeight'), { target: { value: '1000' } }); - await fireEvent.blur(screen.getByTestId('destination.address.county')); - const saveButton = screen.getByRole('button', { name: 'Save and Continue' }); + await userEvent.type(screen.getAllByLabelText('ZIP')[1], '90210'); - await waitFor(() => { - expect(saveButton).not.toBeDisabled(); - }); + await userEvent.type(screen.getByLabelText('Estimated PPM weight'), '1000'); - await fireEvent.click(saveButton); + const saveButton = screen.getByRole('button', { name: 'Save and Continue' }); + expect(saveButton).not.toBeDisabled(); + await userEvent.click(saveButton); }); await waitFor(() => { @@ -1414,91 +1109,91 @@ describe('ShipmentForm component', () => { expect(mockNavigate).not.toHaveBeenCalled(); }); - // it('saves the update to the counselor remarks when the save button is clicked', async () => { - // const newCounselorRemarks = 'Counselor remarks'; - - // const expectedPayload = { - // body: { - // customerRemarks: 'mock customer remarks', - // counselorRemarks: newCounselorRemarks, - // hasSecondaryDeliveryAddress: false, - // hasSecondaryPickupAddress: false, - // hasTertiaryDeliveryAddress: false, - // hasTertiaryPickupAddress: false, - // destinationAddress: { - // streetAddress1: '441 SW Rio de la Plata Drive', - // city: 'Tacoma', - // state: 'WA', - // postalCode: '98421', - // streetAddress2: '', - // county: 'PIERCE', - // }, - // pickupAddress: { - // streetAddress1: '812 S 129th St', - // city: 'San Antonio', - // state: 'TX', - // postalCode: '78234', - // streetAddress2: '', - // county: 'BEXAR', - // }, - // agents: [ - // { - // agentType: 'RELEASING_AGENT', - // email: 'jasn@email.com', - // firstName: 'Jason', - // lastName: 'Ash', - // phone: '999-999-9999', - // }, - // { - // agentType: 'RECEIVING_AGENT', - // email: 'rbaker@email.com', - // firstName: 'Riley', - // lastName: 'Baker', - // phone: '863-555-9664', - // }, - // ], - // requestedDeliveryDate: '2020-03-30', - // requestedPickupDate: '2020-03-01', - // shipmentType: SHIPMENT_OPTIONS.HHG, - // }, - // shipmentID: 'shipment123', - // moveTaskOrderID: 'mock move id', - // normalize: false, - // }; - - // const patchResponse = { - // ...expectedPayload, - // created_at: '2021-02-08T16:48:04.117Z', - // updated_at: '2021-02-11T16:48:04.117Z', - // }; - - // const mockSubmitHandler = jest.fn(() => Promise.resolve(patchResponse)); - - // renderWithRouter( - // , - // ); - // const counselorRemarks = await screen.findByLabelText('Counselor remarks'); - - // await act(async () => { - // await userEvent.clear(counselorRemarks); - // await userEvent.type(counselorRemarks, newCounselorRemarks); - // const saveButton = screen.getByRole('button', { name: 'Save' }); - // expect(saveButton).not.toBeDisabled(); - // await userEvent.click(saveButton); - // }); - - // await waitFor(() => { - // expect(mockSubmitHandler).toHaveBeenCalledWith(expectedPayload, { - // onSuccess: expect.any(Function), - // onError: expect.any(Function), - // }); - // }); - // }); + it('saves the update to the counselor remarks when the save button is clicked', async () => { + const newCounselorRemarks = 'Counselor remarks'; + + const expectedPayload = { + body: { + customerRemarks: 'mock customer remarks', + counselorRemarks: newCounselorRemarks, + hasSecondaryDeliveryAddress: false, + hasSecondaryPickupAddress: false, + hasTertiaryDeliveryAddress: false, + hasTertiaryPickupAddress: false, + destinationAddress: { + streetAddress1: '441 SW Rio de la Plata Drive', + city: 'Tacoma', + state: 'WA', + postalCode: '98421', + streetAddress2: '', + county: 'PIERCE', + }, + pickupAddress: { + streetAddress1: '812 S 129th St', + city: 'San Antonio', + state: 'TX', + postalCode: '78234', + streetAddress2: '', + county: 'BEXAR', + }, + agents: [ + { + agentType: 'RELEASING_AGENT', + email: 'jasn@email.com', + firstName: 'Jason', + lastName: 'Ash', + phone: '999-999-9999', + }, + { + agentType: 'RECEIVING_AGENT', + email: 'rbaker@email.com', + firstName: 'Riley', + lastName: 'Baker', + phone: '863-555-9664', + }, + ], + requestedDeliveryDate: '2020-03-30', + requestedPickupDate: '2020-03-01', + shipmentType: SHIPMENT_OPTIONS.HHG, + }, + shipmentID: 'shipment123', + moveTaskOrderID: 'mock move id', + normalize: false, + }; + + const patchResponse = { + ...expectedPayload, + created_at: '2021-02-08T16:48:04.117Z', + updated_at: '2021-02-11T16:48:04.117Z', + }; + + const mockSubmitHandler = jest.fn(() => Promise.resolve(patchResponse)); + + renderWithRouter( + , + ); + const counselorRemarks = await screen.findByLabelText('Counselor remarks'); + + await act(async () => { + await userEvent.clear(counselorRemarks); + await userEvent.type(counselorRemarks, newCounselorRemarks); + const saveButton = screen.getByRole('button', { name: 'Save' }); + expect(saveButton).not.toBeDisabled(); + await userEvent.click(saveButton); + }); + + await waitFor(() => { + expect(mockSubmitHandler).toHaveBeenCalledWith(expectedPayload, { + onSuccess: expect.any(Function), + onError: expect.any(Function), + }); + }); + }); }); describe('external vendor shipment', () => { @@ -1571,67 +1266,63 @@ describe('ShipmentForm component', () => { expect(await screen.getByLabelText('Planned Departure Date')).toHaveValue('01 Apr 2022'); - expect(await screen.getByTestId('pickup.address.streetAddress1')).toHaveValue( + expect(await screen.getAllByLabelText('Address 1')[0]).toHaveValue( mockPPMShipment.ppmShipment.pickupAddress.streetAddress1, ); - expect(await screen.getByTestId('pickup.address.streetAddress2')).toHaveValue( + expect(await screen.getAllByLabelText(/Address 2/)[0]).toHaveValue( mockPPMShipment.ppmShipment.pickupAddress.streetAddress2, ); - expect(await screen.getByTestId('pickup.address.city')).toHaveValue( - mockPPMShipment.ppmShipment.pickupAddress.city, - ); - expect(await screen.getByTestId('pickup.address.state')).toHaveValue( - mockPPMShipment.ppmShipment.pickupAddress.state, - ); - expect(await screen.getByTestId('pickup.address.postalCode')).toHaveValue( + expect(await screen.getAllByLabelText('City')[0]).toHaveValue(mockPPMShipment.ppmShipment.pickupAddress.city); + expect(await screen.getAllByLabelText('State')[0]).toHaveValue(mockPPMShipment.ppmShipment.pickupAddress.state); + expect(await screen.getAllByLabelText('ZIP')[0]).toHaveValue( mockPPMShipment.ppmShipment.pickupAddress.postalCode, ); - expect(await screen.getByTestId('secondaryPickup.address.streetAddress1')).toHaveValue( + expect(await screen.getAllByLabelText('Address 1')[1]).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.streetAddress1, ); - expect(await screen.getByTestId('secondaryPickup.address.streetAddress2')).toHaveValue( + expect(await screen.getAllByLabelText(/Address 2/)[1]).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.streetAddress2, ); - expect(await screen.getByTestId('secondaryPickup.address.city')).toHaveValue( + expect(await screen.getAllByLabelText('City')[1]).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.city, ); - expect(await screen.getByTestId('secondaryPickup.address.state')).toHaveValue( + expect(await screen.getAllByLabelText('State')[1]).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.state, ); - expect(await screen.getByTestId('secondaryPickup.address.postalCode')).toHaveValue( + expect(await screen.getAllByLabelText('ZIP')[1]).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.postalCode, ); - expect(await screen.getByTestId('destination.address.streetAddress1')).toHaveValue( + expect(await screen.getAllByLabelText('Address 1')[2]).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.streetAddress1, ); - expect(await screen.getByTestId('destination.address.streetAddress2')).toHaveValue( + expect(await screen.getAllByLabelText(/Address 2/)[2]).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.streetAddress2, ); - expect(await screen.getByTestId('destination.address.city')).toHaveValue( + expect(await screen.getAllByLabelText('City')[2]).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.city, ); - expect(await screen.getByTestId('destination.address.state')).toHaveValue( + expect(await screen.getAllByLabelText('State')[2]).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.state, ); - expect(await screen.getByTestId('destination.address.postalCode')).toHaveValue( + expect(await screen.getAllByLabelText('ZIP')[2]).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.postalCode, ); - expect(await screen.getByTestId('secondaryDestination.address.streetAddress1')).toHaveValue( + expect(await screen.getAllByLabelText('Address 1')[3]).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.streetAddress1, ); - expect(await screen.getByTestId('secondaryDestination.address.streetAddress2')).toHaveValue( + expect(await screen.getAllByLabelText(/Address 2/)[3]).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.streetAddress2, ); - expect(await screen.getByTestId('secondaryDestination.address.city')).toHaveValue( + expect(await screen.getAllByLabelText('City')[3]).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.city, ); - expect(await screen.getByTestId('secondaryDestination.address.state')).toHaveValue( + expect(await screen.getAllByLabelText('State')[3]).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.state, ); - expect(await screen.getByTestId('secondaryDestination.address.postalCode')).toHaveValue( + expect(await screen.getAllByLabelText('ZIP')[3]).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.postalCode, ); @@ -1698,67 +1389,63 @@ describe('ShipmentForm component', () => { expect(await screen.getByLabelText('Planned Departure Date')).toHaveValue('01 Apr 2022'); - expect(await screen.getByTestId('pickup.address.streetAddress1')).toHaveValue( + expect(await screen.getAllByLabelText('Address 1')[0]).toHaveValue( mockPPMShipment.ppmShipment.pickupAddress.streetAddress1, ); - expect(await screen.getByTestId('pickup.address.streetAddress2')).toHaveValue( + expect(await screen.getAllByLabelText(/Address 2/)[0]).toHaveValue( mockPPMShipment.ppmShipment.pickupAddress.streetAddress2, ); - expect(await screen.getByTestId('pickup.address.city')).toHaveValue( - mockPPMShipment.ppmShipment.pickupAddress.city, - ); - expect(await screen.getByTestId('pickup.address.state')).toHaveValue( - mockPPMShipment.ppmShipment.pickupAddress.state, - ); - expect(await screen.getByTestId('pickup.address.postalCode')).toHaveValue( + expect(await screen.getAllByLabelText('City')[0]).toHaveValue(mockPPMShipment.ppmShipment.pickupAddress.city); + expect(await screen.getAllByLabelText('State')[0]).toHaveValue(mockPPMShipment.ppmShipment.pickupAddress.state); + expect(await screen.getAllByLabelText('ZIP')[0]).toHaveValue( mockPPMShipment.ppmShipment.pickupAddress.postalCode, ); - expect(await screen.getByTestId('secondaryPickup.address.streetAddress1')).toHaveValue( + expect(await screen.getAllByLabelText('Address 1')[1]).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.streetAddress1, ); - expect(await screen.getByTestId('secondaryPickup.address.streetAddress2')).toHaveValue( + expect(await screen.getAllByLabelText(/Address 2/)[1]).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.streetAddress2, ); - expect(await screen.getByTestId('secondaryPickup.address.city')).toHaveValue( + expect(await screen.getAllByLabelText('City')[1]).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.city, ); - expect(await screen.getByTestId('secondaryPickup.address.state')).toHaveValue( + expect(await screen.getAllByLabelText('State')[1]).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.state, ); - expect(await screen.getByTestId('secondaryPickup.address.postalCode')).toHaveValue( + expect(await screen.getAllByLabelText('ZIP')[1]).toHaveValue( mockPPMShipment.ppmShipment.secondaryPickupAddress.postalCode, ); - expect(await screen.getByTestId('destination.address.streetAddress1')).toHaveValue( + expect(await screen.getAllByLabelText('Address 1')[2]).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.streetAddress1, ); - expect(await screen.getByTestId('destination.address.streetAddress2')).toHaveValue( + expect(await screen.getAllByLabelText(/Address 2/)[2]).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.streetAddress2, ); - expect(await screen.getByTestId('destination.address.city')).toHaveValue( + expect(await screen.getAllByLabelText('City')[2]).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.city, ); - expect(screen.getByTestId('destination.address.state')).toHaveValue( + expect(await screen.getAllByLabelText('State')[2]).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.state, ); - expect(await screen.getByTestId('destination.address.postalCode')).toHaveValue( + expect(await screen.getAllByLabelText('ZIP')[2]).toHaveValue( mockPPMShipment.ppmShipment.destinationAddress.postalCode, ); - expect(await screen.getByTestId('secondaryDestination.address.streetAddress1')).toHaveValue( + expect(await screen.getAllByLabelText('Address 1')[3]).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.streetAddress1, ); - expect(await screen.getByTestId('secondaryDestination.address.streetAddress2')).toHaveValue( + expect(await screen.getAllByLabelText(/Address 2/)[3]).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.streetAddress2, ); - expect(await screen.getByTestId('secondaryDestination.address.city')).toHaveValue( + expect(await screen.getAllByLabelText('City')[3]).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.city, ); - expect(await screen.getByTestId('secondaryDestination.address.state')).toHaveValue( + expect(await screen.getAllByLabelText('State')[3]).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.state, ); - expect(await screen.getByTestId('secondaryDestination.address.postalCode')).toHaveValue( + expect(await screen.getAllByLabelText('ZIP')[3]).toHaveValue( mockPPMShipment.ppmShipment.secondaryDestinationAddress.postalCode, ); From 28e33db39b6d8734b8a5e9f849cd7bb851229e84 Mon Sep 17 00:00:00 2001 From: Cory Kleinjan Date: Fri, 30 Aug 2024 20:14:40 +0000 Subject: [PATCH 055/216] Udapting ShipmentForm tests --- .../Office/ShipmentForm/ShipmentForm.test.jsx | 48 ++++++++++++------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx index 1ee9a49e59c..33905368f79 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx @@ -733,7 +733,8 @@ describe('ShipmentForm component', () => { const officeRemarksAnswer = 'Here are my remarks from the office'; await act(async () => { await user.click(approvalYes); - await user.type(officeRemarks, officeRemarksAnswer); + officeRemarks.focus(); + await user.paste(officeRemarksAnswer); await user.click(save); }); @@ -892,7 +893,8 @@ describe('ShipmentForm component', () => { ); await act(async () => { - await userEvent.type(screen.getByLabelText('Requested pickup date'), '26 Mar 2022'); + screen.getByLabelText('Requested pickup date').focus(); + await userEvent.paste('26 Mar 2022'); await userEvent.click(screen.getByTestId('useCurrentResidence')); }); @@ -1078,21 +1080,29 @@ describe('ShipmentForm component', () => { ); await act(async () => { - await userEvent.type(screen.getByLabelText('Planned Departure Date'), '26 Mar 2022'); + screen.getByLabelText('Planned Departure Date').focus(); + await userEvent.paste('26 Mar 2022'); - await userEvent.type(screen.getAllByLabelText('Address 1')[0], 'Test Street 1'); - await userEvent.type(screen.getAllByLabelText('City')[0], 'TestOne City'); + screen.getAllByLabelText('Address 1')[0].focus(); + await userEvent.paste('Test Street 1'); + screen.getAllByLabelText('City')[0].focus(); + await userEvent.paste('TestOne City'); const pickupStateInput = screen.getAllByLabelText('State')[0]; await userEvent.selectOptions(pickupStateInput, 'CA'); - await userEvent.type(screen.getAllByLabelText('ZIP')[0], '90210'); + screen.getAllByLabelText('ZIP')[0].focus(); + await userEvent.paste('90210'); - await userEvent.type(screen.getAllByLabelText('Address 1')[1], 'Test Street 3'); - await userEvent.type(screen.getAllByLabelText('City')[1], 'TestTwo City'); + screen.getAllByLabelText('Address 1')[1].focus(); + await userEvent.paste('Test Street 3'); + screen.getAllByLabelText('City')[1].focus(); + await userEvent.paste('TestTwo City'); const destinationStateInput = screen.getAllByLabelText('State')[1]; await userEvent.selectOptions(destinationStateInput, 'CA'); - await userEvent.type(screen.getAllByLabelText('ZIP')[1], '90210'); + screen.getAllByLabelText('ZIP')[1].focus(); + await userEvent.paste('90210'); - await userEvent.type(screen.getByLabelText('Estimated PPM weight'), '1000'); + screen.getByLabelText('Estimated PPM weight').focus(); + await userEvent.paste('1000'); const saveButton = screen.getByRole('button', { name: 'Save and Continue' }); expect(saveButton).not.toBeDisabled(); @@ -1181,7 +1191,8 @@ describe('ShipmentForm component', () => { await act(async () => { await userEvent.clear(counselorRemarks); - await userEvent.type(counselorRemarks, newCounselorRemarks); + counselorRemarks.focus(); + await userEvent.paste(newCounselorRemarks); const saveButton = screen.getByRole('button', { name: 'Save' }); expect(saveButton).not.toBeDisabled(); await userEvent.click(saveButton); @@ -1532,7 +1543,8 @@ describe('ShipmentForm component', () => { expect(screen.queryByLabelText('Amount requested')).not.toBeInTheDocument(); await act(async () => { - await userEvent.type(screen.getByLabelText('Counselor remarks'), 'retirees are not given advances'); + screen.getByLabelText('Counselor remarks').focus(); + await userEvent.paste('retirees are not given advances'); await userEvent.tab(); }); @@ -1582,7 +1594,8 @@ describe('ShipmentForm component', () => { // Edit a requested advance amount await act(async () => { await userEvent.clear(advanceAmountInput); - await userEvent.type(advanceAmountInput, '2,000'); + advanceAmountInput.focus(); + await userEvent.paste('2,000'); advanceAmountInput.blur(); }); await waitFor(() => { @@ -1605,7 +1618,8 @@ describe('ShipmentForm component', () => { }); const advanceAmountRequested = screen.getByLabelText('Amount requested'); await act(async () => { - await userEvent.type(advanceAmountRequested, '0'); + advanceAmountRequested.focus(); + await userEvent.paste('0'); }); expect(advanceAmountRequested).toHaveValue('0'); @@ -1661,10 +1675,8 @@ describe('ShipmentForm component', () => { expect(requiredAlert[0]).toHaveTextContent('Required'); await act(async () => { - await userEvent.type( - screen.getByLabelText('Counselor remarks'), - 'I, a service counselor, have rejected your advance request', - ); + screen.getByLabelText('Counselor remarks').focus(); + await userEvent.paste('I, a service counselor, have rejected your advance request'); await userEvent.tab(); }); From 6f590b4bcd8e40cde1b58ba869831fc4992731fa Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Tue, 3 Sep 2024 16:35:53 +0000 Subject: [PATCH 056/216] added second alert for dates --- .../Office/ShipmentForm/ShipmentForm.jsx | 17 ++++++++---- .../Office/ShipmentForm/ShipmentForm.test.jsx | 27 ++++++++++--------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/components/Office/ShipmentForm/ShipmentForm.jsx b/src/components/Office/ShipmentForm/ShipmentForm.jsx index 69e13309a0c..994401757ce 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.jsx @@ -94,6 +94,7 @@ const ShipmentForm = (props) => { const navigate = useNavigate(); const [errorMessage, setErrorMessage] = useState(null); + const [datesErrorMessage, setDatesErrorMessage] = useState(null); const [successMessage, setSuccessMessage] = useState(null); const [shipmentAddressUpdateReviewErrorMessage, setShipmentAddressUpdateReviewErrorMessage] = useState(null); @@ -202,7 +203,7 @@ const ShipmentForm = (props) => { useEffect(() => { const onErrorHandler = (e) => { const { response } = e; - setErrorMessage(response?.body?.detail); + setDatesErrorMessage(response?.body?.detail); }; dateSelectionWeekendHolidayCheck( dateSelectionIsWeekendHoliday, @@ -219,7 +220,7 @@ const ShipmentForm = (props) => { useEffect(() => { const onErrorHandler = (e) => { const { response } = e; - setErrorMessage(response?.body?.detail); + setDatesErrorMessage(response?.body?.detail); }; dateSelectionWeekendHolidayCheck( dateSelectionIsWeekendHoliday, @@ -806,7 +807,7 @@ const ShipmentForm = (props) => { }); const onErrorHandler = (errResponse) => { const { response } = errResponse; - setErrorMessage(response?.body?.detail); + setDatesErrorMessage(response?.body?.detail); }; dateSelectionWeekendHolidayCheck( dateSelectionIsWeekendHoliday, @@ -829,7 +830,7 @@ const ShipmentForm = (props) => { }); const onErrorHandler = (errResponse) => { const { response } = errResponse; - setErrorMessage(response?.body?.detail); + setDatesErrorMessage(response?.body?.detail); }; dateSelectionWeekendHolidayCheck( dateSelectionIsWeekendHoliday, @@ -877,9 +878,15 @@ const ShipmentForm = (props) => { errorMessage={shipmentAddressUpdateReviewErrorMessage} setErrorMessage={setShipmentAddressUpdateReviewErrorMessage} /> + + {datesErrorMessage && ( + + {datesErrorMessage} + + )} {errorMessage && ( - + {errorMessage} )} diff --git a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx index 33905368f79..36262504ffc 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx @@ -1014,18 +1014,15 @@ describe('ShipmentForm component', () => { const saveButton = screen.getByRole('button', { name: 'Save' }); expect(saveButton).not.toBeDisabled(); - - await act(async () => { - await userEvent.click(saveButton); - }); + await userEvent.click(saveButton); await waitFor(() => { expect(mockSubmitHandler).toHaveBeenCalled(); }); - expect( - await screen.findByText('Something went wrong, and your changes were not saved. Please try again.'), - ).toBeInTheDocument(); + await waitFor(() => { + expect(screen.getByTestId('errorMessage')).toBeVisible(); + }); expect(mockNavigate).not.toHaveBeenCalled(); }); @@ -1056,9 +1053,9 @@ describe('ShipmentForm component', () => { expect(mockSubmitHandler).toHaveBeenCalled(); }); - expect( - await screen.findByText('Something went wrong, and your changes were not saved. Please try again.'), - ).toBeInTheDocument(); + await waitFor(() => { + expect(screen.getByTestId('errorMessage')).toBeVisible(); + }); expect(mockNavigate).not.toHaveBeenCalled(); }); @@ -1091,6 +1088,8 @@ describe('ShipmentForm component', () => { await userEvent.selectOptions(pickupStateInput, 'CA'); screen.getAllByLabelText('ZIP')[0].focus(); await userEvent.paste('90210'); + screen.getAllByLabelText('County')[0].focus(); + await userEvent.paste('LOS ANGELES'); screen.getAllByLabelText('Address 1')[1].focus(); await userEvent.paste('Test Street 3'); @@ -1100,6 +1099,8 @@ describe('ShipmentForm component', () => { await userEvent.selectOptions(destinationStateInput, 'CA'); screen.getAllByLabelText('ZIP')[1].focus(); await userEvent.paste('90210'); + screen.getAllByLabelText('County')[1].focus(); + await userEvent.paste('LOS ANGELES'); screen.getByLabelText('Estimated PPM weight').focus(); await userEvent.paste('1000'); @@ -1113,9 +1114,9 @@ describe('ShipmentForm component', () => { expect(mockSubmitHandler).toHaveBeenCalled(); }); - expect( - await screen.findByText('Something went wrong, and your changes were not saved. Please try again.'), - ).toBeInTheDocument(); + await waitFor(() => { + expect(screen.getByTestId('errorMessage')).toBeVisible(); + }); expect(mockNavigate).not.toHaveBeenCalled(); }); From 5194161b5b998dbacf963a33bbc8d39257596c2c Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Tue, 3 Sep 2024 22:03:25 +0000 Subject: [PATCH 057/216] fix storybook issues --- .../BackupAddressForm.stories.jsx | 67 +++++++----- .../EditContactInfoForm.stories.jsx | 65 ++++++----- .../ResidentialAddressForm.stories.jsx | 103 ++++++++++-------- .../CustomerContactInfoForm.stories.jsx | 63 ++++++----- .../EditPPMHeaderSummaryModal.stories.jsx | 11 +- 5 files changed, 179 insertions(+), 130 deletions(-) diff --git a/src/components/Customer/BackupAddressForm/BackupAddressForm.stories.jsx b/src/components/Customer/BackupAddressForm/BackupAddressForm.stories.jsx index 43ffd79bb94..28c84d56c49 100644 --- a/src/components/Customer/BackupAddressForm/BackupAddressForm.stories.jsx +++ b/src/components/Customer/BackupAddressForm/BackupAddressForm.stories.jsx @@ -1,7 +1,10 @@ import React from 'react'; +import { Provider } from 'react-redux'; import BackupAddressForm from './BackupAddressForm'; +import { configureStore } from 'shared/store'; + export default { title: 'Customer Components / Forms / BackupAddressForm', component: BackupAddressForm, @@ -15,36 +18,44 @@ export default { }, }; +const mockStore = configureStore({}); + export const DefaultState = (argTypes) => ( - + + + ); export const WithInitialValues = (argTypes) => ( - + + + ); diff --git a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.stories.jsx b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.stories.jsx index 9df9324dfe0..69a24b82655 100644 --- a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.stories.jsx +++ b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.stories.jsx @@ -1,7 +1,10 @@ import React from 'react'; +import { Provider } from 'react-redux'; import EditContactInfoForm from './EditContactInfoForm'; +import { configureStore } from 'shared/store'; + export default { title: 'Customer Components / Forms / EditContactInfoForm', component: EditContactInfoForm, @@ -42,37 +45,43 @@ const fakeData = { }, }; +const mockStore = configureStore({}); + export const DefaultState = (argTypes) => ( - + + secondary_telephone: '', + personal_email: '', + residential_address: { + streetAddress1: '', + streetAddress2: '', + city: '', + state: '', + postalCode: '', + }, + backup_mailing_address: { + streetAddress1: '', + streetAddress2: '', + city: '', + state: '', + postalCode: '', + }, + backup_contact: { + name: '', + email: '', + telephone: '', + }, + }} + onCancel={argTypes.onCancel} + onSubmit={argTypes.onSubmit} + /> + ); export const WithInitialValues = (argTypes) => ( - + + + ); diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.stories.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.stories.jsx index 88707bb0071..49322458ff4 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.stories.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.stories.jsx @@ -1,7 +1,10 @@ import React from 'react'; +import { Provider } from 'react-redux'; import ResidentialAddressForm from './ResidentialAddressForm'; +import { configureStore } from 'shared/store'; + export default { title: 'Customer Components / Forms / ResidentialAddressForm', component: ResidentialAddressForm, @@ -15,57 +18,65 @@ export default { }, }; +const mockStore = configureStore({}); + export const DefaultState = (argTypes) => ( - + + + ); export const WithInitialValues = (argTypes) => ( - + + + ); export const WithCustomValidators = (argTypes) => ( - (value === 'Nowhere' ? 'No one lives there' : ''), - postalCode: (value) => (value !== '99999' ? 'ZIP code must be 99999' : ''), - }} - /> + + (value === 'Nowhere' ? 'No one lives there' : ''), + postalCode: (value) => (value !== '99999' ? 'ZIP code must be 99999' : ''), + }} + /> + ); diff --git a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.stories.jsx b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.stories.jsx index 35c80163aa3..d5c9cd6bd08 100644 --- a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.stories.jsx +++ b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.stories.jsx @@ -1,7 +1,10 @@ import React from 'react'; +import { Provider } from 'react-redux'; import CustomerContactInfoForm from './CustomerContactInfoForm'; +import { configureStore } from 'shared/store'; + export default { title: 'Office Components / Forms/ Customer Contact Info Form', component: CustomerContactInfoForm, @@ -11,35 +14,41 @@ export default { }, }; +const mockStore = configureStore({}); + export const DefaultState = (argTypes) => ( -
- -
+ +
+ +
+
); export const WithInitialValues = (argTypes) => ( -
- -
+ +
+ +
+
); diff --git a/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.stories.jsx b/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.stories.jsx index 79bdabb7f8b..121833698d6 100644 --- a/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.stories.jsx +++ b/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.stories.jsx @@ -1,13 +1,18 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; +import { Provider } from 'react-redux'; import EditPPMHeaderSummaryModal from './EditPPMHeaderSummaryModal'; +import { configureStore } from 'shared/store'; + export default { title: 'Office Components/EditPPMHeaderSummaryModal', component: EditPPMHeaderSummaryModal, }; +const mockStore = configureStore({}); + // Mock data for the story const sectionInfo = { actualMoveDate: '2022-01-01', @@ -36,7 +41,11 @@ const sectionInfo = { }; export const Basic = (args) => { - return ; + return ( + + + + ); }; export const EditShipmentInfo = Basic.bind({}); From 9f7ffcffc208d781e2f9de4998a041d6650ebc74 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Tue, 22 Oct 2024 17:52:32 +0000 Subject: [PATCH 058/216] pass in locationState --- src/components/form/fields/ZipCityInput.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/form/fields/ZipCityInput.jsx b/src/components/form/fields/ZipCityInput.jsx index 90284c52969..f1bea7e9104 100644 --- a/src/components/form/fields/ZipCityInput.jsx +++ b/src/components/form/fields/ZipCityInput.jsx @@ -22,6 +22,7 @@ export const ZipCityInput = (props) => { input={{ value: field.value, onChange: helpers.setValue, + locationState: () => {}, name, }} errorMsg={errorString} From 9c97d435d394514d38d9a558564681035537e6c1 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 25 Oct 2024 00:47:01 +0000 Subject: [PATCH 059/216] updated parsing --- pkg/services/address/address_lookup.go | 43 ++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/pkg/services/address/address_lookup.go b/pkg/services/address/address_lookup.go index 69d1f8781ff..052a445cccf 100644 --- a/pkg/services/address/address_lookup.go +++ b/pkg/services/address/address_lookup.go @@ -3,6 +3,8 @@ package address import ( "database/sql" "fmt" + "regexp" + "strings" "github.com/gofrs/uuid" "github.com/pkg/errors" @@ -37,10 +39,45 @@ func (o usPostRegionCity) GetLocationsByZipCity(appCtx appcontext.AppContext, se func FindLocationsByZipCity(appCtx appcontext.AppContext, search string) (models.UsPostRegionCities, error) { var locationList []models.UsPostRegionCity + search = strings.ReplaceAll(search, ",", "") //remove any commas so they are not used in the search + searchSlice := strings.Split(search, " ") + city := "" + state := "" + postalCode := "" + + var postalCodeRegex = regexp.MustCompile(`^[0-9]+$`) + + if len(searchSlice) == 1 { + // check if this is a zip only search + if postalCodeRegex.MatchString(search) { + postalCode = search + } else { + city = search + } + } else if postalCode == "" && len(searchSlice) == 2 { + city = strings.TrimSpace(searchSlice[0]) + state = strings.TrimSpace(searchSlice[1]) + } else if len(searchSlice) == 3 { + if postalCodeRegex.MatchString(searchSlice[2]) { + postalCode = strings.TrimSpace(searchSlice[2]) + } + city = strings.TrimSpace(searchSlice[0]) + state = strings.TrimSpace(searchSlice[1]) + } + + // user may have typed a comma as part of the city name we need to remove that do to the query + if city != "" { + city = strings.ReplaceAll(city, ",", "") + } + + // city = "swansea" + // state = "IL" + // postalCode = "62226" + sqlQuery := fmt.Sprintf(` - select uprc.u_s_post_region_city_nm, uprc.state, uprc.usprc_county_nm, uprc.uspr_zip_id - from us_post_region_cities uprc where uprc.uspr_zip_id like '%[1]s%%' or - uprc.u_s_post_region_city_nm like upper('%[1]s%%') limit 30`, search) + select vl.city_name, vl.state, vl.usprc_county_nm, vl.uspr_zip_id + from v_locations vl where vl.uspr_zip_id like '%[1]s%%' and + vl.city_name like upper('%[2]s%%') and vl.state like upper('%[3]s%%') limit 30`, postalCode, city, state) query := appCtx.DB().Q().RawQuery(sqlQuery) if err := query.All(&locationList); err != nil { if errors.Cause(err).Error() != models.RecordNotFoundErrorString { From 474ac11f5adf93ef790ecca95d58e6465eada3f4 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 25 Oct 2024 04:35:46 +0000 Subject: [PATCH 060/216] updated to use v_locations view --- pkg/gen/ghcapi/embedded_spec.go | 40 +-- .../get_location_by_zip_city_responses.go | 8 +- pkg/gen/ghcmessages/us_post_region_city.go | 281 ------------------ pkg/gen/ghcmessages/v_location.go | 281 ++++++++++++++++++ ...s_post_region_cities.go => v_locations.go} | 14 +- pkg/gen/internalapi/embedded_spec.go | 40 +-- .../get_location_by_zip_city_responses.go | 8 +- .../internalmessages/us_post_region_city.go | 281 ------------------ pkg/gen/internalmessages/v_location.go | 281 ++++++++++++++++++ ...s_post_region_cities.go => v_locations.go} | 14 +- pkg/handlers/ghcapi/addresses.go | 6 +- pkg/handlers/ghcapi/addresses_test.go | 12 +- pkg/handlers/ghcapi/api.go | 4 +- .../internal/payloads/model_to_payload.go | 30 +- .../internal/payloads/payload_to_model.go | 15 +- pkg/handlers/internalapi/addresses.go | 6 +- pkg/handlers/internalapi/addresses_test.go | 12 +- pkg/handlers/internalapi/api.go | 4 +- .../internal/payloads/model_to_payload.go | 26 +- .../internal/payloads/payload_to_model.go | 15 +- pkg/models/v_locations.go | 44 +++ pkg/services/address.go | 4 +- pkg/services/address/address_lookup.go | 12 +- swagger-def/definitions/VLocation.yaml | 126 ++++++++ swagger-def/ghc.yaml | 6 +- swagger-def/internal.yaml | 6 +- swagger/ghc.yaml | 12 +- swagger/internal.yaml | 12 +- 28 files changed, 884 insertions(+), 716 deletions(-) delete mode 100644 pkg/gen/ghcmessages/us_post_region_city.go create mode 100644 pkg/gen/ghcmessages/v_location.go rename pkg/gen/ghcmessages/{us_post_region_cities.go => v_locations.go} (75%) delete mode 100644 pkg/gen/internalmessages/us_post_region_city.go create mode 100644 pkg/gen/internalmessages/v_location.go rename pkg/gen/internalmessages/{us_post_region_cities.go => v_locations.go} (75%) create mode 100644 pkg/models/v_locations.go create mode 100644 swagger-def/definitions/VLocation.yaml diff --git a/pkg/gen/ghcapi/embedded_spec.go b/pkg/gen/ghcapi/embedded_spec.go index aa287280545..7587cae74b9 100644 --- a/pkg/gen/ghcapi/embedded_spec.go +++ b/pkg/gen/ghcapi/embedded_spec.go @@ -56,7 +56,7 @@ func init() { "200": { "description": "the requested list of city, state, county, and postal code matches", "schema": { - "$ref": "#/definitions/UsPostRegionCities" + "$ref": "#/definitions/VLocations" } }, "400": { @@ -13909,14 +13909,8 @@ func init() { } } }, - "UsPostRegionCities": { - "type": "array", - "items": { - "$ref": "#/definitions/UsPostRegionCity" - } - }, - "UsPostRegionCity": { - "description": "A postal code and city lookup", + "VLocation": { + "description": "A postal code, city, and state lookup", "type": "object", "properties": { "city": { @@ -13934,7 +13928,7 @@ func init() { "type": "string", "format": "zip", "title": "ZIP", - "pattern": "^(\\d{5}([\\-]\\d{4})?)$", + "pattern": "^(\\d{5}?)$", "example": "90210" }, "state": { @@ -14049,6 +14043,12 @@ func init() { } } }, + "VLocations": { + "type": "array", + "items": { + "$ref": "#/definitions/VLocation" + } + }, "ValidationError": { "required": [ "invalid_fields" @@ -14441,7 +14441,7 @@ func init() { "200": { "description": "the requested list of city, state, county, and postal code matches", "schema": { - "$ref": "#/definitions/UsPostRegionCities" + "$ref": "#/definitions/VLocations" } }, "400": { @@ -29914,14 +29914,8 @@ func init() { } } }, - "UsPostRegionCities": { - "type": "array", - "items": { - "$ref": "#/definitions/UsPostRegionCity" - } - }, - "UsPostRegionCity": { - "description": "A postal code and city lookup", + "VLocation": { + "description": "A postal code, city, and state lookup", "type": "object", "properties": { "city": { @@ -29939,7 +29933,7 @@ func init() { "type": "string", "format": "zip", "title": "ZIP", - "pattern": "^(\\d{5}([\\-]\\d{4})?)$", + "pattern": "^(\\d{5}?)$", "example": "90210" }, "state": { @@ -30054,6 +30048,12 @@ func init() { } } }, + "VLocations": { + "type": "array", + "items": { + "$ref": "#/definitions/VLocation" + } + }, "ValidationError": { "required": [ "invalid_fields" diff --git a/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_responses.go b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_responses.go index abfd0c3b7f9..30c9c3a1d79 100644 --- a/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_responses.go +++ b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_responses.go @@ -26,7 +26,7 @@ type GetLocationByZipCityOK struct { /* In: Body */ - Payload ghcmessages.UsPostRegionCities `json:"body,omitempty"` + Payload ghcmessages.VLocations `json:"body,omitempty"` } // NewGetLocationByZipCityOK creates GetLocationByZipCityOK with default headers values @@ -36,13 +36,13 @@ func NewGetLocationByZipCityOK() *GetLocationByZipCityOK { } // WithPayload adds the payload to the get location by zip city o k response -func (o *GetLocationByZipCityOK) WithPayload(payload ghcmessages.UsPostRegionCities) *GetLocationByZipCityOK { +func (o *GetLocationByZipCityOK) WithPayload(payload ghcmessages.VLocations) *GetLocationByZipCityOK { o.Payload = payload return o } // SetPayload sets the payload to the get location by zip city o k response -func (o *GetLocationByZipCityOK) SetPayload(payload ghcmessages.UsPostRegionCities) { +func (o *GetLocationByZipCityOK) SetPayload(payload ghcmessages.VLocations) { o.Payload = payload } @@ -53,7 +53,7 @@ func (o *GetLocationByZipCityOK) WriteResponse(rw http.ResponseWriter, producer payload := o.Payload if payload == nil { // return empty array - payload = ghcmessages.UsPostRegionCities{} + payload = ghcmessages.VLocations{} } if err := producer.Produce(rw, payload); err != nil { diff --git a/pkg/gen/ghcmessages/us_post_region_city.go b/pkg/gen/ghcmessages/us_post_region_city.go deleted file mode 100644 index ad9ed32d27d..00000000000 --- a/pkg/gen/ghcmessages/us_post_region_city.go +++ /dev/null @@ -1,281 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package ghcmessages - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "encoding/json" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// UsPostRegionCity A postal code and city lookup -// -// swagger:model UsPostRegionCity -type UsPostRegionCity struct { - - // City - // Example: Anytown - City string `json:"city,omitempty"` - - // County - // Example: LOS ANGELES - County *string `json:"county,omitempty"` - - // ZIP - // Example: 90210 - // Pattern: ^(\d{5}([\-]\d{4})?)$ - PostalCode string `json:"postalCode,omitempty"` - - // State - // Enum: [AL AK AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD TN TX UT VA VT WA WI WV WY] - State string `json:"state,omitempty"` -} - -// Validate validates this us post region city -func (m *UsPostRegionCity) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validatePostalCode(formats); err != nil { - res = append(res, err) - } - - if err := m.validateState(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *UsPostRegionCity) validatePostalCode(formats strfmt.Registry) error { - if swag.IsZero(m.PostalCode) { // not required - return nil - } - - if err := validate.Pattern("postalCode", "body", m.PostalCode, `^(\d{5}([\-]\d{4})?)$`); err != nil { - return err - } - - return nil -} - -var usPostRegionCityTypeStatePropEnum []interface{} - -func init() { - var res []string - if err := json.Unmarshal([]byte(`["AL","AK","AR","AZ","CA","CO","CT","DC","DE","FL","GA","HI","IA","ID","IL","IN","KS","KY","LA","MA","MD","ME","MI","MN","MO","MS","MT","NC","ND","NE","NH","NJ","NM","NV","NY","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VA","VT","WA","WI","WV","WY"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - usPostRegionCityTypeStatePropEnum = append(usPostRegionCityTypeStatePropEnum, v) - } -} - -const ( - - // UsPostRegionCityStateAL captures enum value "AL" - UsPostRegionCityStateAL string = "AL" - - // UsPostRegionCityStateAK captures enum value "AK" - UsPostRegionCityStateAK string = "AK" - - // UsPostRegionCityStateAR captures enum value "AR" - UsPostRegionCityStateAR string = "AR" - - // UsPostRegionCityStateAZ captures enum value "AZ" - UsPostRegionCityStateAZ string = "AZ" - - // UsPostRegionCityStateCA captures enum value "CA" - UsPostRegionCityStateCA string = "CA" - - // UsPostRegionCityStateCO captures enum value "CO" - UsPostRegionCityStateCO string = "CO" - - // UsPostRegionCityStateCT captures enum value "CT" - UsPostRegionCityStateCT string = "CT" - - // UsPostRegionCityStateDC captures enum value "DC" - UsPostRegionCityStateDC string = "DC" - - // UsPostRegionCityStateDE captures enum value "DE" - UsPostRegionCityStateDE string = "DE" - - // UsPostRegionCityStateFL captures enum value "FL" - UsPostRegionCityStateFL string = "FL" - - // UsPostRegionCityStateGA captures enum value "GA" - UsPostRegionCityStateGA string = "GA" - - // UsPostRegionCityStateHI captures enum value "HI" - UsPostRegionCityStateHI string = "HI" - - // UsPostRegionCityStateIA captures enum value "IA" - UsPostRegionCityStateIA string = "IA" - - // UsPostRegionCityStateID captures enum value "ID" - UsPostRegionCityStateID string = "ID" - - // UsPostRegionCityStateIL captures enum value "IL" - UsPostRegionCityStateIL string = "IL" - - // UsPostRegionCityStateIN captures enum value "IN" - UsPostRegionCityStateIN string = "IN" - - // UsPostRegionCityStateKS captures enum value "KS" - UsPostRegionCityStateKS string = "KS" - - // UsPostRegionCityStateKY captures enum value "KY" - UsPostRegionCityStateKY string = "KY" - - // UsPostRegionCityStateLA captures enum value "LA" - UsPostRegionCityStateLA string = "LA" - - // UsPostRegionCityStateMA captures enum value "MA" - UsPostRegionCityStateMA string = "MA" - - // UsPostRegionCityStateMD captures enum value "MD" - UsPostRegionCityStateMD string = "MD" - - // UsPostRegionCityStateME captures enum value "ME" - UsPostRegionCityStateME string = "ME" - - // UsPostRegionCityStateMI captures enum value "MI" - UsPostRegionCityStateMI string = "MI" - - // UsPostRegionCityStateMN captures enum value "MN" - UsPostRegionCityStateMN string = "MN" - - // UsPostRegionCityStateMO captures enum value "MO" - UsPostRegionCityStateMO string = "MO" - - // UsPostRegionCityStateMS captures enum value "MS" - UsPostRegionCityStateMS string = "MS" - - // UsPostRegionCityStateMT captures enum value "MT" - UsPostRegionCityStateMT string = "MT" - - // UsPostRegionCityStateNC captures enum value "NC" - UsPostRegionCityStateNC string = "NC" - - // UsPostRegionCityStateND captures enum value "ND" - UsPostRegionCityStateND string = "ND" - - // UsPostRegionCityStateNE captures enum value "NE" - UsPostRegionCityStateNE string = "NE" - - // UsPostRegionCityStateNH captures enum value "NH" - UsPostRegionCityStateNH string = "NH" - - // UsPostRegionCityStateNJ captures enum value "NJ" - UsPostRegionCityStateNJ string = "NJ" - - // UsPostRegionCityStateNM captures enum value "NM" - UsPostRegionCityStateNM string = "NM" - - // UsPostRegionCityStateNV captures enum value "NV" - UsPostRegionCityStateNV string = "NV" - - // UsPostRegionCityStateNY captures enum value "NY" - UsPostRegionCityStateNY string = "NY" - - // UsPostRegionCityStateOH captures enum value "OH" - UsPostRegionCityStateOH string = "OH" - - // UsPostRegionCityStateOK captures enum value "OK" - UsPostRegionCityStateOK string = "OK" - - // UsPostRegionCityStateOR captures enum value "OR" - UsPostRegionCityStateOR string = "OR" - - // UsPostRegionCityStatePA captures enum value "PA" - UsPostRegionCityStatePA string = "PA" - - // UsPostRegionCityStateRI captures enum value "RI" - UsPostRegionCityStateRI string = "RI" - - // UsPostRegionCityStateSC captures enum value "SC" - UsPostRegionCityStateSC string = "SC" - - // UsPostRegionCityStateSD captures enum value "SD" - UsPostRegionCityStateSD string = "SD" - - // UsPostRegionCityStateTN captures enum value "TN" - UsPostRegionCityStateTN string = "TN" - - // UsPostRegionCityStateTX captures enum value "TX" - UsPostRegionCityStateTX string = "TX" - - // UsPostRegionCityStateUT captures enum value "UT" - UsPostRegionCityStateUT string = "UT" - - // UsPostRegionCityStateVA captures enum value "VA" - UsPostRegionCityStateVA string = "VA" - - // UsPostRegionCityStateVT captures enum value "VT" - UsPostRegionCityStateVT string = "VT" - - // UsPostRegionCityStateWA captures enum value "WA" - UsPostRegionCityStateWA string = "WA" - - // UsPostRegionCityStateWI captures enum value "WI" - UsPostRegionCityStateWI string = "WI" - - // UsPostRegionCityStateWV captures enum value "WV" - UsPostRegionCityStateWV string = "WV" - - // UsPostRegionCityStateWY captures enum value "WY" - UsPostRegionCityStateWY string = "WY" -) - -// prop value enum -func (m *UsPostRegionCity) validateStateEnum(path, location string, value string) error { - if err := validate.EnumCase(path, location, value, usPostRegionCityTypeStatePropEnum, true); err != nil { - return err - } - return nil -} - -func (m *UsPostRegionCity) validateState(formats strfmt.Registry) error { - if swag.IsZero(m.State) { // not required - return nil - } - - // value enum - if err := m.validateStateEnum("state", "body", m.State); err != nil { - return err - } - - return nil -} - -// ContextValidate validates this us post region city based on context it is used -func (m *UsPostRegionCity) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *UsPostRegionCity) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *UsPostRegionCity) UnmarshalBinary(b []byte) error { - var res UsPostRegionCity - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/gen/ghcmessages/v_location.go b/pkg/gen/ghcmessages/v_location.go new file mode 100644 index 00000000000..b8adb4ef48b --- /dev/null +++ b/pkg/gen/ghcmessages/v_location.go @@ -0,0 +1,281 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ghcmessages + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// VLocation A postal code, city, and state lookup +// +// swagger:model VLocation +type VLocation struct { + + // City + // Example: Anytown + City string `json:"city,omitempty"` + + // County + // Example: LOS ANGELES + County *string `json:"county,omitempty"` + + // ZIP + // Example: 90210 + // Pattern: ^(\d{5}?)$ + PostalCode string `json:"postalCode,omitempty"` + + // State + // Enum: [AL AK AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD TN TX UT VA VT WA WI WV WY] + State string `json:"state,omitempty"` +} + +// Validate validates this v location +func (m *VLocation) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePostalCode(formats); err != nil { + res = append(res, err) + } + + if err := m.validateState(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VLocation) validatePostalCode(formats strfmt.Registry) error { + if swag.IsZero(m.PostalCode) { // not required + return nil + } + + if err := validate.Pattern("postalCode", "body", m.PostalCode, `^(\d{5}?)$`); err != nil { + return err + } + + return nil +} + +var vLocationTypeStatePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["AL","AK","AR","AZ","CA","CO","CT","DC","DE","FL","GA","HI","IA","ID","IL","IN","KS","KY","LA","MA","MD","ME","MI","MN","MO","MS","MT","NC","ND","NE","NH","NJ","NM","NV","NY","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VA","VT","WA","WI","WV","WY"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + vLocationTypeStatePropEnum = append(vLocationTypeStatePropEnum, v) + } +} + +const ( + + // VLocationStateAL captures enum value "AL" + VLocationStateAL string = "AL" + + // VLocationStateAK captures enum value "AK" + VLocationStateAK string = "AK" + + // VLocationStateAR captures enum value "AR" + VLocationStateAR string = "AR" + + // VLocationStateAZ captures enum value "AZ" + VLocationStateAZ string = "AZ" + + // VLocationStateCA captures enum value "CA" + VLocationStateCA string = "CA" + + // VLocationStateCO captures enum value "CO" + VLocationStateCO string = "CO" + + // VLocationStateCT captures enum value "CT" + VLocationStateCT string = "CT" + + // VLocationStateDC captures enum value "DC" + VLocationStateDC string = "DC" + + // VLocationStateDE captures enum value "DE" + VLocationStateDE string = "DE" + + // VLocationStateFL captures enum value "FL" + VLocationStateFL string = "FL" + + // VLocationStateGA captures enum value "GA" + VLocationStateGA string = "GA" + + // VLocationStateHI captures enum value "HI" + VLocationStateHI string = "HI" + + // VLocationStateIA captures enum value "IA" + VLocationStateIA string = "IA" + + // VLocationStateID captures enum value "ID" + VLocationStateID string = "ID" + + // VLocationStateIL captures enum value "IL" + VLocationStateIL string = "IL" + + // VLocationStateIN captures enum value "IN" + VLocationStateIN string = "IN" + + // VLocationStateKS captures enum value "KS" + VLocationStateKS string = "KS" + + // VLocationStateKY captures enum value "KY" + VLocationStateKY string = "KY" + + // VLocationStateLA captures enum value "LA" + VLocationStateLA string = "LA" + + // VLocationStateMA captures enum value "MA" + VLocationStateMA string = "MA" + + // VLocationStateMD captures enum value "MD" + VLocationStateMD string = "MD" + + // VLocationStateME captures enum value "ME" + VLocationStateME string = "ME" + + // VLocationStateMI captures enum value "MI" + VLocationStateMI string = "MI" + + // VLocationStateMN captures enum value "MN" + VLocationStateMN string = "MN" + + // VLocationStateMO captures enum value "MO" + VLocationStateMO string = "MO" + + // VLocationStateMS captures enum value "MS" + VLocationStateMS string = "MS" + + // VLocationStateMT captures enum value "MT" + VLocationStateMT string = "MT" + + // VLocationStateNC captures enum value "NC" + VLocationStateNC string = "NC" + + // VLocationStateND captures enum value "ND" + VLocationStateND string = "ND" + + // VLocationStateNE captures enum value "NE" + VLocationStateNE string = "NE" + + // VLocationStateNH captures enum value "NH" + VLocationStateNH string = "NH" + + // VLocationStateNJ captures enum value "NJ" + VLocationStateNJ string = "NJ" + + // VLocationStateNM captures enum value "NM" + VLocationStateNM string = "NM" + + // VLocationStateNV captures enum value "NV" + VLocationStateNV string = "NV" + + // VLocationStateNY captures enum value "NY" + VLocationStateNY string = "NY" + + // VLocationStateOH captures enum value "OH" + VLocationStateOH string = "OH" + + // VLocationStateOK captures enum value "OK" + VLocationStateOK string = "OK" + + // VLocationStateOR captures enum value "OR" + VLocationStateOR string = "OR" + + // VLocationStatePA captures enum value "PA" + VLocationStatePA string = "PA" + + // VLocationStateRI captures enum value "RI" + VLocationStateRI string = "RI" + + // VLocationStateSC captures enum value "SC" + VLocationStateSC string = "SC" + + // VLocationStateSD captures enum value "SD" + VLocationStateSD string = "SD" + + // VLocationStateTN captures enum value "TN" + VLocationStateTN string = "TN" + + // VLocationStateTX captures enum value "TX" + VLocationStateTX string = "TX" + + // VLocationStateUT captures enum value "UT" + VLocationStateUT string = "UT" + + // VLocationStateVA captures enum value "VA" + VLocationStateVA string = "VA" + + // VLocationStateVT captures enum value "VT" + VLocationStateVT string = "VT" + + // VLocationStateWA captures enum value "WA" + VLocationStateWA string = "WA" + + // VLocationStateWI captures enum value "WI" + VLocationStateWI string = "WI" + + // VLocationStateWV captures enum value "WV" + VLocationStateWV string = "WV" + + // VLocationStateWY captures enum value "WY" + VLocationStateWY string = "WY" +) + +// prop value enum +func (m *VLocation) validateStateEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, vLocationTypeStatePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *VLocation) validateState(formats strfmt.Registry) error { + if swag.IsZero(m.State) { // not required + return nil + } + + // value enum + if err := m.validateStateEnum("state", "body", m.State); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this v location based on context it is used +func (m *VLocation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *VLocation) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VLocation) UnmarshalBinary(b []byte) error { + var res VLocation + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/ghcmessages/us_post_region_cities.go b/pkg/gen/ghcmessages/v_locations.go similarity index 75% rename from pkg/gen/ghcmessages/us_post_region_cities.go rename to pkg/gen/ghcmessages/v_locations.go index 2256a1f3035..82af765b9f3 100644 --- a/pkg/gen/ghcmessages/us_post_region_cities.go +++ b/pkg/gen/ghcmessages/v_locations.go @@ -14,13 +14,13 @@ import ( "github.com/go-openapi/swag" ) -// UsPostRegionCities us post region cities +// VLocations v locations // -// swagger:model UsPostRegionCities -type UsPostRegionCities []*UsPostRegionCity +// swagger:model VLocations +type VLocations []*VLocation -// Validate validates this us post region cities -func (m UsPostRegionCities) Validate(formats strfmt.Registry) error { +// Validate validates this v locations +func (m VLocations) Validate(formats strfmt.Registry) error { var res []error for i := 0; i < len(m); i++ { @@ -47,8 +47,8 @@ func (m UsPostRegionCities) Validate(formats strfmt.Registry) error { return nil } -// ContextValidate validate this us post region cities based on the context it is used -func (m UsPostRegionCities) ContextValidate(ctx context.Context, formats strfmt.Registry) error { +// ContextValidate validate this v locations based on the context it is used +func (m VLocations) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error for i := 0; i < len(m); i++ { diff --git a/pkg/gen/internalapi/embedded_spec.go b/pkg/gen/internalapi/embedded_spec.go index 76952db7c6b..f3db24c8e38 100644 --- a/pkg/gen/internalapi/embedded_spec.go +++ b/pkg/gen/internalapi/embedded_spec.go @@ -59,7 +59,7 @@ func init() { "200": { "description": "the requested list of city, state, county, and postal code matches", "schema": { - "$ref": "#/definitions/UsPostRegionCities" + "$ref": "#/definitions/VLocations" } }, "400": { @@ -7815,14 +7815,8 @@ func init() { } } }, - "UsPostRegionCities": { - "type": "array", - "items": { - "$ref": "#/definitions/UsPostRegionCity" - } - }, - "UsPostRegionCity": { - "description": "A postal code and city lookup", + "VLocation": { + "description": "A postal code, city, and state lookup", "type": "object", "properties": { "city": { @@ -7840,7 +7834,7 @@ func init() { "type": "string", "format": "zip", "title": "ZIP", - "pattern": "^(\\d{5}([\\-]\\d{4})?)$", + "pattern": "^(\\d{5}?)$", "example": "90210" }, "state": { @@ -7955,6 +7949,12 @@ func init() { } } }, + "VLocations": { + "type": "array", + "items": { + "$ref": "#/definitions/VLocation" + } + }, "ValidationError": { "required": [ "invalidFields" @@ -8415,7 +8415,7 @@ func init() { "200": { "description": "the requested list of city, state, county, and postal code matches", "schema": { - "$ref": "#/definitions/UsPostRegionCities" + "$ref": "#/definitions/VLocations" } }, "400": { @@ -16635,14 +16635,8 @@ func init() { } } }, - "UsPostRegionCities": { - "type": "array", - "items": { - "$ref": "#/definitions/UsPostRegionCity" - } - }, - "UsPostRegionCity": { - "description": "A postal code and city lookup", + "VLocation": { + "description": "A postal code, city, and state lookup", "type": "object", "properties": { "city": { @@ -16660,7 +16654,7 @@ func init() { "type": "string", "format": "zip", "title": "ZIP", - "pattern": "^(\\d{5}([\\-]\\d{4})?)$", + "pattern": "^(\\d{5}?)$", "example": "90210" }, "state": { @@ -16775,6 +16769,12 @@ func init() { } } }, + "VLocations": { + "type": "array", + "items": { + "$ref": "#/definitions/VLocation" + } + }, "ValidationError": { "required": [ "invalidFields" diff --git a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_responses.go b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_responses.go index b1b9e4315b7..7369a6a275c 100644 --- a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_responses.go +++ b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_responses.go @@ -26,7 +26,7 @@ type GetLocationByZipCityOK struct { /* In: Body */ - Payload internalmessages.UsPostRegionCities `json:"body,omitempty"` + Payload internalmessages.VLocations `json:"body,omitempty"` } // NewGetLocationByZipCityOK creates GetLocationByZipCityOK with default headers values @@ -36,13 +36,13 @@ func NewGetLocationByZipCityOK() *GetLocationByZipCityOK { } // WithPayload adds the payload to the get location by zip city o k response -func (o *GetLocationByZipCityOK) WithPayload(payload internalmessages.UsPostRegionCities) *GetLocationByZipCityOK { +func (o *GetLocationByZipCityOK) WithPayload(payload internalmessages.VLocations) *GetLocationByZipCityOK { o.Payload = payload return o } // SetPayload sets the payload to the get location by zip city o k response -func (o *GetLocationByZipCityOK) SetPayload(payload internalmessages.UsPostRegionCities) { +func (o *GetLocationByZipCityOK) SetPayload(payload internalmessages.VLocations) { o.Payload = payload } @@ -53,7 +53,7 @@ func (o *GetLocationByZipCityOK) WriteResponse(rw http.ResponseWriter, producer payload := o.Payload if payload == nil { // return empty array - payload = internalmessages.UsPostRegionCities{} + payload = internalmessages.VLocations{} } if err := producer.Produce(rw, payload); err != nil { diff --git a/pkg/gen/internalmessages/us_post_region_city.go b/pkg/gen/internalmessages/us_post_region_city.go deleted file mode 100644 index d4f71c2c614..00000000000 --- a/pkg/gen/internalmessages/us_post_region_city.go +++ /dev/null @@ -1,281 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package internalmessages - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "encoding/json" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// UsPostRegionCity A postal code and city lookup -// -// swagger:model UsPostRegionCity -type UsPostRegionCity struct { - - // City - // Example: Anytown - City string `json:"city,omitempty"` - - // County - // Example: LOS ANGELES - County *string `json:"county,omitempty"` - - // ZIP - // Example: 90210 - // Pattern: ^(\d{5}([\-]\d{4})?)$ - PostalCode string `json:"postalCode,omitempty"` - - // State - // Enum: [AL AK AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD TN TX UT VA VT WA WI WV WY] - State string `json:"state,omitempty"` -} - -// Validate validates this us post region city -func (m *UsPostRegionCity) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validatePostalCode(formats); err != nil { - res = append(res, err) - } - - if err := m.validateState(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *UsPostRegionCity) validatePostalCode(formats strfmt.Registry) error { - if swag.IsZero(m.PostalCode) { // not required - return nil - } - - if err := validate.Pattern("postalCode", "body", m.PostalCode, `^(\d{5}([\-]\d{4})?)$`); err != nil { - return err - } - - return nil -} - -var usPostRegionCityTypeStatePropEnum []interface{} - -func init() { - var res []string - if err := json.Unmarshal([]byte(`["AL","AK","AR","AZ","CA","CO","CT","DC","DE","FL","GA","HI","IA","ID","IL","IN","KS","KY","LA","MA","MD","ME","MI","MN","MO","MS","MT","NC","ND","NE","NH","NJ","NM","NV","NY","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VA","VT","WA","WI","WV","WY"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - usPostRegionCityTypeStatePropEnum = append(usPostRegionCityTypeStatePropEnum, v) - } -} - -const ( - - // UsPostRegionCityStateAL captures enum value "AL" - UsPostRegionCityStateAL string = "AL" - - // UsPostRegionCityStateAK captures enum value "AK" - UsPostRegionCityStateAK string = "AK" - - // UsPostRegionCityStateAR captures enum value "AR" - UsPostRegionCityStateAR string = "AR" - - // UsPostRegionCityStateAZ captures enum value "AZ" - UsPostRegionCityStateAZ string = "AZ" - - // UsPostRegionCityStateCA captures enum value "CA" - UsPostRegionCityStateCA string = "CA" - - // UsPostRegionCityStateCO captures enum value "CO" - UsPostRegionCityStateCO string = "CO" - - // UsPostRegionCityStateCT captures enum value "CT" - UsPostRegionCityStateCT string = "CT" - - // UsPostRegionCityStateDC captures enum value "DC" - UsPostRegionCityStateDC string = "DC" - - // UsPostRegionCityStateDE captures enum value "DE" - UsPostRegionCityStateDE string = "DE" - - // UsPostRegionCityStateFL captures enum value "FL" - UsPostRegionCityStateFL string = "FL" - - // UsPostRegionCityStateGA captures enum value "GA" - UsPostRegionCityStateGA string = "GA" - - // UsPostRegionCityStateHI captures enum value "HI" - UsPostRegionCityStateHI string = "HI" - - // UsPostRegionCityStateIA captures enum value "IA" - UsPostRegionCityStateIA string = "IA" - - // UsPostRegionCityStateID captures enum value "ID" - UsPostRegionCityStateID string = "ID" - - // UsPostRegionCityStateIL captures enum value "IL" - UsPostRegionCityStateIL string = "IL" - - // UsPostRegionCityStateIN captures enum value "IN" - UsPostRegionCityStateIN string = "IN" - - // UsPostRegionCityStateKS captures enum value "KS" - UsPostRegionCityStateKS string = "KS" - - // UsPostRegionCityStateKY captures enum value "KY" - UsPostRegionCityStateKY string = "KY" - - // UsPostRegionCityStateLA captures enum value "LA" - UsPostRegionCityStateLA string = "LA" - - // UsPostRegionCityStateMA captures enum value "MA" - UsPostRegionCityStateMA string = "MA" - - // UsPostRegionCityStateMD captures enum value "MD" - UsPostRegionCityStateMD string = "MD" - - // UsPostRegionCityStateME captures enum value "ME" - UsPostRegionCityStateME string = "ME" - - // UsPostRegionCityStateMI captures enum value "MI" - UsPostRegionCityStateMI string = "MI" - - // UsPostRegionCityStateMN captures enum value "MN" - UsPostRegionCityStateMN string = "MN" - - // UsPostRegionCityStateMO captures enum value "MO" - UsPostRegionCityStateMO string = "MO" - - // UsPostRegionCityStateMS captures enum value "MS" - UsPostRegionCityStateMS string = "MS" - - // UsPostRegionCityStateMT captures enum value "MT" - UsPostRegionCityStateMT string = "MT" - - // UsPostRegionCityStateNC captures enum value "NC" - UsPostRegionCityStateNC string = "NC" - - // UsPostRegionCityStateND captures enum value "ND" - UsPostRegionCityStateND string = "ND" - - // UsPostRegionCityStateNE captures enum value "NE" - UsPostRegionCityStateNE string = "NE" - - // UsPostRegionCityStateNH captures enum value "NH" - UsPostRegionCityStateNH string = "NH" - - // UsPostRegionCityStateNJ captures enum value "NJ" - UsPostRegionCityStateNJ string = "NJ" - - // UsPostRegionCityStateNM captures enum value "NM" - UsPostRegionCityStateNM string = "NM" - - // UsPostRegionCityStateNV captures enum value "NV" - UsPostRegionCityStateNV string = "NV" - - // UsPostRegionCityStateNY captures enum value "NY" - UsPostRegionCityStateNY string = "NY" - - // UsPostRegionCityStateOH captures enum value "OH" - UsPostRegionCityStateOH string = "OH" - - // UsPostRegionCityStateOK captures enum value "OK" - UsPostRegionCityStateOK string = "OK" - - // UsPostRegionCityStateOR captures enum value "OR" - UsPostRegionCityStateOR string = "OR" - - // UsPostRegionCityStatePA captures enum value "PA" - UsPostRegionCityStatePA string = "PA" - - // UsPostRegionCityStateRI captures enum value "RI" - UsPostRegionCityStateRI string = "RI" - - // UsPostRegionCityStateSC captures enum value "SC" - UsPostRegionCityStateSC string = "SC" - - // UsPostRegionCityStateSD captures enum value "SD" - UsPostRegionCityStateSD string = "SD" - - // UsPostRegionCityStateTN captures enum value "TN" - UsPostRegionCityStateTN string = "TN" - - // UsPostRegionCityStateTX captures enum value "TX" - UsPostRegionCityStateTX string = "TX" - - // UsPostRegionCityStateUT captures enum value "UT" - UsPostRegionCityStateUT string = "UT" - - // UsPostRegionCityStateVA captures enum value "VA" - UsPostRegionCityStateVA string = "VA" - - // UsPostRegionCityStateVT captures enum value "VT" - UsPostRegionCityStateVT string = "VT" - - // UsPostRegionCityStateWA captures enum value "WA" - UsPostRegionCityStateWA string = "WA" - - // UsPostRegionCityStateWI captures enum value "WI" - UsPostRegionCityStateWI string = "WI" - - // UsPostRegionCityStateWV captures enum value "WV" - UsPostRegionCityStateWV string = "WV" - - // UsPostRegionCityStateWY captures enum value "WY" - UsPostRegionCityStateWY string = "WY" -) - -// prop value enum -func (m *UsPostRegionCity) validateStateEnum(path, location string, value string) error { - if err := validate.EnumCase(path, location, value, usPostRegionCityTypeStatePropEnum, true); err != nil { - return err - } - return nil -} - -func (m *UsPostRegionCity) validateState(formats strfmt.Registry) error { - if swag.IsZero(m.State) { // not required - return nil - } - - // value enum - if err := m.validateStateEnum("state", "body", m.State); err != nil { - return err - } - - return nil -} - -// ContextValidate validates this us post region city based on context it is used -func (m *UsPostRegionCity) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *UsPostRegionCity) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *UsPostRegionCity) UnmarshalBinary(b []byte) error { - var res UsPostRegionCity - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/gen/internalmessages/v_location.go b/pkg/gen/internalmessages/v_location.go new file mode 100644 index 00000000000..b863a62d4f2 --- /dev/null +++ b/pkg/gen/internalmessages/v_location.go @@ -0,0 +1,281 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package internalmessages + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// VLocation A postal code, city, and state lookup +// +// swagger:model VLocation +type VLocation struct { + + // City + // Example: Anytown + City string `json:"city,omitempty"` + + // County + // Example: LOS ANGELES + County *string `json:"county,omitempty"` + + // ZIP + // Example: 90210 + // Pattern: ^(\d{5}?)$ + PostalCode string `json:"postalCode,omitempty"` + + // State + // Enum: [AL AK AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD TN TX UT VA VT WA WI WV WY] + State string `json:"state,omitempty"` +} + +// Validate validates this v location +func (m *VLocation) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePostalCode(formats); err != nil { + res = append(res, err) + } + + if err := m.validateState(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VLocation) validatePostalCode(formats strfmt.Registry) error { + if swag.IsZero(m.PostalCode) { // not required + return nil + } + + if err := validate.Pattern("postalCode", "body", m.PostalCode, `^(\d{5}?)$`); err != nil { + return err + } + + return nil +} + +var vLocationTypeStatePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["AL","AK","AR","AZ","CA","CO","CT","DC","DE","FL","GA","HI","IA","ID","IL","IN","KS","KY","LA","MA","MD","ME","MI","MN","MO","MS","MT","NC","ND","NE","NH","NJ","NM","NV","NY","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VA","VT","WA","WI","WV","WY"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + vLocationTypeStatePropEnum = append(vLocationTypeStatePropEnum, v) + } +} + +const ( + + // VLocationStateAL captures enum value "AL" + VLocationStateAL string = "AL" + + // VLocationStateAK captures enum value "AK" + VLocationStateAK string = "AK" + + // VLocationStateAR captures enum value "AR" + VLocationStateAR string = "AR" + + // VLocationStateAZ captures enum value "AZ" + VLocationStateAZ string = "AZ" + + // VLocationStateCA captures enum value "CA" + VLocationStateCA string = "CA" + + // VLocationStateCO captures enum value "CO" + VLocationStateCO string = "CO" + + // VLocationStateCT captures enum value "CT" + VLocationStateCT string = "CT" + + // VLocationStateDC captures enum value "DC" + VLocationStateDC string = "DC" + + // VLocationStateDE captures enum value "DE" + VLocationStateDE string = "DE" + + // VLocationStateFL captures enum value "FL" + VLocationStateFL string = "FL" + + // VLocationStateGA captures enum value "GA" + VLocationStateGA string = "GA" + + // VLocationStateHI captures enum value "HI" + VLocationStateHI string = "HI" + + // VLocationStateIA captures enum value "IA" + VLocationStateIA string = "IA" + + // VLocationStateID captures enum value "ID" + VLocationStateID string = "ID" + + // VLocationStateIL captures enum value "IL" + VLocationStateIL string = "IL" + + // VLocationStateIN captures enum value "IN" + VLocationStateIN string = "IN" + + // VLocationStateKS captures enum value "KS" + VLocationStateKS string = "KS" + + // VLocationStateKY captures enum value "KY" + VLocationStateKY string = "KY" + + // VLocationStateLA captures enum value "LA" + VLocationStateLA string = "LA" + + // VLocationStateMA captures enum value "MA" + VLocationStateMA string = "MA" + + // VLocationStateMD captures enum value "MD" + VLocationStateMD string = "MD" + + // VLocationStateME captures enum value "ME" + VLocationStateME string = "ME" + + // VLocationStateMI captures enum value "MI" + VLocationStateMI string = "MI" + + // VLocationStateMN captures enum value "MN" + VLocationStateMN string = "MN" + + // VLocationStateMO captures enum value "MO" + VLocationStateMO string = "MO" + + // VLocationStateMS captures enum value "MS" + VLocationStateMS string = "MS" + + // VLocationStateMT captures enum value "MT" + VLocationStateMT string = "MT" + + // VLocationStateNC captures enum value "NC" + VLocationStateNC string = "NC" + + // VLocationStateND captures enum value "ND" + VLocationStateND string = "ND" + + // VLocationStateNE captures enum value "NE" + VLocationStateNE string = "NE" + + // VLocationStateNH captures enum value "NH" + VLocationStateNH string = "NH" + + // VLocationStateNJ captures enum value "NJ" + VLocationStateNJ string = "NJ" + + // VLocationStateNM captures enum value "NM" + VLocationStateNM string = "NM" + + // VLocationStateNV captures enum value "NV" + VLocationStateNV string = "NV" + + // VLocationStateNY captures enum value "NY" + VLocationStateNY string = "NY" + + // VLocationStateOH captures enum value "OH" + VLocationStateOH string = "OH" + + // VLocationStateOK captures enum value "OK" + VLocationStateOK string = "OK" + + // VLocationStateOR captures enum value "OR" + VLocationStateOR string = "OR" + + // VLocationStatePA captures enum value "PA" + VLocationStatePA string = "PA" + + // VLocationStateRI captures enum value "RI" + VLocationStateRI string = "RI" + + // VLocationStateSC captures enum value "SC" + VLocationStateSC string = "SC" + + // VLocationStateSD captures enum value "SD" + VLocationStateSD string = "SD" + + // VLocationStateTN captures enum value "TN" + VLocationStateTN string = "TN" + + // VLocationStateTX captures enum value "TX" + VLocationStateTX string = "TX" + + // VLocationStateUT captures enum value "UT" + VLocationStateUT string = "UT" + + // VLocationStateVA captures enum value "VA" + VLocationStateVA string = "VA" + + // VLocationStateVT captures enum value "VT" + VLocationStateVT string = "VT" + + // VLocationStateWA captures enum value "WA" + VLocationStateWA string = "WA" + + // VLocationStateWI captures enum value "WI" + VLocationStateWI string = "WI" + + // VLocationStateWV captures enum value "WV" + VLocationStateWV string = "WV" + + // VLocationStateWY captures enum value "WY" + VLocationStateWY string = "WY" +) + +// prop value enum +func (m *VLocation) validateStateEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, vLocationTypeStatePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *VLocation) validateState(formats strfmt.Registry) error { + if swag.IsZero(m.State) { // not required + return nil + } + + // value enum + if err := m.validateStateEnum("state", "body", m.State); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this v location based on context it is used +func (m *VLocation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *VLocation) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VLocation) UnmarshalBinary(b []byte) error { + var res VLocation + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/internalmessages/us_post_region_cities.go b/pkg/gen/internalmessages/v_locations.go similarity index 75% rename from pkg/gen/internalmessages/us_post_region_cities.go rename to pkg/gen/internalmessages/v_locations.go index b8b2177aec5..4a2e1f0b605 100644 --- a/pkg/gen/internalmessages/us_post_region_cities.go +++ b/pkg/gen/internalmessages/v_locations.go @@ -14,13 +14,13 @@ import ( "github.com/go-openapi/swag" ) -// UsPostRegionCities us post region cities +// VLocations v locations // -// swagger:model UsPostRegionCities -type UsPostRegionCities []*UsPostRegionCity +// swagger:model VLocations +type VLocations []*VLocation -// Validate validates this us post region cities -func (m UsPostRegionCities) Validate(formats strfmt.Registry) error { +// Validate validates this v locations +func (m VLocations) Validate(formats strfmt.Registry) error { var res []error for i := 0; i < len(m); i++ { @@ -47,8 +47,8 @@ func (m UsPostRegionCities) Validate(formats strfmt.Registry) error { return nil } -// ContextValidate validate this us post region cities based on the context it is used -func (m UsPostRegionCities) ContextValidate(ctx context.Context, formats strfmt.Registry) error { +// ContextValidate validate this v locations based on the context it is used +func (m VLocations) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error for i := 0; i < len(m); i++ { diff --git a/pkg/handlers/ghcapi/addresses.go b/pkg/handlers/ghcapi/addresses.go index cd1c4c3d8d2..820dce28426 100644 --- a/pkg/handlers/ghcapi/addresses.go +++ b/pkg/handlers/ghcapi/addresses.go @@ -15,7 +15,7 @@ import ( type GetLocationByZipCityHandler struct { handlers.HandlerConfig - services.UsPostRegionCity + services.VLocation } func (h GetLocationByZipCityHandler) Handle(params addressop.GetLocationByZipCityParams) middleware.Responder { @@ -28,11 +28,11 @@ func (h GetLocationByZipCityHandler) Handle(params addressop.GetLocationByZipCit locationList, err := h.GetLocationsByZipCity(appCtx, params.Search) if err != nil { - appCtx.Logger().Error("Error searching for Zip/City: ", zap.Error(err)) + appCtx.Logger().Error("Error searching for Zip/City/State: ", zap.Error(err)) return addressop.NewGetLocationByZipCityInternalServerError(), err } - returnPayload := payloads.UsPostRegionCities(*locationList) + returnPayload := payloads.VLocations(*locationList) return addressop.NewGetLocationByZipCityOK().WithPayload(returnPayload), nil }) } diff --git a/pkg/handlers/ghcapi/addresses_test.go b/pkg/handlers/ghcapi/addresses_test.go index 71098eec85d..d42c38d3b9e 100644 --- a/pkg/handlers/ghcapi/addresses_test.go +++ b/pkg/handlers/ghcapi/addresses_test.go @@ -14,13 +14,13 @@ import ( func (suite *HandlerSuite) TestGetLocationByZipCityHandler() { suite.Run("successful zip city lookup", func() { zip := "90210" - var fetchedUsPostRegionCity models.UsPostRegionCity - err := suite.DB().Where("uspr_zip_id = $1", zip).First(&fetchedUsPostRegionCity) + var fetchedVLocation models.VLocation + err := suite.DB().Where("uspr_zip_id = $1", zip).First(&fetchedVLocation) suite.NoError(err) - suite.Equal(zip, fetchedUsPostRegionCity.UsprZipID) + suite.Equal(zip, fetchedVLocation.UsprZipID) - usPostRegionCityService := address.NewUsPostRegionCity() + vLocationService := address.NewVLocation() officeUser := factory.BuildOfficeUser(nil, nil, nil) req := httptest.NewRequest("GET", "/addresses/zip_city_lookup/"+zip, nil) req = suite.AuthenticateOfficeRequest(req, officeUser) @@ -30,8 +30,8 @@ func (suite *HandlerSuite) TestGetLocationByZipCityHandler() { } handler := GetLocationByZipCityHandler{ - HandlerConfig: suite.HandlerConfig(), - UsPostRegionCity: usPostRegionCityService} + HandlerConfig: suite.HandlerConfig(), + VLocation: vLocationService} response := handler.Handle(params) suite.Assertions.IsType(&addressop.GetLocationByZipCityOK{}, response) diff --git a/pkg/handlers/ghcapi/api.go b/pkg/handlers/ghcapi/api.go index a6e80ea31ba..0367a7092dc 100644 --- a/pkg/handlers/ghcapi/api.go +++ b/pkg/handlers/ghcapi/api.go @@ -104,7 +104,7 @@ func NewGhcAPIHandler(handlerConfig handlers.HandlerConfig) *ghcops.MymoveAPI { transportationOfficeFetcher := transportationoffice.NewTransportationOfficesFetcher() closeoutOfficeUpdater := move.NewCloseoutOfficeUpdater(move.NewMoveFetcher(), transportationOfficeFetcher) assignedOfficeUserUpdater := move.NewAssignedOfficeUserUpdater(move.NewMoveFetcher()) - usPostRegionCity := address.NewUsPostRegionCity() + vLocation := address.NewVLocation() shipmentSITStatus := sitstatus.NewShipmentSITStatus() @@ -632,7 +632,7 @@ func NewGhcAPIHandler(handlerConfig handlers.HandlerConfig) *ghcops.MymoveAPI { ghcAPI.AddressesGetLocationByZipCityHandler = GetLocationByZipCityHandler{ handlerConfig, - usPostRegionCity, + vLocation, } ghcAPI.OfficeUsersCreateRequestedOfficeUserHandler = RequestOfficeUserHandler{ diff --git a/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go b/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go index 342259f6bd4..16ad8c0bd32 100644 --- a/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go +++ b/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go @@ -2386,29 +2386,29 @@ func SearchCustomers(customers models.ServiceMemberSearchResults) *ghcmessages.S return &searchCustomers } -// UsPostRegionCity payload -func UsPostRegionCity(usPostRegionCity *models.UsPostRegionCity) *ghcmessages.UsPostRegionCity { - if usPostRegionCity == nil { +// VLocation payload +func VLocation(vLocation *models.VLocation) *ghcmessages.VLocation { + if vLocation == nil { return nil } - if *usPostRegionCity == (models.UsPostRegionCity{}) { + if *vLocation == (models.VLocation{}) { return nil } - return &ghcmessages.UsPostRegionCity{ - City: usPostRegionCity.USPostRegionCityNm, - State: usPostRegionCity.State, - PostalCode: usPostRegionCity.UsprZipID, - County: &usPostRegionCity.UsprcCountyNm, + return &ghcmessages.VLocation{ + City: vLocation.CityName, + State: vLocation.StateName, + PostalCode: vLocation.UsprZipID, + County: &vLocation.UsprcCountyNm, } } -// UsPostRegionCities payload -func UsPostRegionCities(usPostRegionCities models.UsPostRegionCities) ghcmessages.UsPostRegionCities { - payload := make(ghcmessages.UsPostRegionCities, len(usPostRegionCities)) - for i, usPostRegionCity := range usPostRegionCities { - copyOfUsPostRegionCity := usPostRegionCity - payload[i] = UsPostRegionCity(©OfUsPostRegionCity) +// VLocations payload +func VLocations(vLocations models.VLocations) ghcmessages.VLocations { + payload := make(ghcmessages.VLocations, len(vLocations)) + for i, vLocation := range vLocations { + copyOfVLocation := vLocation + payload[i] = VLocation(©OfVLocation) } return payload } diff --git a/pkg/handlers/ghcapi/internal/payloads/payload_to_model.go b/pkg/handlers/ghcapi/internal/payloads/payload_to_model.go index d1675eaf8b2..1883c15fbe1 100644 --- a/pkg/handlers/ghcapi/internal/payloads/payload_to_model.go +++ b/pkg/handlers/ghcapi/internal/payloads/payload_to_model.go @@ -909,16 +909,15 @@ func EvaluationReportFromUpdate(evaluationReport *ghcmessages.EvaluationReport) return &model, nil } -// UsPostRegionCityModel model -func UsPostRegionCityModel(usPostRegionCity *ghcmessages.UsPostRegionCity) *models.UsPostRegionCity { - if usPostRegionCity == nil { +func VLocationModel(vLocation *ghcmessages.VLocation) *models.VLocation { + if vLocation == nil { return nil } - return &models.UsPostRegionCity{ - USPostRegionCityNm: usPostRegionCity.City, - State: usPostRegionCity.State, - UsprZipID: usPostRegionCity.PostalCode, - UsprcCountyNm: *usPostRegionCity.County, + return &models.VLocation{ + CityName: vLocation.City, + StateName: vLocation.State, + UsprZipID: vLocation.PostalCode, + UsprcCountyNm: *vLocation.County, } } diff --git a/pkg/handlers/internalapi/addresses.go b/pkg/handlers/internalapi/addresses.go index 11b4354efb2..5180d932117 100644 --- a/pkg/handlers/internalapi/addresses.go +++ b/pkg/handlers/internalapi/addresses.go @@ -70,7 +70,7 @@ func (h ShowAddressHandler) Handle(params addressop.ShowAddressParams) middlewar type GetLocationByZipCityHandler struct { handlers.HandlerConfig - services.UsPostRegionCity + services.VLocation } func (h GetLocationByZipCityHandler) Handle(params addressop.GetLocationByZipCityParams) middleware.Responder { @@ -83,11 +83,11 @@ func (h GetLocationByZipCityHandler) Handle(params addressop.GetLocationByZipCit locationList, err := h.GetLocationsByZipCity(appCtx, params.Search) if err != nil { - appCtx.Logger().Error("Error searching for Zip/City: ", zap.Error(err)) + appCtx.Logger().Error("Error searching for Zip/City/State: ", zap.Error(err)) return addressop.NewGetLocationByZipCityInternalServerError(), err } - returnPayload := payloads.UsPostRegionCities(*locationList) + returnPayload := payloads.VLocations(*locationList) return addressop.NewGetLocationByZipCityOK().WithPayload(returnPayload), nil }) } diff --git a/pkg/handlers/internalapi/addresses_test.go b/pkg/handlers/internalapi/addresses_test.go index 99dca4c8e0f..8bb6ad5d3f8 100644 --- a/pkg/handlers/internalapi/addresses_test.go +++ b/pkg/handlers/internalapi/addresses_test.go @@ -82,13 +82,13 @@ func (suite *HandlerSuite) TestShowAddressHandler() { func (suite *HandlerSuite) TestGetLocationByZipCityHandler() { suite.Run("successful zip city lookup", func() { zip := "90210" - var fetchedUsPostRegionCity models.UsPostRegionCity - err := suite.DB().Where("uspr_zip_id = $1", zip).First(&fetchedUsPostRegionCity) + var fetchedVLocation models.VLocation + err := suite.DB().Where("uspr_zip_id = $1", zip).First(&fetchedVLocation) suite.NoError(err) - suite.Equal(zip, fetchedUsPostRegionCity.UsprZipID) + suite.Equal(zip, fetchedVLocation.UsprZipID) - usPostRegionCityService := address.NewUsPostRegionCity() + vLocationServices := address.NewVLocation() move := factory.BuildMove(suite.DB(), nil, nil) req := httptest.NewRequest("GET", "/addresses/zip_city_lookup/"+zip, nil) req = suite.AuthenticateRequest(req, move.Orders.ServiceMember) @@ -98,8 +98,8 @@ func (suite *HandlerSuite) TestGetLocationByZipCityHandler() { } handler := GetLocationByZipCityHandler{ - HandlerConfig: suite.HandlerConfig(), - UsPostRegionCity: usPostRegionCityService} + HandlerConfig: suite.HandlerConfig(), + VLocation: vLocationServices} response := handler.Handle(params) suite.Assertions.IsType(&addressop.GetLocationByZipCityOK{}, response) diff --git a/pkg/handlers/internalapi/api.go b/pkg/handlers/internalapi/api.go index bdd45324c46..ae386fc7e44 100644 --- a/pkg/handlers/internalapi/api.go +++ b/pkg/handlers/internalapi/api.go @@ -92,7 +92,7 @@ func NewInternalAPI(handlerConfig handlers.HandlerConfig) *internalops.MymoveAPI closeoutOfficeUpdater := move.NewCloseoutOfficeUpdater(move.NewMoveFetcher(), transportationOfficeFetcher) addressCreator := address.NewAddressCreator() addressUpdater := address.NewAddressUpdater() - usPostRegionCity := address.NewUsPostRegionCity() + vLocation := address.NewVLocation() ppmShipmentUpdater := ppmshipment.NewPPMShipmentUpdater(ppmEstimator, addressCreator, addressUpdater) boatShipmentUpdater := boatshipment.NewBoatShipmentUpdater() @@ -280,7 +280,7 @@ func NewInternalAPI(handlerConfig handlers.HandlerConfig) *internalops.MymoveAPI internalAPI.AddressesGetLocationByZipCityHandler = GetLocationByZipCityHandler{ handlerConfig, - usPostRegionCity, + vLocation, } paymentPacketCreator := ppmshipment.NewPaymentPacketCreator(ppmShipmentFetcher, pdfGenerator, AOAPacketCreator) diff --git a/pkg/handlers/internalapi/internal/payloads/model_to_payload.go b/pkg/handlers/internalapi/internal/payloads/model_to_payload.go index e422403c824..22b421bdad5 100644 --- a/pkg/handlers/internalapi/internal/payloads/model_to_payload.go +++ b/pkg/handlers/internalapi/internal/payloads/model_to_payload.go @@ -626,26 +626,26 @@ func SignedCertification(signedCertification *models.SignedCertification) *inter return model } -// UsPostRegionCity payload -func UsPostRegionCity(usPostRegionCity *models.UsPostRegionCity) *internalmessages.UsPostRegionCity { - if usPostRegionCity == nil || *usPostRegionCity == (models.UsPostRegionCity{}) { +// VLocation payload +func VLocation(vLocation *models.VLocation) *internalmessages.VLocation { + if vLocation == nil || *vLocation == (models.VLocation{}) { return nil } - return &internalmessages.UsPostRegionCity{ - City: usPostRegionCity.USPostRegionCityNm, - State: usPostRegionCity.State, - PostalCode: usPostRegionCity.UsprZipID, - County: &usPostRegionCity.UsprcCountyNm, + return &internalmessages.VLocation{ + City: vLocation.CityName, + State: vLocation.StateName, + PostalCode: vLocation.UsprZipID, + County: &vLocation.UsprcCountyNm, } } // UsPostRegionCities payload -func UsPostRegionCities(usPostRegionCities models.UsPostRegionCities) internalmessages.UsPostRegionCities { - payload := make(internalmessages.UsPostRegionCities, len(usPostRegionCities)) - for i, usPostRegionCity := range usPostRegionCities { - copyOfUsPostRegionCity := usPostRegionCity - payload[i] = UsPostRegionCity(©OfUsPostRegionCity) +func VLocations(vLocations models.VLocations) internalmessages.VLocations { + payload := make(internalmessages.VLocations, len(vLocations)) + for i, vLocation := range vLocations { + copyOfVLocation := vLocation + payload[i] = VLocation(©OfVLocation) } return payload } diff --git a/pkg/handlers/internalapi/internal/payloads/payload_to_model.go b/pkg/handlers/internalapi/internal/payloads/payload_to_model.go index d3d9bffa946..8860c69c1fc 100644 --- a/pkg/handlers/internalapi/internal/payloads/payload_to_model.go +++ b/pkg/handlers/internalapi/internal/payloads/payload_to_model.go @@ -31,17 +31,16 @@ func AddressModel(address *internalmessages.Address) *models.Address { } } -// UsPostRegionCityModel model -func UsPostRegionCityModel(usPostRegionCity *internalmessages.UsPostRegionCity) *models.UsPostRegionCity { - if usPostRegionCity == nil { +func VLocationModel(vLocation *internalmessages.VLocation) *models.VLocation { + if vLocation == nil { return nil } - return &models.UsPostRegionCity{ - USPostRegionCityNm: usPostRegionCity.City, - State: usPostRegionCity.State, - UsprZipID: usPostRegionCity.PostalCode, - UsprcCountyNm: *usPostRegionCity.County, + return &models.VLocation{ + CityName: vLocation.City, + StateName: vLocation.State, + UsprZipID: vLocation.PostalCode, + UsprcCountyNm: *vLocation.County, } } diff --git a/pkg/models/v_locations.go b/pkg/models/v_locations.go new file mode 100644 index 00000000000..a836c2b0cc1 --- /dev/null +++ b/pkg/models/v_locations.go @@ -0,0 +1,44 @@ +package models + +import ( + "github.com/gofrs/uuid" +) + +// VLocations is a read only view that represents postal region information retrieved from TRDM +/* +Column comments +uprc_id IS 'An id of a record in the us_post_region_cities table' +city_name IS 'A US postal region city name' +state IS 'A US postal region state name' +uspr_zip_id IS 'A US postal region zip identifier' +usprc_county_nm IS 'A name of the county or parish in which the UNITED-STATES-POSTAL-REGION-CITY resides' +country IS 'A name of the country' +cities_id IS 'An id of a record in the re_cities table' +state_id IS 'An id of a record in the re_states table' +us_post_regions_id IS 'An id of a record in the re_us_post_regions table' +country_id IS 'An id of a record in the re_countries table' +*/ +type VLocation struct { + UprcId *uuid.UUID `db:"uprc_id" json:"uprc_id" rw:"r"` + UsPostRegionCity *UsPostRegionCity `belongs_to:"us_post_region_cities" fk_id:"uprc_id" rw:"r"` + CityName string `db:"city_name" json:"city_name" rw:"r"` + CityId *uuid.UUID `db:"cities_id" json:"cities_id" rw:"r"` + City *City `belongs_to:"re_cities" fk_id:"cities_id" rw:"r"` + StateName string `db:"state" json:"state" rw:"r"` + StateId *uuid.UUID `db:"state_id" json:"state_id" rw:"r"` + State *State `belongs_to:"re_states" fk_id:"state_id" rw:"r"` + UsprZipID string `db:"uspr_zip_id" json:"uspr_zip_id" rw:"r"` + UsprcCountyNm string `db:"usprc_county_nm" json:"usprc_county_nm" rw:"r"` + UsPostRegionId *uuid.UUID `db:"us_post_regions_id" json:"us_post_regions_id" rw:"r"` + UsPostRegion *UsPostRegion `belongs_to:"re_us_post_regions" fk_id:"us_post_regions_id" rw:"r"` + CountryName string `db:"country" json:"country" rw:"r"` + CountryId *uuid.UUID `db:"country_id" json:"country_id" rw:"r"` + Country *Country `belongs_to:"re_countries" fk_id:"country_id" rw:"r"` +} + +type VLocations []VLocation + +// TableName overrides the table name used by Pop. +func (v VLocation) TableName() string { + return "v_locations" +} diff --git a/pkg/services/address.go b/pkg/services/address.go index 0f515aa7e8f..2d8276a0323 100644 --- a/pkg/services/address.go +++ b/pkg/services/address.go @@ -14,6 +14,6 @@ type AddressUpdater interface { } //go:generate mockery --name UsPostRegionCity -type UsPostRegionCity interface { - GetLocationsByZipCity(appCtx appcontext.AppContext, search string) (*models.UsPostRegionCities, error) +type VLocation interface { + GetLocationsByZipCity(appCtx appcontext.AppContext, search string) (*models.VLocations, error) } diff --git a/pkg/services/address/address_lookup.go b/pkg/services/address/address_lookup.go index 052a445cccf..9249afed2e2 100644 --- a/pkg/services/address/address_lookup.go +++ b/pkg/services/address/address_lookup.go @@ -15,14 +15,14 @@ import ( "github.com/transcom/mymove/pkg/services" ) -type usPostRegionCity struct { +type vLocation struct { } -func NewUsPostRegionCity() services.UsPostRegionCity { - return &usPostRegionCity{} +func NewVLocation() services.VLocation { + return &vLocation{} } -func (o usPostRegionCity) GetLocationsByZipCity(appCtx appcontext.AppContext, search string) (*models.UsPostRegionCities, error) { +func (o vLocation) GetLocationsByZipCity(appCtx appcontext.AppContext, search string) (*models.VLocations, error) { locationList, err := FindLocationsByZipCity(appCtx, search) if err != nil { @@ -37,8 +37,8 @@ func (o usPostRegionCity) GetLocationsByZipCity(appCtx appcontext.AppContext, se return &locationList, nil } -func FindLocationsByZipCity(appCtx appcontext.AppContext, search string) (models.UsPostRegionCities, error) { - var locationList []models.UsPostRegionCity +func FindLocationsByZipCity(appCtx appcontext.AppContext, search string) (models.VLocations, error) { + var locationList []models.VLocation search = strings.ReplaceAll(search, ",", "") //remove any commas so they are not used in the search searchSlice := strings.Split(search, " ") city := "" diff --git a/swagger-def/definitions/VLocation.yaml b/swagger-def/definitions/VLocation.yaml new file mode 100644 index 00000000000..213319be775 --- /dev/null +++ b/swagger-def/definitions/VLocation.yaml @@ -0,0 +1,126 @@ +description: A postal code, city, and state lookup +type: object +properties: + city: + type: string + example: Anytown + title: City + state: + title: State + type: string + x-display-value: + AL: AL + AK: AK + AR: AR + AZ: AZ + CA: CA + CO: CO + CT: CT + DC: DC + DE: DE + FL: FL + GA: GA + HI: HI + IA: IA + ID: ID + IL: IL + IN: IN + KS: KS + KY: KY + LA: LA + MA: MA + MD: MD + ME: ME + MI: MI + MN: MN + MO: MO + MS: MS + MT: MT + NC: NC + ND: ND + NE: NE + NH: NH + NJ: NJ + NM: NM + NV: NV + NY: NY + OH: OH + OK: OK + OR: OR + PA: PA + RI: RI + SC: SC + SD: SD + TN: TN + TX: TX + UT: UT + VA: VA + VT: VT + WA: WA + WI: WI + WV: WV + WY: WY + enum: + - AL + - AK + - AR + - AZ + - CA + - CO + - CT + - DC + - DE + - FL + - GA + - HI + - IA + - ID + - IL + - IN + - KS + - KY + - LA + - MA + - MD + - ME + - MI + - MN + - MO + - MS + - MT + - NC + - ND + - NE + - NH + - NJ + - NM + - NV + - NY + - OH + - OK + - OR + - PA + - RI + - SC + - SD + - TN + - TX + - UT + - VA + - VT + - WA + - WI + - WV + - WY + postalCode: + type: string + format: zip + title: ZIP + example: '90210' + pattern: '^(\d{5}?)$' + county: + type: string + title: County + x-nullable: true + example: 'LOS ANGELES' + diff --git a/swagger-def/ghc.yaml b/swagger-def/ghc.yaml index 7eacc3f97ef..e9c1af2664b 100644 --- a/swagger-def/ghc.yaml +++ b/swagger-def/ghc.yaml @@ -3933,7 +3933,7 @@ paths: "200": description: the requested list of city, state, county, and postal code matches schema: - $ref: "#/definitions/UsPostRegionCities" + $ref: "#/definitions/VLocations" "400": description: invalid request "403": @@ -7333,10 +7333,10 @@ definitions: type: array items: $ref: 'definitions/TransportationOffice.yaml' - UsPostRegionCities: + VLocations: type: array items: - $ref: "definitions/UsPostRegionCity.yaml" + $ref: "definitions/VLocation.yaml" GBLOCs: type: array items: diff --git a/swagger-def/internal.yaml b/swagger-def/internal.yaml index 43170a35eed..d426587c752 100644 --- a/swagger-def/internal.yaml +++ b/swagger-def/internal.yaml @@ -591,10 +591,10 @@ definitions: type: array items: $ref: "definitions/TransportationOffice.yaml" - UsPostRegionCities: + VLocations: type: array items: - $ref: "definitions/UsPostRegionCity.yaml" + $ref: "definitions/VLocation.yaml" OfficeUser: type: object properties: @@ -4400,7 +4400,7 @@ paths: "200": description: the requested list of city, state, county, and postal code matches schema: - $ref: "#/definitions/UsPostRegionCities" + $ref: "#/definitions/VLocations" "400": description: invalid request "403": diff --git a/swagger/ghc.yaml b/swagger/ghc.yaml index bca726c21ad..adec5c88e9a 100644 --- a/swagger/ghc.yaml +++ b/swagger/ghc.yaml @@ -4125,7 +4125,7 @@ paths: '200': description: the requested list of city, state, county, and postal code matches schema: - $ref: '#/definitions/UsPostRegionCities' + $ref: '#/definitions/VLocations' '400': description: invalid request '403': @@ -7634,10 +7634,10 @@ definitions: type: array items: $ref: '#/definitions/TransportationOffice' - UsPostRegionCities: + VLocations: type: array items: - $ref: '#/definitions/UsPostRegionCity' + $ref: '#/definitions/VLocation' GBLOCs: type: array items: @@ -10846,8 +10846,8 @@ definitions: validHhgProgramCodeForLoa: type: boolean x-nullable: true - UsPostRegionCity: - description: A postal code and city lookup + VLocation: + description: A postal code, city, and state lookup type: object properties: city: @@ -10966,7 +10966,7 @@ definitions: format: zip title: ZIP example: '90210' - pattern: ^(\d{5}([\-]\d{4})?)$ + pattern: ^(\d{5}?)$ county: type: string title: County diff --git a/swagger/internal.yaml b/swagger/internal.yaml index f35089f1b28..f6fb53c5fc1 100644 --- a/swagger/internal.yaml +++ b/swagger/internal.yaml @@ -612,10 +612,10 @@ definitions: type: array items: $ref: '#/definitions/TransportationOffice' - UsPostRegionCities: + VLocations: type: array items: - $ref: '#/definitions/UsPostRegionCity' + $ref: '#/definitions/VLocation' OfficeUser: type: object properties: @@ -3930,8 +3930,8 @@ definitions: RENTAL_EQUIPMENT: Rental equipment TOLLS: Tolls WEIGHING_FEE: Weighing fee - UsPostRegionCity: - description: A postal code and city lookup + VLocation: + description: A postal code, city, and state lookup type: object properties: city: @@ -4050,7 +4050,7 @@ definitions: format: zip title: ZIP example: '90210' - pattern: ^(\d{5}([\-]\d{4})?)$ + pattern: ^(\d{5}?)$ county: type: string title: County @@ -6110,7 +6110,7 @@ paths: '200': description: the requested list of city, state, county, and postal code matches schema: - $ref: '#/definitions/UsPostRegionCities' + $ref: '#/definitions/VLocations' '400': description: invalid request '403': From 5cba038dbb204cb0fa07bbca2eb79194269ebfc3 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 25 Oct 2024 20:26:22 +0000 Subject: [PATCH 061/216] pass usprc id back to UI from search --- pkg/gen/ghcapi/embedded_spec.go | 20 ++++++++++++++++ pkg/gen/ghcmessages/address.go | 21 +++++++++++++++++ pkg/gen/ghcmessages/v_location.go | 21 +++++++++++++++++ pkg/gen/internalapi/embedded_spec.go | 20 ++++++++++++++++ pkg/gen/internalmessages/address.go | 21 +++++++++++++++++ pkg/gen/internalmessages/v_location.go | 21 +++++++++++++++++ pkg/gen/pptasapi/embedded_spec.go | 10 ++++++++ pkg/gen/pptasmessages/address.go | 21 +++++++++++++++++ pkg/gen/primeapi/embedded_spec.go | 10 ++++++++ pkg/gen/primemessages/address.go | 21 +++++++++++++++++ pkg/gen/primev2api/embedded_spec.go | 10 ++++++++ pkg/gen/primev2messages/address.go | 21 +++++++++++++++++ pkg/gen/primev3api/embedded_spec.go | 10 ++++++++ pkg/gen/primev3messages/address.go | 21 +++++++++++++++++ .../internal/payloads/model_to_payload.go | 9 ++++---- .../internal/payloads/payload_to_model.go | 12 +++++++--- pkg/handlers/internalapi/addresses.go | 20 ++++++++++------ .../internal/payloads/model_to_payload.go | 11 +++++---- .../internal/payloads/payload_to_model.go | 23 ++++++++++++------- pkg/services/address/address_lookup.go | 2 +- .../ResidentialAddressForm.jsx | 1 + src/types/address.js | 5 ++++ swagger-def/definitions/Address.yaml | 4 ++++ swagger-def/definitions/VLocation.yaml | 5 +++- swagger/ghc.yaml | 8 +++++++ swagger/internal.yaml | 8 +++++++ swagger/pptas.yaml | 4 ++++ swagger/prime.yaml | 4 ++++ swagger/prime_v2.yaml | 4 ++++ swagger/prime_v3.yaml | 4 ++++ 30 files changed, 343 insertions(+), 29 deletions(-) diff --git a/pkg/gen/ghcapi/embedded_spec.go b/pkg/gen/ghcapi/embedded_spec.go index 7587cae74b9..1ec2450873e 100644 --- a/pkg/gen/ghcapi/embedded_spec.go +++ b/pkg/gen/ghcapi/embedded_spec.go @@ -6315,6 +6315,11 @@ func init() { "title": "Address Line 3", "x-nullable": true, "example": "Montmârtre" + }, + "usPostRegionCitiesId": { + "type": "string", + "format": "uuid", + "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" } } }, @@ -14040,6 +14045,11 @@ func init() { "WV": "WV", "WY": "WY" } + }, + "usPostRegionCitiesId": { + "type": "string", + "format": "uuid", + "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" } } }, @@ -22180,6 +22190,11 @@ func init() { "title": "Address Line 3", "x-nullable": true, "example": "Montmârtre" + }, + "usPostRegionCitiesId": { + "type": "string", + "format": "uuid", + "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" } } }, @@ -30045,6 +30060,11 @@ func init() { "WV": "WV", "WY": "WY" } + }, + "usPostRegionCitiesId": { + "type": "string", + "format": "uuid", + "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" } } }, diff --git a/pkg/gen/ghcmessages/address.go b/pkg/gen/ghcmessages/address.go index 61548f58979..67349867c16 100644 --- a/pkg/gen/ghcmessages/address.go +++ b/pkg/gen/ghcmessages/address.go @@ -72,6 +72,11 @@ type Address struct { // Address Line 3 // Example: Montmârtre StreetAddress3 *string `json:"streetAddress3,omitempty"` + + // us post region cities Id + // Example: c56a4180-65aa-42ec-a945-5fd21dec0538 + // Format: uuid + UsPostRegionCitiesID strfmt.UUID `json:"usPostRegionCitiesId,omitempty"` } // Validate validates this address @@ -102,6 +107,10 @@ func (m *Address) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateUsPostRegionCitiesID(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -353,6 +362,18 @@ func (m *Address) validateStreetAddress1(formats strfmt.Registry) error { return nil } +func (m *Address) validateUsPostRegionCitiesID(formats strfmt.Registry) error { + if swag.IsZero(m.UsPostRegionCitiesID) { // not required + return nil + } + + if err := validate.FormatOf("usPostRegionCitiesId", "body", "uuid", m.UsPostRegionCitiesID.String(), formats); err != nil { + return err + } + + return nil +} + // ContextValidate validate this address based on the context it is used func (m *Address) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error diff --git a/pkg/gen/ghcmessages/v_location.go b/pkg/gen/ghcmessages/v_location.go index b8adb4ef48b..3f1ab2114e4 100644 --- a/pkg/gen/ghcmessages/v_location.go +++ b/pkg/gen/ghcmessages/v_location.go @@ -36,6 +36,11 @@ type VLocation struct { // State // Enum: [AL AK AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD TN TX UT VA VT WA WI WV WY] State string `json:"state,omitempty"` + + // us post region cities Id + // Example: c56a4180-65aa-42ec-a945-5fd21dec0538 + // Format: uuid + UsPostRegionCitiesID strfmt.UUID `json:"usPostRegionCitiesId,omitempty"` } // Validate validates this v location @@ -50,6 +55,10 @@ func (m *VLocation) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateUsPostRegionCitiesID(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -257,6 +266,18 @@ func (m *VLocation) validateState(formats strfmt.Registry) error { return nil } +func (m *VLocation) validateUsPostRegionCitiesID(formats strfmt.Registry) error { + if swag.IsZero(m.UsPostRegionCitiesID) { // not required + return nil + } + + if err := validate.FormatOf("usPostRegionCitiesId", "body", "uuid", m.UsPostRegionCitiesID.String(), formats); err != nil { + return err + } + + return nil +} + // ContextValidate validates this v location based on context it is used func (m *VLocation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { return nil diff --git a/pkg/gen/internalapi/embedded_spec.go b/pkg/gen/internalapi/embedded_spec.go index f3db24c8e38..0fd77219319 100644 --- a/pkg/gen/internalapi/embedded_spec.go +++ b/pkg/gen/internalapi/embedded_spec.go @@ -3519,6 +3519,11 @@ func init() { "title": "Address Line 3", "x-nullable": true, "example": "Montmârtre" + }, + "usPostRegionCitiesId": { + "type": "string", + "format": "uuid", + "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" } } }, @@ -7946,6 +7951,11 @@ func init() { "WV": "WV", "WY": "WY" } + }, + "usPostRegionCitiesId": { + "type": "string", + "format": "uuid", + "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" } } }, @@ -12328,6 +12338,11 @@ func init() { "title": "Address Line 3", "x-nullable": true, "example": "Montmârtre" + }, + "usPostRegionCitiesId": { + "type": "string", + "format": "uuid", + "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" } } }, @@ -16766,6 +16781,11 @@ func init() { "WV": "WV", "WY": "WY" } + }, + "usPostRegionCitiesId": { + "type": "string", + "format": "uuid", + "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" } } }, diff --git a/pkg/gen/internalmessages/address.go b/pkg/gen/internalmessages/address.go index f181c14283c..7af0581d924 100644 --- a/pkg/gen/internalmessages/address.go +++ b/pkg/gen/internalmessages/address.go @@ -72,6 +72,11 @@ type Address struct { // Address Line 3 // Example: Montmârtre StreetAddress3 *string `json:"streetAddress3,omitempty"` + + // us post region cities Id + // Example: c56a4180-65aa-42ec-a945-5fd21dec0538 + // Format: uuid + UsPostRegionCitiesID strfmt.UUID `json:"usPostRegionCitiesId,omitempty"` } // Validate validates this address @@ -102,6 +107,10 @@ func (m *Address) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateUsPostRegionCitiesID(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -353,6 +362,18 @@ func (m *Address) validateStreetAddress1(formats strfmt.Registry) error { return nil } +func (m *Address) validateUsPostRegionCitiesID(formats strfmt.Registry) error { + if swag.IsZero(m.UsPostRegionCitiesID) { // not required + return nil + } + + if err := validate.FormatOf("usPostRegionCitiesId", "body", "uuid", m.UsPostRegionCitiesID.String(), formats); err != nil { + return err + } + + return nil +} + // ContextValidate validate this address based on the context it is used func (m *Address) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error diff --git a/pkg/gen/internalmessages/v_location.go b/pkg/gen/internalmessages/v_location.go index b863a62d4f2..f362f55e4f2 100644 --- a/pkg/gen/internalmessages/v_location.go +++ b/pkg/gen/internalmessages/v_location.go @@ -36,6 +36,11 @@ type VLocation struct { // State // Enum: [AL AK AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD TN TX UT VA VT WA WI WV WY] State string `json:"state,omitempty"` + + // us post region cities Id + // Example: c56a4180-65aa-42ec-a945-5fd21dec0538 + // Format: uuid + UsPostRegionCitiesID strfmt.UUID `json:"usPostRegionCitiesId,omitempty"` } // Validate validates this v location @@ -50,6 +55,10 @@ func (m *VLocation) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateUsPostRegionCitiesID(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -257,6 +266,18 @@ func (m *VLocation) validateState(formats strfmt.Registry) error { return nil } +func (m *VLocation) validateUsPostRegionCitiesID(formats strfmt.Registry) error { + if swag.IsZero(m.UsPostRegionCitiesID) { // not required + return nil + } + + if err := validate.FormatOf("usPostRegionCitiesId", "body", "uuid", m.UsPostRegionCitiesID.String(), formats); err != nil { + return err + } + + return nil +} + // ContextValidate validates this v location based on context it is used func (m *VLocation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { return nil diff --git a/pkg/gen/pptasapi/embedded_spec.go b/pkg/gen/pptasapi/embedded_spec.go index 0c8c13f5247..6b178298eec 100644 --- a/pkg/gen/pptasapi/embedded_spec.go +++ b/pkg/gen/pptasapi/embedded_spec.go @@ -262,6 +262,11 @@ func init() { "title": "Address Line 3", "x-nullable": true, "example": "Montmârtre" + }, + "usPostRegionCitiesId": { + "type": "string", + "format": "uuid", + "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" } } }, @@ -1151,6 +1156,11 @@ func init() { "title": "Address Line 3", "x-nullable": true, "example": "Montmârtre" + }, + "usPostRegionCitiesId": { + "type": "string", + "format": "uuid", + "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" } } }, diff --git a/pkg/gen/pptasmessages/address.go b/pkg/gen/pptasmessages/address.go index 1e3f09e7f2b..76b1e586e93 100644 --- a/pkg/gen/pptasmessages/address.go +++ b/pkg/gen/pptasmessages/address.go @@ -72,6 +72,11 @@ type Address struct { // Address Line 3 // Example: Montmârtre StreetAddress3 *string `json:"streetAddress3,omitempty"` + + // us post region cities Id + // Example: c56a4180-65aa-42ec-a945-5fd21dec0538 + // Format: uuid + UsPostRegionCitiesID strfmt.UUID `json:"usPostRegionCitiesId,omitempty"` } // Validate validates this address @@ -102,6 +107,10 @@ func (m *Address) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateUsPostRegionCitiesID(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -353,6 +362,18 @@ func (m *Address) validateStreetAddress1(formats strfmt.Registry) error { return nil } +func (m *Address) validateUsPostRegionCitiesID(formats strfmt.Registry) error { + if swag.IsZero(m.UsPostRegionCitiesID) { // not required + return nil + } + + if err := validate.FormatOf("usPostRegionCitiesId", "body", "uuid", m.UsPostRegionCitiesID.String(), formats); err != nil { + return err + } + + return nil +} + // ContextValidate validate this address based on the context it is used func (m *Address) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error diff --git a/pkg/gen/primeapi/embedded_spec.go b/pkg/gen/primeapi/embedded_spec.go index 53b0967c06d..b18b6cd49d0 100644 --- a/pkg/gen/primeapi/embedded_spec.go +++ b/pkg/gen/primeapi/embedded_spec.go @@ -1362,6 +1362,11 @@ func init() { "title": "Address Line 3", "x-nullable": true, "example": "Montmârtre" + }, + "usPostRegionCitiesId": { + "type": "string", + "format": "uuid", + "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" } } }, @@ -6075,6 +6080,11 @@ func init() { "title": "Address Line 3", "x-nullable": true, "example": "Montmârtre" + }, + "usPostRegionCitiesId": { + "type": "string", + "format": "uuid", + "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" } } }, diff --git a/pkg/gen/primemessages/address.go b/pkg/gen/primemessages/address.go index 4d366b7692b..c45f7467efc 100644 --- a/pkg/gen/primemessages/address.go +++ b/pkg/gen/primemessages/address.go @@ -72,6 +72,11 @@ type Address struct { // Address Line 3 // Example: Montmârtre StreetAddress3 *string `json:"streetAddress3,omitempty"` + + // us post region cities Id + // Example: c56a4180-65aa-42ec-a945-5fd21dec0538 + // Format: uuid + UsPostRegionCitiesID strfmt.UUID `json:"usPostRegionCitiesId,omitempty"` } // Validate validates this address @@ -102,6 +107,10 @@ func (m *Address) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateUsPostRegionCitiesID(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -353,6 +362,18 @@ func (m *Address) validateStreetAddress1(formats strfmt.Registry) error { return nil } +func (m *Address) validateUsPostRegionCitiesID(formats strfmt.Registry) error { + if swag.IsZero(m.UsPostRegionCitiesID) { // not required + return nil + } + + if err := validate.FormatOf("usPostRegionCitiesId", "body", "uuid", m.UsPostRegionCitiesID.String(), formats); err != nil { + return err + } + + return nil +} + // ContextValidate validate this address based on the context it is used func (m *Address) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error diff --git a/pkg/gen/primev2api/embedded_spec.go b/pkg/gen/primev2api/embedded_spec.go index 2857267df7d..5e8bc622ec3 100644 --- a/pkg/gen/primev2api/embedded_spec.go +++ b/pkg/gen/primev2api/embedded_spec.go @@ -547,6 +547,11 @@ func init() { "title": "Address Line 3", "x-nullable": true, "example": "Montmârtre" + }, + "usPostRegionCitiesId": { + "type": "string", + "format": "uuid", + "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" } } }, @@ -4021,6 +4026,11 @@ func init() { "title": "Address Line 3", "x-nullable": true, "example": "Montmârtre" + }, + "usPostRegionCitiesId": { + "type": "string", + "format": "uuid", + "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" } } }, diff --git a/pkg/gen/primev2messages/address.go b/pkg/gen/primev2messages/address.go index e1952eb6f27..9adaa14ca47 100644 --- a/pkg/gen/primev2messages/address.go +++ b/pkg/gen/primev2messages/address.go @@ -72,6 +72,11 @@ type Address struct { // Address Line 3 // Example: Montmârtre StreetAddress3 *string `json:"streetAddress3,omitempty"` + + // us post region cities Id + // Example: c56a4180-65aa-42ec-a945-5fd21dec0538 + // Format: uuid + UsPostRegionCitiesID strfmt.UUID `json:"usPostRegionCitiesId,omitempty"` } // Validate validates this address @@ -102,6 +107,10 @@ func (m *Address) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateUsPostRegionCitiesID(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -353,6 +362,18 @@ func (m *Address) validateStreetAddress1(formats strfmt.Registry) error { return nil } +func (m *Address) validateUsPostRegionCitiesID(formats strfmt.Registry) error { + if swag.IsZero(m.UsPostRegionCitiesID) { // not required + return nil + } + + if err := validate.FormatOf("usPostRegionCitiesId", "body", "uuid", m.UsPostRegionCitiesID.String(), formats); err != nil { + return err + } + + return nil +} + // ContextValidate validate this address based on the context it is used func (m *Address) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error diff --git a/pkg/gen/primev3api/embedded_spec.go b/pkg/gen/primev3api/embedded_spec.go index 2dcc1067b4e..267dc0e6538 100644 --- a/pkg/gen/primev3api/embedded_spec.go +++ b/pkg/gen/primev3api/embedded_spec.go @@ -553,6 +553,11 @@ func init() { "title": "Address Line 3", "x-nullable": true, "example": "Montmârtre" + }, + "usPostRegionCitiesId": { + "type": "string", + "format": "uuid", + "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" } } }, @@ -4381,6 +4386,11 @@ func init() { "title": "Address Line 3", "x-nullable": true, "example": "Montmârtre" + }, + "usPostRegionCitiesId": { + "type": "string", + "format": "uuid", + "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" } } }, diff --git a/pkg/gen/primev3messages/address.go b/pkg/gen/primev3messages/address.go index e9228742eff..8f91c3cb0e0 100644 --- a/pkg/gen/primev3messages/address.go +++ b/pkg/gen/primev3messages/address.go @@ -72,6 +72,11 @@ type Address struct { // Address Line 3 // Example: Montmârtre StreetAddress3 *string `json:"streetAddress3,omitempty"` + + // us post region cities Id + // Example: c56a4180-65aa-42ec-a945-5fd21dec0538 + // Format: uuid + UsPostRegionCitiesID strfmt.UUID `json:"usPostRegionCitiesId,omitempty"` } // Validate validates this address @@ -102,6 +107,10 @@ func (m *Address) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateUsPostRegionCitiesID(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -353,6 +362,18 @@ func (m *Address) validateStreetAddress1(formats strfmt.Registry) error { return nil } +func (m *Address) validateUsPostRegionCitiesID(formats strfmt.Registry) error { + if swag.IsZero(m.UsPostRegionCitiesID) { // not required + return nil + } + + if err := validate.FormatOf("usPostRegionCitiesId", "body", "uuid", m.UsPostRegionCitiesID.String(), formats); err != nil { + return err + } + + return nil +} + // ContextValidate validate this address based on the context it is used func (m *Address) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error diff --git a/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go b/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go index 16ad8c0bd32..c55eecf76c1 100644 --- a/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go +++ b/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go @@ -2396,10 +2396,11 @@ func VLocation(vLocation *models.VLocation) *ghcmessages.VLocation { } return &ghcmessages.VLocation{ - City: vLocation.CityName, - State: vLocation.StateName, - PostalCode: vLocation.UsprZipID, - County: &vLocation.UsprcCountyNm, + City: vLocation.CityName, + State: vLocation.StateName, + PostalCode: vLocation.UsprZipID, + County: &vLocation.UsprcCountyNm, + UsPostRegionCitiesID: *handlers.FmtUUID(*vLocation.UprcId), } } diff --git a/pkg/handlers/ghcapi/internal/payloads/payload_to_model.go b/pkg/handlers/ghcapi/internal/payloads/payload_to_model.go index 1883c15fbe1..700a3f12424 100644 --- a/pkg/handlers/ghcapi/internal/payloads/payload_to_model.go +++ b/pkg/handlers/ghcapi/internal/payloads/payload_to_model.go @@ -91,10 +91,13 @@ func AddressModel(address *ghcmessages.Address) *models.Address { return nil } + usprcID := uuid.FromStringOrNil(address.UsPostRegionCitiesID.String()) + modelAddress := &models.Address{ - ID: uuid.FromStringOrNil(address.ID.String()), - StreetAddress2: address.StreetAddress2, - StreetAddress3: address.StreetAddress3, + ID: uuid.FromStringOrNil(address.ID.String()), + StreetAddress2: address.StreetAddress2, + StreetAddress3: address.StreetAddress3, + UsPostRegionCityId: &usprcID, } if address.StreetAddress1 != nil { modelAddress.StreetAddress1 = *address.StreetAddress1 @@ -914,10 +917,13 @@ func VLocationModel(vLocation *ghcmessages.VLocation) *models.VLocation { return nil } + usprcID := uuid.FromStringOrNil(vLocation.UsPostRegionCitiesID.String()) + return &models.VLocation{ CityName: vLocation.City, StateName: vLocation.State, UsprZipID: vLocation.PostalCode, UsprcCountyNm: *vLocation.County, + UprcId: &usprcID, } } diff --git a/pkg/handlers/internalapi/addresses.go b/pkg/handlers/internalapi/addresses.go index 5180d932117..2c35e1cec2a 100644 --- a/pkg/handlers/internalapi/addresses.go +++ b/pkg/handlers/internalapi/addresses.go @@ -22,14 +22,18 @@ func addressModelFromPayload(rawAddress *internalmessages.Address) *models.Addre if rawAddress.County == nil { rawAddress.County = models.StringPointer("") } + + usprcID := uuid.FromStringOrNil(rawAddress.UsPostRegionCitiesID.String()) + return &models.Address{ - StreetAddress1: *rawAddress.StreetAddress1, - StreetAddress2: rawAddress.StreetAddress2, - StreetAddress3: rawAddress.StreetAddress3, - City: *rawAddress.City, - State: *rawAddress.State, - PostalCode: *rawAddress.PostalCode, - County: *rawAddress.County, + StreetAddress1: *rawAddress.StreetAddress1, + StreetAddress2: rawAddress.StreetAddress2, + StreetAddress3: rawAddress.StreetAddress3, + City: *rawAddress.City, + State: *rawAddress.State, + PostalCode: *rawAddress.PostalCode, + County: *rawAddress.County, + UsPostRegionCityId: &usprcID, } } @@ -40,6 +44,8 @@ func updateAddressWithPayload(a *models.Address, payload *internalmessages.Addre a.City = *payload.City a.State = *payload.State a.PostalCode = *payload.PostalCode + usprcID := uuid.FromStringOrNil(payload.UsPostRegionCitiesID.String()) + a.UsPostRegionCityId = &usprcID if payload.County == nil { a.County = "" } else { diff --git a/pkg/handlers/internalapi/internal/payloads/model_to_payload.go b/pkg/handlers/internalapi/internal/payloads/model_to_payload.go index 22b421bdad5..43ef5c42d8d 100644 --- a/pkg/handlers/internalapi/internal/payloads/model_to_payload.go +++ b/pkg/handlers/internalapi/internal/payloads/model_to_payload.go @@ -633,14 +633,15 @@ func VLocation(vLocation *models.VLocation) *internalmessages.VLocation { } return &internalmessages.VLocation{ - City: vLocation.CityName, - State: vLocation.StateName, - PostalCode: vLocation.UsprZipID, - County: &vLocation.UsprcCountyNm, + City: vLocation.CityName, + State: vLocation.StateName, + PostalCode: vLocation.UsprZipID, + County: &vLocation.UsprcCountyNm, + UsPostRegionCitiesID: *handlers.FmtUUID(*vLocation.UprcId), } } -// UsPostRegionCities payload +// VLocations payload func VLocations(vLocations models.VLocations) internalmessages.VLocations { payload := make(internalmessages.VLocations, len(vLocations)) for i, vLocation := range vLocations { diff --git a/pkg/handlers/internalapi/internal/payloads/payload_to_model.go b/pkg/handlers/internalapi/internal/payloads/payload_to_model.go index 8860c69c1fc..838ee8394f1 100644 --- a/pkg/handlers/internalapi/internal/payloads/payload_to_model.go +++ b/pkg/handlers/internalapi/internal/payloads/payload_to_model.go @@ -19,15 +19,19 @@ func AddressModel(address *internalmessages.Address) *models.Address { if address.County == nil { address.County = models.StringPointer("") } + + usprcID := uuid.FromStringOrNil(address.UsPostRegionCitiesID.String()) + return &models.Address{ - ID: uuid.FromStringOrNil(address.ID.String()), - StreetAddress1: *address.StreetAddress1, - StreetAddress2: address.StreetAddress2, - StreetAddress3: address.StreetAddress3, - City: *address.City, - State: *address.State, - PostalCode: *address.PostalCode, - County: *address.County, + ID: uuid.FromStringOrNil(address.ID.String()), + StreetAddress1: *address.StreetAddress1, + StreetAddress2: address.StreetAddress2, + StreetAddress3: address.StreetAddress3, + City: *address.City, + State: *address.State, + PostalCode: *address.PostalCode, + County: *address.County, + UsPostRegionCityId: &usprcID, } } @@ -36,11 +40,14 @@ func VLocationModel(vLocation *internalmessages.VLocation) *models.VLocation { return nil } + usprcID := uuid.FromStringOrNil(vLocation.UsPostRegionCitiesID.String()) + return &models.VLocation{ CityName: vLocation.City, StateName: vLocation.State, UsprZipID: vLocation.PostalCode, UsprcCountyNm: *vLocation.County, + UprcId: &usprcID, } } diff --git a/pkg/services/address/address_lookup.go b/pkg/services/address/address_lookup.go index 9249afed2e2..a1dc34e9f4f 100644 --- a/pkg/services/address/address_lookup.go +++ b/pkg/services/address/address_lookup.go @@ -75,7 +75,7 @@ func FindLocationsByZipCity(appCtx appcontext.AppContext, search string) (models // postalCode = "62226" sqlQuery := fmt.Sprintf(` - select vl.city_name, vl.state, vl.usprc_county_nm, vl.uspr_zip_id + select vl.city_name, vl.state, vl.usprc_county_nm, vl.uspr_zip_id, vl.uprc_id from v_locations vl where vl.uspr_zip_id like '%[1]s%%' and vl.city_name like upper('%[2]s%%') and vl.state like upper('%[3]s%%') limit 30`, postalCode, city, state) query := appCtx.DB().Q().RawQuery(sqlQuery) diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx index 3cfbfb2d8c1..d1c085f433d 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx @@ -92,6 +92,7 @@ ResidentialAddressForm.propTypes = { state: PropTypes.func, postalCode: PropTypes.func, county: PropTypes.func, + usprcId: PropTypes.func, }), }; diff --git a/src/types/address.js b/src/types/address.js index eaba641562e..a610a273bef 100644 --- a/src/types/address.js +++ b/src/types/address.js @@ -5,12 +5,14 @@ export const SimpleAddressShape = shape({ city: string, state: string, postalCode: string, + usprcID: string, }); export const MandatorySimpleAddressShape = shape({ city: string.isRequired, state: string.isRequired, postalCode: string.isRequired, + usprcID: string, }); export const AddressShape = shape({ @@ -21,6 +23,7 @@ export const AddressShape = shape({ streetAddress2: string, streetAddress3: string, country: string, + usprcID: string, }); export const ResidentialAddressShape = shape({ @@ -29,6 +32,7 @@ export const ResidentialAddressShape = shape({ city: string, state: string, postalCode: string, + usprcID: string, }); export const W2AddressShape = shape({ @@ -37,4 +41,5 @@ export const W2AddressShape = shape({ city: string, state: string, postalCode: string, + usprcID: string, }); diff --git a/swagger-def/definitions/Address.yaml b/swagger-def/definitions/Address.yaml index a0ae6e0a39b..a9bfaafab20 100644 --- a/swagger-def/definitions/Address.yaml +++ b/swagger-def/definitions/Address.yaml @@ -157,6 +157,10 @@ properties: title: isOconus x-nullable: true example: false + usPostRegionCitiesId: + type: string + format: uuid + example: c56a4180-65aa-42ec-a945-5fd21dec0538 required: - streetAddress1 - city diff --git a/swagger-def/definitions/VLocation.yaml b/swagger-def/definitions/VLocation.yaml index 213319be775..ef8b2e2d386 100644 --- a/swagger-def/definitions/VLocation.yaml +++ b/swagger-def/definitions/VLocation.yaml @@ -123,4 +123,7 @@ properties: title: County x-nullable: true example: 'LOS ANGELES' - + usPostRegionCitiesId: + type: string + format: uuid + example: c56a4180-65aa-42ec-a945-5fd21dec0538 diff --git a/swagger/ghc.yaml b/swagger/ghc.yaml index adec5c88e9a..b45b388b373 100644 --- a/swagger/ghc.yaml +++ b/swagger/ghc.yaml @@ -7922,6 +7922,10 @@ definitions: title: isOconus x-nullable: true example: false + usPostRegionCitiesId: + type: string + format: uuid + example: c56a4180-65aa-42ec-a945-5fd21dec0538 required: - streetAddress1 - city @@ -10972,6 +10976,10 @@ definitions: title: County x-nullable: true example: LOS ANGELES + usPostRegionCitiesId: + type: string + format: uuid + example: c56a4180-65aa-42ec-a945-5fd21dec0538 responses: InvalidRequest: description: The request payload is invalid diff --git a/swagger/internal.yaml b/swagger/internal.yaml index f6fb53c5fc1..84e9383ffab 100644 --- a/swagger/internal.yaml +++ b/swagger/internal.yaml @@ -2678,6 +2678,10 @@ definitions: title: isOconus x-nullable: true example: false + usPostRegionCitiesId: + type: string + format: uuid + example: c56a4180-65aa-42ec-a945-5fd21dec0538 required: - streetAddress1 - city @@ -4056,6 +4060,10 @@ definitions: title: County x-nullable: true example: LOS ANGELES + usPostRegionCitiesId: + type: string + format: uuid + example: c56a4180-65aa-42ec-a945-5fd21dec0538 paths: /feature-flags/user-boolean/{key}: post: diff --git a/swagger/pptas.yaml b/swagger/pptas.yaml index 78fb09f97fc..92a6f57ff5d 100644 --- a/swagger/pptas.yaml +++ b/swagger/pptas.yaml @@ -241,6 +241,10 @@ definitions: title: isOconus x-nullable: true example: false + usPostRegionCitiesId: + type: string + format: uuid + example: c56a4180-65aa-42ec-a945-5fd21dec0538 required: - streetAddress1 - city diff --git a/swagger/prime.yaml b/swagger/prime.yaml index 546f5a800f2..4f35d2c41f8 100644 --- a/swagger/prime.yaml +++ b/swagger/prime.yaml @@ -2808,6 +2808,10 @@ definitions: title: isOconus x-nullable: true example: false + usPostRegionCitiesId: + type: string + format: uuid + example: c56a4180-65aa-42ec-a945-5fd21dec0538 required: - streetAddress1 - city diff --git a/swagger/prime_v2.yaml b/swagger/prime_v2.yaml index 3392e4f18f5..3b94fa55737 100644 --- a/swagger/prime_v2.yaml +++ b/swagger/prime_v2.yaml @@ -1485,6 +1485,10 @@ definitions: title: isOconus x-nullable: true example: false + usPostRegionCitiesId: + type: string + format: uuid + example: c56a4180-65aa-42ec-a945-5fd21dec0538 required: - streetAddress1 - city diff --git a/swagger/prime_v3.yaml b/swagger/prime_v3.yaml index 86d7f3a7453..60162b36533 100644 --- a/swagger/prime_v3.yaml +++ b/swagger/prime_v3.yaml @@ -1573,6 +1573,10 @@ definitions: title: isOconus x-nullable: true example: false + usPostRegionCitiesId: + type: string + format: uuid + example: c56a4180-65aa-42ec-a945-5fd21dec0538 required: - streetAddress1 - city From bc2a526b473e55a71a70eaeb935677646bc5a9fe Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 25 Oct 2024 22:40:22 +0000 Subject: [PATCH 062/216] save usprcid with address save --- pkg/gen/ghcapi/embedded_spec.go | 4 ++-- pkg/gen/ghcmessages/address.go | 12 ++++++------ pkg/gen/internalapi/embedded_spec.go | 4 ++-- pkg/gen/internalmessages/address.go | 12 ++++++------ pkg/gen/pptasapi/embedded_spec.go | 4 ++-- pkg/gen/pptasmessages/address.go | 12 ++++++------ pkg/gen/primeapi/embedded_spec.go | 4 ++-- pkg/gen/primemessages/address.go | 12 ++++++------ pkg/gen/primev2api/embedded_spec.go | 4 ++-- pkg/gen/primev2messages/address.go | 12 ++++++------ pkg/gen/primev3api/embedded_spec.go | 4 ++-- pkg/gen/primev3messages/address.go | 12 ++++++------ .../ghcapi/internal/payloads/payload_to_model.go | 2 +- pkg/handlers/internalapi/addresses.go | 4 ++-- .../internal/payloads/payload_to_model.go | 2 +- .../ResidentialAddressForm.jsx | 1 + src/pages/MyMove/Profile/ResidentialAddress.jsx | 1 + src/types/address.js | 10 +++++----- swagger-def/definitions/Address.yaml | 2 +- swagger/ghc.yaml | 2 +- swagger/internal.yaml | 2 +- swagger/pptas.yaml | 2 +- swagger/prime.yaml | 2 +- swagger/prime_v2.yaml | 2 +- swagger/prime_v3.yaml | 2 +- 25 files changed, 66 insertions(+), 64 deletions(-) diff --git a/pkg/gen/ghcapi/embedded_spec.go b/pkg/gen/ghcapi/embedded_spec.go index 1ec2450873e..4eb930c8e82 100644 --- a/pkg/gen/ghcapi/embedded_spec.go +++ b/pkg/gen/ghcapi/embedded_spec.go @@ -6316,7 +6316,7 @@ func init() { "x-nullable": true, "example": "Montmârtre" }, - "usPostRegionCitiesId": { + "usprcId": { "type": "string", "format": "uuid", "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" @@ -22191,7 +22191,7 @@ func init() { "x-nullable": true, "example": "Montmârtre" }, - "usPostRegionCitiesId": { + "usprcId": { "type": "string", "format": "uuid", "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" diff --git a/pkg/gen/ghcmessages/address.go b/pkg/gen/ghcmessages/address.go index 67349867c16..eaf2442588b 100644 --- a/pkg/gen/ghcmessages/address.go +++ b/pkg/gen/ghcmessages/address.go @@ -73,10 +73,10 @@ type Address struct { // Example: Montmârtre StreetAddress3 *string `json:"streetAddress3,omitempty"` - // us post region cities Id + // usprc Id // Example: c56a4180-65aa-42ec-a945-5fd21dec0538 // Format: uuid - UsPostRegionCitiesID strfmt.UUID `json:"usPostRegionCitiesId,omitempty"` + UsprcID strfmt.UUID `json:"usprcId,omitempty"` } // Validate validates this address @@ -107,7 +107,7 @@ func (m *Address) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateUsPostRegionCitiesID(formats); err != nil { + if err := m.validateUsprcID(formats); err != nil { res = append(res, err) } @@ -362,12 +362,12 @@ func (m *Address) validateStreetAddress1(formats strfmt.Registry) error { return nil } -func (m *Address) validateUsPostRegionCitiesID(formats strfmt.Registry) error { - if swag.IsZero(m.UsPostRegionCitiesID) { // not required +func (m *Address) validateUsprcID(formats strfmt.Registry) error { + if swag.IsZero(m.UsprcID) { // not required return nil } - if err := validate.FormatOf("usPostRegionCitiesId", "body", "uuid", m.UsPostRegionCitiesID.String(), formats); err != nil { + if err := validate.FormatOf("usprcId", "body", "uuid", m.UsprcID.String(), formats); err != nil { return err } diff --git a/pkg/gen/internalapi/embedded_spec.go b/pkg/gen/internalapi/embedded_spec.go index 0fd77219319..2d67ab5ba5c 100644 --- a/pkg/gen/internalapi/embedded_spec.go +++ b/pkg/gen/internalapi/embedded_spec.go @@ -3520,7 +3520,7 @@ func init() { "x-nullable": true, "example": "Montmârtre" }, - "usPostRegionCitiesId": { + "usprcId": { "type": "string", "format": "uuid", "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" @@ -12339,7 +12339,7 @@ func init() { "x-nullable": true, "example": "Montmârtre" }, - "usPostRegionCitiesId": { + "usprcId": { "type": "string", "format": "uuid", "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" diff --git a/pkg/gen/internalmessages/address.go b/pkg/gen/internalmessages/address.go index 7af0581d924..8541910901d 100644 --- a/pkg/gen/internalmessages/address.go +++ b/pkg/gen/internalmessages/address.go @@ -73,10 +73,10 @@ type Address struct { // Example: Montmârtre StreetAddress3 *string `json:"streetAddress3,omitempty"` - // us post region cities Id + // usprc Id // Example: c56a4180-65aa-42ec-a945-5fd21dec0538 // Format: uuid - UsPostRegionCitiesID strfmt.UUID `json:"usPostRegionCitiesId,omitempty"` + UsprcID strfmt.UUID `json:"usprcId,omitempty"` } // Validate validates this address @@ -107,7 +107,7 @@ func (m *Address) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateUsPostRegionCitiesID(formats); err != nil { + if err := m.validateUsprcID(formats); err != nil { res = append(res, err) } @@ -362,12 +362,12 @@ func (m *Address) validateStreetAddress1(formats strfmt.Registry) error { return nil } -func (m *Address) validateUsPostRegionCitiesID(formats strfmt.Registry) error { - if swag.IsZero(m.UsPostRegionCitiesID) { // not required +func (m *Address) validateUsprcID(formats strfmt.Registry) error { + if swag.IsZero(m.UsprcID) { // not required return nil } - if err := validate.FormatOf("usPostRegionCitiesId", "body", "uuid", m.UsPostRegionCitiesID.String(), formats); err != nil { + if err := validate.FormatOf("usprcId", "body", "uuid", m.UsprcID.String(), formats); err != nil { return err } diff --git a/pkg/gen/pptasapi/embedded_spec.go b/pkg/gen/pptasapi/embedded_spec.go index 6b178298eec..833d0124dd3 100644 --- a/pkg/gen/pptasapi/embedded_spec.go +++ b/pkg/gen/pptasapi/embedded_spec.go @@ -263,7 +263,7 @@ func init() { "x-nullable": true, "example": "Montmârtre" }, - "usPostRegionCitiesId": { + "usprcId": { "type": "string", "format": "uuid", "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" @@ -1157,7 +1157,7 @@ func init() { "x-nullable": true, "example": "Montmârtre" }, - "usPostRegionCitiesId": { + "usprcId": { "type": "string", "format": "uuid", "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" diff --git a/pkg/gen/pptasmessages/address.go b/pkg/gen/pptasmessages/address.go index 76b1e586e93..d288c5082ed 100644 --- a/pkg/gen/pptasmessages/address.go +++ b/pkg/gen/pptasmessages/address.go @@ -73,10 +73,10 @@ type Address struct { // Example: Montmârtre StreetAddress3 *string `json:"streetAddress3,omitempty"` - // us post region cities Id + // usprc Id // Example: c56a4180-65aa-42ec-a945-5fd21dec0538 // Format: uuid - UsPostRegionCitiesID strfmt.UUID `json:"usPostRegionCitiesId,omitempty"` + UsprcID strfmt.UUID `json:"usprcId,omitempty"` } // Validate validates this address @@ -107,7 +107,7 @@ func (m *Address) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateUsPostRegionCitiesID(formats); err != nil { + if err := m.validateUsprcID(formats); err != nil { res = append(res, err) } @@ -362,12 +362,12 @@ func (m *Address) validateStreetAddress1(formats strfmt.Registry) error { return nil } -func (m *Address) validateUsPostRegionCitiesID(formats strfmt.Registry) error { - if swag.IsZero(m.UsPostRegionCitiesID) { // not required +func (m *Address) validateUsprcID(formats strfmt.Registry) error { + if swag.IsZero(m.UsprcID) { // not required return nil } - if err := validate.FormatOf("usPostRegionCitiesId", "body", "uuid", m.UsPostRegionCitiesID.String(), formats); err != nil { + if err := validate.FormatOf("usprcId", "body", "uuid", m.UsprcID.String(), formats); err != nil { return err } diff --git a/pkg/gen/primeapi/embedded_spec.go b/pkg/gen/primeapi/embedded_spec.go index b18b6cd49d0..be83c3796f3 100644 --- a/pkg/gen/primeapi/embedded_spec.go +++ b/pkg/gen/primeapi/embedded_spec.go @@ -1363,7 +1363,7 @@ func init() { "x-nullable": true, "example": "Montmârtre" }, - "usPostRegionCitiesId": { + "usprcId": { "type": "string", "format": "uuid", "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" @@ -6081,7 +6081,7 @@ func init() { "x-nullable": true, "example": "Montmârtre" }, - "usPostRegionCitiesId": { + "usprcId": { "type": "string", "format": "uuid", "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" diff --git a/pkg/gen/primemessages/address.go b/pkg/gen/primemessages/address.go index c45f7467efc..18ba65d8a55 100644 --- a/pkg/gen/primemessages/address.go +++ b/pkg/gen/primemessages/address.go @@ -73,10 +73,10 @@ type Address struct { // Example: Montmârtre StreetAddress3 *string `json:"streetAddress3,omitempty"` - // us post region cities Id + // usprc Id // Example: c56a4180-65aa-42ec-a945-5fd21dec0538 // Format: uuid - UsPostRegionCitiesID strfmt.UUID `json:"usPostRegionCitiesId,omitempty"` + UsprcID strfmt.UUID `json:"usprcId,omitempty"` } // Validate validates this address @@ -107,7 +107,7 @@ func (m *Address) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateUsPostRegionCitiesID(formats); err != nil { + if err := m.validateUsprcID(formats); err != nil { res = append(res, err) } @@ -362,12 +362,12 @@ func (m *Address) validateStreetAddress1(formats strfmt.Registry) error { return nil } -func (m *Address) validateUsPostRegionCitiesID(formats strfmt.Registry) error { - if swag.IsZero(m.UsPostRegionCitiesID) { // not required +func (m *Address) validateUsprcID(formats strfmt.Registry) error { + if swag.IsZero(m.UsprcID) { // not required return nil } - if err := validate.FormatOf("usPostRegionCitiesId", "body", "uuid", m.UsPostRegionCitiesID.String(), formats); err != nil { + if err := validate.FormatOf("usprcId", "body", "uuid", m.UsprcID.String(), formats); err != nil { return err } diff --git a/pkg/gen/primev2api/embedded_spec.go b/pkg/gen/primev2api/embedded_spec.go index 5e8bc622ec3..41fd0bf1f42 100644 --- a/pkg/gen/primev2api/embedded_spec.go +++ b/pkg/gen/primev2api/embedded_spec.go @@ -548,7 +548,7 @@ func init() { "x-nullable": true, "example": "Montmârtre" }, - "usPostRegionCitiesId": { + "usprcId": { "type": "string", "format": "uuid", "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" @@ -4027,7 +4027,7 @@ func init() { "x-nullable": true, "example": "Montmârtre" }, - "usPostRegionCitiesId": { + "usprcId": { "type": "string", "format": "uuid", "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" diff --git a/pkg/gen/primev2messages/address.go b/pkg/gen/primev2messages/address.go index 9adaa14ca47..99a7f2425ef 100644 --- a/pkg/gen/primev2messages/address.go +++ b/pkg/gen/primev2messages/address.go @@ -73,10 +73,10 @@ type Address struct { // Example: Montmârtre StreetAddress3 *string `json:"streetAddress3,omitempty"` - // us post region cities Id + // usprc Id // Example: c56a4180-65aa-42ec-a945-5fd21dec0538 // Format: uuid - UsPostRegionCitiesID strfmt.UUID `json:"usPostRegionCitiesId,omitempty"` + UsprcID strfmt.UUID `json:"usprcId,omitempty"` } // Validate validates this address @@ -107,7 +107,7 @@ func (m *Address) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateUsPostRegionCitiesID(formats); err != nil { + if err := m.validateUsprcID(formats); err != nil { res = append(res, err) } @@ -362,12 +362,12 @@ func (m *Address) validateStreetAddress1(formats strfmt.Registry) error { return nil } -func (m *Address) validateUsPostRegionCitiesID(formats strfmt.Registry) error { - if swag.IsZero(m.UsPostRegionCitiesID) { // not required +func (m *Address) validateUsprcID(formats strfmt.Registry) error { + if swag.IsZero(m.UsprcID) { // not required return nil } - if err := validate.FormatOf("usPostRegionCitiesId", "body", "uuid", m.UsPostRegionCitiesID.String(), formats); err != nil { + if err := validate.FormatOf("usprcId", "body", "uuid", m.UsprcID.String(), formats); err != nil { return err } diff --git a/pkg/gen/primev3api/embedded_spec.go b/pkg/gen/primev3api/embedded_spec.go index 267dc0e6538..1aa7a41993c 100644 --- a/pkg/gen/primev3api/embedded_spec.go +++ b/pkg/gen/primev3api/embedded_spec.go @@ -554,7 +554,7 @@ func init() { "x-nullable": true, "example": "Montmârtre" }, - "usPostRegionCitiesId": { + "usprcId": { "type": "string", "format": "uuid", "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" @@ -4387,7 +4387,7 @@ func init() { "x-nullable": true, "example": "Montmârtre" }, - "usPostRegionCitiesId": { + "usprcId": { "type": "string", "format": "uuid", "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" diff --git a/pkg/gen/primev3messages/address.go b/pkg/gen/primev3messages/address.go index 8f91c3cb0e0..769e4ac86f9 100644 --- a/pkg/gen/primev3messages/address.go +++ b/pkg/gen/primev3messages/address.go @@ -73,10 +73,10 @@ type Address struct { // Example: Montmârtre StreetAddress3 *string `json:"streetAddress3,omitempty"` - // us post region cities Id + // usprc Id // Example: c56a4180-65aa-42ec-a945-5fd21dec0538 // Format: uuid - UsPostRegionCitiesID strfmt.UUID `json:"usPostRegionCitiesId,omitempty"` + UsprcID strfmt.UUID `json:"usprcId,omitempty"` } // Validate validates this address @@ -107,7 +107,7 @@ func (m *Address) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateUsPostRegionCitiesID(formats); err != nil { + if err := m.validateUsprcID(formats); err != nil { res = append(res, err) } @@ -362,12 +362,12 @@ func (m *Address) validateStreetAddress1(formats strfmt.Registry) error { return nil } -func (m *Address) validateUsPostRegionCitiesID(formats strfmt.Registry) error { - if swag.IsZero(m.UsPostRegionCitiesID) { // not required +func (m *Address) validateUsprcID(formats strfmt.Registry) error { + if swag.IsZero(m.UsprcID) { // not required return nil } - if err := validate.FormatOf("usPostRegionCitiesId", "body", "uuid", m.UsPostRegionCitiesID.String(), formats); err != nil { + if err := validate.FormatOf("usprcId", "body", "uuid", m.UsprcID.String(), formats); err != nil { return err } diff --git a/pkg/handlers/ghcapi/internal/payloads/payload_to_model.go b/pkg/handlers/ghcapi/internal/payloads/payload_to_model.go index 700a3f12424..8a723b95e74 100644 --- a/pkg/handlers/ghcapi/internal/payloads/payload_to_model.go +++ b/pkg/handlers/ghcapi/internal/payloads/payload_to_model.go @@ -91,7 +91,7 @@ func AddressModel(address *ghcmessages.Address) *models.Address { return nil } - usprcID := uuid.FromStringOrNil(address.UsPostRegionCitiesID.String()) + usprcID := uuid.FromStringOrNil(address.UsprcID.String()) modelAddress := &models.Address{ ID: uuid.FromStringOrNil(address.ID.String()), diff --git a/pkg/handlers/internalapi/addresses.go b/pkg/handlers/internalapi/addresses.go index 2c35e1cec2a..38e9e114485 100644 --- a/pkg/handlers/internalapi/addresses.go +++ b/pkg/handlers/internalapi/addresses.go @@ -23,7 +23,7 @@ func addressModelFromPayload(rawAddress *internalmessages.Address) *models.Addre rawAddress.County = models.StringPointer("") } - usprcID := uuid.FromStringOrNil(rawAddress.UsPostRegionCitiesID.String()) + usprcID := uuid.FromStringOrNil(rawAddress.UsprcID.String()) return &models.Address{ StreetAddress1: *rawAddress.StreetAddress1, @@ -44,7 +44,7 @@ func updateAddressWithPayload(a *models.Address, payload *internalmessages.Addre a.City = *payload.City a.State = *payload.State a.PostalCode = *payload.PostalCode - usprcID := uuid.FromStringOrNil(payload.UsPostRegionCitiesID.String()) + usprcID := uuid.FromStringOrNil(payload.UsprcID.String()) a.UsPostRegionCityId = &usprcID if payload.County == nil { a.County = "" diff --git a/pkg/handlers/internalapi/internal/payloads/payload_to_model.go b/pkg/handlers/internalapi/internal/payloads/payload_to_model.go index 838ee8394f1..67ef8404b43 100644 --- a/pkg/handlers/internalapi/internal/payloads/payload_to_model.go +++ b/pkg/handlers/internalapi/internal/payloads/payload_to_model.go @@ -20,7 +20,7 @@ func AddressModel(address *internalmessages.Address) *models.Address { address.County = models.StringPointer("") } - usprcID := uuid.FromStringOrNil(address.UsPostRegionCitiesID.String()) + usprcID := uuid.FromStringOrNil(address.UsprcID.String()) return &models.Address{ ID: uuid.FromStringOrNil(address.ID.String()), diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx index d1c085f433d..bbd4a91583a 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx @@ -39,6 +39,7 @@ const ResidentialAddressForm = ({ formFieldsName, initialValues, onSubmit, onBac state: value.state ? value.state : '', county: value.county ? value.county : '', postalCode: value.postalCode ? value.postalCode : '', + usprcId: value.usPostRegionCitiesId ? value.usPostRegionCitiesId : '', }, }, { shouldValidate: true }, diff --git a/src/pages/MyMove/Profile/ResidentialAddress.jsx b/src/pages/MyMove/Profile/ResidentialAddress.jsx index c97b8a4835b..6204bca6803 100644 --- a/src/pages/MyMove/Profile/ResidentialAddress.jsx +++ b/src/pages/MyMove/Profile/ResidentialAddress.jsx @@ -28,6 +28,7 @@ export const ResidentialAddress = ({ serviceMember, updateServiceMember }) => { state: serviceMember.residential_address?.state || '', postalCode: serviceMember.residential_address?.postalCode || '', county: serviceMember.residential_address?.county || '', + usprcId: serviceMember.residential_address?.usprcID || '', }, }; diff --git a/src/types/address.js b/src/types/address.js index a610a273bef..4b4598b7fcc 100644 --- a/src/types/address.js +++ b/src/types/address.js @@ -5,14 +5,14 @@ export const SimpleAddressShape = shape({ city: string, state: string, postalCode: string, - usprcID: string, + usprcId: string, }); export const MandatorySimpleAddressShape = shape({ city: string.isRequired, state: string.isRequired, postalCode: string.isRequired, - usprcID: string, + usprcId: string, }); export const AddressShape = shape({ @@ -23,7 +23,7 @@ export const AddressShape = shape({ streetAddress2: string, streetAddress3: string, country: string, - usprcID: string, + usprcId: string, }); export const ResidentialAddressShape = shape({ @@ -32,7 +32,7 @@ export const ResidentialAddressShape = shape({ city: string, state: string, postalCode: string, - usprcID: string, + usprcId: string, }); export const W2AddressShape = shape({ @@ -41,5 +41,5 @@ export const W2AddressShape = shape({ city: string, state: string, postalCode: string, - usprcID: string, + usprcId: string, }); diff --git a/swagger-def/definitions/Address.yaml b/swagger-def/definitions/Address.yaml index a9bfaafab20..79ef5cc24c3 100644 --- a/swagger-def/definitions/Address.yaml +++ b/swagger-def/definitions/Address.yaml @@ -157,7 +157,7 @@ properties: title: isOconus x-nullable: true example: false - usPostRegionCitiesId: + usprcId: type: string format: uuid example: c56a4180-65aa-42ec-a945-5fd21dec0538 diff --git a/swagger/ghc.yaml b/swagger/ghc.yaml index b45b388b373..f056168530f 100644 --- a/swagger/ghc.yaml +++ b/swagger/ghc.yaml @@ -7922,7 +7922,7 @@ definitions: title: isOconus x-nullable: true example: false - usPostRegionCitiesId: + usprcId: type: string format: uuid example: c56a4180-65aa-42ec-a945-5fd21dec0538 diff --git a/swagger/internal.yaml b/swagger/internal.yaml index 84e9383ffab..365a5817ed4 100644 --- a/swagger/internal.yaml +++ b/swagger/internal.yaml @@ -2678,7 +2678,7 @@ definitions: title: isOconus x-nullable: true example: false - usPostRegionCitiesId: + usprcId: type: string format: uuid example: c56a4180-65aa-42ec-a945-5fd21dec0538 diff --git a/swagger/pptas.yaml b/swagger/pptas.yaml index 92a6f57ff5d..01dbc800af7 100644 --- a/swagger/pptas.yaml +++ b/swagger/pptas.yaml @@ -241,7 +241,7 @@ definitions: title: isOconus x-nullable: true example: false - usPostRegionCitiesId: + usprcId: type: string format: uuid example: c56a4180-65aa-42ec-a945-5fd21dec0538 diff --git a/swagger/prime.yaml b/swagger/prime.yaml index 4f35d2c41f8..96d60b2cb81 100644 --- a/swagger/prime.yaml +++ b/swagger/prime.yaml @@ -2808,7 +2808,7 @@ definitions: title: isOconus x-nullable: true example: false - usPostRegionCitiesId: + usprcId: type: string format: uuid example: c56a4180-65aa-42ec-a945-5fd21dec0538 diff --git a/swagger/prime_v2.yaml b/swagger/prime_v2.yaml index 3b94fa55737..03924d4be9e 100644 --- a/swagger/prime_v2.yaml +++ b/swagger/prime_v2.yaml @@ -1485,7 +1485,7 @@ definitions: title: isOconus x-nullable: true example: false - usPostRegionCitiesId: + usprcId: type: string format: uuid example: c56a4180-65aa-42ec-a945-5fd21dec0538 diff --git a/swagger/prime_v3.yaml b/swagger/prime_v3.yaml index 60162b36533..08dde7d71a6 100644 --- a/swagger/prime_v3.yaml +++ b/swagger/prime_v3.yaml @@ -1573,7 +1573,7 @@ definitions: title: isOconus x-nullable: true example: false - usPostRegionCitiesId: + usprcId: type: string format: uuid example: c56a4180-65aa-42ec-a945-5fd21dec0538 From 60e1e50713263cb8721c5948c2015fcccacdeef6 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Tue, 29 Oct 2024 19:59:56 +0000 Subject: [PATCH 063/216] updating variable names --- pkg/gen/ghcapi/configure_mymove.go | 6 +- pkg/gen/ghcapi/embedded_spec.go | 8 +- .../addresses/get_location_by_zip_city.go | 58 ------- .../get_location_by_zip_city_responses.go | 162 ------------------ .../get_location_by_zip_city_state.go | 58 +++++++ ..._location_by_zip_city_state_parameters.go} | 18 +- ...et_location_by_zip_city_state_responses.go | 162 ++++++++++++++++++ ..._location_by_zip_city_state_urlbuilder.go} | 24 +-- pkg/gen/ghcapi/ghcoperations/mymove_api.go | 14 +- pkg/gen/internalapi/configure_mymove.go | 6 +- pkg/gen/internalapi/embedded_spec.go | 8 +- .../addresses/get_location_by_zip_city.go | 58 ------- .../get_location_by_zip_city_responses.go | 162 ------------------ .../get_location_by_zip_city_state.go | 58 +++++++ ..._location_by_zip_city_state_parameters.go} | 18 +- ...et_location_by_zip_city_state_responses.go | 162 ++++++++++++++++++ ..._location_by_zip_city_state_urlbuilder.go} | 24 +-- .../internaloperations/mymove_api.go | 14 +- pkg/handlers/ghcapi/addresses.go | 10 +- pkg/handlers/ghcapi/addresses_test.go | 8 +- pkg/handlers/ghcapi/api.go | 2 +- pkg/handlers/internalapi/addresses.go | 10 +- pkg/handlers/internalapi/addresses_test.go | 8 +- pkg/handlers/internalapi/api.go | 2 +- .../BackupAddressForm.test.jsx | 6 +- .../ResidentialAddressForm.test.jsx | 33 +--- .../LocationSearchBox/LocationSearchBox.jsx | 14 +- .../LocationSearchBox.stories.jsx | 2 +- .../form/AddressFields/AddressFields.jsx | 18 +- .../form/AddressFields/AddressFields.test.jsx | 2 +- .../{ZipCityInput.jsx => LocationInput.jsx} | 20 +-- ...yInput.test.jsx => LocationInput.test.jsx} | 12 +- .../Profile/ResidentialAddress.test.jsx | 41 +---- src/services/ghcApi.js | 4 +- src/services/internalApi.js | 4 +- src/setupTests.js | 2 +- swagger-def/ghc.yaml | 4 +- swagger-def/internal.yaml | 4 +- swagger/ghc.yaml | 4 +- swagger/internal.yaml | 4 +- 40 files changed, 590 insertions(+), 644 deletions(-) delete mode 100644 pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city.go delete mode 100644 pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_responses.go create mode 100644 pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_state.go rename pkg/gen/ghcapi/ghcoperations/addresses/{get_location_by_zip_city_parameters.go => get_location_by_zip_city_state_parameters.go} (65%) create mode 100644 pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_state_responses.go rename pkg/gen/ghcapi/ghcoperations/addresses/{get_location_by_zip_city_urlbuilder.go => get_location_by_zip_city_state_urlbuilder.go} (72%) delete mode 100644 pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city.go delete mode 100644 pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_responses.go create mode 100644 pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_state.go rename pkg/gen/internalapi/internaloperations/addresses/{get_location_by_zip_city_parameters.go => get_location_by_zip_city_state_parameters.go} (65%) create mode 100644 pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_state_responses.go rename pkg/gen/internalapi/internaloperations/addresses/{get_location_by_zip_city_urlbuilder.go => get_location_by_zip_city_state_urlbuilder.go} (72%) rename src/components/form/fields/{ZipCityInput.jsx => LocationInput.jsx} (73%) rename src/components/form/fields/{ZipCityInput.test.jsx => LocationInput.test.jsx} (83%) diff --git a/pkg/gen/ghcapi/configure_mymove.go b/pkg/gen/ghcapi/configure_mymove.go index ea19a868536..6db7094d6c2 100644 --- a/pkg/gen/ghcapi/configure_mymove.go +++ b/pkg/gen/ghcapi/configure_mymove.go @@ -226,9 +226,9 @@ func configureAPI(api *ghcoperations.MymoveAPI) http.Handler { return middleware.NotImplemented("operation evaluation_reports.GetEvaluationReport has not yet been implemented") }) } - if api.AddressesGetLocationByZipCityHandler == nil { - api.AddressesGetLocationByZipCityHandler = addresses.GetLocationByZipCityHandlerFunc(func(params addresses.GetLocationByZipCityParams) middleware.Responder { - return middleware.NotImplemented("operation addresses.GetLocationByZipCity has not yet been implemented") + if api.AddressesGetLocationByZipCityStateHandler == nil { + api.AddressesGetLocationByZipCityStateHandler = addresses.GetLocationByZipCityStateHandlerFunc(func(params addresses.GetLocationByZipCityStateParams) middleware.Responder { + return middleware.NotImplemented("operation addresses.GetLocationByZipCityState has not yet been implemented") }) } if api.MtoServiceItemGetMTOServiceItemHandler == nil { diff --git a/pkg/gen/ghcapi/embedded_spec.go b/pkg/gen/ghcapi/embedded_spec.go index 4eb930c8e82..e29ae1d05af 100644 --- a/pkg/gen/ghcapi/embedded_spec.go +++ b/pkg/gen/ghcapi/embedded_spec.go @@ -42,8 +42,8 @@ func init() { "tags": [ "addresses" ], - "summary": "Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City string", - "operationId": "getLocationByZipCity", + "summary": "Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City and State string", + "operationId": "getLocationByZipCityState", "parameters": [ { "type": "string", @@ -14437,8 +14437,8 @@ func init() { "tags": [ "addresses" ], - "summary": "Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City string", - "operationId": "getLocationByZipCity", + "summary": "Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City and State string", + "operationId": "getLocationByZipCityState", "parameters": [ { "type": "string", diff --git a/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city.go b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city.go deleted file mode 100644 index 288f11ae2d1..00000000000 --- a/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city.go +++ /dev/null @@ -1,58 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package addresses - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime/middleware" -) - -// GetLocationByZipCityHandlerFunc turns a function with the right signature into a get location by zip city handler -type GetLocationByZipCityHandlerFunc func(GetLocationByZipCityParams) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetLocationByZipCityHandlerFunc) Handle(params GetLocationByZipCityParams) middleware.Responder { - return fn(params) -} - -// GetLocationByZipCityHandler interface for that can handle valid get location by zip city params -type GetLocationByZipCityHandler interface { - Handle(GetLocationByZipCityParams) middleware.Responder -} - -// NewGetLocationByZipCity creates a new http.Handler for the get location by zip city operation -func NewGetLocationByZipCity(ctx *middleware.Context, handler GetLocationByZipCityHandler) *GetLocationByZipCity { - return &GetLocationByZipCity{Context: ctx, Handler: handler} -} - -/* - GetLocationByZipCity swagger:route GET /addresses/zip_city_lookup/{search} addresses getLocationByZipCity - -Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City string - -Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code. -*/ -type GetLocationByZipCity struct { - Context *middleware.Context - Handler GetLocationByZipCityHandler -} - -func (o *GetLocationByZipCity) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - *r = *rCtx - } - var Params = NewGetLocationByZipCityParams() - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_responses.go b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_responses.go deleted file mode 100644 index 30c9c3a1d79..00000000000 --- a/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_responses.go +++ /dev/null @@ -1,162 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package addresses - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - - "github.com/transcom/mymove/pkg/gen/ghcmessages" -) - -// GetLocationByZipCityOKCode is the HTTP code returned for type GetLocationByZipCityOK -const GetLocationByZipCityOKCode int = 200 - -/* -GetLocationByZipCityOK the requested list of city, state, county, and postal code matches - -swagger:response getLocationByZipCityOK -*/ -type GetLocationByZipCityOK struct { - - /* - In: Body - */ - Payload ghcmessages.VLocations `json:"body,omitempty"` -} - -// NewGetLocationByZipCityOK creates GetLocationByZipCityOK with default headers values -func NewGetLocationByZipCityOK() *GetLocationByZipCityOK { - - return &GetLocationByZipCityOK{} -} - -// WithPayload adds the payload to the get location by zip city o k response -func (o *GetLocationByZipCityOK) WithPayload(payload ghcmessages.VLocations) *GetLocationByZipCityOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get location by zip city o k response -func (o *GetLocationByZipCityOK) SetPayload(payload ghcmessages.VLocations) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetLocationByZipCityOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(200) - payload := o.Payload - if payload == nil { - // return empty array - payload = ghcmessages.VLocations{} - } - - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } -} - -// GetLocationByZipCityBadRequestCode is the HTTP code returned for type GetLocationByZipCityBadRequest -const GetLocationByZipCityBadRequestCode int = 400 - -/* -GetLocationByZipCityBadRequest invalid request - -swagger:response getLocationByZipCityBadRequest -*/ -type GetLocationByZipCityBadRequest struct { -} - -// NewGetLocationByZipCityBadRequest creates GetLocationByZipCityBadRequest with default headers values -func NewGetLocationByZipCityBadRequest() *GetLocationByZipCityBadRequest { - - return &GetLocationByZipCityBadRequest{} -} - -// WriteResponse to the client -func (o *GetLocationByZipCityBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(400) -} - -// GetLocationByZipCityForbiddenCode is the HTTP code returned for type GetLocationByZipCityForbidden -const GetLocationByZipCityForbiddenCode int = 403 - -/* -GetLocationByZipCityForbidden not authorized - -swagger:response getLocationByZipCityForbidden -*/ -type GetLocationByZipCityForbidden struct { -} - -// NewGetLocationByZipCityForbidden creates GetLocationByZipCityForbidden with default headers values -func NewGetLocationByZipCityForbidden() *GetLocationByZipCityForbidden { - - return &GetLocationByZipCityForbidden{} -} - -// WriteResponse to the client -func (o *GetLocationByZipCityForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(403) -} - -// GetLocationByZipCityNotFoundCode is the HTTP code returned for type GetLocationByZipCityNotFound -const GetLocationByZipCityNotFoundCode int = 404 - -/* -GetLocationByZipCityNotFound not found - -swagger:response getLocationByZipCityNotFound -*/ -type GetLocationByZipCityNotFound struct { -} - -// NewGetLocationByZipCityNotFound creates GetLocationByZipCityNotFound with default headers values -func NewGetLocationByZipCityNotFound() *GetLocationByZipCityNotFound { - - return &GetLocationByZipCityNotFound{} -} - -// WriteResponse to the client -func (o *GetLocationByZipCityNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(404) -} - -// GetLocationByZipCityInternalServerErrorCode is the HTTP code returned for type GetLocationByZipCityInternalServerError -const GetLocationByZipCityInternalServerErrorCode int = 500 - -/* -GetLocationByZipCityInternalServerError server error - -swagger:response getLocationByZipCityInternalServerError -*/ -type GetLocationByZipCityInternalServerError struct { -} - -// NewGetLocationByZipCityInternalServerError creates GetLocationByZipCityInternalServerError with default headers values -func NewGetLocationByZipCityInternalServerError() *GetLocationByZipCityInternalServerError { - - return &GetLocationByZipCityInternalServerError{} -} - -// WriteResponse to the client -func (o *GetLocationByZipCityInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(500) -} diff --git a/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_state.go b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_state.go new file mode 100644 index 00000000000..408bd7434e8 --- /dev/null +++ b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_state.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package addresses + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLocationByZipCityStateHandlerFunc turns a function with the right signature into a get location by zip city state handler +type GetLocationByZipCityStateHandlerFunc func(GetLocationByZipCityStateParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLocationByZipCityStateHandlerFunc) Handle(params GetLocationByZipCityStateParams) middleware.Responder { + return fn(params) +} + +// GetLocationByZipCityStateHandler interface for that can handle valid get location by zip city state params +type GetLocationByZipCityStateHandler interface { + Handle(GetLocationByZipCityStateParams) middleware.Responder +} + +// NewGetLocationByZipCityState creates a new http.Handler for the get location by zip city state operation +func NewGetLocationByZipCityState(ctx *middleware.Context, handler GetLocationByZipCityStateHandler) *GetLocationByZipCityState { + return &GetLocationByZipCityState{Context: ctx, Handler: handler} +} + +/* + GetLocationByZipCityState swagger:route GET /addresses/zip_city_lookup/{search} addresses getLocationByZipCityState + +Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City and State string + +Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code. +*/ +type GetLocationByZipCityState struct { + Context *middleware.Context + Handler GetLocationByZipCityStateHandler +} + +func (o *GetLocationByZipCityState) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetLocationByZipCityStateParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_parameters.go b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_state_parameters.go similarity index 65% rename from pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_parameters.go rename to pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_state_parameters.go index 17f92305b63..0e8106fb581 100644 --- a/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_parameters.go +++ b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_state_parameters.go @@ -13,19 +13,19 @@ import ( "github.com/go-openapi/strfmt" ) -// NewGetLocationByZipCityParams creates a new GetLocationByZipCityParams object +// NewGetLocationByZipCityStateParams creates a new GetLocationByZipCityStateParams object // // There are no default values defined in the spec. -func NewGetLocationByZipCityParams() GetLocationByZipCityParams { +func NewGetLocationByZipCityStateParams() GetLocationByZipCityStateParams { - return GetLocationByZipCityParams{} + return GetLocationByZipCityStateParams{} } -// GetLocationByZipCityParams contains all the bound params for the get location by zip city operation +// GetLocationByZipCityStateParams contains all the bound params for the get location by zip city state operation // typically these are obtained from a http.Request // -// swagger:parameters getLocationByZipCity -type GetLocationByZipCityParams struct { +// swagger:parameters getLocationByZipCityState +type GetLocationByZipCityStateParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` @@ -40,8 +40,8 @@ type GetLocationByZipCityParams struct { // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface // for simple values it will use straight method calls. // -// To ensure default values, the struct must have been initialized with NewGetLocationByZipCityParams() beforehand. -func (o *GetLocationByZipCityParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { +// To ensure default values, the struct must have been initialized with NewGetLocationByZipCityStateParams() beforehand. +func (o *GetLocationByZipCityStateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { var res []error o.HTTPRequest = r @@ -57,7 +57,7 @@ func (o *GetLocationByZipCityParams) BindRequest(r *http.Request, route *middlew } // bindSearch binds and validates parameter Search from path. -func (o *GetLocationByZipCityParams) bindSearch(rawData []string, hasKey bool, formats strfmt.Registry) error { +func (o *GetLocationByZipCityStateParams) bindSearch(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] diff --git a/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_state_responses.go b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_state_responses.go new file mode 100644 index 00000000000..60f53d3b57b --- /dev/null +++ b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_state_responses.go @@ -0,0 +1,162 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package addresses + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/transcom/mymove/pkg/gen/ghcmessages" +) + +// GetLocationByZipCityStateOKCode is the HTTP code returned for type GetLocationByZipCityStateOK +const GetLocationByZipCityStateOKCode int = 200 + +/* +GetLocationByZipCityStateOK the requested list of city, state, county, and postal code matches + +swagger:response getLocationByZipCityStateOK +*/ +type GetLocationByZipCityStateOK struct { + + /* + In: Body + */ + Payload ghcmessages.VLocations `json:"body,omitempty"` +} + +// NewGetLocationByZipCityStateOK creates GetLocationByZipCityStateOK with default headers values +func NewGetLocationByZipCityStateOK() *GetLocationByZipCityStateOK { + + return &GetLocationByZipCityStateOK{} +} + +// WithPayload adds the payload to the get location by zip city state o k response +func (o *GetLocationByZipCityStateOK) WithPayload(payload ghcmessages.VLocations) *GetLocationByZipCityStateOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get location by zip city state o k response +func (o *GetLocationByZipCityStateOK) SetPayload(payload ghcmessages.VLocations) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLocationByZipCityStateOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = ghcmessages.VLocations{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetLocationByZipCityStateBadRequestCode is the HTTP code returned for type GetLocationByZipCityStateBadRequest +const GetLocationByZipCityStateBadRequestCode int = 400 + +/* +GetLocationByZipCityStateBadRequest invalid request + +swagger:response getLocationByZipCityStateBadRequest +*/ +type GetLocationByZipCityStateBadRequest struct { +} + +// NewGetLocationByZipCityStateBadRequest creates GetLocationByZipCityStateBadRequest with default headers values +func NewGetLocationByZipCityStateBadRequest() *GetLocationByZipCityStateBadRequest { + + return &GetLocationByZipCityStateBadRequest{} +} + +// WriteResponse to the client +func (o *GetLocationByZipCityStateBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(400) +} + +// GetLocationByZipCityStateForbiddenCode is the HTTP code returned for type GetLocationByZipCityStateForbidden +const GetLocationByZipCityStateForbiddenCode int = 403 + +/* +GetLocationByZipCityStateForbidden not authorized + +swagger:response getLocationByZipCityStateForbidden +*/ +type GetLocationByZipCityStateForbidden struct { +} + +// NewGetLocationByZipCityStateForbidden creates GetLocationByZipCityStateForbidden with default headers values +func NewGetLocationByZipCityStateForbidden() *GetLocationByZipCityStateForbidden { + + return &GetLocationByZipCityStateForbidden{} +} + +// WriteResponse to the client +func (o *GetLocationByZipCityStateForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(403) +} + +// GetLocationByZipCityStateNotFoundCode is the HTTP code returned for type GetLocationByZipCityStateNotFound +const GetLocationByZipCityStateNotFoundCode int = 404 + +/* +GetLocationByZipCityStateNotFound not found + +swagger:response getLocationByZipCityStateNotFound +*/ +type GetLocationByZipCityStateNotFound struct { +} + +// NewGetLocationByZipCityStateNotFound creates GetLocationByZipCityStateNotFound with default headers values +func NewGetLocationByZipCityStateNotFound() *GetLocationByZipCityStateNotFound { + + return &GetLocationByZipCityStateNotFound{} +} + +// WriteResponse to the client +func (o *GetLocationByZipCityStateNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(404) +} + +// GetLocationByZipCityStateInternalServerErrorCode is the HTTP code returned for type GetLocationByZipCityStateInternalServerError +const GetLocationByZipCityStateInternalServerErrorCode int = 500 + +/* +GetLocationByZipCityStateInternalServerError server error + +swagger:response getLocationByZipCityStateInternalServerError +*/ +type GetLocationByZipCityStateInternalServerError struct { +} + +// NewGetLocationByZipCityStateInternalServerError creates GetLocationByZipCityStateInternalServerError with default headers values +func NewGetLocationByZipCityStateInternalServerError() *GetLocationByZipCityStateInternalServerError { + + return &GetLocationByZipCityStateInternalServerError{} +} + +// WriteResponse to the client +func (o *GetLocationByZipCityStateInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(500) +} diff --git a/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_urlbuilder.go b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_state_urlbuilder.go similarity index 72% rename from pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_urlbuilder.go rename to pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_state_urlbuilder.go index 4a00f0c4e66..e1352c6f387 100644 --- a/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_urlbuilder.go +++ b/pkg/gen/ghcapi/ghcoperations/addresses/get_location_by_zip_city_state_urlbuilder.go @@ -12,8 +12,8 @@ import ( "strings" ) -// GetLocationByZipCityURL generates an URL for the get location by zip city operation -type GetLocationByZipCityURL struct { +// GetLocationByZipCityStateURL generates an URL for the get location by zip city state operation +type GetLocationByZipCityStateURL struct { Search string _basePath string @@ -24,7 +24,7 @@ type GetLocationByZipCityURL struct { // WithBasePath sets the base path for this url builder, only required when it's different from the // base path specified in the swagger spec. // When the value of the base path is an empty string -func (o *GetLocationByZipCityURL) WithBasePath(bp string) *GetLocationByZipCityURL { +func (o *GetLocationByZipCityStateURL) WithBasePath(bp string) *GetLocationByZipCityStateURL { o.SetBasePath(bp) return o } @@ -32,12 +32,12 @@ func (o *GetLocationByZipCityURL) WithBasePath(bp string) *GetLocationByZipCityU // SetBasePath sets the base path for this url builder, only required when it's different from the // base path specified in the swagger spec. // When the value of the base path is an empty string -func (o *GetLocationByZipCityURL) SetBasePath(bp string) { +func (o *GetLocationByZipCityStateURL) SetBasePath(bp string) { o._basePath = bp } // Build a url path and query string -func (o *GetLocationByZipCityURL) Build() (*url.URL, error) { +func (o *GetLocationByZipCityStateURL) Build() (*url.URL, error) { var _result url.URL var _path = "/addresses/zip_city_lookup/{search}" @@ -46,7 +46,7 @@ func (o *GetLocationByZipCityURL) Build() (*url.URL, error) { if search != "" { _path = strings.Replace(_path, "{search}", search, -1) } else { - return nil, errors.New("search is required on GetLocationByZipCityURL") + return nil, errors.New("search is required on GetLocationByZipCityStateURL") } _basePath := o._basePath @@ -59,7 +59,7 @@ func (o *GetLocationByZipCityURL) Build() (*url.URL, error) { } // Must is a helper function to panic when the url builder returns an error -func (o *GetLocationByZipCityURL) Must(u *url.URL, err error) *url.URL { +func (o *GetLocationByZipCityStateURL) Must(u *url.URL, err error) *url.URL { if err != nil { panic(err) } @@ -70,17 +70,17 @@ func (o *GetLocationByZipCityURL) Must(u *url.URL, err error) *url.URL { } // String returns the string representation of the path with query string -func (o *GetLocationByZipCityURL) String() string { +func (o *GetLocationByZipCityStateURL) String() string { return o.Must(o.Build()).String() } // BuildFull builds a full url with scheme, host, path and query string -func (o *GetLocationByZipCityURL) BuildFull(scheme, host string) (*url.URL, error) { +func (o *GetLocationByZipCityStateURL) BuildFull(scheme, host string) (*url.URL, error) { if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetLocationByZipCityURL") + return nil, errors.New("scheme is required for a full url on GetLocationByZipCityStateURL") } if host == "" { - return nil, errors.New("host is required for a full url on GetLocationByZipCityURL") + return nil, errors.New("host is required for a full url on GetLocationByZipCityStateURL") } base, err := o.Build() @@ -94,6 +94,6 @@ func (o *GetLocationByZipCityURL) BuildFull(scheme, host string) (*url.URL, erro } // StringFull returns the string representation of a complete url -func (o *GetLocationByZipCityURL) StringFull(scheme, host string) string { +func (o *GetLocationByZipCityStateURL) StringFull(scheme, host string) string { return o.Must(o.BuildFull(scheme, host)).String() } diff --git a/pkg/gen/ghcapi/ghcoperations/mymove_api.go b/pkg/gen/ghcapi/ghcoperations/mymove_api.go index eab3d1c105f..839389fc429 100644 --- a/pkg/gen/ghcapi/ghcoperations/mymove_api.go +++ b/pkg/gen/ghcapi/ghcoperations/mymove_api.go @@ -163,8 +163,8 @@ func NewMymoveAPI(spec *loads.Document) *MymoveAPI { EvaluationReportsGetEvaluationReportHandler: evaluation_reports.GetEvaluationReportHandlerFunc(func(params evaluation_reports.GetEvaluationReportParams) middleware.Responder { return middleware.NotImplemented("operation evaluation_reports.GetEvaluationReport has not yet been implemented") }), - AddressesGetLocationByZipCityHandler: addresses.GetLocationByZipCityHandlerFunc(func(params addresses.GetLocationByZipCityParams) middleware.Responder { - return middleware.NotImplemented("operation addresses.GetLocationByZipCity has not yet been implemented") + AddressesGetLocationByZipCityStateHandler: addresses.GetLocationByZipCityStateHandlerFunc(func(params addresses.GetLocationByZipCityStateParams) middleware.Responder { + return middleware.NotImplemented("operation addresses.GetLocationByZipCityState has not yet been implemented") }), MtoServiceItemGetMTOServiceItemHandler: mto_service_item.GetMTOServiceItemHandlerFunc(func(params mto_service_item.GetMTOServiceItemParams) middleware.Responder { return middleware.NotImplemented("operation mto_service_item.GetMTOServiceItem has not yet been implemented") @@ -484,8 +484,8 @@ type MymoveAPI struct { MoveTaskOrderGetEntitlementsHandler move_task_order.GetEntitlementsHandler // EvaluationReportsGetEvaluationReportHandler sets the operation handler for the get evaluation report operation EvaluationReportsGetEvaluationReportHandler evaluation_reports.GetEvaluationReportHandler - // AddressesGetLocationByZipCityHandler sets the operation handler for the get location by zip city operation - AddressesGetLocationByZipCityHandler addresses.GetLocationByZipCityHandler + // AddressesGetLocationByZipCityStateHandler sets the operation handler for the get location by zip city state operation + AddressesGetLocationByZipCityStateHandler addresses.GetLocationByZipCityStateHandler // MtoServiceItemGetMTOServiceItemHandler sets the operation handler for the get m t o service item operation MtoServiceItemGetMTOServiceItemHandler mto_service_item.GetMTOServiceItemHandler // MoveGetMoveHandler sets the operation handler for the get move operation @@ -802,8 +802,8 @@ func (o *MymoveAPI) Validate() error { if o.EvaluationReportsGetEvaluationReportHandler == nil { unregistered = append(unregistered, "evaluation_reports.GetEvaluationReportHandler") } - if o.AddressesGetLocationByZipCityHandler == nil { - unregistered = append(unregistered, "addresses.GetLocationByZipCityHandler") + if o.AddressesGetLocationByZipCityStateHandler == nil { + unregistered = append(unregistered, "addresses.GetLocationByZipCityStateHandler") } if o.MtoServiceItemGetMTOServiceItemHandler == nil { unregistered = append(unregistered, "mto_service_item.GetMTOServiceItemHandler") @@ -1234,7 +1234,7 @@ func (o *MymoveAPI) initHandlerCache() { if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } - o.handlers["GET"]["/addresses/zip_city_lookup/{search}"] = addresses.NewGetLocationByZipCity(o.context, o.AddressesGetLocationByZipCityHandler) + o.handlers["GET"]["/addresses/zip_city_lookup/{search}"] = addresses.NewGetLocationByZipCityState(o.context, o.AddressesGetLocationByZipCityStateHandler) if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } diff --git a/pkg/gen/internalapi/configure_mymove.go b/pkg/gen/internalapi/configure_mymove.go index 97d71572a1f..3b277e0037c 100644 --- a/pkg/gen/internalapi/configure_mymove.go +++ b/pkg/gen/internalapi/configure_mymove.go @@ -195,9 +195,9 @@ func configureAPI(api *internaloperations.MymoveAPI) http.Handler { return middleware.NotImplemented("operation moves.GetAllMoves has not yet been implemented") }) } - if api.AddressesGetLocationByZipCityHandler == nil { - api.AddressesGetLocationByZipCityHandler = addresses.GetLocationByZipCityHandlerFunc(func(params addresses.GetLocationByZipCityParams) middleware.Responder { - return middleware.NotImplemented("operation addresses.GetLocationByZipCity has not yet been implemented") + if api.AddressesGetLocationByZipCityStateHandler == nil { + api.AddressesGetLocationByZipCityStateHandler = addresses.GetLocationByZipCityStateHandlerFunc(func(params addresses.GetLocationByZipCityStateParams) middleware.Responder { + return middleware.NotImplemented("operation addresses.GetLocationByZipCityState has not yet been implemented") }) } if api.TransportationOfficesGetTransportationOfficesHandler == nil { diff --git a/pkg/gen/internalapi/embedded_spec.go b/pkg/gen/internalapi/embedded_spec.go index 2d67ab5ba5c..61586843f78 100644 --- a/pkg/gen/internalapi/embedded_spec.go +++ b/pkg/gen/internalapi/embedded_spec.go @@ -45,8 +45,8 @@ func init() { "tags": [ "addresses" ], - "summary": "Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City string", - "operationId": "getLocationByZipCity", + "summary": "Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City State string", + "operationId": "getLocationByZipCityState", "parameters": [ { "type": "string", @@ -8411,8 +8411,8 @@ func init() { "tags": [ "addresses" ], - "summary": "Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City string", - "operationId": "getLocationByZipCity", + "summary": "Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City State string", + "operationId": "getLocationByZipCityState", "parameters": [ { "type": "string", diff --git a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city.go b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city.go deleted file mode 100644 index 288f11ae2d1..00000000000 --- a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city.go +++ /dev/null @@ -1,58 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package addresses - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime/middleware" -) - -// GetLocationByZipCityHandlerFunc turns a function with the right signature into a get location by zip city handler -type GetLocationByZipCityHandlerFunc func(GetLocationByZipCityParams) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetLocationByZipCityHandlerFunc) Handle(params GetLocationByZipCityParams) middleware.Responder { - return fn(params) -} - -// GetLocationByZipCityHandler interface for that can handle valid get location by zip city params -type GetLocationByZipCityHandler interface { - Handle(GetLocationByZipCityParams) middleware.Responder -} - -// NewGetLocationByZipCity creates a new http.Handler for the get location by zip city operation -func NewGetLocationByZipCity(ctx *middleware.Context, handler GetLocationByZipCityHandler) *GetLocationByZipCity { - return &GetLocationByZipCity{Context: ctx, Handler: handler} -} - -/* - GetLocationByZipCity swagger:route GET /addresses/zip_city_lookup/{search} addresses getLocationByZipCity - -Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City string - -Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code. -*/ -type GetLocationByZipCity struct { - Context *middleware.Context - Handler GetLocationByZipCityHandler -} - -func (o *GetLocationByZipCity) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - *r = *rCtx - } - var Params = NewGetLocationByZipCityParams() - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_responses.go b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_responses.go deleted file mode 100644 index 7369a6a275c..00000000000 --- a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_responses.go +++ /dev/null @@ -1,162 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package addresses - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - - "github.com/transcom/mymove/pkg/gen/internalmessages" -) - -// GetLocationByZipCityOKCode is the HTTP code returned for type GetLocationByZipCityOK -const GetLocationByZipCityOKCode int = 200 - -/* -GetLocationByZipCityOK the requested list of city, state, county, and postal code matches - -swagger:response getLocationByZipCityOK -*/ -type GetLocationByZipCityOK struct { - - /* - In: Body - */ - Payload internalmessages.VLocations `json:"body,omitempty"` -} - -// NewGetLocationByZipCityOK creates GetLocationByZipCityOK with default headers values -func NewGetLocationByZipCityOK() *GetLocationByZipCityOK { - - return &GetLocationByZipCityOK{} -} - -// WithPayload adds the payload to the get location by zip city o k response -func (o *GetLocationByZipCityOK) WithPayload(payload internalmessages.VLocations) *GetLocationByZipCityOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get location by zip city o k response -func (o *GetLocationByZipCityOK) SetPayload(payload internalmessages.VLocations) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetLocationByZipCityOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(200) - payload := o.Payload - if payload == nil { - // return empty array - payload = internalmessages.VLocations{} - } - - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } -} - -// GetLocationByZipCityBadRequestCode is the HTTP code returned for type GetLocationByZipCityBadRequest -const GetLocationByZipCityBadRequestCode int = 400 - -/* -GetLocationByZipCityBadRequest invalid request - -swagger:response getLocationByZipCityBadRequest -*/ -type GetLocationByZipCityBadRequest struct { -} - -// NewGetLocationByZipCityBadRequest creates GetLocationByZipCityBadRequest with default headers values -func NewGetLocationByZipCityBadRequest() *GetLocationByZipCityBadRequest { - - return &GetLocationByZipCityBadRequest{} -} - -// WriteResponse to the client -func (o *GetLocationByZipCityBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(400) -} - -// GetLocationByZipCityForbiddenCode is the HTTP code returned for type GetLocationByZipCityForbidden -const GetLocationByZipCityForbiddenCode int = 403 - -/* -GetLocationByZipCityForbidden not authorized - -swagger:response getLocationByZipCityForbidden -*/ -type GetLocationByZipCityForbidden struct { -} - -// NewGetLocationByZipCityForbidden creates GetLocationByZipCityForbidden with default headers values -func NewGetLocationByZipCityForbidden() *GetLocationByZipCityForbidden { - - return &GetLocationByZipCityForbidden{} -} - -// WriteResponse to the client -func (o *GetLocationByZipCityForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(403) -} - -// GetLocationByZipCityNotFoundCode is the HTTP code returned for type GetLocationByZipCityNotFound -const GetLocationByZipCityNotFoundCode int = 404 - -/* -GetLocationByZipCityNotFound not found - -swagger:response getLocationByZipCityNotFound -*/ -type GetLocationByZipCityNotFound struct { -} - -// NewGetLocationByZipCityNotFound creates GetLocationByZipCityNotFound with default headers values -func NewGetLocationByZipCityNotFound() *GetLocationByZipCityNotFound { - - return &GetLocationByZipCityNotFound{} -} - -// WriteResponse to the client -func (o *GetLocationByZipCityNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(404) -} - -// GetLocationByZipCityInternalServerErrorCode is the HTTP code returned for type GetLocationByZipCityInternalServerError -const GetLocationByZipCityInternalServerErrorCode int = 500 - -/* -GetLocationByZipCityInternalServerError server error - -swagger:response getLocationByZipCityInternalServerError -*/ -type GetLocationByZipCityInternalServerError struct { -} - -// NewGetLocationByZipCityInternalServerError creates GetLocationByZipCityInternalServerError with default headers values -func NewGetLocationByZipCityInternalServerError() *GetLocationByZipCityInternalServerError { - - return &GetLocationByZipCityInternalServerError{} -} - -// WriteResponse to the client -func (o *GetLocationByZipCityInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(500) -} diff --git a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_state.go b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_state.go new file mode 100644 index 00000000000..bc0b8f50803 --- /dev/null +++ b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_state.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package addresses + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLocationByZipCityStateHandlerFunc turns a function with the right signature into a get location by zip city state handler +type GetLocationByZipCityStateHandlerFunc func(GetLocationByZipCityStateParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLocationByZipCityStateHandlerFunc) Handle(params GetLocationByZipCityStateParams) middleware.Responder { + return fn(params) +} + +// GetLocationByZipCityStateHandler interface for that can handle valid get location by zip city state params +type GetLocationByZipCityStateHandler interface { + Handle(GetLocationByZipCityStateParams) middleware.Responder +} + +// NewGetLocationByZipCityState creates a new http.Handler for the get location by zip city state operation +func NewGetLocationByZipCityState(ctx *middleware.Context, handler GetLocationByZipCityStateHandler) *GetLocationByZipCityState { + return &GetLocationByZipCityState{Context: ctx, Handler: handler} +} + +/* + GetLocationByZipCityState swagger:route GET /addresses/zip_city_lookup/{search} addresses getLocationByZipCityState + +Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City State string + +Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code. +*/ +type GetLocationByZipCityState struct { + Context *middleware.Context + Handler GetLocationByZipCityStateHandler +} + +func (o *GetLocationByZipCityState) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetLocationByZipCityStateParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_parameters.go b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_state_parameters.go similarity index 65% rename from pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_parameters.go rename to pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_state_parameters.go index 17f92305b63..0e8106fb581 100644 --- a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_parameters.go +++ b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_state_parameters.go @@ -13,19 +13,19 @@ import ( "github.com/go-openapi/strfmt" ) -// NewGetLocationByZipCityParams creates a new GetLocationByZipCityParams object +// NewGetLocationByZipCityStateParams creates a new GetLocationByZipCityStateParams object // // There are no default values defined in the spec. -func NewGetLocationByZipCityParams() GetLocationByZipCityParams { +func NewGetLocationByZipCityStateParams() GetLocationByZipCityStateParams { - return GetLocationByZipCityParams{} + return GetLocationByZipCityStateParams{} } -// GetLocationByZipCityParams contains all the bound params for the get location by zip city operation +// GetLocationByZipCityStateParams contains all the bound params for the get location by zip city state operation // typically these are obtained from a http.Request // -// swagger:parameters getLocationByZipCity -type GetLocationByZipCityParams struct { +// swagger:parameters getLocationByZipCityState +type GetLocationByZipCityStateParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` @@ -40,8 +40,8 @@ type GetLocationByZipCityParams struct { // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface // for simple values it will use straight method calls. // -// To ensure default values, the struct must have been initialized with NewGetLocationByZipCityParams() beforehand. -func (o *GetLocationByZipCityParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { +// To ensure default values, the struct must have been initialized with NewGetLocationByZipCityStateParams() beforehand. +func (o *GetLocationByZipCityStateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { var res []error o.HTTPRequest = r @@ -57,7 +57,7 @@ func (o *GetLocationByZipCityParams) BindRequest(r *http.Request, route *middlew } // bindSearch binds and validates parameter Search from path. -func (o *GetLocationByZipCityParams) bindSearch(rawData []string, hasKey bool, formats strfmt.Registry) error { +func (o *GetLocationByZipCityStateParams) bindSearch(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] diff --git a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_state_responses.go b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_state_responses.go new file mode 100644 index 00000000000..ea727782af4 --- /dev/null +++ b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_state_responses.go @@ -0,0 +1,162 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package addresses + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/transcom/mymove/pkg/gen/internalmessages" +) + +// GetLocationByZipCityStateOKCode is the HTTP code returned for type GetLocationByZipCityStateOK +const GetLocationByZipCityStateOKCode int = 200 + +/* +GetLocationByZipCityStateOK the requested list of city, state, county, and postal code matches + +swagger:response getLocationByZipCityStateOK +*/ +type GetLocationByZipCityStateOK struct { + + /* + In: Body + */ + Payload internalmessages.VLocations `json:"body,omitempty"` +} + +// NewGetLocationByZipCityStateOK creates GetLocationByZipCityStateOK with default headers values +func NewGetLocationByZipCityStateOK() *GetLocationByZipCityStateOK { + + return &GetLocationByZipCityStateOK{} +} + +// WithPayload adds the payload to the get location by zip city state o k response +func (o *GetLocationByZipCityStateOK) WithPayload(payload internalmessages.VLocations) *GetLocationByZipCityStateOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get location by zip city state o k response +func (o *GetLocationByZipCityStateOK) SetPayload(payload internalmessages.VLocations) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLocationByZipCityStateOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = internalmessages.VLocations{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetLocationByZipCityStateBadRequestCode is the HTTP code returned for type GetLocationByZipCityStateBadRequest +const GetLocationByZipCityStateBadRequestCode int = 400 + +/* +GetLocationByZipCityStateBadRequest invalid request + +swagger:response getLocationByZipCityStateBadRequest +*/ +type GetLocationByZipCityStateBadRequest struct { +} + +// NewGetLocationByZipCityStateBadRequest creates GetLocationByZipCityStateBadRequest with default headers values +func NewGetLocationByZipCityStateBadRequest() *GetLocationByZipCityStateBadRequest { + + return &GetLocationByZipCityStateBadRequest{} +} + +// WriteResponse to the client +func (o *GetLocationByZipCityStateBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(400) +} + +// GetLocationByZipCityStateForbiddenCode is the HTTP code returned for type GetLocationByZipCityStateForbidden +const GetLocationByZipCityStateForbiddenCode int = 403 + +/* +GetLocationByZipCityStateForbidden not authorized + +swagger:response getLocationByZipCityStateForbidden +*/ +type GetLocationByZipCityStateForbidden struct { +} + +// NewGetLocationByZipCityStateForbidden creates GetLocationByZipCityStateForbidden with default headers values +func NewGetLocationByZipCityStateForbidden() *GetLocationByZipCityStateForbidden { + + return &GetLocationByZipCityStateForbidden{} +} + +// WriteResponse to the client +func (o *GetLocationByZipCityStateForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(403) +} + +// GetLocationByZipCityStateNotFoundCode is the HTTP code returned for type GetLocationByZipCityStateNotFound +const GetLocationByZipCityStateNotFoundCode int = 404 + +/* +GetLocationByZipCityStateNotFound not found + +swagger:response getLocationByZipCityStateNotFound +*/ +type GetLocationByZipCityStateNotFound struct { +} + +// NewGetLocationByZipCityStateNotFound creates GetLocationByZipCityStateNotFound with default headers values +func NewGetLocationByZipCityStateNotFound() *GetLocationByZipCityStateNotFound { + + return &GetLocationByZipCityStateNotFound{} +} + +// WriteResponse to the client +func (o *GetLocationByZipCityStateNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(404) +} + +// GetLocationByZipCityStateInternalServerErrorCode is the HTTP code returned for type GetLocationByZipCityStateInternalServerError +const GetLocationByZipCityStateInternalServerErrorCode int = 500 + +/* +GetLocationByZipCityStateInternalServerError server error + +swagger:response getLocationByZipCityStateInternalServerError +*/ +type GetLocationByZipCityStateInternalServerError struct { +} + +// NewGetLocationByZipCityStateInternalServerError creates GetLocationByZipCityStateInternalServerError with default headers values +func NewGetLocationByZipCityStateInternalServerError() *GetLocationByZipCityStateInternalServerError { + + return &GetLocationByZipCityStateInternalServerError{} +} + +// WriteResponse to the client +func (o *GetLocationByZipCityStateInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(500) +} diff --git a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_urlbuilder.go b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_state_urlbuilder.go similarity index 72% rename from pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_urlbuilder.go rename to pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_state_urlbuilder.go index 9d57f272323..5047f6a2a55 100644 --- a/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_urlbuilder.go +++ b/pkg/gen/internalapi/internaloperations/addresses/get_location_by_zip_city_state_urlbuilder.go @@ -12,8 +12,8 @@ import ( "strings" ) -// GetLocationByZipCityURL generates an URL for the get location by zip city operation -type GetLocationByZipCityURL struct { +// GetLocationByZipCityStateURL generates an URL for the get location by zip city state operation +type GetLocationByZipCityStateURL struct { Search string _basePath string @@ -24,7 +24,7 @@ type GetLocationByZipCityURL struct { // WithBasePath sets the base path for this url builder, only required when it's different from the // base path specified in the swagger spec. // When the value of the base path is an empty string -func (o *GetLocationByZipCityURL) WithBasePath(bp string) *GetLocationByZipCityURL { +func (o *GetLocationByZipCityStateURL) WithBasePath(bp string) *GetLocationByZipCityStateURL { o.SetBasePath(bp) return o } @@ -32,12 +32,12 @@ func (o *GetLocationByZipCityURL) WithBasePath(bp string) *GetLocationByZipCityU // SetBasePath sets the base path for this url builder, only required when it's different from the // base path specified in the swagger spec. // When the value of the base path is an empty string -func (o *GetLocationByZipCityURL) SetBasePath(bp string) { +func (o *GetLocationByZipCityStateURL) SetBasePath(bp string) { o._basePath = bp } // Build a url path and query string -func (o *GetLocationByZipCityURL) Build() (*url.URL, error) { +func (o *GetLocationByZipCityStateURL) Build() (*url.URL, error) { var _result url.URL var _path = "/addresses/zip_city_lookup/{search}" @@ -46,7 +46,7 @@ func (o *GetLocationByZipCityURL) Build() (*url.URL, error) { if search != "" { _path = strings.Replace(_path, "{search}", search, -1) } else { - return nil, errors.New("search is required on GetLocationByZipCityURL") + return nil, errors.New("search is required on GetLocationByZipCityStateURL") } _basePath := o._basePath @@ -59,7 +59,7 @@ func (o *GetLocationByZipCityURL) Build() (*url.URL, error) { } // Must is a helper function to panic when the url builder returns an error -func (o *GetLocationByZipCityURL) Must(u *url.URL, err error) *url.URL { +func (o *GetLocationByZipCityStateURL) Must(u *url.URL, err error) *url.URL { if err != nil { panic(err) } @@ -70,17 +70,17 @@ func (o *GetLocationByZipCityURL) Must(u *url.URL, err error) *url.URL { } // String returns the string representation of the path with query string -func (o *GetLocationByZipCityURL) String() string { +func (o *GetLocationByZipCityStateURL) String() string { return o.Must(o.Build()).String() } // BuildFull builds a full url with scheme, host, path and query string -func (o *GetLocationByZipCityURL) BuildFull(scheme, host string) (*url.URL, error) { +func (o *GetLocationByZipCityStateURL) BuildFull(scheme, host string) (*url.URL, error) { if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetLocationByZipCityURL") + return nil, errors.New("scheme is required for a full url on GetLocationByZipCityStateURL") } if host == "" { - return nil, errors.New("host is required for a full url on GetLocationByZipCityURL") + return nil, errors.New("host is required for a full url on GetLocationByZipCityStateURL") } base, err := o.Build() @@ -94,6 +94,6 @@ func (o *GetLocationByZipCityURL) BuildFull(scheme, host string) (*url.URL, erro } // StringFull returns the string representation of a complete url -func (o *GetLocationByZipCityURL) StringFull(scheme, host string) string { +func (o *GetLocationByZipCityStateURL) StringFull(scheme, host string) string { return o.Must(o.BuildFull(scheme, host)).String() } diff --git a/pkg/gen/internalapi/internaloperations/mymove_api.go b/pkg/gen/internalapi/internaloperations/mymove_api.go index 656aba1453b..b8e51e78303 100644 --- a/pkg/gen/internalapi/internaloperations/mymove_api.go +++ b/pkg/gen/internalapi/internaloperations/mymove_api.go @@ -142,8 +142,8 @@ func NewMymoveAPI(spec *loads.Document) *MymoveAPI { MovesGetAllMovesHandler: moves.GetAllMovesHandlerFunc(func(params moves.GetAllMovesParams) middleware.Responder { return middleware.NotImplemented("operation moves.GetAllMoves has not yet been implemented") }), - AddressesGetLocationByZipCityHandler: addresses.GetLocationByZipCityHandlerFunc(func(params addresses.GetLocationByZipCityParams) middleware.Responder { - return middleware.NotImplemented("operation addresses.GetLocationByZipCity has not yet been implemented") + AddressesGetLocationByZipCityStateHandler: addresses.GetLocationByZipCityStateHandlerFunc(func(params addresses.GetLocationByZipCityStateParams) middleware.Responder { + return middleware.NotImplemented("operation addresses.GetLocationByZipCityState has not yet been implemented") }), TransportationOfficesGetTransportationOfficesHandler: transportation_offices.GetTransportationOfficesHandlerFunc(func(params transportation_offices.GetTransportationOfficesParams) middleware.Responder { return middleware.NotImplemented("operation transportation_offices.GetTransportationOffices has not yet been implemented") @@ -374,8 +374,8 @@ type MymoveAPI struct { PpmDeleteWeightTicketHandler ppm.DeleteWeightTicketHandler // MovesGetAllMovesHandler sets the operation handler for the get all moves operation MovesGetAllMovesHandler moves.GetAllMovesHandler - // AddressesGetLocationByZipCityHandler sets the operation handler for the get location by zip city operation - AddressesGetLocationByZipCityHandler addresses.GetLocationByZipCityHandler + // AddressesGetLocationByZipCityStateHandler sets the operation handler for the get location by zip city state operation + AddressesGetLocationByZipCityStateHandler addresses.GetLocationByZipCityStateHandler // TransportationOfficesGetTransportationOfficesHandler sets the operation handler for the get transportation offices operation TransportationOfficesGetTransportationOfficesHandler transportation_offices.GetTransportationOfficesHandler // EntitlementsIndexEntitlementsHandler sets the operation handler for the index entitlements operation @@ -622,8 +622,8 @@ func (o *MymoveAPI) Validate() error { if o.MovesGetAllMovesHandler == nil { unregistered = append(unregistered, "moves.GetAllMovesHandler") } - if o.AddressesGetLocationByZipCityHandler == nil { - unregistered = append(unregistered, "addresses.GetLocationByZipCityHandler") + if o.AddressesGetLocationByZipCityStateHandler == nil { + unregistered = append(unregistered, "addresses.GetLocationByZipCityStateHandler") } if o.TransportationOfficesGetTransportationOfficesHandler == nil { unregistered = append(unregistered, "transportation_offices.GetTransportationOfficesHandler") @@ -952,7 +952,7 @@ func (o *MymoveAPI) initHandlerCache() { if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } - o.handlers["GET"]["/addresses/zip_city_lookup/{search}"] = addresses.NewGetLocationByZipCity(o.context, o.AddressesGetLocationByZipCityHandler) + o.handlers["GET"]["/addresses/zip_city_lookup/{search}"] = addresses.NewGetLocationByZipCityState(o.context, o.AddressesGetLocationByZipCityStateHandler) if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } diff --git a/pkg/handlers/ghcapi/addresses.go b/pkg/handlers/ghcapi/addresses.go index 820dce28426..697c767fd9a 100644 --- a/pkg/handlers/ghcapi/addresses.go +++ b/pkg/handlers/ghcapi/addresses.go @@ -13,26 +13,26 @@ import ( "github.com/transcom/mymove/pkg/services" ) -type GetLocationByZipCityHandler struct { +type GetLocationByZipCityStateHandler struct { handlers.HandlerConfig services.VLocation } -func (h GetLocationByZipCityHandler) Handle(params addressop.GetLocationByZipCityParams) middleware.Responder { +func (h GetLocationByZipCityStateHandler) Handle(params addressop.GetLocationByZipCityStateParams) middleware.Responder { return h.AuditableAppContextFromRequestWithErrors(params.HTTPRequest, func(appCtx appcontext.AppContext) (middleware.Responder, error) { if !appCtx.Session().IsOfficeApp() && appCtx.Session().OfficeUserID == uuid.Nil { noOfficeUserIDErr := apperror.NewSessionError("No office user ID") - return addressop.NewGetLocationByZipCityForbidden(), noOfficeUserIDErr + return addressop.NewGetLocationByZipCityStateForbidden(), noOfficeUserIDErr } locationList, err := h.GetLocationsByZipCity(appCtx, params.Search) if err != nil { appCtx.Logger().Error("Error searching for Zip/City/State: ", zap.Error(err)) - return addressop.NewGetLocationByZipCityInternalServerError(), err + return addressop.NewGetLocationByZipCityStateInternalServerError(), err } returnPayload := payloads.VLocations(*locationList) - return addressop.NewGetLocationByZipCityOK().WithPayload(returnPayload), nil + return addressop.NewGetLocationByZipCityStateOK().WithPayload(returnPayload), nil }) } diff --git a/pkg/handlers/ghcapi/addresses_test.go b/pkg/handlers/ghcapi/addresses_test.go index d42c38d3b9e..4026666dc81 100644 --- a/pkg/handlers/ghcapi/addresses_test.go +++ b/pkg/handlers/ghcapi/addresses_test.go @@ -24,18 +24,18 @@ func (suite *HandlerSuite) TestGetLocationByZipCityHandler() { officeUser := factory.BuildOfficeUser(nil, nil, nil) req := httptest.NewRequest("GET", "/addresses/zip_city_lookup/"+zip, nil) req = suite.AuthenticateOfficeRequest(req, officeUser) - params := addressop.GetLocationByZipCityParams{ + params := addressop.GetLocationByZipCityStateParams{ HTTPRequest: req, Search: zip, } - handler := GetLocationByZipCityHandler{ + handler := GetLocationByZipCityStateHandler{ HandlerConfig: suite.HandlerConfig(), VLocation: vLocationService} response := handler.Handle(params) - suite.Assertions.IsType(&addressop.GetLocationByZipCityOK{}, response) - responsePayload := response.(*addressop.GetLocationByZipCityOK) + suite.Assertions.IsType(&addressop.GetLocationByZipCityStateOK{}, response) + responsePayload := response.(*addressop.GetLocationByZipCityStateOK) suite.NoError(responsePayload.Payload.Validate(strfmt.Default)) suite.Equal(zip, responsePayload.Payload[0].PostalCode) }) diff --git a/pkg/handlers/ghcapi/api.go b/pkg/handlers/ghcapi/api.go index 0367a7092dc..61906ff662f 100644 --- a/pkg/handlers/ghcapi/api.go +++ b/pkg/handlers/ghcapi/api.go @@ -630,7 +630,7 @@ func NewGhcAPIHandler(handlerConfig handlers.HandlerConfig) *ghcops.MymoveAPI { closeoutOfficeUpdater, } - ghcAPI.AddressesGetLocationByZipCityHandler = GetLocationByZipCityHandler{ + ghcAPI.AddressesGetLocationByZipCityStateHandler = GetLocationByZipCityStateHandler{ handlerConfig, vLocation, } diff --git a/pkg/handlers/internalapi/addresses.go b/pkg/handlers/internalapi/addresses.go index 38e9e114485..c90bf2cd0a4 100644 --- a/pkg/handlers/internalapi/addresses.go +++ b/pkg/handlers/internalapi/addresses.go @@ -74,26 +74,26 @@ func (h ShowAddressHandler) Handle(params addressop.ShowAddressParams) middlewar }) } -type GetLocationByZipCityHandler struct { +type GetLocationByZipCityStateHandler struct { handlers.HandlerConfig services.VLocation } -func (h GetLocationByZipCityHandler) Handle(params addressop.GetLocationByZipCityParams) middleware.Responder { +func (h GetLocationByZipCityStateHandler) Handle(params addressop.GetLocationByZipCityStateParams) middleware.Responder { return h.AuditableAppContextFromRequestWithErrors(params.HTTPRequest, func(appCtx appcontext.AppContext) (middleware.Responder, error) { if !appCtx.Session().IsMilApp() && appCtx.Session().ServiceMemberID == uuid.Nil { noServiceMemberIDErr := apperror.NewSessionError("No service member ID") - return addressop.NewGetLocationByZipCityForbidden(), noServiceMemberIDErr + return addressop.NewGetLocationByZipCityStateForbidden(), noServiceMemberIDErr } locationList, err := h.GetLocationsByZipCity(appCtx, params.Search) if err != nil { appCtx.Logger().Error("Error searching for Zip/City/State: ", zap.Error(err)) - return addressop.NewGetLocationByZipCityInternalServerError(), err + return addressop.NewGetLocationByZipCityStateInternalServerError(), err } returnPayload := payloads.VLocations(*locationList) - return addressop.NewGetLocationByZipCityOK().WithPayload(returnPayload), nil + return addressop.NewGetLocationByZipCityStateOK().WithPayload(returnPayload), nil }) } diff --git a/pkg/handlers/internalapi/addresses_test.go b/pkg/handlers/internalapi/addresses_test.go index 8bb6ad5d3f8..1a2f2123181 100644 --- a/pkg/handlers/internalapi/addresses_test.go +++ b/pkg/handlers/internalapi/addresses_test.go @@ -92,18 +92,18 @@ func (suite *HandlerSuite) TestGetLocationByZipCityHandler() { move := factory.BuildMove(suite.DB(), nil, nil) req := httptest.NewRequest("GET", "/addresses/zip_city_lookup/"+zip, nil) req = suite.AuthenticateRequest(req, move.Orders.ServiceMember) - params := addressop.GetLocationByZipCityParams{ + params := addressop.GetLocationByZipCityStateParams{ HTTPRequest: req, Search: zip, } - handler := GetLocationByZipCityHandler{ + handler := GetLocationByZipCityStateHandler{ HandlerConfig: suite.HandlerConfig(), VLocation: vLocationServices} response := handler.Handle(params) - suite.Assertions.IsType(&addressop.GetLocationByZipCityOK{}, response) - responsePayload := response.(*addressop.GetLocationByZipCityOK) + suite.Assertions.IsType(&addressop.GetLocationByZipCityStateOK{}, response) + responsePayload := response.(*addressop.GetLocationByZipCityStateOK) suite.NoError(responsePayload.Payload.Validate(strfmt.Default)) suite.Equal(zip, responsePayload.Payload[0].PostalCode) }) diff --git a/pkg/handlers/internalapi/api.go b/pkg/handlers/internalapi/api.go index ae386fc7e44..4d39fea8c3b 100644 --- a/pkg/handlers/internalapi/api.go +++ b/pkg/handlers/internalapi/api.go @@ -278,7 +278,7 @@ func NewInternalAPI(handlerConfig handlers.HandlerConfig) *internalops.MymoveAPI transportationOfficeFetcher, } - internalAPI.AddressesGetLocationByZipCityHandler = GetLocationByZipCityHandler{ + internalAPI.AddressesGetLocationByZipCityStateHandler = GetLocationByZipCityStateHandler{ handlerConfig, vLocation, } diff --git a/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx b/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx index b82aadd9083..b3e5d7ef7dc 100644 --- a/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx +++ b/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx @@ -64,7 +64,7 @@ describe('BackupAddressForm component', () => { expect(getByLabelText(/Address 2/)).toBeInstanceOf(HTMLInputElement); - expect(getByLabelText(/City/)).toBeInstanceOf(HTMLInputElement); + expect(getByLabelText('City')).toBeInstanceOf(HTMLInputElement); expect(getByLabelText('State')).toBeInstanceOf(HTMLInputElement); @@ -106,9 +106,7 @@ describe('BackupAddressForm component', () => { await userEvent.type(getByLabelText(/Address 1/), fakeAddress.streetAddress1); await userEvent.type(getByLabelText(/Address 2/), fakeAddress.streetAddress2); - await userEvent.type(getByLabelText(/City/), fakeAddress.city); - await userEvent.selectOptions(getByLabelText(/State/), [fakeAddress.state]); - await userEvent.type(getByLabelText(/ZIP/), fakeAddress.postalCode); + await userEvent.tab(); await waitFor(() => { diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx index 58f9efb35fd..bfdd6e673ba 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx @@ -59,42 +59,20 @@ describe('ResidentialAddressForm component', () => { ); await waitFor(() => { - expect(getByLabelText(/Address 1/)).toBeInstanceOf(HTMLInputElement); + expect(getByLabelText('Address 1')).toBeInstanceOf(HTMLInputElement); expect(getByLabelText(/Address 2/)).toBeInstanceOf(HTMLInputElement); - expect(getByLabelText(/City/)).toBeInstanceOf(HTMLInputElement); + expect(getByLabelText('City')).toBeInstanceOf(HTMLInputElement); expect(getByLabelText('State')).toBeInstanceOf(HTMLInputElement); - expect(getByLabelText(/ZIP/)).toBeInstanceOf(HTMLInputElement); + expect(getByLabelText('ZIP')).toBeInstanceOf(HTMLInputElement); expect(getByText('Must be a physical address.')).toBeInTheDocument(); }); }); - it('passes custom validators to fields', async () => { - const postalCodeValidator = jest.fn().mockImplementation(() => undefined); - - const { findByLabelText } = render( - , - ); - - const postalCodeInput = await findByLabelText(/ZIP/); - - const postalCode = '99999'; - - await userEvent.type(postalCodeInput, postalCode); - - await waitFor(() => { - // We expect this to be called 6 times. - // 1 - validate on mount - // 5 - once for each 9 that was typed, since we are validating on change - expect(postalCodeValidator).toHaveBeenCalledTimes(6); - expect(postalCodeValidator).toHaveBeenCalledWith(postalCode); - }); - }); - it('shows an error message if trying to submit an invalid form', async () => { const mockStore = configureStore({}); const { getByRole, findAllByRole, getByLabelText } = render( @@ -102,7 +80,7 @@ describe('ResidentialAddressForm component', () => { , ); - await userEvent.click(getByLabelText('Address 1')); + await userEvent.click(getByLabelText(/Address 1/)); await userEvent.click(getByLabelText(/Address 2/)); const submitBtn = getByRole('button', { name: 'Next' }); @@ -130,9 +108,6 @@ describe('ResidentialAddressForm component', () => { await userEvent.type(getByLabelText(/Address 1/), fakeAddress.streetAddress1); await userEvent.type(getByLabelText(/Address 2/), fakeAddress.streetAddress2); - await userEvent.type(getByLabelText(/City/), fakeAddress.city); - await userEvent.selectOptions(getByLabelText(/State/), [fakeAddress.state]); - await userEvent.type(getByLabelText(/ZIP/), fakeAddress.postalCode); await userEvent.tab(); await waitFor(() => { diff --git a/src/components/LocationSearchBox/LocationSearchBox.jsx b/src/components/LocationSearchBox/LocationSearchBox.jsx index e7ea37d293b..64609e3b6b7 100644 --- a/src/components/LocationSearchBox/LocationSearchBox.jsx +++ b/src/components/LocationSearchBox/LocationSearchBox.jsx @@ -111,7 +111,7 @@ export const LocationSearchBoxComponent = ({ hint, placeholder, isDisabled, - handleZipCityOnChange, + handleLocationOnChange, }) => { const { value, onChange, locationState, name: inputName } = input; @@ -163,7 +163,7 @@ export const LocationSearchBoxComponent = ({ }, DEBOUNCE_TIMER_MS); const selectOption = async (selectedValue) => { - if (!selectedValue.address && !handleZipCityOnChange) { + if (!selectedValue.address && !handleLocationOnChange) { const address = await showAddress(selectedValue.address_id); const newValue = { ...selectedValue, @@ -177,8 +177,8 @@ export const LocationSearchBoxComponent = ({ locationState(selectedValue); onChange(selectedValue); - if (handleZipCityOnChange !== null) { - handleZipCityOnChange(selectedValue); + if (handleLocationOnChange !== null) { + handleLocationOnChange(selectedValue); } return selectedValue; }; @@ -226,7 +226,7 @@ export const LocationSearchBoxComponent = ({ inputId={inputId} className={dutyInputClasses} cacheOptions - formatOptionLabel={handleZipCityOnChange ? formatZipCity : formatOptionLabel} + formatOptionLabel={handleLocationOnChange ? formatZipCity : formatOptionLabel} getOptionValue={getOptionName} loadOptions={loadOptions} onChange={selectOption} @@ -271,7 +271,7 @@ LocationSearchBoxContainer.propTypes = { placeholder: PropTypes.string, isDisabled: PropTypes.bool, searchLocations: PropTypes.func, - handleZipCityOnChange: PropTypes.func, + handleLocationOnChange: PropTypes.func, }; LocationSearchBoxContainer.defaultProps = { @@ -288,7 +288,7 @@ LocationSearchBoxContainer.defaultProps = { placeholder: 'Start typing a duty location...', isDisabled: false, searchLocations: SearchDutyLocations, - handleZipCityOnChange: null, + handleLocationOnChange: null, }; LocationSearchBoxComponent.propTypes = { diff --git a/src/components/LocationSearchBox/LocationSearchBox.stories.jsx b/src/components/LocationSearchBox/LocationSearchBox.stories.jsx index c19250b69cc..8f4c0987f2d 100644 --- a/src/components/LocationSearchBox/LocationSearchBox.stories.jsx +++ b/src/components/LocationSearchBox/LocationSearchBox.stories.jsx @@ -305,7 +305,7 @@ export const ZipCityLocationBasic = () => { name="test_component" searchLocations={mockZipCity} displayAddress={false} - handleZipCityOnChange={handleZipCityOnChange} + handleLocationOnChange={handleZipCityOnChange} /> ); }; diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index c9d2879fdab..5fde6064a60 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -10,7 +10,7 @@ import styles from 'components/form/AddressFields/AddressFields.module.scss'; import { technicalHelpDeskURL } from 'shared/constants'; import TextField from 'components/form/fields/TextField/TextField'; import { DropdownInput } from 'components/form/fields/DropdownInput'; -import ZipCityInput from 'components/form/fields/ZipCityInput'; +import LocationInput from 'components/form/fields/LocationInput'; /** * @param legend @@ -33,7 +33,7 @@ export const AddressFields = ({ validators, zipCityEnabled, zipCityError, - handleZipCityChange, + handleZipCityChange: handleLocationChange, formikFunctionsToValidatePostalCodeOnChange, labelHint: labelHintProp, }) => { @@ -125,16 +125,16 @@ export const AddressFields = ({ data-testid={`${name}.streetAddress3`} validate={validators?.streetAddress3} /> - {handleZipCityChange && ( + {handleLocationChange && ( <> - {!zipCityError && ( - + {infoStr} Technical Help Desk @@ -164,7 +164,7 @@ export const AddressFields = ({ validate={validators?.city} isDisabled={zipCityEnabled} /> - {handleZipCityChange && ( + {handleLocationChange && ( { expect(getByLabelText('City')).toHaveValue(initialValues.address.city); expect(getByLabelText('State')).toHaveValue(initialValues.address.state); expect(getByLabelText('ZIP')).toHaveValue(initialValues.address.postalCode); - expect(getByTestId('zipCityInfo')).toBeInTheDocument(); + expect(getByTestId('locationInfo')).toBeInTheDocument(); }); it('renders zip city lookup with error', () => { const initialValues = { diff --git a/src/components/form/fields/ZipCityInput.jsx b/src/components/form/fields/LocationInput.jsx similarity index 73% rename from src/components/form/fields/ZipCityInput.jsx rename to src/components/form/fields/LocationInput.jsx index f1bea7e9104..62a14106e6b 100644 --- a/src/components/form/fields/ZipCityInput.jsx +++ b/src/components/form/fields/LocationInput.jsx @@ -5,13 +5,13 @@ import PropTypes from 'prop-types'; import './DropdownInput.module.scss'; import LocationSearchBox from 'components/LocationSearchBox/LocationSearchBox'; -import { searchLocationByZipCity } from 'services/internalApi'; -import { searchLocationByZipCity as ghcSearchLocationByZipCity } from 'services/ghcApi'; +import { searchLocationByZipCityState } from 'services/internalApi'; +import { searchLocationByZipCityState as ghcSearchLocationByZipCityState } from 'services/ghcApi'; import { selectLoggedInUser } from 'store/entities/selectors'; import { OfficeUserInfoShape } from 'types/index'; -export const ZipCityInput = (props) => { - const { label, name, displayAddress, hint, placeholder, isDisabled, handleZipCityChange, officeUser } = props; +export const LocationInput = (props) => { + const { label, name, displayAddress, hint, placeholder, isDisabled, handleLocationChange, officeUser } = props; const [field, meta, helpers] = useField(props); const errorString = meta.value?.name ? meta.error?.name || meta.error : ''; @@ -30,24 +30,24 @@ export const ZipCityInput = (props) => { hint={hint} placeholder={placeholder} isDisabled={isDisabled} - searchLocations={officeUser?.id ? ghcSearchLocationByZipCity : searchLocationByZipCity} - handleZipCityOnChange={handleZipCityChange} + searchLocations={officeUser?.id ? ghcSearchLocationByZipCityState : searchLocationByZipCityState} + handleLocationOnChange={handleLocationChange} /> ); }; -ZipCityInput.propTypes = { +LocationInput.propTypes = { label: PropTypes.string.isRequired, name: PropTypes.string.isRequired, displayAddress: PropTypes.bool, hint: PropTypes.node, placeholder: PropTypes.string, isDisabled: PropTypes.bool, - handleZipCityChange: PropTypes.func.isRequired, + handleLocationChange: PropTypes.func.isRequired, officeUser: OfficeUserInfoShape, }; -ZipCityInput.defaultProps = { +LocationInput.defaultProps = { displayAddress: false, hint: '', placeholder: '', @@ -65,4 +65,4 @@ const mapStateToProps = (state) => { const mapDispatchToProps = {}; -export default connect(mapStateToProps, mapDispatchToProps)(ZipCityInput); +export default connect(mapStateToProps, mapDispatchToProps)(LocationInput); diff --git a/src/components/form/fields/ZipCityInput.test.jsx b/src/components/form/fields/LocationInput.test.jsx similarity index 83% rename from src/components/form/fields/ZipCityInput.test.jsx rename to src/components/form/fields/LocationInput.test.jsx index 587e6a8a239..319bab266bc 100644 --- a/src/components/form/fields/ZipCityInput.test.jsx +++ b/src/components/form/fields/LocationInput.test.jsx @@ -2,10 +2,10 @@ import React from 'react'; import { shallow } from 'enzyme'; import AsyncSelect from 'react-select/async'; -import { ZipCityInput } from './ZipCityInput'; +import { LocationInput } from './LocationInput'; import { LocationSearchBoxComponent, LocationSearchBoxContainer } from 'components/LocationSearchBox/LocationSearchBox'; -import { searchLocationByZipCity } from 'services/internalApi'; +import { searchLocationByZipCityState } from 'services/internalApi'; const mockOnChange = jest.fn(); const mockSetValue = jest.fn(); @@ -26,7 +26,7 @@ jest.mock('formik', () => { jest.mock('services/internalApi', () => ({ ...jest.requireActual('services/internalApi'), - searchLocationByZipCity: jest.fn(), + searchLocationByZipCityState: jest.fn(), })); const handleZipCityChange = jest.fn(); @@ -34,12 +34,12 @@ const handleZipCityChange = jest.fn(); describe('ZipCityInput', () => { describe('with all required props', () => { const wrapper = shallow( - , ); @@ -50,7 +50,7 @@ describe('ZipCityInput', () => { it('triggers onChange properly', async () => { const cityName = 'El Paso'; - searchLocationByZipCity.mockImplementation(() => Promise.resolve(cityName)); + searchLocationByZipCityState.mockImplementation(() => Promise.resolve(cityName)); const container = wrapper.find(LocationSearchBoxContainer).dive(); const component = container.find(LocationSearchBoxComponent).dive(); const select = component.find(AsyncSelect); diff --git a/src/pages/MyMove/Profile/ResidentialAddress.test.jsx b/src/pages/MyMove/Profile/ResidentialAddress.test.jsx index 1b2ecb56c79..c47bfd66c18 100644 --- a/src/pages/MyMove/Profile/ResidentialAddress.test.jsx +++ b/src/pages/MyMove/Profile/ResidentialAddress.test.jsx @@ -38,6 +38,7 @@ describe('ResidentialAddress page', () => { state: 'TX', postalCode: '79912', county: 'El Paso', + usprcId: '', }; const blankAddress = Object.fromEntries(Object.keys(fakeAddress).map((k) => [k, ''])); @@ -66,27 +67,6 @@ describe('ResidentialAddress page', () => { }); }); - it('validates zip code using api endpoint', async () => { - const testProps = generateTestProps(blankAddress); - - ValidateZipRateData.mockImplementation(() => ({ - valid: true, - })); - - render(); - - const postalCodeInput = await screen.findByLabelText(/ZIP/); - - const postalCode = '99999'; - - await userEvent.type(postalCodeInput, postalCode); - await userEvent.tab(); - - await waitFor(() => { - expect(ValidateZipRateData).toHaveBeenCalledWith(postalCode, 'origin'); - }); - }); - it('back button goes to the contact info step', async () => { const testProps = generateTestProps(blankAddress); const mockStore = configureStore({}); @@ -121,10 +101,6 @@ describe('ResidentialAddress page', () => { , ); - await userEvent.type(screen.getByLabelText(/Address 1/), fakeAddress.streetAddress1); - await userEvent.type(screen.getByLabelText(/Address 2/), fakeAddress.streetAddress2); - await userEvent.tab(); - const submitButton = screen.getByRole('button', { name: 'Next' }); expect(submitButton).toBeInTheDocument(); await userEvent.click(submitButton); @@ -139,26 +115,23 @@ describe('ResidentialAddress page', () => { it('shows an error if the ValidateZipRateData API returns an error', async () => { const testProps = generateTestProps(fakeAddress); + const mockStore = configureStore({}); ValidateZipRateData.mockImplementation(() => ({ valid: false, })); patchServiceMember.mockImplementation(() => Promise.resolve(testProps.serviceMember)); - render(); - - // Touch field so that error message can be displayed - await userEvent.click(screen.getByLabelText(/ZIP/)); + render( + + + , + ); const submitButton = screen.getByRole('button', { name: 'Next' }); expect(submitButton).toBeInTheDocument(); await userEvent.click(submitButton); - const alert = await screen.findByRole('alert'); - - expect(alert).toHaveTextContent( - 'Sorry, we don’t support that zip code yet. Please contact your local PPPO for assistance.', - ); expect(patchServiceMember).not.toHaveBeenCalled(); expect(testProps.updateServiceMember).not.toHaveBeenCalled(); expect(mockNavigate).not.toHaveBeenCalled(); diff --git a/src/services/ghcApi.js b/src/services/ghcApi.js index 32908930344..cb45f26012e 100644 --- a/src/services/ghcApi.js +++ b/src/services/ghcApi.js @@ -848,8 +848,8 @@ export async function bulkDownloadPaymentRequest(paymentRequestID) { return makeGHCRequestRaw('paymentRequests.bulkDownload', { paymentRequestID }); } -export async function searchLocationByZipCity(search) { - return makeGHCRequest('addresses.getLocationByZipCity', { search }, { normalize: false }); +export async function searchLocationByZipCityState(search) { + return makeGHCRequest('addresses.getLocationByZipCityState', { search }, { normalize: false }); } export async function dateSelectionIsWeekendHoliday(countryCode, date) { diff --git a/src/services/internalApi.js b/src/services/internalApi.js index 4fabebc2398..c18314f95e6 100644 --- a/src/services/internalApi.js +++ b/src/services/internalApi.js @@ -538,8 +538,8 @@ export async function downloadPPMPaymentPacket(ppmShipmentId) { return makeInternalRequestRaw('ppm.showPaymentPacket', { ppmShipmentId }); } -export async function searchLocationByZipCity(search) { - return makeInternalRequest('addresses.getLocationByZipCity', { search }, { normalize: false }); +export async function searchLocationByZipCityState(search) { + return makeInternalRequest('addresses.getLocationByZipCityState', { search }, { normalize: false }); } export async function dateSelectionIsWeekendHoliday(countryCode, date) { diff --git a/src/setupTests.js b/src/setupTests.js index e42087c5daa..afb5ce6e471 100644 --- a/src/setupTests.js +++ b/src/setupTests.js @@ -19,5 +19,5 @@ global.performance = { }; jestPreviewConfigure({ - autoPreview: false, + autoPreview: true, }); diff --git a/swagger-def/ghc.yaml b/swagger-def/ghc.yaml index e9c1af2664b..4b63b8fe8fe 100644 --- a/swagger-def/ghc.yaml +++ b/swagger-def/ghc.yaml @@ -3919,9 +3919,9 @@ paths: $ref: '#/responses/ServerError' /addresses/zip_city_lookup/{search}: get: - summary: Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City string + summary: Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City and State string description: Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code. - operationId: getLocationByZipCity + operationId: getLocationByZipCityState tags: - addresses parameters: diff --git a/swagger-def/internal.yaml b/swagger-def/internal.yaml index d426587c752..ec124cb3506 100644 --- a/swagger-def/internal.yaml +++ b/swagger-def/internal.yaml @@ -4386,9 +4386,9 @@ paths: description: server error /addresses/zip_city_lookup/{search}: get: - summary: Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City string + summary: Returns City, State, Postal Code, and County associated with the specified full/partial Postal Code or City State string description: Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code. - operationId: getLocationByZipCity + operationId: getLocationByZipCityState tags: - addresses parameters: diff --git a/swagger/ghc.yaml b/swagger/ghc.yaml index f056168530f..591cf83a2fb 100644 --- a/swagger/ghc.yaml +++ b/swagger/ghc.yaml @@ -4108,12 +4108,12 @@ paths: get: summary: >- Returns City, State, Postal Code, and County associated with the - specified full/partial Postal Code or City string + specified full/partial Postal Code or City and State string description: >- Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code. - operationId: getLocationByZipCity + operationId: getLocationByZipCityState tags: - addresses parameters: diff --git a/swagger/internal.yaml b/swagger/internal.yaml index 365a5817ed4..7c367f8758b 100644 --- a/swagger/internal.yaml +++ b/swagger/internal.yaml @@ -6101,12 +6101,12 @@ paths: get: summary: >- Returns City, State, Postal Code, and County associated with the - specified full/partial Postal Code or City string + specified full/partial Postal Code or City State string description: >- Find by API using full/partial Postal Code or City name that returns an us_post_region_cities json object containing city, state, county and postal code. - operationId: getLocationByZipCity + operationId: getLocationByZipCityState tags: - addresses parameters: From 653dc3e7c7122f95b768f56319d00c810eaf3902 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Tue, 29 Oct 2024 21:21:45 +0000 Subject: [PATCH 064/216] FF for enable alaska, method rename --- pkg/handlers/ghcapi/addresses.go | 2 +- pkg/handlers/internalapi/addresses.go | 2 +- pkg/services/address.go | 2 +- pkg/services/address/address_lookup.go | 39 ++++++++++++++++++++++---- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/pkg/handlers/ghcapi/addresses.go b/pkg/handlers/ghcapi/addresses.go index 697c767fd9a..f74eec0af41 100644 --- a/pkg/handlers/ghcapi/addresses.go +++ b/pkg/handlers/ghcapi/addresses.go @@ -26,7 +26,7 @@ func (h GetLocationByZipCityStateHandler) Handle(params addressop.GetLocationByZ return addressop.NewGetLocationByZipCityStateForbidden(), noOfficeUserIDErr } - locationList, err := h.GetLocationsByZipCity(appCtx, params.Search) + locationList, err := h.GetLocationsByZipCityState(appCtx, params.Search) if err != nil { appCtx.Logger().Error("Error searching for Zip/City/State: ", zap.Error(err)) return addressop.NewGetLocationByZipCityStateInternalServerError(), err diff --git a/pkg/handlers/internalapi/addresses.go b/pkg/handlers/internalapi/addresses.go index c90bf2cd0a4..240839d04ed 100644 --- a/pkg/handlers/internalapi/addresses.go +++ b/pkg/handlers/internalapi/addresses.go @@ -87,7 +87,7 @@ func (h GetLocationByZipCityStateHandler) Handle(params addressop.GetLocationByZ return addressop.NewGetLocationByZipCityStateForbidden(), noServiceMemberIDErr } - locationList, err := h.GetLocationsByZipCity(appCtx, params.Search) + locationList, err := h.GetLocationsByZipCityState(appCtx, params.Search) if err != nil { appCtx.Logger().Error("Error searching for Zip/City/State: ", zap.Error(err)) return addressop.NewGetLocationByZipCityStateInternalServerError(), err diff --git a/pkg/services/address.go b/pkg/services/address.go index 2d8276a0323..f8b15fb39e1 100644 --- a/pkg/services/address.go +++ b/pkg/services/address.go @@ -15,5 +15,5 @@ type AddressUpdater interface { //go:generate mockery --name UsPostRegionCity type VLocation interface { - GetLocationsByZipCity(appCtx appcontext.AppContext, search string) (*models.VLocations, error) + GetLocationsByZipCityState(appCtx appcontext.AppContext, search string) (*models.VLocations, error) } diff --git a/pkg/services/address/address_lookup.go b/pkg/services/address/address_lookup.go index a1dc34e9f4f..ea20306de5d 100644 --- a/pkg/services/address/address_lookup.go +++ b/pkg/services/address/address_lookup.go @@ -1,6 +1,7 @@ package address import ( + "context" "database/sql" "fmt" "regexp" @@ -8,11 +9,15 @@ import ( "github.com/gofrs/uuid" "github.com/pkg/errors" + "github.com/spf13/viper" + "go.uber.org/zap" "github.com/transcom/mymove/pkg/appcontext" "github.com/transcom/mymove/pkg/apperror" + "github.com/transcom/mymove/pkg/cli" "github.com/transcom/mymove/pkg/models" "github.com/transcom/mymove/pkg/services" + "github.com/transcom/mymove/pkg/services/featureflag" ) type vLocation struct { @@ -22,7 +27,7 @@ func NewVLocation() services.VLocation { return &vLocation{} } -func (o vLocation) GetLocationsByZipCity(appCtx appcontext.AppContext, search string) (*models.VLocations, error) { +func (o vLocation) GetLocationsByZipCityState(appCtx appcontext.AppContext, search string) (*models.VLocations, error) { locationList, err := FindLocationsByZipCity(appCtx, search) if err != nil { @@ -70,14 +75,36 @@ func FindLocationsByZipCity(appCtx appcontext.AppContext, search string) (models city = strings.ReplaceAll(city, ",", "") } - // city = "swansea" - // state = "IL" - // postalCode = "62226" + /** Feature Flag - Alaska - Determines if AK be included/excluded **/ + isAlaskaEnabled := false + featureFlagName := "enable_alaska" + config := cli.GetFliptFetcherConfig(viper.GetViper()) + flagFetcher, err := featureflag.NewFeatureFlagFetcher(config) + if err != nil { + appCtx.Logger().Error("Error initializing FeatureFlagFetcher", zap.String("featureFlagKey", featureFlagName), zap.Error(err)) + } + + flag, err := flagFetcher.GetBooleanFlagForUser(context.TODO(), appCtx, featureFlagName, map[string]string{}) + if err != nil { + appCtx.Logger().Error("Error fetching feature flag", zap.String("featureFlagKey", featureFlagName), zap.Error(err)) + } else { + isAlaskaEnabled = flag.Match + } + + sqlQuery := "" - sqlQuery := fmt.Sprintf(` + if isAlaskaEnabled { + sqlQuery = fmt.Sprintf(` + select vl.city_name, vl.state, vl.usprc_county_nm, vl.uspr_zip_id, vl.uprc_id + from v_locations vl where vl.uspr_zip_id like '%[1]s%%' and + vl.city_name like upper('%[2]s%%') and vl.state like upper('%[3]s%%') limit 30`, postalCode, city, state) + } else { + sqlQuery = fmt.Sprintf(` select vl.city_name, vl.state, vl.usprc_county_nm, vl.uspr_zip_id, vl.uprc_id from v_locations vl where vl.uspr_zip_id like '%[1]s%%' and - vl.city_name like upper('%[2]s%%') and vl.state like upper('%[3]s%%') limit 30`, postalCode, city, state) + vl.city_name like upper('%[2]s%%') and vl.state like upper('%[3]s%%') and (vl.state != 'AK' or vl.state != 'HI') limit 30`, postalCode, city, state) + } + query := appCtx.DB().Q().RawQuery(sqlQuery) if err := query.All(&locationList); err != nil { if errors.Cause(err).Error() != models.RecordNotFoundErrorString { From a5ec68c6527ba40365461f1ca09843fabf22ed7b Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 30 Oct 2024 03:48:16 +0000 Subject: [PATCH 065/216] test fixes --- playwright/tests/my/mymove/onboarding.spec.js | 10 +++++----- .../BackupAddressForm/BackupAddressForm.test.jsx | 4 ++-- .../ResidentialAddressForm.test.jsx | 6 +++--- src/pages/MyMove/Profile/BackupAddress.test.jsx | 2 +- src/setupTests.js | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/playwright/tests/my/mymove/onboarding.spec.js b/playwright/tests/my/mymove/onboarding.spec.js index 8ad21eb1ae7..fbc1a495e30 100644 --- a/playwright/tests/my/mymove/onboarding.spec.js +++ b/playwright/tests/my/mymove/onboarding.spec.js @@ -3,7 +3,7 @@ import { test, expect } from '../../utils/my/customerTest'; const multiMoveEnabled = process.env.FEATURE_FLAG_MULTI_MOVE; -const zipCityLookup = 'ATCO, NJ 08004 (CAMDEN)'; +const LocationLookup = 'ATCO, NJ 08004 (CAMDEN)'; test.describe('Onboarding', () => { test.skip(multiMoveEnabled === 'true', 'Skip if MultiMove workflow is enabled.'); @@ -97,8 +97,8 @@ test.describe('(MultiMove) Onboarding', () => { await customerPage.waitForPage.onboardingCurrentAddress(); await page.getByLabel('Address 1').fill('7 Q St'); await page.getByLabel('Address 1').blur(); - await page.getByLabel('Zip/City Lookup').fill('08004'); - await expect(page.getByText(zipCityLookup, { exact: true })).toBeVisible(); + await page.getByLabel('Location Lookup').fill('08004'); + await expect(page.getByText(LocationLookup, { exact: true })).toBeVisible(); await page.keyboard.press('Enter'); await customerPage.navigateForward(); @@ -106,8 +106,8 @@ test.describe('(MultiMove) Onboarding', () => { await customerPage.waitForPage.onboardingBackupAddress(); await page.getByLabel('Address 1').fill('7 Q St'); await page.getByLabel('Address 1').blur(); - await page.getByLabel('Zip/City Lookup').fill('08004'); - await expect(page.getByText(zipCityLookup, { exact: true })).toBeVisible(); + await page.getByLabel('Location Lookup').fill('08004'); + await expect(page.getByText(LocationLookup, { exact: true })).toBeVisible(); await page.keyboard.press('Enter'); await customerPage.navigateForward(); diff --git a/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx b/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx index 74b99e5186a..252fd609da3 100644 --- a/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx +++ b/src/components/Customer/BackupAddressForm/BackupAddressForm.test.jsx @@ -64,9 +64,9 @@ describe('BackupAddressForm component', () => { expect(getByLabelText(/Address 2/)).toBeInstanceOf(HTMLInputElement); - expect(getByLabelText('City')).toBeInstanceOf(HTMLInputElement); + expect(getByLabelText(/City/)).toBeInstanceOf(HTMLInputElement); - expect(getByLabelText('State')).toBeInstanceOf(HTMLInputElement); + expect(getByLabelText(/State/)).toBeInstanceOf(HTMLInputElement); expect(getByLabelText(/ZIP/)).toBeInstanceOf(HTMLInputElement); }); diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx index 4aa433a4210..717938f6cfd 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.test.jsx @@ -63,11 +63,11 @@ describe('ResidentialAddressForm component', () => { expect(getByLabelText(/Address 2/)).toBeInstanceOf(HTMLInputElement); - expect(getByLabelText('City')).toBeInstanceOf(HTMLInputElement); + expect(getByLabelText(/City/)).toBeInstanceOf(HTMLInputElement); - expect(getByLabelText('State')).toBeInstanceOf(HTMLInputElement); + expect(getByLabelText(/State/)).toBeInstanceOf(HTMLInputElement); - expect(getByLabelText('ZIP')).toBeInstanceOf(HTMLInputElement); + expect(getByLabelText(/ZIP/)).toBeInstanceOf(HTMLInputElement); expect(getByText('Must be a physical address.')).toBeInTheDocument(); }); diff --git a/src/pages/MyMove/Profile/BackupAddress.test.jsx b/src/pages/MyMove/Profile/BackupAddress.test.jsx index a4c1c0826b3..fb3890bd840 100644 --- a/src/pages/MyMove/Profile/BackupAddress.test.jsx +++ b/src/pages/MyMove/Profile/BackupAddress.test.jsx @@ -104,7 +104,7 @@ describe('BackupAddress page', () => { patchServiceMember.mockImplementation(() => Promise.resolve(expectedServiceMemberPayload)); - const { getByRole, getByLabelText } = render( + const { getByRole } = render( , diff --git a/src/setupTests.js b/src/setupTests.js index afb5ce6e471..e42087c5daa 100644 --- a/src/setupTests.js +++ b/src/setupTests.js @@ -19,5 +19,5 @@ global.performance = { }; jestPreviewConfigure({ - autoPreview: true, + autoPreview: false, }); From fa27821e6cbd68c8b1fc3803d0997f6ef115a971 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 30 Oct 2024 04:17:21 +0000 Subject: [PATCH 066/216] playwright test fix --- .../tests/office/primesimulator/primeSimulatorFlows.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playwright/tests/office/primesimulator/primeSimulatorFlows.spec.js b/playwright/tests/office/primesimulator/primeSimulatorFlows.spec.js index a6cc84e9f04..fdbacb180b2 100644 --- a/playwright/tests/office/primesimulator/primeSimulatorFlows.spec.js +++ b/playwright/tests/office/primesimulator/primeSimulatorFlows.spec.js @@ -148,7 +148,7 @@ test.describe('Prime simulator user', () => { await page.locator('input[name="destinationAddress.city"]').fill('Joshua Tree'); await page.locator('select[name="destinationAddress.state"]').selectOption({ label: 'CA' }); await page.locator('input[name="destinationAddress.postalCode"]').fill('92252'); - await page.getByTestId('dropdown').nth(5).selectOption('Home of record (HOR)'); + await page.locator('select[name="destinationType"]').selectOption({ label: 'Home of record (HOR)' }); await page.getByText('Save').click(); await expect(page.getByText('Successfully updated shipment')).toHaveCount(1); From ca8b0e3ae3adf75067f50ffdf70b561720076895 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 30 Oct 2024 04:53:24 +0000 Subject: [PATCH 067/216] fix enable alaska query --- pkg/services/address/address_lookup.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/services/address/address_lookup.go b/pkg/services/address/address_lookup.go index ea20306de5d..33b735cae9e 100644 --- a/pkg/services/address/address_lookup.go +++ b/pkg/services/address/address_lookup.go @@ -102,7 +102,7 @@ func FindLocationsByZipCity(appCtx appcontext.AppContext, search string) (models sqlQuery = fmt.Sprintf(` select vl.city_name, vl.state, vl.usprc_county_nm, vl.uspr_zip_id, vl.uprc_id from v_locations vl where vl.uspr_zip_id like '%[1]s%%' and - vl.city_name like upper('%[2]s%%') and vl.state like upper('%[3]s%%') and (vl.state != 'AK' or vl.state != 'HI') limit 30`, postalCode, city, state) + vl.city_name like upper('%[2]s%%') and vl.state like upper('%[3]s%%') and vl.state NOT in ('AK','HI') limit 30`, postalCode, city, state) } query := appCtx.DB().Q().RawQuery(sqlQuery) From 2c8181c6888f082b9039b434d29ea01f372acba3 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 30 Oct 2024 05:09:30 +0000 Subject: [PATCH 068/216] make fields read only by default --- .../Customer/BackupAddressForm/BackupAddressForm.jsx | 1 - .../Customer/EditContactInfoForm/EditContactInfoForm.jsx | 2 -- .../ResidentialAddressForm/ResidentialAddressForm.jsx | 1 - src/components/form/AddressFields/AddressFields.jsx | 2 +- .../form/AddressFields/AddressFields.stories.jsx | 2 +- src/components/form/AddressFields/AddressFields.test.jsx | 8 +------- 6 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx b/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx index 7507cdd1ac4..77b55ceaae9 100644 --- a/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx +++ b/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx @@ -61,7 +61,6 @@ const BackupAddressForm = ({ formFieldsName, initialValues, onSubmit, onBack }) diff --git a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx index 71a120d20af..26b82454f3b 100644 --- a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx +++ b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx @@ -101,7 +101,6 @@ const EditContactInfoForm = ({ initialValues, onSubmit, onCancel }) => { @@ -117,7 +116,6 @@ const EditContactInfoForm = ({ initialValues, onSubmit, onCancel }) => { diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx index bbd4a91583a..9ae92c124da 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx @@ -61,7 +61,6 @@ const ResidentialAddressForm = ({ formFieldsName, initialValues, onSubmit, onBac labelHint="Required" name={formFieldsName} validators={validators} - zipCityEnabled zipCityError={isLookupErrorVisible} handleZipCityChange={handleZipCityChange} /> diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index 5fde6064a60..ca54a4a7f96 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -214,7 +214,7 @@ AddressFields.defaultProps = { legend: '', className: '', render: (fields) => fields, - zipCityEnabled: false, + zipCityEnabled: true, zipCityError: false, handleZipCityChange: null, validators: {}, diff --git a/src/components/form/AddressFields/AddressFields.stories.jsx b/src/components/form/AddressFields/AddressFields.stories.jsx index 33476511fd2..1110d878045 100644 --- a/src/components/form/AddressFields/AddressFields.stories.jsx +++ b/src/components/form/AddressFields/AddressFields.stories.jsx @@ -141,7 +141,7 @@ export const ZipCityAddress = () => ( > {() => ( - + )}
diff --git a/src/components/form/AddressFields/AddressFields.test.jsx b/src/components/form/AddressFields/AddressFields.test.jsx index f9fa324bc38..c950f0e3f27 100644 --- a/src/components/form/AddressFields/AddressFields.test.jsx +++ b/src/components/form/AddressFields/AddressFields.test.jsx @@ -143,12 +143,7 @@ describe('AddressFields component', () => { const { getByLabelText, getByTestId } = render( - + , ); @@ -178,7 +173,6 @@ describe('AddressFields component', () => { From 0d597149c5871c73eb3f1e7177cdb9545d65b430 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Thu, 31 Oct 2024 14:13:07 +0000 Subject: [PATCH 069/216] test fixes --- .../MtoShipmentForm/MtoShipmentForm.test.jsx | 25 ++----------------- .../CustomerContactInfoForm.test.jsx | 2 +- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/src/components/Customer/MtoShipmentForm/MtoShipmentForm.test.jsx b/src/components/Customer/MtoShipmentForm/MtoShipmentForm.test.jsx index 3d6391e5c0c..5dcfbc6fc69 100644 --- a/src/components/Customer/MtoShipmentForm/MtoShipmentForm.test.jsx +++ b/src/components/Customer/MtoShipmentForm/MtoShipmentForm.test.jsx @@ -1677,6 +1677,7 @@ describe('MtoShipmentForm component', () => { city: 'San Marcos', state: 'TX', postalCode: '78666', + county: 'HAYS', }, }; @@ -1733,17 +1734,6 @@ describe('MtoShipmentForm component', () => { await userEvent.clear(pickupAddress2Input); await userEvent.type(pickupAddress2Input, shipmentInfo.pickupAddress.streetAddress2); - const pickupCityInput = screen.getAllByLabelText(/City/)[0]; - await userEvent.clear(pickupCityInput); - await userEvent.type(pickupCityInput, shipmentInfo.pickupAddress.city); - - const pickupStateInput = screen.getAllByLabelText(/State/)[0]; - await userEvent.selectOptions(pickupStateInput, shipmentInfo.pickupAddress.state); - - const pickupPostalCodeInput = screen.getAllByLabelText(/ZIP/)[0]; - await userEvent.clear(pickupPostalCodeInput); - await userEvent.type(pickupPostalCodeInput, shipmentInfo.pickupAddress.postalCode); - const saveButton = await screen.findByRole('button', { name: 'Save' }); expect(saveButton).not.toBeDisabled(); await userEvent.click(saveButton); @@ -1791,17 +1781,6 @@ describe('MtoShipmentForm component', () => { await userEvent.clear(pickupAddress2Input); await userEvent.type(pickupAddress2Input, shipmentInfo.pickupAddress.streetAddress2); - const pickupCityInput = screen.getAllByLabelText(/City/)[0]; - await userEvent.clear(pickupCityInput); - await userEvent.type(pickupCityInput, shipmentInfo.pickupAddress.city); - - const pickupStateInput = screen.getAllByLabelText(/State/)[0]; - await userEvent.selectOptions(pickupStateInput, shipmentInfo.pickupAddress.state); - - const pickupPostalCodeInput = screen.getAllByLabelText(/ZIP/)[0]; - await userEvent.clear(pickupPostalCodeInput); - await userEvent.type(pickupPostalCodeInput, shipmentInfo.pickupAddress.postalCode); - const saveButton = await screen.findByRole('button', { name: 'Save' }); expect(saveButton).not.toBeDisabled(); await userEvent.click(saveButton); @@ -1984,7 +1963,7 @@ describe('MtoShipmentForm component', () => { expect(screen.getByLabelText(/Address 1/)).toBeInstanceOf(HTMLInputElement); expect(screen.getByLabelText(/Address 2/)).toBeInstanceOf(HTMLInputElement); expect(screen.getByLabelText(/City/)).toBeInstanceOf(HTMLInputElement); - expect(screen.getByLabelText(/State/)).toBeInstanceOf(HTMLSelectElement); + expect(screen.getByLabelText(/State/)).toBeInstanceOf(HTMLInputElement); expect(screen.getByLabelText(/ZIP/)).toBeInstanceOf(HTMLInputElement); expect(screen.getByText(/Releasing agent/).parentElement).toBeInstanceOf(HTMLLegendElement); diff --git a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.test.jsx b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.test.jsx index f3c7d50093b..79bd2047a09 100644 --- a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.test.jsx +++ b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.test.jsx @@ -109,7 +109,7 @@ describe('CustomerContactInfoForm Component', () => { expect(screen.getByDisplayValue('123 Happy St')).toBeInstanceOf(HTMLInputElement); expect(screen.getByDisplayValue('Unit 4')).toBeInstanceOf(HTMLInputElement); expect(screen.getByDisplayValue('Missoula')).toBeInstanceOf(HTMLInputElement); - expect(screen.getByDisplayValue('MT')).toBeInstanceOf(HTMLSelectElement); + expect(screen.getByDisplayValue('MT')).toBeInstanceOf(HTMLInputElement); expect(screen.getByDisplayValue('59802')).toBeInstanceOf(HTMLInputElement); expect(screen.getByLabelText('Name')).toBeInstanceOf(HTMLInputElement); From 01c12eeec3bb660ce8a3373e03ed1648589f45b2 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Thu, 31 Oct 2024 17:58:07 +0000 Subject: [PATCH 070/216] renaming handlers, adding city finder to pages --- .../BackupAddressForm/BackupAddressForm.jsx | 5 +- .../EditContactInfoForm.jsx | 6 +- .../MtoShipmentForm/MtoShipmentForm.test.jsx | 25 +++- .../ResidentialAddressForm.jsx | 5 +- .../CustomerContactInfoForm.jsx | 31 ++++- .../EditFacilityInfoModal.jsx | 31 ++++- .../EditPPMHeaderSummaryModal.jsx | 6 +- .../Office/ShipmentForm/ShipmentForm.jsx | 110 +++++++++++++++--- .../StorageFacilityAddress.jsx | 86 +++++++++----- .../form/AddressFields/AddressFields.jsx | 8 +- .../AddressFields/AddressFields.stories.jsx | 4 +- 11 files changed, 255 insertions(+), 62 deletions(-) diff --git a/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx b/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx index 77b55ceaae9..494df3340bb 100644 --- a/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx +++ b/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx @@ -26,7 +26,7 @@ const BackupAddressForm = ({ formFieldsName, initialValues, onSubmit, onBack }) validationSchema={validationSchema} > {({ isValid, isSubmitting, handleSubmit, values, setValues }) => { - const handleZipCityChange = (value) => { + const handleLocationChange = (value) => { setValues( { ...values, @@ -61,8 +61,9 @@ const BackupAddressForm = ({ formFieldsName, initialValues, onSubmit, onBack }) diff --git a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx index 26b82454f3b..d37cf7376c9 100644 --- a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx +++ b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx @@ -101,8 +101,9 @@ const EditContactInfoForm = ({ initialValues, onSubmit, onCancel }) => { @@ -116,8 +117,9 @@ const EditContactInfoForm = ({ initialValues, onSubmit, onCancel }) => { diff --git a/src/components/Customer/MtoShipmentForm/MtoShipmentForm.test.jsx b/src/components/Customer/MtoShipmentForm/MtoShipmentForm.test.jsx index 5dcfbc6fc69..3d6391e5c0c 100644 --- a/src/components/Customer/MtoShipmentForm/MtoShipmentForm.test.jsx +++ b/src/components/Customer/MtoShipmentForm/MtoShipmentForm.test.jsx @@ -1677,7 +1677,6 @@ describe('MtoShipmentForm component', () => { city: 'San Marcos', state: 'TX', postalCode: '78666', - county: 'HAYS', }, }; @@ -1734,6 +1733,17 @@ describe('MtoShipmentForm component', () => { await userEvent.clear(pickupAddress2Input); await userEvent.type(pickupAddress2Input, shipmentInfo.pickupAddress.streetAddress2); + const pickupCityInput = screen.getAllByLabelText(/City/)[0]; + await userEvent.clear(pickupCityInput); + await userEvent.type(pickupCityInput, shipmentInfo.pickupAddress.city); + + const pickupStateInput = screen.getAllByLabelText(/State/)[0]; + await userEvent.selectOptions(pickupStateInput, shipmentInfo.pickupAddress.state); + + const pickupPostalCodeInput = screen.getAllByLabelText(/ZIP/)[0]; + await userEvent.clear(pickupPostalCodeInput); + await userEvent.type(pickupPostalCodeInput, shipmentInfo.pickupAddress.postalCode); + const saveButton = await screen.findByRole('button', { name: 'Save' }); expect(saveButton).not.toBeDisabled(); await userEvent.click(saveButton); @@ -1781,6 +1791,17 @@ describe('MtoShipmentForm component', () => { await userEvent.clear(pickupAddress2Input); await userEvent.type(pickupAddress2Input, shipmentInfo.pickupAddress.streetAddress2); + const pickupCityInput = screen.getAllByLabelText(/City/)[0]; + await userEvent.clear(pickupCityInput); + await userEvent.type(pickupCityInput, shipmentInfo.pickupAddress.city); + + const pickupStateInput = screen.getAllByLabelText(/State/)[0]; + await userEvent.selectOptions(pickupStateInput, shipmentInfo.pickupAddress.state); + + const pickupPostalCodeInput = screen.getAllByLabelText(/ZIP/)[0]; + await userEvent.clear(pickupPostalCodeInput); + await userEvent.type(pickupPostalCodeInput, shipmentInfo.pickupAddress.postalCode); + const saveButton = await screen.findByRole('button', { name: 'Save' }); expect(saveButton).not.toBeDisabled(); await userEvent.click(saveButton); @@ -1963,7 +1984,7 @@ describe('MtoShipmentForm component', () => { expect(screen.getByLabelText(/Address 1/)).toBeInstanceOf(HTMLInputElement); expect(screen.getByLabelText(/Address 2/)).toBeInstanceOf(HTMLInputElement); expect(screen.getByLabelText(/City/)).toBeInstanceOf(HTMLInputElement); - expect(screen.getByLabelText(/State/)).toBeInstanceOf(HTMLInputElement); + expect(screen.getByLabelText(/State/)).toBeInstanceOf(HTMLSelectElement); expect(screen.getByLabelText(/ZIP/)).toBeInstanceOf(HTMLInputElement); expect(screen.getByText(/Releasing agent/).parentElement).toBeInstanceOf(HTMLLegendElement); diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx index 9ae92c124da..9c36a20813b 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx @@ -29,7 +29,7 @@ const ResidentialAddressForm = ({ formFieldsName, initialValues, onSubmit, onBac validationSchema={validationSchema} > {({ isValid, isSubmitting, handleSubmit, values, setValues }) => { - const handleZipCityChange = (value) => { + const handleLocationChange = (value) => { setValues( { ...values, @@ -61,8 +61,9 @@ const ResidentialAddressForm = ({ formFieldsName, initialValues, onSubmit, onBac labelHint="Required" name={formFieldsName} validators={validators} + zipCityEnabled zipCityError={isLookupErrorVisible} - handleZipCityChange={handleZipCityChange} + handleLocationChange={handleLocationChange} /> diff --git a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx index ee50c953a05..275f57cc376 100644 --- a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx +++ b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import { React, useState } from 'react'; import { Field, Formik } from 'formik'; import * as Yup from 'yup'; import PropTypes from 'prop-types'; @@ -41,6 +41,9 @@ const CustomerContactInfoForm = ({ initialValues, onSubmit, onBack }) => { emailIsPreferred: Yup.boolean(), cacUser: Yup.boolean().required('Required'), }); + + const [isLookupErrorVisible, setIsLookupErrorVisible] = useState(false); + return ( @@ -61,6 +64,12 @@ const CustomerContactInfoForm = ({ initialValues, onSubmit, onBack }) => { }, { shouldValidate: true }, ); + + if (!value.city || !value.state || !value.county || !value.postalCode) { + setIsLookupErrorVisible(true); + } else { + setIsLookupErrorVisible(false); + } }; const handleBackupZipCityChange = (value) => { setValues( @@ -76,6 +85,12 @@ const CustomerContactInfoForm = ({ initialValues, onSubmit, onBack }) => { }, { shouldValidate: true }, ); + + if (!value.city || !value.state || !value.county || !value.postalCode) { + setIsLookupErrorVisible(true); + } else { + setIsLookupErrorVisible(false); + } }; return (
@@ -95,9 +110,19 @@ const CustomerContactInfoForm = ({ initialValues, onSubmit, onBack }) => { )} />

Current Address

- +

Backup Address

- +

Backup contact

diff --git a/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx b/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx index f5f7e2b3f72..ff14e6dfead 100644 --- a/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx +++ b/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import { React, useState } from 'react'; import { Formik, Field } from 'formik'; import PropTypes from 'prop-types'; import * as Yup from 'yup'; @@ -32,6 +32,8 @@ export const EditFacilityInfoModal = ({ enabledAK, }); + const [isLookupErrorVisible, setIsLookupErrorVisible] = useState(false); + return ( @@ -48,7 +50,28 @@ export const EditFacilityInfoModal = ({ enabledAK, }} > - {({ isValid }) => { + {({ isValid, handleChange, setFieldTouched, values, setValues }) => { + const handleLocationChange = (value) => { + setValues( + { + ...values, + backup_mailing_address: { + ...values.backup_mailing_address, + city: value.city, + state: value.state ? value.state : '', + county: value.county, + postalCode: value.postalCode, + }, + }, + { shouldValidate: true }, + ); + + if (!value.city || !value.state || !value.county || !value.postalCode) { + setIsLookupErrorVisible(true); + } else { + setIsLookupErrorVisible(false); + } + }; return (
@@ -96,6 +119,10 @@ export const EditFacilityInfoModal = ({ ( <> {fields} diff --git a/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx b/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx index 918106c34e3..50ce8c651f6 100644 --- a/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx +++ b/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx @@ -139,8 +139,9 @@ const EditPPMHeaderSummaryModal = ({ sectionType, sectionInfo, onClose, onSubmit legend="Pickup Address" className={styles.AddressFieldSet} formikFunctionsToValidatePostalCodeOnChange={{ handleChange, setFieldTouched }} + zipCityEnabled zipCityError={isLookupErrorVisible} - handleZipCityChange={handlePickupZipCityChange} + handleLocationChange={handlePickupZipCityChange} /> )} {editItemName === 'destinationAddress' && ( @@ -149,8 +150,9 @@ const EditPPMHeaderSummaryModal = ({ sectionType, sectionInfo, onClose, onSubmit legend="Destination Address" className={styles.AddressFieldSet} formikFunctionsToValidatePostalCodeOnChange={{ handleChange, setFieldTouched }} + zipCityEnabled zipCityError={isLookupErrorVisible} - handleZipCityChange={handleDestinationZipCityChange} + handleLocationChange={handleDestinationZipCityChange} /> )}
diff --git a/src/components/Office/ShipmentForm/ShipmentForm.jsx b/src/components/Office/ShipmentForm/ShipmentForm.jsx index 0e02520bf72..10b7b36fe44 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.jsx @@ -622,6 +622,8 @@ const ShipmentForm = (props) => { } }; + const [isLookupErrorVisible, setIsLookupErrorVisible] = useState(false); + return ( { }, { shouldValidate: true }, ); + + if (!value.city || !value.state || !value.county || !value.postalCode) { + setIsLookupErrorVisible(true); + } else { + setIsLookupErrorVisible(false); + } }; const handleSecondaryPickupZipCityChange = (value) => { @@ -756,6 +764,12 @@ const ShipmentForm = (props) => { }, { shouldValidate: true }, ); + + if (!value.city || !value.state || !value.county || !value.postalCode) { + setIsLookupErrorVisible(true); + } else { + setIsLookupErrorVisible(false); + } }; const handleTertiaryPickupZipCityChange = (value) => { @@ -775,6 +789,12 @@ const ShipmentForm = (props) => { }, { shouldValidate: true }, ); + + if (!value.city || !value.state || !value.county || !value.postalCode) { + setIsLookupErrorVisible(true); + } else { + setIsLookupErrorVisible(false); + } }; const handleDeliveryZipCityChange = (value) => { @@ -794,6 +814,12 @@ const ShipmentForm = (props) => { }, { shouldValidate: true }, ); + + if (!value.city || !value.state || !value.county || !value.postalCode) { + setIsLookupErrorVisible(true); + } else { + setIsLookupErrorVisible(false); + } }; const handleSecondaryDeliveryZipCityChange = (value) => { @@ -813,6 +839,12 @@ const ShipmentForm = (props) => { }, { shouldValidate: true }, ); + + if (!value.city || !value.state || !value.county || !value.postalCode) { + setIsLookupErrorVisible(true); + } else { + setIsLookupErrorVisible(false); + } }; const handleTertiaryDeliveryZipCityChange = (value) => { @@ -851,6 +883,12 @@ const ShipmentForm = (props) => { }, { shouldValidate: true }, ); + + if (!value.city || !value.state || !value.county || !value.postalCode) { + setIsLookupErrorVisible(true); + } else { + setIsLookupErrorVisible(false); + } }; const handleSecondaryDestinationZipCityChange = (value) => { @@ -870,6 +908,12 @@ const ShipmentForm = (props) => { }, { shouldValidate: true }, ); + + if (!value.city || !value.state || !value.county || !value.postalCode) { + setIsLookupErrorVisible(true); + } else { + setIsLookupErrorVisible(false); + } }; const handleTertiaryDestinationZipCityChange = (value) => { @@ -889,6 +933,12 @@ const ShipmentForm = (props) => { }, { shouldValidate: true }, ); + + if (!value.city || !value.state || !value.county || !value.postalCode) { + setIsLookupErrorVisible(true); + } else { + setIsLookupErrorVisible(false); + } }; const handlePickupDateChange = (e) => { @@ -1082,7 +1132,9 @@ const ShipmentForm = (props) => { ( <>

What address are the movers picking up from?

@@ -1124,7 +1176,9 @@ const ShipmentForm = (props) => { <> {isTertiaryAddressEnabled && ( <> @@ -1157,7 +1211,9 @@ const ShipmentForm = (props) => { {hasTertiaryPickup === 'yes' && ( )} @@ -1237,7 +1293,9 @@ const ShipmentForm = (props) => { > { return fields; }} @@ -1272,7 +1330,9 @@ const ShipmentForm = (props) => { <> {isTertiaryAddressEnabled && ( <> @@ -1305,7 +1365,9 @@ const ShipmentForm = (props) => { {hasTertiaryDelivery === 'yes' && ( )} @@ -1384,7 +1446,9 @@ const ShipmentForm = (props) => { {hasDeliveryAddress === 'yes' ? ( ( <> {fields} @@ -1426,7 +1490,9 @@ const ShipmentForm = (props) => { <> {isTertiaryAddressEnabled && ( <> @@ -1461,7 +1527,9 @@ const ShipmentForm = (props) => { {hasTertiaryDelivery === 'yes' && ( )} @@ -1520,7 +1588,9 @@ const ShipmentForm = (props) => { ( <>

What address are you moving from?

@@ -1565,7 +1635,9 @@ const ShipmentForm = (props) => { <> {isTertiaryAddressEnabled && ( <> @@ -1601,7 +1673,9 @@ const ShipmentForm = (props) => { {hasTertiaryPickup === 'true' && ( )} @@ -1614,7 +1688,9 @@ const ShipmentForm = (props) => { ( <> {fields} @@ -1651,7 +1727,9 @@ const ShipmentForm = (props) => { <> {isTertiaryAddressEnabled && ( <> @@ -1687,7 +1765,9 @@ const ShipmentForm = (props) => { {hasTertiaryDestination === 'true' && ( )} diff --git a/src/components/Office/StorageFacilityAddress/StorageFacilityAddress.jsx b/src/components/Office/StorageFacilityAddress/StorageFacilityAddress.jsx index 4529d8545e6..f0095ea2806 100644 --- a/src/components/Office/StorageFacilityAddress/StorageFacilityAddress.jsx +++ b/src/components/Office/StorageFacilityAddress/StorageFacilityAddress.jsx @@ -1,6 +1,6 @@ -import React from 'react'; +import { React, useState } from 'react'; import { Fieldset, FormGroup, Label, TextInput, Grid } from '@trussworks/react-uswds'; -import { Field } from 'formik'; +import { Formik, Field } from 'formik'; import formStyles from 'styles/form.module.scss'; import styles from 'components/Office/ShipmentForm/ShipmentForm.module.scss'; @@ -8,31 +8,65 @@ import SectionWrapper from 'components/Customer/SectionWrapper'; import { AddressFields } from 'components/form/AddressFields/AddressFields'; const StorageFacilityAddress = () => { + const [isLookupErrorVisible, setIsLookupErrorVisible] = useState(false); return ( - -
-

Storage facility address

- ( - <> - {fields} - - - - - - - - - - )} - /> -
-
+ + {({ values, setValues }) => { + const handleLocationChange = (value) => { + setValues( + { + ...values, + storageFacility: { + ...values.storageFacility, + address: { + ...values.storageFacility.address, + city: value.city, + state: value.state ? value.state : '', + county: value.county, + postalCode: value.postalCode, + }, + }, + }, + { shouldValidate: true }, + ); + + if (!value.city || !value.state || !value.county || !value.postalCode) { + setIsLookupErrorVisible(true); + } else { + setIsLookupErrorVisible(false); + } + }; + return ( + +
+

Storage facility address

+ ( + <> + {fields} + + + + + + + + + + )} + /> +
+
+ ); + }} +
); }; diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index ca54a4a7f96..c9a1b166a24 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -33,7 +33,7 @@ export const AddressFields = ({ validators, zipCityEnabled, zipCityError, - handleZipCityChange: handleLocationChange, + handleLocationChange, formikFunctionsToValidatePostalCodeOnChange, labelHint: labelHintProp, }) => { @@ -195,7 +195,7 @@ AddressFields.propTypes = { render: PropTypes.func, zipCityEnabled: PropTypes.bool, zipCityError: PropTypes.bool, - handleZipCityChange: PropTypes.func, + handleLocationChange: PropTypes.func, validators: PropTypes.shape({ streetAddress1: PropTypes.func, streetAddress2: PropTypes.func, @@ -214,9 +214,9 @@ AddressFields.defaultProps = { legend: '', className: '', render: (fields) => fields, - zipCityEnabled: true, + zipCityEnabled: false, zipCityError: false, - handleZipCityChange: null, + handleLocationChange: null, validators: {}, formikFunctionsToValidatePostalCodeOnChange: null, }; diff --git a/src/components/form/AddressFields/AddressFields.stories.jsx b/src/components/form/AddressFields/AddressFields.stories.jsx index 1110d878045..0649305961d 100644 --- a/src/components/form/AddressFields/AddressFields.stories.jsx +++ b/src/components/form/AddressFields/AddressFields.stories.jsx @@ -126,7 +126,7 @@ export const InsideSectionWrapper = () => (
); -export const ZipCityAddress = () => ( +export const ZipCityStateAddress = () => ( ( > {() => ( - + )} From cce1df229680590e681b4108ef70f6e2c7a8084d Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Thu, 31 Oct 2024 18:48:06 +0000 Subject: [PATCH 071/216] remove zipCityError, add finder to storage address --- .../BackupAddressForm/BackupAddressForm.jsx | 10 +- .../EditContactInfoForm.jsx | 18 +-- .../ResidentialAddressForm.jsx | 10 +- .../CustomerContactInfoForm.jsx | 18 +-- .../EditFacilityInfoModal.jsx | 11 +- .../EditPPMHeaderSummaryModal.jsx | 17 +-- .../Office/ShipmentForm/ShipmentForm.jsx | 134 ++++++------------ .../StorageFacilityAddress.jsx | 95 +++++-------- .../form/AddressFields/AddressFields.jsx | 29 +--- 9 files changed, 91 insertions(+), 251 deletions(-) diff --git a/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx b/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx index 494df3340bb..8d6fbad06f6 100644 --- a/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx +++ b/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx @@ -1,4 +1,4 @@ -import { React, useState } from 'react'; +import React from 'react'; import PropTypes from 'prop-types'; import { Formik } from 'formik'; import * as Yup from 'yup'; @@ -15,7 +15,6 @@ const BackupAddressForm = ({ formFieldsName, initialValues, onSubmit, onBack }) const validationSchema = Yup.object().shape({ [formFieldsName]: requiredAddressSchema.required(), }); - const [isLookupErrorVisible, setIsLookupErrorVisible] = useState(false); return ( diff --git a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx index d37cf7376c9..8b4985d1878 100644 --- a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx +++ b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx @@ -1,5 +1,5 @@ import classnames from 'classnames'; -import { React, useState } from 'react'; +import React from 'react'; import PropTypes from 'prop-types'; import { Formik } from 'formik'; import * as Yup from 'yup'; @@ -37,8 +37,6 @@ const EditContactInfoForm = ({ initialValues, onSubmit, onCancel }) => { .test('contactMethodRequired', 'Please select a preferred method of contact.', preferredContactMethodValidation); const sectionStyles = classnames(formStyles.formSection, editContactInfoFormStyle.formSection); - const [isCurrentLookupErrorVisible, setIsCurrentLookupErrorVisible] = useState(false); - const [isBackupLookupErrorVisible, setIsBackupLookupErrorVisible] = useState(false); return ( @@ -57,12 +55,6 @@ const EditContactInfoForm = ({ initialValues, onSubmit, onCancel }) => { }, { shouldValidate: true }, ); - - if (!value.city || !value.state || !value.county || !value.postalCode) { - setIsCurrentLookupErrorVisible(true); - } else { - setIsCurrentLookupErrorVisible(false); - } }; const handleBackupZipCityChange = (value) => { setValues( @@ -78,12 +70,6 @@ const EditContactInfoForm = ({ initialValues, onSubmit, onCancel }) => { }, { shouldValidate: true }, ); - - if (!value.city || !value.state || !value.county || !value.postalCode) { - setIsBackupLookupErrorVisible(true); - } else { - setIsBackupLookupErrorVisible(false); - } }; return (
@@ -102,7 +88,6 @@ const EditContactInfoForm = ({ initialValues, onSubmit, onCancel }) => { name={residentialAddressName} labelHint="Required" zipCityEnabled - zipCityError={isCurrentLookupErrorVisible} handleLocationChange={handleCurrentZipCityChange} /> @@ -118,7 +103,6 @@ const EditContactInfoForm = ({ initialValues, onSubmit, onCancel }) => { name={backupAddressName} labelHint="Required" zipCityEnabled - zipCityError={isBackupLookupErrorVisible} handleLocationChange={handleBackupZipCityChange} /> diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx index 9c36a20813b..4a3aee05d6e 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx @@ -1,4 +1,4 @@ -import { React, useState } from 'react'; +import React from 'react'; import PropTypes from 'prop-types'; import { Formik } from 'formik'; import classnames from 'classnames'; @@ -18,7 +18,6 @@ const ResidentialAddressForm = ({ formFieldsName, initialValues, onSubmit, onBac const validationSchema = Yup.object().shape({ [formFieldsName]: requiredAddressSchema.required(), }); - const [isLookupErrorVisible, setIsLookupErrorVisible] = useState(false); return ( diff --git a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx index 275f57cc376..130a1b2718f 100644 --- a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx +++ b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx @@ -1,4 +1,4 @@ -import { React, useState } from 'react'; +import React from 'react'; import { Field, Formik } from 'formik'; import * as Yup from 'yup'; import PropTypes from 'prop-types'; @@ -42,8 +42,6 @@ const CustomerContactInfoForm = ({ initialValues, onSubmit, onBack }) => { cacUser: Yup.boolean().required('Required'), }); - const [isLookupErrorVisible, setIsLookupErrorVisible] = useState(false); - return ( @@ -64,12 +62,6 @@ const CustomerContactInfoForm = ({ initialValues, onSubmit, onBack }) => { }, { shouldValidate: true }, ); - - if (!value.city || !value.state || !value.county || !value.postalCode) { - setIsLookupErrorVisible(true); - } else { - setIsLookupErrorVisible(false); - } }; const handleBackupZipCityChange = (value) => { setValues( @@ -85,12 +77,6 @@ const CustomerContactInfoForm = ({ initialValues, onSubmit, onBack }) => { }, { shouldValidate: true }, ); - - if (!value.city || !value.state || !value.county || !value.postalCode) { - setIsLookupErrorVisible(true); - } else { - setIsLookupErrorVisible(false); - } }; return ( @@ -113,14 +99,12 @@ const CustomerContactInfoForm = ({ initialValues, onSubmit, onBack }) => {

Backup Address

diff --git a/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx b/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx index ff14e6dfead..724cec2e7fd 100644 --- a/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx +++ b/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx @@ -1,4 +1,4 @@ -import { React, useState } from 'react'; +import React from 'react'; import { Formik, Field } from 'formik'; import PropTypes from 'prop-types'; import * as Yup from 'yup'; @@ -32,8 +32,6 @@ export const EditFacilityInfoModal = ({ enabledAK, }); - const [isLookupErrorVisible, setIsLookupErrorVisible] = useState(false); - return ( @@ -65,12 +63,6 @@ export const EditFacilityInfoModal = ({ }, { shouldValidate: true }, ); - - if (!value.city || !value.state || !value.county || !value.postalCode) { - setIsLookupErrorVisible(true); - } else { - setIsLookupErrorVisible(false); - } }; return ( @@ -121,7 +113,6 @@ export const EditFacilityInfoModal = ({ className={styles.AddressFields} formikFunctionsToValidatePostalCodeOnChange={{ handleChange, setFieldTouched }} zipCityEnabled - zipCityError={isLookupErrorVisible} handleLocationChange={handleLocationChange} render={(fields) => ( <> diff --git a/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx b/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx index 50ce8c651f6..6d05688e721 100644 --- a/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx +++ b/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx @@ -1,4 +1,4 @@ -import { React, useState } from 'react'; +import React from 'react'; import { Formik } from 'formik'; import PropTypes from 'prop-types'; import * as Yup from 'yup'; @@ -53,7 +53,6 @@ const EditPPMHeaderSummaryModal = ({ sectionType, sectionInfo, onClose, onSubmit otherwise: (schema) => schema, }), }); - const [isLookupErrorVisible, setIsLookupErrorVisible] = useState(false); return (
@@ -80,12 +79,6 @@ const EditPPMHeaderSummaryModal = ({ sectionType, sectionInfo, onClose, onSubmit }, { shouldValidate: true }, ); - - if (!value.city || !value.state || !value.county || !value.postalCode) { - setIsLookupErrorVisible(true); - } else { - setIsLookupErrorVisible(false); - } }; const handleDestinationZipCityChange = (value) => { setValues( @@ -101,12 +94,6 @@ const EditPPMHeaderSummaryModal = ({ sectionType, sectionInfo, onClose, onSubmit }, { shouldValidate: true }, ); - - if (!value.city || !value.state || !value.county || !value.postalCode) { - setIsLookupErrorVisible(true); - } else { - setIsLookupErrorVisible(false); - } }; return ( @@ -140,7 +127,6 @@ const EditPPMHeaderSummaryModal = ({ sectionType, sectionInfo, onClose, onSubmit className={styles.AddressFieldSet} formikFunctionsToValidatePostalCodeOnChange={{ handleChange, setFieldTouched }} zipCityEnabled - zipCityError={isLookupErrorVisible} handleLocationChange={handlePickupZipCityChange} /> )} @@ -151,7 +137,6 @@ const EditPPMHeaderSummaryModal = ({ sectionType, sectionInfo, onClose, onSubmit className={styles.AddressFieldSet} formikFunctionsToValidatePostalCodeOnChange={{ handleChange, setFieldTouched }} zipCityEnabled - zipCityError={isLookupErrorVisible} handleLocationChange={handleDestinationZipCityChange} /> )} diff --git a/src/components/Office/ShipmentForm/ShipmentForm.jsx b/src/components/Office/ShipmentForm/ShipmentForm.jsx index 10b7b36fe44..02808c0895b 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.jsx @@ -622,8 +622,6 @@ const ShipmentForm = (props) => { } }; - const [isLookupErrorVisible, setIsLookupErrorVisible] = useState(false); - return ( { } }; - const handlePickupZipCityChange = (value) => { + const handlePickupLocationChange = (value) => { setValues( { ...values, @@ -739,15 +737,9 @@ const ShipmentForm = (props) => { }, { shouldValidate: true }, ); - - if (!value.city || !value.state || !value.county || !value.postalCode) { - setIsLookupErrorVisible(true); - } else { - setIsLookupErrorVisible(false); - } }; - const handleSecondaryPickupZipCityChange = (value) => { + const handleSecondaryPickupLocationChange = (value) => { setValues( { ...values, @@ -764,15 +756,9 @@ const ShipmentForm = (props) => { }, { shouldValidate: true }, ); - - if (!value.city || !value.state || !value.county || !value.postalCode) { - setIsLookupErrorVisible(true); - } else { - setIsLookupErrorVisible(false); - } }; - const handleTertiaryPickupZipCityChange = (value) => { + const handleTertiaryPickupLocationChange = (value) => { setValues( { ...values, @@ -789,15 +775,9 @@ const ShipmentForm = (props) => { }, { shouldValidate: true }, ); - - if (!value.city || !value.state || !value.county || !value.postalCode) { - setIsLookupErrorVisible(true); - } else { - setIsLookupErrorVisible(false); - } }; - const handleDeliveryZipCityChange = (value) => { + const handleDeliveryLocationChange = (value) => { setValues( { ...values, @@ -814,15 +794,9 @@ const ShipmentForm = (props) => { }, { shouldValidate: true }, ); - - if (!value.city || !value.state || !value.county || !value.postalCode) { - setIsLookupErrorVisible(true); - } else { - setIsLookupErrorVisible(false); - } }; - const handleSecondaryDeliveryZipCityChange = (value) => { + const handleSecondaryDeliveryLocationChange = (value) => { setValues( { ...values, @@ -839,15 +813,9 @@ const ShipmentForm = (props) => { }, { shouldValidate: true }, ); - - if (!value.city || !value.state || !value.county || !value.postalCode) { - setIsLookupErrorVisible(true); - } else { - setIsLookupErrorVisible(false); - } }; - const handleTertiaryDeliveryZipCityChange = (value) => { + const handleTertiaryDeliveryLocationChange = (value) => { setValues( { ...values, @@ -866,7 +834,7 @@ const ShipmentForm = (props) => { ); }; - const handleDestinationZipCityChange = (value) => { + const handleDestinationLocationChange = (value) => { setValues( { ...values, @@ -883,15 +851,9 @@ const ShipmentForm = (props) => { }, { shouldValidate: true }, ); - - if (!value.city || !value.state || !value.county || !value.postalCode) { - setIsLookupErrorVisible(true); - } else { - setIsLookupErrorVisible(false); - } }; - const handleSecondaryDestinationZipCityChange = (value) => { + const handleSecondaryDestinationLocationChange = (value) => { setValues( { ...values, @@ -908,15 +870,9 @@ const ShipmentForm = (props) => { }, { shouldValidate: true }, ); - - if (!value.city || !value.state || !value.county || !value.postalCode) { - setIsLookupErrorVisible(true); - } else { - setIsLookupErrorVisible(false); - } }; - const handleTertiaryDestinationZipCityChange = (value) => { + const handleTertiaryDestinationLocationChange = (value) => { setValues( { ...values, @@ -933,12 +889,25 @@ const ShipmentForm = (props) => { }, { shouldValidate: true }, ); + }; - if (!value.city || !value.state || !value.county || !value.postalCode) { - setIsLookupErrorVisible(true); - } else { - setIsLookupErrorVisible(false); - } + const handleStorageFacilityLocationChange = (value) => { + setValues( + { + ...values, + storageFacility: { + ...values.storageFacility, + address: { + ...values.storageFacility.address, + city: value.city, + state: value.state ? value.state : '', + county: value.county, + postalCode: value.postalCode, + }, + }, + }, + { shouldValidate: true }, + ); }; const handlePickupDateChange = (e) => { @@ -1133,8 +1102,7 @@ const ShipmentForm = (props) => { name="pickup.address" legend="Pickup location" zipCityEnabled - zipCityError={isLookupErrorVisible} - handleLocationChange={handlePickupZipCityChange} + handleLocationChange={handlePickupLocationChange} render={(fields) => ( <>

What address are the movers picking up from?

@@ -1177,8 +1145,7 @@ const ShipmentForm = (props) => { {isTertiaryAddressEnabled && ( <> @@ -1212,8 +1179,7 @@ const ShipmentForm = (props) => { )} @@ -1239,14 +1205,14 @@ const ShipmentForm = (props) => { {isTOO && (isNTS || isNTSR) && ( <> - + )} {isServiceCounselor && isNTSR && ( <> - + )} @@ -1294,8 +1260,7 @@ const ShipmentForm = (props) => { { return fields; }} @@ -1331,8 +1296,7 @@ const ShipmentForm = (props) => { {isTertiaryAddressEnabled && ( <> @@ -1366,8 +1330,7 @@ const ShipmentForm = (props) => { )} @@ -1447,8 +1410,7 @@ const ShipmentForm = (props) => { ( <> {fields} @@ -1491,8 +1453,7 @@ const ShipmentForm = (props) => { {isTertiaryAddressEnabled && ( <> @@ -1528,8 +1489,7 @@ const ShipmentForm = (props) => { )} @@ -1589,8 +1549,7 @@ const ShipmentForm = (props) => { name="pickup.address" legend="Pickup Address" zipCityEnabled - zipCityError={isLookupErrorVisible} - handleLocationChange={handlePickupZipCityChange} + handleLocationChange={handlePickupLocationChange} render={(fields) => ( <>

What address are you moving from?

@@ -1636,8 +1595,7 @@ const ShipmentForm = (props) => { {isTertiaryAddressEnabled && ( <> @@ -1674,8 +1632,7 @@ const ShipmentForm = (props) => { )} @@ -1689,8 +1646,7 @@ const ShipmentForm = (props) => { name="destination.address" legend="Delivery Address" zipCityEnabled - zipCityError={isLookupErrorVisible} - handleLocationChange={handleDestinationZipCityChange} + handleLocationChange={handleDestinationLocationChange} render={(fields) => ( <> {fields} @@ -1728,8 +1684,7 @@ const ShipmentForm = (props) => { {isTertiaryAddressEnabled && ( <> @@ -1766,8 +1721,7 @@ const ShipmentForm = (props) => { )} diff --git a/src/components/Office/StorageFacilityAddress/StorageFacilityAddress.jsx b/src/components/Office/StorageFacilityAddress/StorageFacilityAddress.jsx index f0095ea2806..3224f076322 100644 --- a/src/components/Office/StorageFacilityAddress/StorageFacilityAddress.jsx +++ b/src/components/Office/StorageFacilityAddress/StorageFacilityAddress.jsx @@ -1,73 +1,46 @@ -import { React, useState } from 'react'; +import React from 'react'; +import PropTypes from 'prop-types'; import { Fieldset, FormGroup, Label, TextInput, Grid } from '@trussworks/react-uswds'; -import { Formik, Field } from 'formik'; +import { Field } from 'formik'; import formStyles from 'styles/form.module.scss'; import styles from 'components/Office/ShipmentForm/ShipmentForm.module.scss'; import SectionWrapper from 'components/Customer/SectionWrapper'; import { AddressFields } from 'components/form/AddressFields/AddressFields'; -const StorageFacilityAddress = () => { - const [isLookupErrorVisible, setIsLookupErrorVisible] = useState(false); +const StorageFacilityAddress = ({ onLocationChange }) => { return ( - - {({ values, setValues }) => { - const handleLocationChange = (value) => { - setValues( - { - ...values, - storageFacility: { - ...values.storageFacility, - address: { - ...values.storageFacility.address, - city: value.city, - state: value.state ? value.state : '', - county: value.county, - postalCode: value.postalCode, - }, - }, - }, - { shouldValidate: true }, - ); - - if (!value.city || !value.state || !value.county || !value.postalCode) { - setIsLookupErrorVisible(true); - } else { - setIsLookupErrorVisible(false); - } - }; - return ( - -
-

Storage facility address

- ( - <> - {fields} - - - - - - - - - - )} - /> -
-
- ); - }} -
+ +
+

Storage facility address

+ ( + <> + {fields} + + + + + + + + + + )} + /> +
+
); }; +StorageFacilityAddress.propTypes = { + onLocationChange: PropTypes.func.isRequired, +}; + export default StorageFacilityAddress; diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index c9a1b166a24..edd7af784f8 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -32,14 +32,12 @@ export const AddressFields = ({ render, validators, zipCityEnabled, - zipCityError, handleLocationChange, formikFunctionsToValidatePostalCodeOnChange, labelHint: labelHintProp, }) => { const addressFieldsUUID = useRef(uuidv4()); const infoStr = 'If you encounter any inaccurate lookup information please contact the '; - const errorStr = 'Not all data was able to populate successfully. Contact the '; const assistanceStr = ' for further assistance.'; const postalCodeField = formikFunctionsToValidatePostalCodeOnChange ? ( @@ -133,24 +131,13 @@ export const AddressFields = ({ label="Location Lookup" handleLocationChange={handleLocationChange} /> - {!zipCityError && ( - - {infoStr} -
- Technical Help Desk - - {assistanceStr} - - )} - {zipCityError && ( - - {errorStr} - - Technical Help Desk - - {assistanceStr} - - )} + + {infoStr} + + Technical Help Desk + + {assistanceStr} + )}
@@ -194,7 +181,6 @@ AddressFields.propTypes = { name: PropTypes.string.isRequired, render: PropTypes.func, zipCityEnabled: PropTypes.bool, - zipCityError: PropTypes.bool, handleLocationChange: PropTypes.func, validators: PropTypes.shape({ streetAddress1: PropTypes.func, @@ -215,7 +201,6 @@ AddressFields.defaultProps = { className: '', render: (fields) => fields, zipCityEnabled: false, - zipCityError: false, handleLocationChange: null, validators: {}, formikFunctionsToValidatePostalCodeOnChange: null, From 648126bc1c635bf1c5b82e818edc4b5829c6f074 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 1 Nov 2024 15:13:58 +0000 Subject: [PATCH 072/216] removing unneeded error check for missing results --- .../BackupAddressForm/BackupAddressForm.jsx | 4 +- .../EditFacilityInfoModal.test.jsx | 71 ++++++---- .../Office/ShipmentForm/ShipmentForm.test.jsx | 133 ++++++++---------- .../form/AddressFields/AddressFields.jsx | 3 - .../form/AddressFields/AddressFields.test.jsx | 35 +---- .../form/fields/LocationInput.test.jsx | 4 +- .../ServicesCounselingAddShipment.test.jsx | 25 +++- 7 files changed, 130 insertions(+), 145 deletions(-) diff --git a/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx b/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx index 8d6fbad06f6..a4bb1f1f06b 100644 --- a/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx +++ b/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx @@ -29,8 +29,8 @@ const BackupAddressForm = ({ formFieldsName, initialValues, onSubmit, onBack }) setValues( { ...values, - backup_mailing_address: { - ...values.backup_mailing_address, + formFieldsName: { + ...values.formFieldsName, city: value.city, state: value.state ? value.state : '', county: value.county, diff --git a/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.test.jsx b/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.test.jsx index b7f4ea16b17..c68a8c059fa 100644 --- a/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.test.jsx +++ b/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.test.jsx @@ -1,9 +1,12 @@ import React from 'react'; import { render, waitFor, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; +import { Provider } from 'react-redux'; import { EditFacilityInfoModal } from './EditFacilityInfoModal'; +import { configureStore } from 'shared/store'; + describe('EditFacilityInfoModal', () => { const storageFacility = { facilityName: 'My Facility', @@ -34,14 +37,17 @@ describe('EditFacilityInfoModal', () => { it('calls onSubmit prop on save button click when the form has valid data', async () => { const mockOnSubmit = jest.fn(); + const mockStore = configureStore({}); render( - {}} - onSubmit={mockOnSubmit} - storageFacility={storageFacility} - serviceOrderNumber="12345" - shipmentType="HHG_INTO_NTS_DOMESTIC" - />, + + {}} + onSubmit={mockOnSubmit} + storageFacility={storageFacility} + serviceOrderNumber="12345" + shipmentType="HHG_INTO_NTS_DOMESTIC" + /> + , ); const submitBtn = screen.getByRole('button', { name: 'Save' }); @@ -54,14 +60,17 @@ describe('EditFacilityInfoModal', () => { it('calls onSubmit prop on save button click when valid data is entered', async () => { const mockOnSubmit = jest.fn(); + const mockStore = configureStore({}); render( - {}} - onSubmit={mockOnSubmit} - storageFacility={incompleteStorageFacility} - serviceOrderNumber="12345" - shipmentType="HHG_INTO_NTS_DOMESTIC" - />, + + {}} + onSubmit={mockOnSubmit} + storageFacility={incompleteStorageFacility} + serviceOrderNumber="12345" + shipmentType="HHG_INTO_NTS_DOMESTIC" + /> + , ); const addressInput = screen.getByLabelText(/Address 1/); const submitBtn = screen.getByRole('button', { name: 'Save' }); @@ -75,14 +84,17 @@ describe('EditFacilityInfoModal', () => { }); it('does not allow saving with incomplete form data', async () => { + const mockStore = configureStore({}); render( - {}} - onSubmit={() => {}} - storageFacility={incompleteStorageFacility} - serviceOrderNumber="12345" - shipmentType="HHG_INTO_NTS_DOMESTIC" - />, + + {}} + onSubmit={() => {}} + storageFacility={incompleteStorageFacility} + serviceOrderNumber="12345" + shipmentType="HHG_INTO_NTS_DOMESTIC" + /> + , ); const submitBtn = screen.getByRole('button', { name: 'Save' }); await waitFor(() => { @@ -92,14 +104,17 @@ describe('EditFacilityInfoModal', () => { it('calls onclose prop on modal close', async () => { const mockClose = jest.fn(); + const mockStore = configureStore({}); render( - {}} - storageFacility={storageFacility} - serviceOrderNumber="12345" - shipmentType="HHG_INTO_NTS_DOMESTIC" - />, + + {}} + storageFacility={storageFacility} + serviceOrderNumber="12345" + shipmentType="HHG_INTO_NTS_DOMESTIC" + /> + , ); const closeBtn = screen.getByRole('button', { name: 'Cancel' }); diff --git a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx index aaf94dd449c..28f9633dc78 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx @@ -221,7 +221,7 @@ const mockPPMShipment = { streetAddress1: '111 Test Street', streetAddress2: '222 Test Street', streetAddress3: 'Test Man', - city: 'Test City', + city: 'ELIZABETHTOWN', state: 'KY', postalCode: '42701', county: 'HARDIN', @@ -230,7 +230,7 @@ const mockPPMShipment = { streetAddress1: '777 Test Street', streetAddress2: '888 Test Street', streetAddress3: 'Test Man', - city: 'Test City', + city: 'ELIZABETHTOWN', state: 'KY', postalCode: '42702', county: 'HARDIN', @@ -239,16 +239,16 @@ const mockPPMShipment = { streetAddress1: '222 Test Street', streetAddress2: '333 Test Street', streetAddress3: 'Test Man', - city: 'Test City', + city: 'BIG CLIFTY', state: 'KY', - postalCode: '42703', + postalCode: '42712', county: 'HARDIN', }, secondaryDestinationAddress: { streetAddress1: '444 Test Street', streetAddress2: '555 Test Street', streetAddress3: 'Test Man', - city: 'Test City', + city: 'ELIZABETHTOWN', state: 'KY', postalCode: '42701', county: 'HARDIN', @@ -276,7 +276,7 @@ const mockRejectedPPMShipment = { streetAddress1: '111 Test Street', streetAddress2: '222 Test Street', streetAddress3: 'Test Man', - city: 'Test City', + city: 'ELIZABETHTOWN', state: 'KY', postalCode: '42701', county: 'HARDIN', @@ -285,7 +285,7 @@ const mockRejectedPPMShipment = { streetAddress1: '777 Test Street', streetAddress2: '888 Test Street', streetAddress3: 'Test Man', - city: 'Test City', + city: 'ELIZABETHTOWN', state: 'KY', postalCode: '42702', county: 'HARDIN', @@ -294,7 +294,7 @@ const mockRejectedPPMShipment = { streetAddress1: '222 Test Street', streetAddress2: '333 Test Street', streetAddress3: 'Test Man', - city: 'Test City', + city: 'BIG CLIFTY', state: 'KY', postalCode: '42703', county: 'HARDIN', @@ -303,7 +303,7 @@ const mockRejectedPPMShipment = { streetAddress1: '444 Test Street', streetAddress2: '555 Test Street', streetAddress3: 'Test Man', - city: 'Test City', + city: 'ELIZABETHTOWN', state: 'KY', postalCode: '42701', county: 'HARDIN', @@ -407,7 +407,7 @@ describe('ShipmentForm component', () => { expect(screen.getByLabelText(/Address 1/)).toBeInstanceOf(HTMLInputElement); expect(screen.getByLabelText(/Address 2/)).toBeInstanceOf(HTMLInputElement); expect(screen.getByLabelText('City')).toBeInstanceOf(HTMLInputElement); - expect(screen.getByLabelText('State')).toBeInstanceOf(HTMLSelectElement); + expect(screen.getByLabelText('State')).toBeInstanceOf(HTMLInputElement); expect(screen.getByLabelText('ZIP')).toBeInstanceOf(HTMLInputElement); expect(screen.getByText(/Releasing agent/).parentElement).toBeInstanceOf(HTMLLegendElement); @@ -774,7 +774,7 @@ describe('ShipmentForm component', () => { expect(screen.getByLabelText(/Address 1/)).toBeInstanceOf(HTMLInputElement); expect(screen.getByLabelText(/Address 2/)).toBeInstanceOf(HTMLInputElement); expect(screen.getByLabelText('City')).toBeInstanceOf(HTMLInputElement); - expect(screen.getByLabelText('State')).toBeInstanceOf(HTMLSelectElement); + expect(screen.getByLabelText('State')).toBeInstanceOf(HTMLInputElement); expect(screen.getByLabelText('ZIP')).toBeInstanceOf(HTMLInputElement); expect(screen.getByText(/Releasing agent/).parentElement).toBeInstanceOf(HTMLLegendElement); @@ -1059,66 +1059,57 @@ describe('ShipmentForm component', () => { expect(mockNavigate).not.toHaveBeenCalled(); }); - it('shows an error if the submitHandler returns an error when creating a PPM', async () => { - const mockSubmitHandler = jest.fn((payload, { onError }) => { - // fire onError handler on form - onError(); - }); - validatePostalCode.mockImplementation(() => Promise.resolve(false)); - - renderWithRouter( - , - ); - - await act(async () => { - screen.getByLabelText('Planned Departure Date').focus(); - await userEvent.paste('26 Mar 2022'); - - screen.getAllByLabelText('Address 1')[0].focus(); - await userEvent.paste('Test Street 1'); - screen.getAllByLabelText('City')[0].focus(); - await userEvent.paste('TestOne City'); - const pickupStateInput = screen.getAllByLabelText('State')[0]; - await userEvent.selectOptions(pickupStateInput, 'CA'); - screen.getAllByLabelText('ZIP')[0].focus(); - await userEvent.paste('90210'); - screen.getAllByLabelText('County')[0].focus(); - await userEvent.paste('LOS ANGELES'); - - screen.getAllByLabelText('Address 1')[1].focus(); - await userEvent.paste('Test Street 3'); - screen.getAllByLabelText('City')[1].focus(); - await userEvent.paste('TestTwo City'); - const destinationStateInput = screen.getAllByLabelText('State')[1]; - await userEvent.selectOptions(destinationStateInput, 'CA'); - screen.getAllByLabelText('ZIP')[1].focus(); - await userEvent.paste('90210'); - screen.getAllByLabelText('County')[1].focus(); - await userEvent.paste('LOS ANGELES'); - - screen.getByLabelText('Estimated PPM weight').focus(); - await userEvent.paste('1000'); - - const saveButton = screen.getByRole('button', { name: 'Save and Continue' }); - expect(saveButton).not.toBeDisabled(); - await userEvent.click(saveButton); - }); - - await waitFor(() => { - expect(mockSubmitHandler).toHaveBeenCalled(); - }); - - await waitFor(() => { - expect(screen.getByTestId('errorMessage')).toBeVisible(); - }); - expect(mockNavigate).not.toHaveBeenCalled(); - }); + // it('shows an error if the submitHandler returns an error when creating a PPM', async () => { + // const mockSubmitHandler = jest.fn((payload, { onError }) => { + // // fire onError handler on form + // onError(); + // }); + + // renderWithRouter( + // , + // ); + + // await act(async () => { + // screen.getByLabelText('Planned Departure Date').focus(); + // await userEvent.paste('26 Mar 2022'); + + // const inputs = screen.getAllByRole('combobox'); + + // screen.getAllByLabelText('Address 1')[0].focus(); + // await userEvent.paste('Test Street 1'); + // inputs[0].focus(); + // await userEvent.type(inputs[0], '90210'); + // await userEvent.keyboard('{Enter}'); + + // screen.getAllByLabelText('Address 1')[1].focus(); + // await userEvent.paste('Test Street 3'); + // inputs[1].focus(); + // await userEvent.type(inputs[1], '90210'); + // await userEvent.keyboard('{Enter}'); + + // screen.getByLabelText('Estimated PPM weight').focus(); + // await userEvent.paste('1000'); + + // const saveButton = screen.getByRole('button', { name: 'Save and Continue' }); + // expect(saveButton).not.toBeDisabled(); + // await userEvent.click(saveButton); + // }); + + // await waitFor(() => { + // expect(mockSubmitHandler).toHaveBeenCalled(); + // }); + + // await waitFor(() => { + // expect(screen.getByTestId('errorMessage')).toBeVisible(); + // }); + // expect(mockNavigate).not.toHaveBeenCalled(); + // }); it('saves the update to the counselor remarks when the save button is clicked', async () => { const newCounselorRemarks = 'Counselor remarks'; diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index edd7af784f8..caa2a41a737 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -49,7 +49,6 @@ export const AddressFields = ({ maxLength={10} labelHint={labelHintProp} validate={validators?.postalCode} - isDisabled={zipCityEnabled} onChange={async (e) => { // If we are validating on change we need to also set the field to touched when it is changed. // Formik, by default, only sets the field to touched on blur. @@ -149,7 +148,6 @@ export const AddressFields = ({ labelHint={labelHintProp} data-testid={`${name}.city`} validate={validators?.city} - isDisabled={zipCityEnabled} /> {handleLocationChange && ( )}
diff --git a/src/components/form/AddressFields/AddressFields.test.jsx b/src/components/form/AddressFields/AddressFields.test.jsx index c950f0e3f27..b47bd963c17 100644 --- a/src/components/form/AddressFields/AddressFields.test.jsx +++ b/src/components/form/AddressFields/AddressFields.test.jsx @@ -140,7 +140,7 @@ describe('AddressFields component', () => { }; const mockStore = configureStore({}); - const { getByLabelText, getByTestId } = render( + const { getByLabelText } = render( @@ -152,39 +152,6 @@ describe('AddressFields component', () => { expect(getByLabelText('City')).toHaveValue(initialValues.address.city); expect(getByLabelText('State')).toHaveValue(initialValues.address.state); expect(getByLabelText('ZIP')).toHaveValue(initialValues.address.postalCode); - expect(getByTestId('locationInfo')).toBeInTheDocument(); - }); - it('renders zip city lookup with error', () => { - const initialValues = { - address: { - streetAddress1: '123 Main St', - streetAddress2: 'Apt 3A', - city: 'New York', - state: 'NY', - postalCode: '10002', - county: 'NEW YORK', - }, - }; - const mockStore = configureStore({}); - - const { getByLabelText, getByTestId } = render( - - - - - , - ); - expect(getByLabelText('Address 1')).toHaveValue(initialValues.address.streetAddress1); - expect(getByLabelText(/Address 2/)).toHaveValue(initialValues.address.streetAddress2); - expect(getByLabelText('City')).toHaveValue(initialValues.address.city); - expect(getByLabelText('State')).toHaveValue(initialValues.address.state); - expect(getByLabelText('ZIP')).toHaveValue(initialValues.address.postalCode); - expect(getByTestId('zipCityError')).toBeInTheDocument(); }); }); }); diff --git a/src/components/form/fields/LocationInput.test.jsx b/src/components/form/fields/LocationInput.test.jsx index 319bab266bc..d208a4f5d20 100644 --- a/src/components/form/fields/LocationInput.test.jsx +++ b/src/components/form/fields/LocationInput.test.jsx @@ -29,7 +29,7 @@ jest.mock('services/internalApi', () => ({ searchLocationByZipCityState: jest.fn(), })); -const handleZipCityChange = jest.fn(); +const handleLocationChange = jest.fn(); describe('ZipCityInput', () => { describe('with all required props', () => { @@ -39,7 +39,7 @@ describe('ZipCityInput', () => { placeholder="Start typing a Zip Code or City..." label="Zip/City Lookup" displayAddress={false} - handleLocationChange={handleZipCityChange} + handleLocationChange={handleLocationChange} />, ); diff --git a/src/pages/Office/ServicesCounselingAddShipment/ServicesCounselingAddShipment.test.jsx b/src/pages/Office/ServicesCounselingAddShipment/ServicesCounselingAddShipment.test.jsx index a70c3ecc29b..a5e5bc414d8 100644 --- a/src/pages/Office/ServicesCounselingAddShipment/ServicesCounselingAddShipment.test.jsx +++ b/src/pages/Office/ServicesCounselingAddShipment/ServicesCounselingAddShipment.test.jsx @@ -5,7 +5,7 @@ import userEvent from '@testing-library/user-event'; import ServicesCounselingAddShipment from './ServicesCounselingAddShipment'; -import { createMTOShipment } from 'services/ghcApi'; +import { createMTOShipment, searchLocationByZipCityState } from 'services/ghcApi'; import { useEditShipmentQueries } from 'hooks/queries'; import { MockProviders } from 'testUtils'; import { servicesCounselingRoutes } from 'constants/routes'; @@ -20,6 +20,7 @@ jest.mock('react-router-dom', () => ({ jest.mock('services/ghcApi', () => ({ ...jest.requireActual('services/ghcApi'), createMTOShipment: jest.fn(), + searchLocationByZipCityState: jest.fn(), })); jest.mock('hooks/queries', () => ({ @@ -165,6 +166,17 @@ beforeEach(() => { jest.resetAllMocks(); }); +const mockLocation = { + address: { + city: 'San Antonio', + county: 'Bexar', + postalCode: '78234', + state: 'TX', + }, +}; + +const mockSearchLocationByZipCityState = () => Promise.resolve([mockLocation]); + describe('ServicesCounselingAddShipment component', () => { describe('check different component states', () => { it('renders the Loading Placeholder when the query is still loading', async () => { @@ -199,7 +211,7 @@ describe('ServicesCounselingAddShipment component', () => { it('routes to the move details page when the save button is clicked', async () => { useEditShipmentQueries.mockReturnValue(useEditShipmentQueriesReturnValue); createMTOShipment.mockImplementation(() => Promise.resolve({})); - + searchLocationByZipCityState.mockImplementation(mockSearchLocationByZipCityState); renderWithMocks(); const saveButton = screen.getByRole('button', { name: 'Save' }); @@ -213,9 +225,12 @@ describe('ServicesCounselingAddShipment component', () => { expect(screen.getByLabelText('Use current address')).not.toBeChecked(); await userEvent.type(screen.getAllByLabelText('Address 1')[0], '812 S 129th St'); - await userEvent.type(screen.getAllByLabelText('City')[0], 'San Antonio'); - await userEvent.selectOptions(screen.getAllByLabelText('State')[0], ['TX']); - await userEvent.type(screen.getAllByLabelText('ZIP')[0], '78234'); + const inputs = screen.getAllByRole('combobox'); + await userEvent.type(inputs[0], '78234'); + await userEvent.keyboard('{Enter}'); + // await userEvent.type(screen.getAllByLabelText('City')[0], 'San Antonio'); + // await userEvent.selectOptions(screen.getAllByLabelText('State')[0], ['TX']); + // await userEvent.type(screen.getAllByLabelText('ZIP')[0], '78234'); await userEvent.type(screen.getByLabelText('Requested pickup date'), '01 Nov 2020'); await userEvent.type(screen.getByLabelText('Requested delivery date'), '08 Nov 2020'); From ac24c6df78d12880657e2ced356e1adfb14747f4 Mon Sep 17 00:00:00 2001 From: Steven Gleason <180579696+stevengleason-caci@users.noreply.github.com> Date: Fri, 1 Nov 2024 16:08:40 +0000 Subject: [PATCH 073/216] B-21458 PPM move_payment_reminder email destination, for Retirement and Separation, fetch and use the destination address not the duty station. --- pkg/notifications/move_payment_reminder.go | 76 +++++++++-- .../move_payment_reminder_test.go | 125 ++++++++++++++++++ 2 files changed, 191 insertions(+), 10 deletions(-) diff --git a/pkg/notifications/move_payment_reminder.go b/pkg/notifications/move_payment_reminder.go index 1c3f5d7712b..d2987043724 100644 --- a/pkg/notifications/move_payment_reminder.go +++ b/pkg/notifications/move_payment_reminder.go @@ -11,6 +11,7 @@ import ( "github.com/transcom/mymove/pkg/appcontext" "github.com/transcom/mymove/pkg/assets" + "github.com/transcom/mymove/pkg/gen/internalmessages" "github.com/transcom/mymove/pkg/models" "github.com/transcom/mymove/pkg/unit" ) @@ -46,14 +47,21 @@ type PaymentReminderEmailInfos []PaymentReminderEmailInfo // PaymentReminderEmailInfo contains payment reminder data for rendering a template type PaymentReminderEmailInfo struct { - ServiceMemberID uuid.UUID `db:"id"` - Email *string `db:"personal_email"` - NewDutyLocationName string `db:"new_duty_location_name"` - OriginDutyLocationName string `db:"origin_duty_location_name"` - MoveDate string `db:"move_date"` - Locator string `db:"locator"` - WeightEstimate *unit.Pound `db:"weight_estimate"` - IncentiveEstimate *unit.Cents `db:"incentive_estimate"` + ServiceMemberID uuid.UUID `db:"id"` + Email *string `db:"personal_email"` + NewDutyLocationName string `db:"new_duty_location_name"` + OriginDutyLocationName string `db:"origin_duty_location_name"` + MoveDate string `db:"move_date"` + Locator string `db:"locator"` + WeightEstimate *unit.Pound `db:"weight_estimate"` + IncentiveEstimate *unit.Cents `db:"incentive_estimate"` + DestinationStreet1 *string `db:"destination_street_address_1"` + DestinationStreet2 *string `db:"destination_street_address_2"` + DestinationStreet3 *string `db:"destination_street_address_3"` + DestinationCity *string `db:"destination_city"` + DestinationState *string `db:"destination_state"` + DestinationPostalCode *string `db:"destination_postal_code"` + OrdersType internalmessages.OrdersType `db:"orders_type"` } // GetEmailInfo fetches payment email information @@ -65,7 +73,14 @@ func (m PaymentReminder) GetEmailInfo(appCtx appcontext.AppContext) (PaymentRemi ps.expected_departure_date as move_date, dln.name AS new_duty_location_name, dln2.name AS origin_duty_location_name, - m.locator + m.locator, + da.street_address_1 AS destination_street_address_1, + da.street_address_2 AS destination_street_address_2, + da.street_address_3 AS destination_street_address_3, + da.city AS destination_city, + da.state AS destination_state, + da.postal_code AS destination_postal_code, + o.orders_type FROM ppm_shipments ps JOIN mto_shipments ms on ms.id = ps.shipment_id JOIN moves m ON ms.move_id = m.id @@ -73,6 +88,7 @@ FROM ppm_shipments ps JOIN service_members sm ON o.service_member_id = sm.id JOIN duty_locations dln ON o.new_duty_location_id = dln.id JOIN duty_locations dln2 ON o.origin_duty_location_id = dln2.id + JOIN addresses da ON ps.destination_postal_address_id = da.id WHERE ps.status = 'WAITING_ON_CUSTOMER'::public."ppm_shipment_status" AND ms.status = 'APPROVED'::public."mto_shipment_status" AND ps.expected_departure_date <= now() - ($1)::interval @@ -104,13 +120,14 @@ func (m PaymentReminder) emails(appCtx appcontext.AppContext) ([]emailContent, e return m.formatEmails(appCtx, paymentReminderEmailInfos) } +// TODO: rename to DestinationLocation // formatEmails formats email data using both html and text template func (m PaymentReminder) formatEmails(appCtx appcontext.AppContext, PaymentReminderEmailInfos PaymentReminderEmailInfos) ([]emailContent, error) { var emails []emailContent for _, PaymentReminderEmailInfo := range PaymentReminderEmailInfos { htmlBody, textBody, err := m.renderTemplates(appCtx, PaymentReminderEmailData{ OriginDutyLocation: PaymentReminderEmailInfo.OriginDutyLocationName, - DestinationDutyLocation: PaymentReminderEmailInfo.NewDutyLocationName, + DestinationDutyLocation: getDestinationLocation(appCtx, PaymentReminderEmailInfo), Locator: PaymentReminderEmailInfo.Locator, OneSourceLink: OneSourceTransportationOfficeLink, MyMoveLink: MyMoveLink, @@ -152,6 +169,45 @@ func (m PaymentReminder) renderTemplates(appCtx appcontext.AppContext, data Paym return htmlBody, textBody, nil } +func getDestinationLocation(appCtx appcontext.AppContext, PaymentReminderEmailInfo PaymentReminderEmailInfo) string { + destinationLocation := PaymentReminderEmailInfo.NewDutyLocationName + ordersType := PaymentReminderEmailInfo.OrdersType + street1 := PaymentReminderEmailInfo.DestinationStreet1 + if street1 != nil { + appCtx.Logger().Error("Street1 is: " + *street1) + } else { + appCtx.Logger().Error("Street1 is nil") + } + isSeparateeOrRetireeOrder := ordersType == internalmessages.OrdersTypeRETIREMENT || ordersType == internalmessages.OrdersTypeSEPARATION + if isSeparateeOrRetireeOrder { + appCtx.Logger().Debug("isSeparateeOrRetireeOrder: true") + } else { + appCtx.Logger().Debug("isSeparateeOrRetireeOrder: false") + } + if isSeparateeOrRetireeOrder && street1 != nil { + appCtx.Logger().Debug("In address section") + street2, street3, city, state, postalCode := "", "", "", "", "" + if PaymentReminderEmailInfo.DestinationStreet2 != nil { + street2 = " " + *PaymentReminderEmailInfo.DestinationStreet2 + } + if PaymentReminderEmailInfo.DestinationStreet3 != nil { + street3 = " " + *PaymentReminderEmailInfo.DestinationStreet3 + } + if PaymentReminderEmailInfo.DestinationCity != nil { + city = ", " + *PaymentReminderEmailInfo.DestinationCity + } + if PaymentReminderEmailInfo.DestinationState != nil { + state = ", " + *PaymentReminderEmailInfo.DestinationState + } + if PaymentReminderEmailInfo.DestinationPostalCode != nil { + postalCode = " " + *PaymentReminderEmailInfo.DestinationPostalCode + } + destinationLocation = fmt.Sprintf("%s%s%s%s%s%s", *street1, street2, street3, city, state, postalCode) + appCtx.Logger().Debug("New location: " + destinationLocation) + } + return destinationLocation +} + // OnSuccess callback passed to be invoked by NewNotificationSender when an email successfully sent // saves the svs the email info along with the SES mail id to the notifications table func (m PaymentReminder) OnSuccess(appCtx appcontext.AppContext, PaymentReminderEmailInfo PaymentReminderEmailInfo) func(string) error { diff --git a/pkg/notifications/move_payment_reminder_test.go b/pkg/notifications/move_payment_reminder_test.go index 2da424994f3..f76107d8b21 100644 --- a/pkg/notifications/move_payment_reminder_test.go +++ b/pkg/notifications/move_payment_reminder_test.go @@ -4,6 +4,7 @@ import ( "time" "github.com/transcom/mymove/pkg/factory" + "github.com/transcom/mymove/pkg/gen/internalmessages" "github.com/transcom/mymove/pkg/models" ) @@ -304,3 +305,127 @@ func (suite *NotificationSuite) TestFormatPaymentRequestedEmails() { // only expect the three moves with non-nil email addresses to get added to formattedEmails suite.Len(formattedEmails, 3) } + +func (suite *NotificationSuite) TestFormatPaymentRequestedEmailsForRetireeSeparation() { + pr, err := NewPaymentReminder() + suite.NoError(err) + + email1 := "email1" + streetOne1 := "100 Street Rd" + streetTwo1 := "STE 1" + streetThree1 := "Floor 1" + city1 := "Alpha City" + state1 := "Alabama" + postalCode1 := "11111" + expectedDestination1 := "100 Street Rd STE 1 Floor 1, Alpha City, Alabama 11111" + + email2 := "email2" + expectedDestination2 := "nd2" // no street address, fall back to duty station + + email3 := "email3" + streetOne3 := "300 Highway Ln" + city3 := "Charlie City" + state3 := "California" + postalCode3 := "33333" + expectedDestination3 := "300 Highway Ln, Charlie City, California 33333" + + email4 := "email4" + streetOne4 := "400 Unused Blvd" + city4 := "Delta City" + state4 := "Delaware" + postalCode4 := "44444" + expectedDestination4 := "nd4" // Permanent Change of Station, ignore street address + + email5 := "email5" + streetOne5 := "500 Parkway Dr" + expectedDestination5 := "500 Parkway Dr" // Tolerate other nil address fields + + expectedDestinations := []string{ + expectedDestination1, + expectedDestination2, + expectedDestination3, + expectedDestination4, + expectedDestination5, + } + + emailInfos := PaymentReminderEmailInfos{ + { + Email: &email1, + NewDutyLocationName: "nd1", + Locator: "abc123", + OrdersType: internalmessages.OrdersTypeRETIREMENT, + DestinationStreet1: &streetOne1, + DestinationStreet2: &streetTwo1, + DestinationStreet3: &streetThree1, + DestinationCity: &city1, + DestinationState: &state1, + DestinationPostalCode: &postalCode1, + }, + { + Email: &email2, + NewDutyLocationName: "nd2", + Locator: "abc456", + OrdersType: internalmessages.OrdersTypeRETIREMENT, + }, + { + Email: &email3, + NewDutyLocationName: "nd3", + Locator: "def123", + OrdersType: internalmessages.OrdersTypeSEPARATION, + DestinationStreet1: &streetOne3, + DestinationCity: &city3, + DestinationState: &state3, + DestinationPostalCode: &postalCode3, + }, + { + Email: &email4, + NewDutyLocationName: "nd4", + Locator: "def456", + OrdersType: internalmessages.OrdersTypePERMANENTCHANGEOFSTATION, + DestinationStreet1: &streetOne4, + DestinationCity: &city4, + DestinationState: &state4, + DestinationPostalCode: &postalCode4, + }, + { + Email: &email5, + NewDutyLocationName: "nd5", + Locator: "ghi123", + OrdersType: internalmessages.OrdersTypeRETIREMENT, + DestinationStreet1: &streetOne5, + DestinationCity: nil, + DestinationState: nil, + DestinationPostalCode: nil, + }, + } + formattedEmails, err := pr.formatEmails(suite.AppContextForTest(), emailInfos) + suite.NoError(err) + + for i, actualEmailContent := range formattedEmails { + emailInfo := emailInfos[i] + expectedDestination := expectedDestinations[i] + + data := PaymentReminderEmailData{ + DestinationDutyLocation: expectedDestination, + Locator: emailInfo.Locator, + OneSourceLink: OneSourceTransportationOfficeLink, + MyMoveLink: MyMoveLink, + } + htmlBody, err := pr.RenderHTML(suite.AppContextForTest(), data) + suite.NoError(err) + textBody, err := pr.RenderText(suite.AppContextForTest(), data) + suite.NoError(err) + expectedEmailContent := emailContent{ + recipientEmail: *emailInfo.Email, + subject: "Complete your Personally Procured Move (PPM)", + htmlBody: htmlBody, + textBody: textBody, + } + if emailInfo.Email != nil { + suite.Equal(expectedEmailContent.recipientEmail, actualEmailContent.recipientEmail) + suite.Equal(expectedEmailContent.subject, actualEmailContent.subject) + suite.Equal(expectedEmailContent.textBody, actualEmailContent.textBody) + } + } + suite.Len(formattedEmails, 5) +} From 6fa9a69151fc1a156a6698938e96af17a37818aa Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 1 Nov 2024 16:19:11 +0000 Subject: [PATCH 074/216] test updates, fix read only city county --- .../form/AddressFields/AddressFields.jsx | 2 ++ .../ServicesCounselingAddShipment.test.jsx | 15 ++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index caa2a41a737..5f0018eaed4 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -148,6 +148,7 @@ export const AddressFields = ({ labelHint={labelHintProp} data-testid={`${name}.city`} validate={validators?.city} + isDisabled={zipCityEnabled} /> {handleLocationChange && ( )}
diff --git a/src/pages/Office/ServicesCounselingAddShipment/ServicesCounselingAddShipment.test.jsx b/src/pages/Office/ServicesCounselingAddShipment/ServicesCounselingAddShipment.test.jsx index a5e5bc414d8..78bdb8ad7f8 100644 --- a/src/pages/Office/ServicesCounselingAddShipment/ServicesCounselingAddShipment.test.jsx +++ b/src/pages/Office/ServicesCounselingAddShipment/ServicesCounselingAddShipment.test.jsx @@ -1,6 +1,6 @@ /* eslint-disable react/jsx-props-no-spreading */ import React from 'react'; -import { render, screen, waitFor } from '@testing-library/react'; +import { render, screen, waitFor, act } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import ServicesCounselingAddShipment from './ServicesCounselingAddShipment'; @@ -172,6 +172,7 @@ const mockLocation = { county: 'Bexar', postalCode: '78234', state: 'TX', + usprcId: '', }, }; @@ -214,6 +215,7 @@ describe('ServicesCounselingAddShipment component', () => { searchLocationByZipCityState.mockImplementation(mockSearchLocationByZipCityState); renderWithMocks(); + const user = userEvent.setup(); const saveButton = screen.getByRole('button', { name: 'Save' }); expect(saveButton).toBeInTheDocument(); @@ -222,15 +224,10 @@ describe('ServicesCounselingAddShipment component', () => { expect(saveButton).toBeDisabled(); }); - expect(screen.getByLabelText('Use current address')).not.toBeChecked(); + await act(async () => { + await user.click(screen.getByLabelText('Use current address')); + }); - await userEvent.type(screen.getAllByLabelText('Address 1')[0], '812 S 129th St'); - const inputs = screen.getAllByRole('combobox'); - await userEvent.type(inputs[0], '78234'); - await userEvent.keyboard('{Enter}'); - // await userEvent.type(screen.getAllByLabelText('City')[0], 'San Antonio'); - // await userEvent.selectOptions(screen.getAllByLabelText('State')[0], ['TX']); - // await userEvent.type(screen.getAllByLabelText('ZIP')[0], '78234'); await userEvent.type(screen.getByLabelText('Requested pickup date'), '01 Nov 2020'); await userEvent.type(screen.getByLabelText('Requested delivery date'), '08 Nov 2020'); From 1bfda3303d5795395c54fd425a83e844a28c3eaa Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 1 Nov 2024 16:40:32 +0000 Subject: [PATCH 075/216] more test fixes --- .../Office/ShipmentForm/ShipmentForm.test.jsx | 93 +++++++++---------- .../Office/AddShipment/AddShipment.test.jsx | 12 +-- .../ServicesCounselingAddShipment.test.jsx | 16 +--- 3 files changed, 49 insertions(+), 72 deletions(-) diff --git a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx index 28f9633dc78..213d376698b 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx @@ -1059,57 +1059,48 @@ describe('ShipmentForm component', () => { expect(mockNavigate).not.toHaveBeenCalled(); }); - // it('shows an error if the submitHandler returns an error when creating a PPM', async () => { - // const mockSubmitHandler = jest.fn((payload, { onError }) => { - // // fire onError handler on form - // onError(); - // }); - - // renderWithRouter( - // , - // ); - - // await act(async () => { - // screen.getByLabelText('Planned Departure Date').focus(); - // await userEvent.paste('26 Mar 2022'); - - // const inputs = screen.getAllByRole('combobox'); - - // screen.getAllByLabelText('Address 1')[0].focus(); - // await userEvent.paste('Test Street 1'); - // inputs[0].focus(); - // await userEvent.type(inputs[0], '90210'); - // await userEvent.keyboard('{Enter}'); - - // screen.getAllByLabelText('Address 1')[1].focus(); - // await userEvent.paste('Test Street 3'); - // inputs[1].focus(); - // await userEvent.type(inputs[1], '90210'); - // await userEvent.keyboard('{Enter}'); - - // screen.getByLabelText('Estimated PPM weight').focus(); - // await userEvent.paste('1000'); - - // const saveButton = screen.getByRole('button', { name: 'Save and Continue' }); - // expect(saveButton).not.toBeDisabled(); - // await userEvent.click(saveButton); - // }); - - // await waitFor(() => { - // expect(mockSubmitHandler).toHaveBeenCalled(); - // }); - - // await waitFor(() => { - // expect(screen.getByTestId('errorMessage')).toBeVisible(); - // }); - // expect(mockNavigate).not.toHaveBeenCalled(); - // }); + it('shows an error if the submitHandler returns an error when creating a PPM', async () => { + const mockSubmitHandler = jest.fn((payload, { onError }) => { + // fire onError handler on form + onError(); + }); + + renderWithRouter( + , + ); + + await act(async () => { + screen.getByLabelText('Planned Departure Date').focus(); + await userEvent.paste('26 Mar 2022'); + const user = userEvent.setup(); + + await act(async () => { + await user.click(screen.getByLabelText('Use Current Address')); + }); + + screen.getByLabelText('Estimated PPM weight').focus(); + await userEvent.paste('1000'); + + const saveButton = screen.getByRole('button', { name: 'Save and Continue' }); + expect(saveButton).not.toBeDisabled(); + await userEvent.click(saveButton); + }); + + await waitFor(() => { + expect(mockSubmitHandler).toHaveBeenCalled(); + }); + + await waitFor(() => { + expect(screen.getByTestId('errorMessage')).toBeVisible(); + }); + expect(mockNavigate).not.toHaveBeenCalled(); + }); it('saves the update to the counselor remarks when the save button is clicked', async () => { const newCounselorRemarks = 'Counselor remarks'; diff --git a/src/pages/Office/AddShipment/AddShipment.test.jsx b/src/pages/Office/AddShipment/AddShipment.test.jsx index 162bc165a02..6d0949f0876 100644 --- a/src/pages/Office/AddShipment/AddShipment.test.jsx +++ b/src/pages/Office/AddShipment/AddShipment.test.jsx @@ -1,6 +1,6 @@ /* eslint-disable react/jsx-props-no-spreading */ import React from 'react'; -import { render, screen, waitFor } from '@testing-library/react'; +import { render, screen, waitFor, act } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import AddShipment from './AddShipment'; @@ -207,12 +207,12 @@ describe('AddShipment component', () => { expect(saveButton).toBeDisabled(); }); - expect(screen.getByLabelText('Use current address')).not.toBeChecked(); + const user = userEvent.setup(); + + await act(async () => { + await user.click(screen.getByLabelText('Use current address')); + }); - await userEvent.type(screen.getAllByLabelText('Address 1')[0], '812 S 129th St'); - await userEvent.type(screen.getAllByLabelText('City')[0], 'San Antonio'); - await userEvent.selectOptions(screen.getAllByLabelText('State')[0], ['TX']); - await userEvent.type(screen.getAllByLabelText('ZIP')[0], '78234'); await userEvent.type(screen.getByLabelText('Requested pickup date'), '01 Nov 2020'); await userEvent.type(screen.getByLabelText('Requested delivery date'), '08 Nov 2020'); diff --git a/src/pages/Office/ServicesCounselingAddShipment/ServicesCounselingAddShipment.test.jsx b/src/pages/Office/ServicesCounselingAddShipment/ServicesCounselingAddShipment.test.jsx index 78bdb8ad7f8..f6362df66e6 100644 --- a/src/pages/Office/ServicesCounselingAddShipment/ServicesCounselingAddShipment.test.jsx +++ b/src/pages/Office/ServicesCounselingAddShipment/ServicesCounselingAddShipment.test.jsx @@ -5,7 +5,7 @@ import userEvent from '@testing-library/user-event'; import ServicesCounselingAddShipment from './ServicesCounselingAddShipment'; -import { createMTOShipment, searchLocationByZipCityState } from 'services/ghcApi'; +import createMTOShipment from 'services/ghcApi'; import { useEditShipmentQueries } from 'hooks/queries'; import { MockProviders } from 'testUtils'; import { servicesCounselingRoutes } from 'constants/routes'; @@ -20,7 +20,6 @@ jest.mock('react-router-dom', () => ({ jest.mock('services/ghcApi', () => ({ ...jest.requireActual('services/ghcApi'), createMTOShipment: jest.fn(), - searchLocationByZipCityState: jest.fn(), })); jest.mock('hooks/queries', () => ({ @@ -166,18 +165,6 @@ beforeEach(() => { jest.resetAllMocks(); }); -const mockLocation = { - address: { - city: 'San Antonio', - county: 'Bexar', - postalCode: '78234', - state: 'TX', - usprcId: '', - }, -}; - -const mockSearchLocationByZipCityState = () => Promise.resolve([mockLocation]); - describe('ServicesCounselingAddShipment component', () => { describe('check different component states', () => { it('renders the Loading Placeholder when the query is still loading', async () => { @@ -212,7 +199,6 @@ describe('ServicesCounselingAddShipment component', () => { it('routes to the move details page when the save button is clicked', async () => { useEditShipmentQueries.mockReturnValue(useEditShipmentQueriesReturnValue); createMTOShipment.mockImplementation(() => Promise.resolve({})); - searchLocationByZipCityState.mockImplementation(mockSearchLocationByZipCityState); renderWithMocks(); const user = userEvent.setup(); From eceb8289b2c8ca7389fcb17106acd357f12a992c Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 1 Nov 2024 18:17:23 +0000 Subject: [PATCH 076/216] fixing shipmentForm tests --- .../Office/ShipmentForm/ShipmentForm.test.jsx | 13 +------------ .../ServicesCounselingAddShipment.test.jsx | 2 +- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx index 213d376698b..47496c4db29 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.test.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.test.jsx @@ -1071,22 +1071,11 @@ describe('ShipmentForm component', () => { shipmentType={SHIPMENT_OPTIONS.PPM} mtoShipment={mockPPMShipment} submitHandler={mockSubmitHandler} - isCreatePage + isCreatePage={false} />, ); await act(async () => { - screen.getByLabelText('Planned Departure Date').focus(); - await userEvent.paste('26 Mar 2022'); - const user = userEvent.setup(); - - await act(async () => { - await user.click(screen.getByLabelText('Use Current Address')); - }); - - screen.getByLabelText('Estimated PPM weight').focus(); - await userEvent.paste('1000'); - const saveButton = screen.getByRole('button', { name: 'Save and Continue' }); expect(saveButton).not.toBeDisabled(); await userEvent.click(saveButton); diff --git a/src/pages/Office/ServicesCounselingAddShipment/ServicesCounselingAddShipment.test.jsx b/src/pages/Office/ServicesCounselingAddShipment/ServicesCounselingAddShipment.test.jsx index f6362df66e6..554dc92fa20 100644 --- a/src/pages/Office/ServicesCounselingAddShipment/ServicesCounselingAddShipment.test.jsx +++ b/src/pages/Office/ServicesCounselingAddShipment/ServicesCounselingAddShipment.test.jsx @@ -5,7 +5,7 @@ import userEvent from '@testing-library/user-event'; import ServicesCounselingAddShipment from './ServicesCounselingAddShipment'; -import createMTOShipment from 'services/ghcApi'; +import { createMTOShipment } from 'services/ghcApi'; import { useEditShipmentQueries } from 'hooks/queries'; import { MockProviders } from 'testUtils'; import { servicesCounselingRoutes } from 'constants/routes'; From 2c9ee9110c49493ad1a75058b55c09c45b69b1de Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 1 Nov 2024 22:39:32 +0000 Subject: [PATCH 077/216] adding usprcId set and fixing backup address --- .../Customer/BackupAddressForm/BackupAddressForm.jsx | 5 +++-- .../Customer/EditContactInfoForm/EditContactInfoForm.jsx | 2 ++ .../CustomerContactInfoForm/CustomerContactInfoForm.jsx | 1 + .../EditFacilityInfoModal/EditFacilityInfoModal.jsx | 1 + src/components/Office/ShipmentForm/ShipmentForm.jsx | 9 +++++++++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx b/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx index a4bb1f1f06b..4dc1b17af17 100644 --- a/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx +++ b/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx @@ -29,12 +29,13 @@ const BackupAddressForm = ({ formFieldsName, initialValues, onSubmit, onBack }) setValues( { ...values, - formFieldsName: { - ...values.formFieldsName, + backup_mailing_address: { + ...values.backup_mailing_address, city: value.city, state: value.state ? value.state : '', county: value.county, postalCode: value.postalCode, + usprcId: value.usPostRegionCitiesId ? value.usPostRegionCitiesId : '', }, }, { shouldValidate: true }, diff --git a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx index 8b4985d1878..ddf390c8e5a 100644 --- a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx +++ b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx @@ -51,6 +51,7 @@ const EditContactInfoForm = ({ initialValues, onSubmit, onCancel }) => { state: value.state ? value.state : '', county: value.county ? value.county : '', postalCode: value.postalCode ? value.postalCode : '', + usprcId: value.usPostRegionCitiesId ? value.usPostRegionCitiesId : '', }, }, { shouldValidate: true }, @@ -66,6 +67,7 @@ const EditContactInfoForm = ({ initialValues, onSubmit, onCancel }) => { state: value.state ? value.state : '', county: value.county ? value.county : '', postalCode: value.postalCode ? value.postalCode : '', + usprcId: value.usPostRegionCitiesId ? value.usPostRegionCitiesId : '', }, }, { shouldValidate: true }, diff --git a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx index 130a1b2718f..5eda3715f57 100644 --- a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx +++ b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx @@ -73,6 +73,7 @@ const CustomerContactInfoForm = ({ initialValues, onSubmit, onBack }) => { state: value.state ? value.state : '', county: value.county ? value.county : '', postalCode: value.postalCode ? value.postalCode : '', + usprcId: value.usPostRegionCitiesId ? value.usPostRegionCitiesId : '', }, }, { shouldValidate: true }, diff --git a/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx b/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx index 724cec2e7fd..6044021f105 100644 --- a/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx +++ b/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx @@ -59,6 +59,7 @@ export const EditFacilityInfoModal = ({ state: value.state ? value.state : '', county: value.county, postalCode: value.postalCode, + usprcId: value.usPostRegionCitiesId ? value.usPostRegionCitiesId : '', }, }, { shouldValidate: true }, diff --git a/src/components/Office/ShipmentForm/ShipmentForm.jsx b/src/components/Office/ShipmentForm/ShipmentForm.jsx index f54bfbb2286..facf1a77497 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.jsx @@ -747,6 +747,7 @@ const ShipmentForm = (props) => { state: value.state ? value.state : '', county: value.county ? value.county : '', postalCode: value.postalCode ? value.postalCode : '', + usprcId: value.usPostRegionCitiesId ? value.usPostRegionCitiesId : '', }, }, }, @@ -766,6 +767,7 @@ const ShipmentForm = (props) => { state: value.state ? value.state : '', county: value.county ? value.county : '', postalCode: value.postalCode ? value.postalCode : '', + usprcId: value.usPostRegionCitiesId ? value.usPostRegionCitiesId : '', }, }, }, @@ -785,6 +787,7 @@ const ShipmentForm = (props) => { state: value.state ? value.state : '', county: value.county ? value.county : '', postalCode: value.postalCode ? value.postalCode : '', + usprcId: value.usPostRegionCitiesId ? value.usPostRegionCitiesId : '', }, }, }, @@ -804,6 +807,7 @@ const ShipmentForm = (props) => { state: value.state ? value.state : '', county: value.county ? value.county : '', postalCode: value.postalCode ? value.postalCode : '', + usprcId: value.usPostRegionCitiesId ? value.usPostRegionCitiesId : '', }, }, }, @@ -823,6 +827,7 @@ const ShipmentForm = (props) => { state: value.state ? value.state : '', county: value.county ? value.county : '', postalCode: value.postalCode ? value.postalCode : '', + usprcId: value.usPostRegionCitiesId ? value.usPostRegionCitiesId : '', }, }, }, @@ -842,6 +847,7 @@ const ShipmentForm = (props) => { state: value.state ? value.state : '', county: value.county ? value.county : '', postalCode: value.postalCode ? value.postalCode : '', + usprcId: value.usPostRegionCitiesId ? value.usPostRegionCitiesId : '', }, }, }, @@ -861,6 +867,7 @@ const ShipmentForm = (props) => { state: value.state ? value.state : '', county: value.county ? value.county : '', postalCode: value.postalCode ? value.postalCode : '', + usprcId: value.usPostRegionCitiesId ? value.usPostRegionCitiesId : '', }, }, }, @@ -880,6 +887,7 @@ const ShipmentForm = (props) => { state: value.state ? value.state : '', county: value.county ? value.county : '', postalCode: value.postalCode ? value.postalCode : '', + usprcId: value.usPostRegionCitiesId ? value.usPostRegionCitiesId : '', }, }, }, @@ -899,6 +907,7 @@ const ShipmentForm = (props) => { state: value.state ? value.state : '', county: value.county ? value.county : '', postalCode: value.postalCode ? value.postalCode : '', + usprcId: value.usPostRegionCitiesId ? value.usPostRegionCitiesId : '', }, }, }, From 50e87bc5a487d2ddc4e2cbe5d2e41b40b75fe191 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Sat, 2 Nov 2024 00:15:17 +0000 Subject: [PATCH 078/216] fix playwright tests --- .../my/milmove/ppms/customerPpmTestFixture.js | 20 ++++++++-------- .../tests/office/ppms/addShipment.spec.js | 4 ++-- .../tests/office/ppms/ppmTestFixture.js | 18 ++++++++------- .../servicesCounselingFlows.spec.js | 23 ++++++++----------- .../servicesCounselingTestFixture.js | 19 ++++++++------- playwright/tests/office/txo/tooFlows.spec.js | 18 +++++++-------- .../tests/office/txo/tooFlowsNTS.spec.js | 9 ++++---- .../tests/office/txo/tooFlowsNTSR.spec.js | 18 +++++++-------- 8 files changed, 63 insertions(+), 66 deletions(-) diff --git a/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js b/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js index f905c25c654..5db86e7420d 100644 --- a/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js +++ b/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js @@ -408,18 +408,18 @@ export class CustomerPpmPage extends CustomerPage { * returns {Promise} */ async navigateFromDateAndLocationPageToEstimatedWeightsPage() { + const PickupLocationLookup = 'BEVERLY HILLS, CA 90210 (LOS ANGELES)'; + const DestinationLocationLookup = 'FORT WORTH, TX 76127 (TARRANT)'; + await this.page.locator('input[name="pickupAddress.address.streetAddress1"]').fill('123 Street'); - await this.page.locator('input[name="pickupAddress.address.city"]').fill('SomeCity - Secondary'); - await this.page.locator('select[name="pickupAddress.address.state"]').selectOption({ label: 'CA' }); - await this.page.locator('input[name="pickupAddress.address.postalCode"]').clear(); - await this.page.locator('input[name="pickupAddress.address.postalCode"]').fill('90210'); - await this.page.locator('input[name="pickupAddress.address.postalCode"]').blur(); - - await this.page.locator('input[name="destinationAddress.address.postalCode"]').clear(); - await this.page.locator('input[name="destinationAddress.address.postalCode"]').fill('76127'); + await this.page.getByLabel('Location Lookup').nth(0).fill('90210'); + await expect(this.page.getByText(PickupLocationLookup, { exact: true })).toBeVisible(); + await this.page.keyboard.press('Enter'); + await this.page.locator('input[name="destinationAddress.address.streetAddress1"]').fill('123 Street'); - await this.page.locator('input[name="destinationAddress.address.city"]').fill('SomeCity'); - await this.page.locator('select[name="destinationAddress.address.state"]').selectOption({ label: 'TX' }); + await this.page.getByLabel('Location Lookup').nth(1).fill('76127'); + await expect(this.page.getByText(DestinationLocationLookup, { exact: true })).toBeVisible(); + await this.page.keyboard.press('Enter'); await this.page.locator('input[name="expectedDepartureDate"]').clear(); await this.page.locator('input[name="expectedDepartureDate"]').fill('01 Feb 2022'); diff --git a/playwright/tests/office/ppms/addShipment.spec.js b/playwright/tests/office/ppms/addShipment.spec.js index b7c234d6c1b..14402343871 100644 --- a/playwright/tests/office/ppms/addShipment.spec.js +++ b/playwright/tests/office/ppms/addShipment.spec.js @@ -51,12 +51,12 @@ test.describe('Services counselor user', () => { await expect(shipmentContainer.locator('[data-testid="expectedDepartureDate"]')).toContainText('09 Jun 2022'); await expect(shipmentContainer.locator('[data-testid="pickupAddress"]')).toContainText('123 Street'); - await expect(shipmentContainer.locator('[data-testid="pickupAddress"]')).toContainText('SomeCity - Secondary'); + await expect(shipmentContainer.locator('[data-testid="pickupAddress"]')).toContainText('BEVERLY HILLS'); await expect(shipmentContainer.locator('[data-testid="pickupAddress"]')).toContainText('CA'); await expect(shipmentContainer.locator('[data-testid="pickupAddress"]')).toContainText('90210'); await expect(shipmentContainer.locator('[data-testid="destinationAddress"]')).toContainText('123 Street'); - await expect(shipmentContainer.locator('[data-testid="destinationAddress"]')).toContainText('SomeCity'); + await expect(shipmentContainer.locator('[data-testid="destinationAddress"]')).toContainText('FORT WORTH'); await expect(shipmentContainer.locator('[data-testid="destinationAddress"]')).toContainText('TX'); await expect(shipmentContainer.locator('[data-testid="destinationAddress"]')).toContainText('76127'); diff --git a/playwright/tests/office/ppms/ppmTestFixture.js b/playwright/tests/office/ppms/ppmTestFixture.js index 8d8f856a3d9..70848428cf5 100644 --- a/playwright/tests/office/ppms/ppmTestFixture.js +++ b/playwright/tests/office/ppms/ppmTestFixture.js @@ -84,13 +84,14 @@ export class PpmPage extends ServiceCounselorPage { * @returns Promise */ async fillOutOriginInfo() { + const LocationLookup = 'BEVERLY HILLS, CA 90210 (LOS ANGELES)'; + await this.page.locator('input[name="expectedDepartureDate"]').fill('09 Jun 2022'); await this.page.locator('input[name="pickup.address.streetAddress1"]').fill('123 Street'); - await this.page.locator('input[name="pickup.address.city"]').fill('SomeCity - Secondary'); - await this.page.locator('select[name="pickup.address.state"]').selectOption({ label: 'CA' }); - await this.page.locator('input[name="pickup.address.postalCode"]').fill('90210'); - await this.page.locator('input[name="pickup.address.county"]').fill('LOS ANGELES'); + await this.page.getByLabel('Location Lookup').nth(0).fill('90210'); + await expect(this.page.getByText(LocationLookup, { exact: true })).toBeVisible(); + await this.page.keyboard.press('Enter'); } /** @@ -101,11 +102,12 @@ export class PpmPage extends ServiceCounselorPage { * @returns Promise */ async fillOutDestinationInfo() { - await this.page.locator('input[name="destination.address.postalCode"]').fill('76127'); + const LocationLookup = 'FORT WORTH, TX 76127 (TARRANT)'; + await this.page.locator('input[name="destination.address.streetAddress1"]').fill('123 Street'); - await this.page.locator('input[name="destination.address.city"]').fill('SomeCity'); - await this.page.locator('select[name="destination.address.state"]').selectOption({ label: 'TX' }); - await this.page.locator('input[name="destination.address.county"]').fill('TARRANT'); + await this.page.getByLabel('Location Lookup').nth(1).fill('76127'); + await expect(this.page.getByText(LocationLookup, { exact: true })).toBeVisible(); + await this.page.keyboard.press('Enter'); } /** diff --git a/playwright/tests/office/servicescounseling/servicesCounselingFlows.spec.js b/playwright/tests/office/servicescounseling/servicesCounselingFlows.spec.js index 9609328e739..f35b91e01d3 100644 --- a/playwright/tests/office/servicescounseling/servicesCounselingFlows.spec.js +++ b/playwright/tests/office/servicescounseling/servicesCounselingFlows.spec.js @@ -10,6 +10,7 @@ import { DEPARTMENT_INDICATOR_OPTIONS } from '../../utils/office/officeTest'; import { test, expect } from './servicesCounselingTestFixture'; const supportingDocsEnabled = process.env.FEATURE_FLAG_MANAGE_SUPPORTING_DOCS; +const LocationLookup = 'BEVERLY HILLS, CA 90210 (LOS ANGELES)'; test.describe('Services counselor user', () => { test.describe('with basic HHG move', () => { @@ -83,11 +84,9 @@ test.describe('Services counselor user', () => { await page.getByRole('group', { name: 'Delivery location' }).getByText('Yes').nth(1).click(); await page.locator('input[name="delivery.address.streetAddress1"]').clear(); await page.locator('input[name="delivery.address.streetAddress1"]').fill('7 q st'); - await page.locator('input[name="delivery.address.city"]').clear(); - await page.locator('input[name="delivery.address.city"]').fill('city'); - await page.locator('select[name="delivery.address.state"]').selectOption({ label: 'OH' }); - await page.locator('input[name="delivery.address.postalCode"]').clear(); - await page.locator('input[name="delivery.address.postalCode"]').fill('90210'); + await page.getByLabel('Location Lookup').nth(1).fill('90210'); + await expect(page.getByText(LocationLookup, { exact: true })).toBeVisible(); + await page.keyboard.press('Enter'); // Select that we do not know the destination address yet await page.getByRole('group', { name: 'Delivery location' }).getByText('No').nth(1).click(); @@ -247,9 +246,9 @@ test.describe('Services counselor user', () => { await page.locator('#requestedDeliveryDate').blur(); await page.getByRole('group', { name: 'Delivery location' }).getByText('Yes').click(); await page.locator('input[name="delivery.address.streetAddress1"]').fill('7 q st'); - await page.locator('input[name="delivery.address.city"]').fill('city'); - await page.locator('select[name="delivery.address.state"]').selectOption({ label: 'OH' }); - await page.locator('input[name="delivery.address.postalCode"]').fill('90210'); + await page.getByLabel('Location Lookup').nth(1).fill('90210'); + await expect(page.getByText(LocationLookup, { exact: true })).toBeVisible(); + await page.keyboard.press('Enter'); await page.locator('select[name="destinationType"]').selectOption({ label: 'Home of record (HOR)' }); await page.locator('[data-testid="submitForm"]').click(); await scPage.waitForLoading(); @@ -348,11 +347,9 @@ test.describe('Services counselor user', () => { await page.getByRole('group', { name: 'Delivery location' }).getByText('Yes').nth(1).click(); await page.locator('input[name="delivery.address.streetAddress1"]').clear(); await page.locator('input[name="delivery.address.streetAddress1"]').fill('7 q st'); - await page.locator('input[name="delivery.address.city"]').clear(); - await page.locator('input[name="delivery.address.city"]').fill('city'); - await page.locator('select[name="delivery.address.state"]').selectOption({ label: 'OH' }); - await page.locator('input[name="delivery.address.postalCode"]').clear(); - await page.locator('input[name="delivery.address.postalCode"]').fill('90210'); + await page.getByLabel('Location Lookup').nth(1).fill('90210'); + await expect(page.getByText(LocationLookup, { exact: true })).toBeVisible(); + await page.keyboard.press('Enter'); await page.locator('select[name="destinationType"]').selectOption({ label: 'Home of selection (HOS)' }); await page.locator('[data-testid="submitForm"]').click(); await scPage.waitForLoading(); diff --git a/playwright/tests/office/servicescounseling/servicesCounselingTestFixture.js b/playwright/tests/office/servicescounseling/servicesCounselingTestFixture.js index 08bc3343bc2..2137ff9fa8b 100644 --- a/playwright/tests/office/servicescounseling/servicesCounselingTestFixture.js +++ b/playwright/tests/office/servicescounseling/servicesCounselingTestFixture.js @@ -157,26 +157,29 @@ export class ServiceCounselorPage extends OfficePage { await storageInfo.getByLabel('Service order number').fill('999999'); // Storage facility address + const StorageLocationLookup = 'ATLANTA, GA 30301 (FULTON)'; + const storageAddress = await this.page.getByRole('heading', { name: 'Storage facility address' }).locator('..'); await storageAddress.getByLabel('Address 1').fill('148 S East St'); await storageAddress.getByLabel('Address 2').fill('Suite 7A'); - await storageAddress.getByLabel('City').fill('Sample City'); - await storageAddress.getByLabel('State').selectOption({ label: 'GA' }); - await storageAddress.getByLabel('ZIP').fill('30301'); - await storageAddress.getByLabel('Lot number').fill('1111111'); + await storageAddress.getByLabel('Location Lookup').nth(0).fill('30301'); + await expect(storageAddress.getByText(StorageLocationLookup, { exact: true })).toBeVisible(); + await this.page.keyboard.press('Enter'); + await this.page.getByLabel('Lot number').fill('1111111'); // Requested delivery date await this.page.getByLabel('Requested delivery date').fill('20 Mar 2022'); await this.page.getByLabel('Requested delivery date').blur(); // Delivery location + const DeliveryLocationLookup = 'MONTGOMERY, AL 36101 (MONTGOMERY)'; + const deliveryLocation = await this.page.getByRole('group', { name: 'Delivery location' }); await deliveryLocation.getByLabel('Address 1').fill('448 Washington Blvd NE'); await deliveryLocation.getByLabel('Address 2').fill('Apt D3'); - await deliveryLocation.getByTestId('delivery.address.city').fill('Another City'); - await deliveryLocation.getByLabel('State').selectOption({ label: 'AL' }); - await deliveryLocation.getByLabel('ZIP', { exact: true }).fill('36101'); - await deliveryLocation.getByLabel('County').fill('MONTGOMERY'); + await deliveryLocation.getByLabel('Location Lookup').nth(0).fill('36101'); + await expect(deliveryLocation.getByText(DeliveryLocationLookup, { exact: true })).toBeVisible(); + await this.page.keyboard.press('Enter'); // Remarks await this.page.getByLabel('Counselor remarks').fill('NTS-release counselor remarks'); diff --git a/playwright/tests/office/txo/tooFlows.spec.js b/playwright/tests/office/txo/tooFlows.spec.js index 17cf2322d86..0c7ea06f24e 100644 --- a/playwright/tests/office/txo/tooFlows.spec.js +++ b/playwright/tests/office/txo/tooFlows.spec.js @@ -532,6 +532,7 @@ test.describe('TOO user', () => { test('is able to edit shipment', async ({ page }) => { const deliveryDate = new Date().toLocaleDateString('en-US'); + const LocationLookup = 'BEVERLY HILLS, CA 90210 (LOS ANGELES)'; // Edit the shipment await page.locator('[data-testid="ShipmentContainer"] .usa-button').first().click(); @@ -541,11 +542,9 @@ test.describe('TOO user', () => { await page.locator('#requestedDeliveryDate').blur(); await page.locator('input[name="delivery.address.streetAddress1"]').clear(); await page.locator('input[name="delivery.address.streetAddress1"]').fill('7 q st'); - await page.locator('input[name="delivery.address.city"]').clear(); - await page.locator('input[name="delivery.address.city"]').fill('city'); - await page.locator('select[name="delivery.address.state"]').selectOption({ label: 'OH' }); - await page.locator('input[name="delivery.address.postalCode"]').clear(); - await page.locator('input[name="delivery.address.postalCode"]').fill('90210'); + await page.getByLabel('Location Lookup').nth(1).fill('90210'); + await expect(page.getByText(LocationLookup, { exact: true })).toBeVisible(); + await page.keyboard.press('Enter'); await page.locator('[data-testid="submitForm"]').click(); await expect(page.locator('[data-testid="submitForm"]')).not.toBeEnabled(); @@ -638,6 +637,7 @@ test.describe('TOO user', () => { test('is able to edit shipment for retiree', async ({ page }) => { const deliveryDate = new Date().toLocaleDateString('en-US'); + const LocationLookup = 'BEVERLY HILLS, CA 90210 (LOS ANGELES)'; // Edit the shipment await page.locator('[data-testid="ShipmentContainer"] .usa-button').first().click(); @@ -648,11 +648,9 @@ test.describe('TOO user', () => { await page.locator('input[name="delivery.address.streetAddress1"]').clear(); await page.locator('input[name="delivery.address.streetAddress1"]').fill('7 q st'); - await page.locator('input[name="delivery.address.city"]').clear(); - await page.locator('input[name="delivery.address.city"]').fill('city'); - await page.locator('select[name="delivery.address.state"]').selectOption({ label: 'OH' }); - await page.locator('input[name="delivery.address.postalCode"]').clear(); - await page.locator('input[name="delivery.address.postalCode"]').fill('90210'); + await page.getByLabel('Location Lookup').nth(1).fill('90210'); + await expect(page.getByText(LocationLookup, { exact: true })).toBeVisible(); + await page.keyboard.press('Enter'); await page.locator('select[name="destinationType"]').selectOption({ label: 'Home of selection (HOS)' }); await page.locator('[data-testid="submitForm"]').click(); diff --git a/playwright/tests/office/txo/tooFlowsNTS.spec.js b/playwright/tests/office/txo/tooFlowsNTS.spec.js index 9c478f47847..026a0580d2c 100644 --- a/playwright/tests/office/txo/tooFlowsNTS.spec.js +++ b/playwright/tests/office/txo/tooFlowsNTS.spec.js @@ -72,15 +72,14 @@ test.describe('TOO user', () => { await page.locator('#facilityServiceOrderNumber').blur(); // Storage facility address + const StorageLocationLookup = 'ATLANTA, GA 30301 (FULTON)'; await page.locator('input[name="storageFacility.address.streetAddress1"]').fill('148 S East St'); await page.locator('input[name="storageFacility.address.streetAddress1"]').blur(); await page.locator('input[name="storageFacility.address.streetAddress2"]').fill('Suite 7A'); await page.locator('input[name="storageFacility.address.streetAddress2"]').blur(); - await page.locator('input[name="storageFacility.address.city"]').fill('Sample City'); - await page.locator('input[name="storageFacility.address.city"]').blur(); - await page.locator('select[name="storageFacility.address.state"]').selectOption({ label: 'GA' }); - await page.locator('input[name="storageFacility.address.postalCode"]').fill('30301'); - await page.locator('input[name="storageFacility.address.postalCode"]').blur(); + await page.getByLabel('Location Lookup').nth(2).fill('30301'); + await expect(page.getByText(StorageLocationLookup, { exact: true })).toBeVisible(); + await page.keyboard.press('Enter'); await page.locator('#facilityLotNumber').fill('1111111'); await page.locator('#facilityLotNumber').blur(); diff --git a/playwright/tests/office/txo/tooFlowsNTSR.spec.js b/playwright/tests/office/txo/tooFlowsNTSR.spec.js index 21f2da043be..93d2547b1d1 100644 --- a/playwright/tests/office/txo/tooFlowsNTSR.spec.js +++ b/playwright/tests/office/txo/tooFlowsNTSR.spec.js @@ -74,15 +74,15 @@ test.describe('TOO user', () => { await page.locator('#facilityServiceOrderNumber').blur(); // Storage facility address + const LocationLookup = 'ATLANTA, GA 30301 (FULTON)'; + await page.locator('input[name="storageFacility.address.streetAddress1"]').fill('148 S East St'); await page.locator('input[name="storageFacility.address.streetAddress1"]').blur(); await page.locator('input[name="storageFacility.address.streetAddress2"]').fill('Suite 7A'); await page.locator('input[name="storageFacility.address.streetAddress2"]').blur(); - await page.locator('input[name="storageFacility.address.city"]').fill('Sample City'); - await page.locator('input[name="storageFacility.address.city"]').blur(); - await page.locator('select[name="storageFacility.address.state"]').selectOption({ label: 'GA' }); - await page.locator('input[name="storageFacility.address.postalCode"]').fill('30301'); - await page.locator('input[name="storageFacility.address.postalCode"]').blur(); + await page.getByLabel('Location Lookup').nth(0).fill('30301'); + await expect(page.getByText(LocationLookup, { exact: true })).toBeVisible(); + await page.keyboard.press('Enter'); await page.locator('#facilityLotNumber').fill('1111111'); await page.locator('#facilityLotNumber').blur(); @@ -94,11 +94,9 @@ test.describe('TOO user', () => { await page.locator('input[name="delivery.address.streetAddress1"]').fill('148 S East St'); await page.locator('input[name="delivery.address.streetAddress2"]').clear(); await page.locator('input[name="delivery.address.streetAddress2"]').fill('Suite 7A'); - await page.locator('input[name="delivery.address.city"]').clear(); - await page.locator('input[name="delivery.address.city"]').fill('Sample City'); - await page.locator('select[name="delivery.address.state"]').selectOption({ label: 'GA' }); - await page.locator('input[name="delivery.address.postalCode"]').clear(); - await page.locator('input[name="delivery.address.postalCode"]').fill('30301'); + await page.getByLabel('Location Lookup').nth(1).fill('30301'); + await expect(page.getByText(LocationLookup, { exact: true })).toBeVisible(); + await page.keyboard.press('Enter'); // TAC and SAC await page.locator('[data-testid="radio"] [for="tacType-NTS"]').click(); From 2f7e89fe94b3402da9df7795e64eb7f895b24374 Mon Sep 17 00:00:00 2001 From: Steven Gleason <180579696+stevengleason-caci@users.noreply.github.com> Date: Mon, 4 Nov 2024 14:54:09 +0000 Subject: [PATCH 079/216] B-21458 additional test for the query. --- pkg/notifications/move_payment_reminder_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/notifications/move_payment_reminder_test.go b/pkg/notifications/move_payment_reminder_test.go index f76107d8b21..5d43c7057ea 100644 --- a/pkg/notifications/move_payment_reminder_test.go +++ b/pkg/notifications/move_payment_reminder_test.go @@ -78,6 +78,13 @@ func (suite *NotificationSuite) TestPaymentReminderFetchSomeFound() { suite.Equal(ppms[i].EstimatedWeight, emailInfo[j].WeightEstimate) suite.Equal(ppms[i].EstimatedIncentive, emailInfo[j].IncentiveEstimate) suite.Equal(ppms[i].Shipment.MoveTaskOrder.Locator, emailInfo[j].Locator) + suite.Equal(ppms[i].DestinationAddress.StreetAddress1, *emailInfo[j].DestinationStreet1) + suite.Equal(ppms[i].DestinationAddress.StreetAddress2, emailInfo[j].DestinationStreet2) + suite.Equal(ppms[i].DestinationAddress.StreetAddress3, emailInfo[j].DestinationStreet3) + suite.Equal(ppms[i].DestinationAddress.City, *emailInfo[j].DestinationCity) + suite.Equal(ppms[i].DestinationAddress.State, *emailInfo[j].DestinationState) + suite.Equal(ppms[i].DestinationAddress.PostalCode, *emailInfo[j].DestinationPostalCode) + suite.Equal(ppms[i].Shipment.MoveTaskOrder.Orders.OrdersType, emailInfo[j].OrdersType) } } } From c4d647bd028c83beeba36665fb899871f82a376a Mon Sep 17 00:00:00 2001 From: Steven Gleason <180579696+stevengleason-caci@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:05:59 +0000 Subject: [PATCH 080/216] B-21458 rename destination field, not necessarily the duty station. --- .../move_payment_reminder_template.html | 2 +- .../move_payment_reminder_template.txt | 2 +- pkg/notifications/move_payment_reminder.go | 21 +++++----- .../move_payment_reminder_test.go | 40 +++++++++---------- 4 files changed, 32 insertions(+), 33 deletions(-) diff --git a/pkg/assets/notifications/templates/move_payment_reminder_template.html b/pkg/assets/notifications/templates/move_payment_reminder_template.html index bf886147d56..d645b79eb98 100644 --- a/pkg/assets/notifications/templates/move_payment_reminder_template.html +++ b/pkg/assets/notifications/templates/move_payment_reminder_template.html @@ -1,7 +1,7 @@

*** DO NOT REPLY directly to this email ***

This is a reminder that your PPM with the assigned move code {{.Locator}} from -{{.OriginDutyLocation}} to {{.DestinationDutyLocation}} is awaiting action in MilMove.

+{{.OriginDutyLocation}} to {{.DestinationLocation}} is awaiting action in MilMove.

Next steps:

diff --git a/pkg/assets/notifications/templates/move_payment_reminder_template.txt b/pkg/assets/notifications/templates/move_payment_reminder_template.txt index ccb29c418ab..f23d1b1deae 100644 --- a/pkg/assets/notifications/templates/move_payment_reminder_template.txt +++ b/pkg/assets/notifications/templates/move_payment_reminder_template.txt @@ -1,7 +1,7 @@ *** DO NOT REPLY directly to this email *** This is a reminder that your PPM with the assigned move code {{.Locator}} from {{.OriginDutyLocation}} -to {{.DestinationDutyLocation}} is awaiting action in MilMove. +to {{.DestinationLocation}} is awaiting action in MilMove. Next steps: diff --git a/pkg/notifications/move_payment_reminder.go b/pkg/notifications/move_payment_reminder.go index d2987043724..ca9d560b12c 100644 --- a/pkg/notifications/move_payment_reminder.go +++ b/pkg/notifications/move_payment_reminder.go @@ -120,17 +120,16 @@ func (m PaymentReminder) emails(appCtx appcontext.AppContext) ([]emailContent, e return m.formatEmails(appCtx, paymentReminderEmailInfos) } -// TODO: rename to DestinationLocation // formatEmails formats email data using both html and text template func (m PaymentReminder) formatEmails(appCtx appcontext.AppContext, PaymentReminderEmailInfos PaymentReminderEmailInfos) ([]emailContent, error) { var emails []emailContent for _, PaymentReminderEmailInfo := range PaymentReminderEmailInfos { htmlBody, textBody, err := m.renderTemplates(appCtx, PaymentReminderEmailData{ - OriginDutyLocation: PaymentReminderEmailInfo.OriginDutyLocationName, - DestinationDutyLocation: getDestinationLocation(appCtx, PaymentReminderEmailInfo), - Locator: PaymentReminderEmailInfo.Locator, - OneSourceLink: OneSourceTransportationOfficeLink, - MyMoveLink: MyMoveLink, + OriginDutyLocation: PaymentReminderEmailInfo.OriginDutyLocationName, + DestinationLocation: getDestinationLocation(appCtx, PaymentReminderEmailInfo), + Locator: PaymentReminderEmailInfo.Locator, + OneSourceLink: OneSourceTransportationOfficeLink, + MyMoveLink: MyMoveLink, }) if err != nil { appCtx.Logger().Error("error rendering template", zap.Error(err)) @@ -230,11 +229,11 @@ func (m PaymentReminder) OnSuccess(appCtx appcontext.AppContext, PaymentReminder // PaymentReminderEmailData is used to render an email template type PaymentReminderEmailData struct { - OriginDutyLocation string - DestinationDutyLocation string - Locator string - OneSourceLink string - MyMoveLink string + OriginDutyLocation string + DestinationLocation string + Locator string + OneSourceLink string + MyMoveLink string } // RenderHTML renders the html for the email diff --git a/pkg/notifications/move_payment_reminder_test.go b/pkg/notifications/move_payment_reminder_test.go index 5d43c7057ea..f685767ce2b 100644 --- a/pkg/notifications/move_payment_reminder_test.go +++ b/pkg/notifications/move_payment_reminder_test.go @@ -144,16 +144,16 @@ func (suite *NotificationSuite) TestPaymentReminderHTMLTemplateRender() { suite.NoError(err) paymentReminderData := PaymentReminderEmailData{ - OriginDutyLocation: "OriginDutyLocation", - DestinationDutyLocation: "DestDutyLocation", - Locator: "abc123", - OneSourceLink: OneSourceTransportationOfficeLink, - MyMoveLink: MyMoveLink, + OriginDutyLocation: "OriginDutyLocation", + DestinationLocation: "DestDutyLocation", + Locator: "abc123", + OneSourceLink: OneSourceTransportationOfficeLink, + MyMoveLink: MyMoveLink, } expectedHTMLContent := `

*** DO NOT REPLY directly to this email ***

This is a reminder that your PPM with the assigned move code ` + paymentReminderData.Locator + ` from -` + paymentReminderData.OriginDutyLocation + ` to ` + paymentReminderData.DestinationDutyLocation + ` is awaiting action in MilMove.

+` + paymentReminderData.OriginDutyLocation + ` to ` + paymentReminderData.DestinationLocation + ` is awaiting action in MilMove.

Next steps:

@@ -201,17 +201,17 @@ func (suite *NotificationSuite) TestPaymentReminderTextTemplateRender() { pr, err := NewPaymentReminder() suite.NoError(err) paymentReminderData := PaymentReminderEmailData{ - OriginDutyLocation: "OriginDutyLocation", - DestinationDutyLocation: "DestDutyLocation", - Locator: "abc123", - OneSourceLink: OneSourceTransportationOfficeLink, - MyMoveLink: MyMoveLink, + OriginDutyLocation: "OriginDutyLocation", + DestinationLocation: "DestDutyLocation", + Locator: "abc123", + OneSourceLink: OneSourceTransportationOfficeLink, + MyMoveLink: MyMoveLink, } expectedTextContent := `*** DO NOT REPLY directly to this email *** This is a reminder that your PPM with the assigned move code ` + paymentReminderData.Locator + ` from ` + paymentReminderData.OriginDutyLocation + ` -to ` + paymentReminderData.DestinationDutyLocation + ` is awaiting action in MilMove. +to ` + paymentReminderData.DestinationLocation + ` is awaiting action in MilMove. Next steps: @@ -288,10 +288,10 @@ func (suite *NotificationSuite) TestFormatPaymentRequestedEmails() { emailInfo := emailInfos[i] data := PaymentReminderEmailData{ - DestinationDutyLocation: emailInfo.NewDutyLocationName, - Locator: emailInfo.Locator, - OneSourceLink: OneSourceTransportationOfficeLink, - MyMoveLink: MyMoveLink, + DestinationLocation: emailInfo.NewDutyLocationName, + Locator: emailInfo.Locator, + OneSourceLink: OneSourceTransportationOfficeLink, + MyMoveLink: MyMoveLink, } htmlBody, err := pr.RenderHTML(suite.AppContextForTest(), data) suite.NoError(err) @@ -413,10 +413,10 @@ func (suite *NotificationSuite) TestFormatPaymentRequestedEmailsForRetireeSepara expectedDestination := expectedDestinations[i] data := PaymentReminderEmailData{ - DestinationDutyLocation: expectedDestination, - Locator: emailInfo.Locator, - OneSourceLink: OneSourceTransportationOfficeLink, - MyMoveLink: MyMoveLink, + DestinationLocation: expectedDestination, + Locator: emailInfo.Locator, + OneSourceLink: OneSourceTransportationOfficeLink, + MyMoveLink: MyMoveLink, } htmlBody, err := pr.RenderHTML(suite.AppContextForTest(), data) suite.NoError(err) From d5780fadcd8850e2abaf7cb325d3a6949ae230fa Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Mon, 4 Nov 2024 17:04:22 +0000 Subject: [PATCH 081/216] undo customer test fix, needs to go in later --- .../my/milmove/ppms/customerPpmTestFixture.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js b/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js index 5db86e7420d..ff52b0da2a9 100644 --- a/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js +++ b/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js @@ -408,18 +408,17 @@ export class CustomerPpmPage extends CustomerPage { * returns {Promise} */ async navigateFromDateAndLocationPageToEstimatedWeightsPage() { - const PickupLocationLookup = 'BEVERLY HILLS, CA 90210 (LOS ANGELES)'; - const DestinationLocationLookup = 'FORT WORTH, TX 76127 (TARRANT)'; - await this.page.locator('input[name="pickupAddress.address.streetAddress1"]').fill('123 Street'); - await this.page.getByLabel('Location Lookup').nth(0).fill('90210'); - await expect(this.page.getByText(PickupLocationLookup, { exact: true })).toBeVisible(); - await this.page.keyboard.press('Enter'); - + await this.page.locator('input[name="pickupAddress.address.city"]').fill('BEVERLY HILLS'); + await this.page.locator('select[name="pickupAddress.address.state"]').selectOption({ label: 'CA' }); + await this.page.locator('input[name="pickupAddress.address.postalCode"]').clear(); + await this.page.locator('input[name="pickupAddress.address.postalCode"]').fill('90210'); + await this.page.locator('input[name="pickupAddress.address.postalCode"]').blur(); + await this.page.locator('input[name="destinationAddress.address.postalCode"]').clear(); + await this.page.locator('input[name="destinationAddress.address.postalCode"]').fill('76127'); await this.page.locator('input[name="destinationAddress.address.streetAddress1"]').fill('123 Street'); - await this.page.getByLabel('Location Lookup').nth(1).fill('76127'); - await expect(this.page.getByText(DestinationLocationLookup, { exact: true })).toBeVisible(); - await this.page.keyboard.press('Enter'); + await this.page.locator('input[name="destinationAddress.address.city"]').fill('FORT WORTH'); + await this.page.locator('select[name="destinationAddress.address.state"]').selectOption({ label: 'TX' }); await this.page.locator('input[name="expectedDepartureDate"]').clear(); await this.page.locator('input[name="expectedDepartureDate"]').fill('01 Feb 2022'); From 0982954eb06b0ad08842922186492b535bfad37a Mon Sep 17 00:00:00 2001 From: Steven Gleason <180579696+stevengleason-caci@users.noreply.github.com> Date: Tue, 5 Nov 2024 16:09:02 +0000 Subject: [PATCH 082/216] B-21458 add htmlBody to the unit tests. --- pkg/notifications/move_payment_reminder_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/notifications/move_payment_reminder_test.go b/pkg/notifications/move_payment_reminder_test.go index f685767ce2b..2b30b22b139 100644 --- a/pkg/notifications/move_payment_reminder_test.go +++ b/pkg/notifications/move_payment_reminder_test.go @@ -307,6 +307,7 @@ func (suite *NotificationSuite) TestFormatPaymentRequestedEmails() { suite.Equal(expectedEmailContent.recipientEmail, actualEmailContent.recipientEmail) suite.Equal(expectedEmailContent.subject, actualEmailContent.subject) suite.Equal(expectedEmailContent.textBody, actualEmailContent.textBody) + suite.Equal(expectedEmailContent.htmlBody, actualEmailContent.htmlBody) } } // only expect the three moves with non-nil email addresses to get added to formattedEmails @@ -432,6 +433,7 @@ func (suite *NotificationSuite) TestFormatPaymentRequestedEmailsForRetireeSepara suite.Equal(expectedEmailContent.recipientEmail, actualEmailContent.recipientEmail) suite.Equal(expectedEmailContent.subject, actualEmailContent.subject) suite.Equal(expectedEmailContent.textBody, actualEmailContent.textBody) + suite.Equal(expectedEmailContent.htmlBody, actualEmailContent.htmlBody) } } suite.Len(formattedEmails, 5) From e351210cdd15c125c41a196bf869e32aaa105cd2 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Tue, 5 Nov 2024 21:04:10 +0000 Subject: [PATCH 083/216] removing unneeded sql --- migrations/app/migrations_manifest.txt | 1 - .../20240805234231_update_us_post_region_cities_state.up.sql | 2 -- 2 files changed, 3 deletions(-) delete mode 100644 migrations/app/schema/20240805234231_update_us_post_region_cities_state.up.sql diff --git a/migrations/app/migrations_manifest.txt b/migrations/app/migrations_manifest.txt index 4644a208584..454a5751572 100644 --- a/migrations/app/migrations_manifest.txt +++ b/migrations/app/migrations_manifest.txt @@ -980,7 +980,6 @@ 20240801135811_create_mobile_home.up.sql 20240801135833_alter_mto_shipment_type_motorhome.up.sql 20240802161708_tpps_paid_invoice_table.up.sql -20240805234231_update_us_post_region_cities_state.up.sql 20240806151051_update_pws_violations.up.sql 20240806230447_add_rotation_to_uploads.up.sql 20240807140736_add_locked_price_cents_to_mto_service_items.up.sql diff --git a/migrations/app/schema/20240805234231_update_us_post_region_cities_state.up.sql b/migrations/app/schema/20240805234231_update_us_post_region_cities_state.up.sql deleted file mode 100644 index b462e3ab960..00000000000 --- a/migrations/app/schema/20240805234231_update_us_post_region_cities_state.up.sql +++ /dev/null @@ -1,2 +0,0 @@ -UPDATE us_post_region_cities SET state = '' WHERE state IS null; -ALTER TABLE public.us_post_region_cities ALTER COLUMN state SET NOT NULL; \ No newline at end of file From a5af1817f4a1db2608b3d305fe7af92f1d8406da Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 6 Nov 2024 01:38:14 +0000 Subject: [PATCH 084/216] allow space in city name, refactor search parsing --- pkg/services/address/address_lookup.go | 36 ++++++++++++-------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/pkg/services/address/address_lookup.go b/pkg/services/address/address_lookup.go index 33b735cae9e..9077b8234af 100644 --- a/pkg/services/address/address_lookup.go +++ b/pkg/services/address/address_lookup.go @@ -42,37 +42,33 @@ func (o vLocation) GetLocationsByZipCityState(appCtx appcontext.AppContext, sear return &locationList, nil } +// Returns a VLocation array containing all results for the search +// This method expects a comma to be entered after the city name has been entered and is used +// to determine when the state and postal code need to be parsed from the search string +// If there is only one result and no comma and the search string is all numbers we then search +// using the entered postal code rather than city name func FindLocationsByZipCity(appCtx appcontext.AppContext, search string) (models.VLocations, error) { var locationList []models.VLocation - search = strings.ReplaceAll(search, ",", "") //remove any commas so they are not used in the search - searchSlice := strings.Split(search, " ") + searchSlice := strings.Split(search, ",") city := "" state := "" postalCode := "" - var postalCodeRegex = regexp.MustCompile(`^[0-9]+$`) - if len(searchSlice) == 1 { - // check if this is a zip only search + if len(searchSlice) > 1 { + city = searchSlice[0] + searchSlice = strings.Split(searchSlice[1], " ") + state = searchSlice[1] + + if len(searchSlice) > 2 { + postalCode = searchSlice[2] + } + } else { if postalCodeRegex.MatchString(search) { - postalCode = search + postalCode = strings.TrimSpace(search) } else { city = search } - } else if postalCode == "" && len(searchSlice) == 2 { - city = strings.TrimSpace(searchSlice[0]) - state = strings.TrimSpace(searchSlice[1]) - } else if len(searchSlice) == 3 { - if postalCodeRegex.MatchString(searchSlice[2]) { - postalCode = strings.TrimSpace(searchSlice[2]) - } - city = strings.TrimSpace(searchSlice[0]) - state = strings.TrimSpace(searchSlice[1]) - } - - // user may have typed a comma as part of the city name we need to remove that do to the query - if city != "" { - city = strings.ReplaceAll(city, ",", "") } /** Feature Flag - Alaska - Determines if AK be included/excluded **/ From a3ddf8153816b7694746a2d16010b36a158bc61f Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 6 Nov 2024 19:36:01 +0000 Subject: [PATCH 085/216] fixing test --- playwright/tests/office/ppms/happyPathFlows.spec.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/playwright/tests/office/ppms/happyPathFlows.spec.js b/playwright/tests/office/ppms/happyPathFlows.spec.js index 8df004b255f..88079024bc5 100644 --- a/playwright/tests/office/ppms/happyPathFlows.spec.js +++ b/playwright/tests/office/ppms/happyPathFlows.spec.js @@ -106,12 +106,10 @@ test.describe('Services counselor user', () => { await expect(shipmentContainer.locator('[data-testid="expectedDepartureDate"]')).toContainText('09 Jun 2022'); await expect(shipmentContainer.locator('[data-testid="pickupAddress"]')).toContainText('123 Street'); - await expect(shipmentContainer.locator('[data-testid="pickupAddress"]')).toContainText('SomeCity - Secondary'); await expect(shipmentContainer.locator('[data-testid="pickupAddress"]')).toContainText('CA'); await expect(shipmentContainer.locator('[data-testid="pickupAddress"]')).toContainText('90210'); await expect(shipmentContainer.locator('[data-testid="destinationAddress"]')).toContainText('123 Street'); - await expect(shipmentContainer.locator('[data-testid="destinationAddress"]')).toContainText('SomeCity,'); await expect(shipmentContainer.locator('[data-testid="destinationAddress"]')).toContainText('TX'); await expect(shipmentContainer.locator('[data-testid="destinationAddress"]')).toContainText('76127'); From 6a97ac8b9fb33db9109ff8c6b4eddd645b7acb41 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 6 Nov 2024 19:43:28 +0000 Subject: [PATCH 086/216] fixing test --- playwright/tests/office/ppms/happyPathFlows.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/playwright/tests/office/ppms/happyPathFlows.spec.js b/playwright/tests/office/ppms/happyPathFlows.spec.js index 88079024bc5..f6c9db33012 100644 --- a/playwright/tests/office/ppms/happyPathFlows.spec.js +++ b/playwright/tests/office/ppms/happyPathFlows.spec.js @@ -106,10 +106,12 @@ test.describe('Services counselor user', () => { await expect(shipmentContainer.locator('[data-testid="expectedDepartureDate"]')).toContainText('09 Jun 2022'); await expect(shipmentContainer.locator('[data-testid="pickupAddress"]')).toContainText('123 Street'); + await expect(shipmentContainer.locator('[data-testid="pickupAddress"]')).toContainText('BEVERLY HILLS'); await expect(shipmentContainer.locator('[data-testid="pickupAddress"]')).toContainText('CA'); await expect(shipmentContainer.locator('[data-testid="pickupAddress"]')).toContainText('90210'); await expect(shipmentContainer.locator('[data-testid="destinationAddress"]')).toContainText('123 Street'); + await expect(shipmentContainer.locator('[data-testid="destinationAddress"]')).toContainText('FORT WORTH,'); await expect(shipmentContainer.locator('[data-testid="destinationAddress"]')).toContainText('TX'); await expect(shipmentContainer.locator('[data-testid="destinationAddress"]')).toContainText('76127'); From 129a44c682f17cf4b9a790890bb3007ccf1b18ee Mon Sep 17 00:00:00 2001 From: Steven Gleason <180579696+stevengleason-caci@users.noreply.github.com> Date: Wed, 6 Nov 2024 20:38:14 +0000 Subject: [PATCH 087/216] B-21458 remove debugging messages. --- pkg/notifications/move_payment_reminder.go | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/pkg/notifications/move_payment_reminder.go b/pkg/notifications/move_payment_reminder.go index ca9d560b12c..6a7e33b02cd 100644 --- a/pkg/notifications/move_payment_reminder.go +++ b/pkg/notifications/move_payment_reminder.go @@ -126,7 +126,7 @@ func (m PaymentReminder) formatEmails(appCtx appcontext.AppContext, PaymentRemin for _, PaymentReminderEmailInfo := range PaymentReminderEmailInfos { htmlBody, textBody, err := m.renderTemplates(appCtx, PaymentReminderEmailData{ OriginDutyLocation: PaymentReminderEmailInfo.OriginDutyLocationName, - DestinationLocation: getDestinationLocation(appCtx, PaymentReminderEmailInfo), + DestinationLocation: getDestinationLocation(PaymentReminderEmailInfo), Locator: PaymentReminderEmailInfo.Locator, OneSourceLink: OneSourceTransportationOfficeLink, MyMoveLink: MyMoveLink, @@ -168,23 +168,12 @@ func (m PaymentReminder) renderTemplates(appCtx appcontext.AppContext, data Paym return htmlBody, textBody, nil } -func getDestinationLocation(appCtx appcontext.AppContext, PaymentReminderEmailInfo PaymentReminderEmailInfo) string { +func getDestinationLocation(PaymentReminderEmailInfo PaymentReminderEmailInfo) string { destinationLocation := PaymentReminderEmailInfo.NewDutyLocationName ordersType := PaymentReminderEmailInfo.OrdersType street1 := PaymentReminderEmailInfo.DestinationStreet1 - if street1 != nil { - appCtx.Logger().Error("Street1 is: " + *street1) - } else { - appCtx.Logger().Error("Street1 is nil") - } isSeparateeOrRetireeOrder := ordersType == internalmessages.OrdersTypeRETIREMENT || ordersType == internalmessages.OrdersTypeSEPARATION - if isSeparateeOrRetireeOrder { - appCtx.Logger().Debug("isSeparateeOrRetireeOrder: true") - } else { - appCtx.Logger().Debug("isSeparateeOrRetireeOrder: false") - } if isSeparateeOrRetireeOrder && street1 != nil { - appCtx.Logger().Debug("In address section") street2, street3, city, state, postalCode := "", "", "", "", "" if PaymentReminderEmailInfo.DestinationStreet2 != nil { street2 = " " + *PaymentReminderEmailInfo.DestinationStreet2 @@ -202,7 +191,6 @@ func getDestinationLocation(appCtx appcontext.AppContext, PaymentReminderEmailIn postalCode = " " + *PaymentReminderEmailInfo.DestinationPostalCode } destinationLocation = fmt.Sprintf("%s%s%s%s%s%s", *street1, street2, street3, city, state, postalCode) - appCtx.Logger().Debug("New location: " + destinationLocation) } return destinationLocation } From 5a083d6e1ad843be95f1e8200c5f0962535df649 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 8 Nov 2024 17:37:23 +0000 Subject: [PATCH 088/216] use labels instead of inputs --- .../BackupAddressForm/BackupAddressForm.jsx | 1 + .../EditContactInfoForm.jsx | 2 + .../ResidentialAddressForm.jsx | 1 + .../CustomerContactInfoForm.jsx | 2 + .../EditFacilityInfoModal.jsx | 1 + .../EditPPMHeaderSummaryModal.jsx | 2 + .../Office/ShipmentForm/ShipmentForm.jsx | 19 ++++- .../StorageFacilityAddress.jsx | 10 ++- .../form/AddressFields/AddressFields.jsx | 72 +++++++++---------- .../AddressFields/AddressFields.module.scss | 9 +++ 10 files changed, 78 insertions(+), 41 deletions(-) diff --git a/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx b/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx index 4dc1b17af17..10167108559 100644 --- a/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx +++ b/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx @@ -55,6 +55,7 @@ const BackupAddressForm = ({ formFieldsName, initialValues, onSubmit, onBack }) diff --git a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx index ddf390c8e5a..daf80425cae 100644 --- a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx +++ b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx @@ -88,6 +88,7 @@ const EditContactInfoForm = ({ initialValues, onSubmit, onCancel }) => { { diff --git a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx index 5eda3715f57..5969e15ce40 100644 --- a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx +++ b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx @@ -99,12 +99,14 @@ const CustomerContactInfoForm = ({ initialValues, onSubmit, onBack }) => {

Current Address

Backup Address

diff --git a/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx b/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx index 6044021f105..9fee72538f0 100644 --- a/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx +++ b/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx @@ -113,6 +113,7 @@ export const EditFacilityInfoModal = ({ name="storageFacility.address" className={styles.AddressFields} formikFunctionsToValidatePostalCodeOnChange={{ handleChange, setFieldTouched }} + values={values} zipCityEnabled handleLocationChange={handleLocationChange} render={(fields) => ( diff --git a/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx b/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx index 492db14af16..0f96f986d4b 100644 --- a/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx +++ b/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx @@ -128,6 +128,7 @@ const EditPPMHeaderSummaryModal = ({ sectionType, sectionInfo, onClose, onSubmit legend="Pickup Address" className={styles.AddressFieldSet} formikFunctionsToValidatePostalCodeOnChange={{ handleChange, setFieldTouched }} + values={values} zipCityEnabled handleLocationChange={handlePickupZipCityChange} /> @@ -138,6 +139,7 @@ const EditPPMHeaderSummaryModal = ({ sectionType, sectionInfo, onClose, onSubmit legend="Destination Address" className={styles.AddressFieldSet} formikFunctionsToValidatePostalCodeOnChange={{ handleChange, setFieldTouched }} + values={values} zipCityEnabled handleLocationChange={handleDestinationZipCityChange} /> diff --git a/src/components/Office/ShipmentForm/ShipmentForm.jsx b/src/components/Office/ShipmentForm/ShipmentForm.jsx index e2735389199..730fa1e4db6 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.jsx @@ -1140,6 +1140,7 @@ const ShipmentForm = (props) => { ( @@ -1183,6 +1184,7 @@ const ShipmentForm = (props) => { <> @@ -1217,6 +1219,7 @@ const ShipmentForm = (props) => { {hasTertiaryPickup === 'yes' && ( @@ -1244,14 +1247,14 @@ const ShipmentForm = (props) => { {isTOO && (isNTS || isNTSR) && ( <> - + )} {isServiceCounselor && isNTSR && ( <> - + )} @@ -1298,6 +1301,7 @@ const ShipmentForm = (props) => { > { @@ -1334,6 +1338,7 @@ const ShipmentForm = (props) => { <> @@ -1368,6 +1373,7 @@ const ShipmentForm = (props) => { {hasTertiaryDelivery === 'yes' && ( @@ -1448,6 +1454,7 @@ const ShipmentForm = (props) => { {hasDeliveryAddress === 'yes' ? ( ( @@ -1491,6 +1498,7 @@ const ShipmentForm = (props) => { <> @@ -1527,6 +1535,7 @@ const ShipmentForm = (props) => { {hasTertiaryDelivery === 'yes' && ( @@ -1621,6 +1630,7 @@ const ShipmentForm = (props) => { ( @@ -1667,6 +1677,7 @@ const ShipmentForm = (props) => { <> @@ -1704,6 +1715,7 @@ const ShipmentForm = (props) => { {hasTertiaryPickup === 'true' && ( @@ -1718,6 +1730,7 @@ const ShipmentForm = (props) => { { <> @@ -1794,6 +1808,7 @@ const ShipmentForm = (props) => { {hasTertiaryDestination === 'true' && ( diff --git a/src/components/Office/StorageFacilityAddress/StorageFacilityAddress.jsx b/src/components/Office/StorageFacilityAddress/StorageFacilityAddress.jsx index 3224f076322..d55b8f06194 100644 --- a/src/components/Office/StorageFacilityAddress/StorageFacilityAddress.jsx +++ b/src/components/Office/StorageFacilityAddress/StorageFacilityAddress.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import PropTypes from 'prop-types'; +import { PropTypes, shape } from 'prop-types'; import { Fieldset, FormGroup, Label, TextInput, Grid } from '@trussworks/react-uswds'; import { Field } from 'formik'; @@ -8,13 +8,14 @@ import styles from 'components/Office/ShipmentForm/ShipmentForm.module.scss'; import SectionWrapper from 'components/Customer/SectionWrapper'; import { AddressFields } from 'components/form/AddressFields/AddressFields'; -const StorageFacilityAddress = ({ onLocationChange }) => { +const StorageFacilityAddress = ({ onLocationChange, values }) => { return (

Storage facility address

( @@ -41,6 +42,11 @@ const StorageFacilityAddress = ({ onLocationChange }) => { StorageFacilityAddress.propTypes = { onLocationChange: PropTypes.func.isRequired, + values: shape({}), +}; + +StorageFacilityAddress.defaultProps = { + values: {}, }; export default StorageFacilityAddress; diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index b2f522c8388..035ec7f60a5 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -1,7 +1,7 @@ import React, { useRef } from 'react'; -import PropTypes from 'prop-types'; +import { PropTypes, shape } from 'prop-types'; import { v4 as uuidv4 } from 'uuid'; -import { Fieldset } from '@trussworks/react-uswds'; +import { Fieldset, Label } from '@trussworks/react-uswds'; import { statesList } from '../../../constants/states'; @@ -32,6 +32,7 @@ export const AddressFields = ({ className, name, render, + values, validators, zipCityEnabled, handleLocationChange, @@ -63,28 +64,21 @@ export const AddressFields = ({ }} /> ) : ( - + <> + + + ); const stateField = zipCityEnabled ? ( - + <> + + + ) : (
- - {handleLocationChange && ( + {!handleLocationChange && ( )} + {handleLocationChange && ( + <> + + + + + + )}
{stateField} @@ -196,6 +192,7 @@ AddressFields.propTypes = { name: PropTypes.string.isRequired, render: PropTypes.func, zipCityEnabled: PropTypes.bool, + values: shape({}), handleLocationChange: PropTypes.func, validators: PropTypes.shape({ streetAddress1: PropTypes.func, @@ -216,6 +213,7 @@ AddressFields.defaultProps = { legend: '', className: '', render: (fields) => fields, + values: {}, zipCityEnabled: false, handleLocationChange: null, validators: {}, diff --git a/src/components/form/AddressFields/AddressFields.module.scss b/src/components/form/AddressFields/AddressFields.module.scss index c6810971d7d..1f628f9d51b 100644 --- a/src/components/form/AddressFields/AddressFields.module.scss +++ b/src/components/form/AddressFields/AddressFields.module.scss @@ -21,4 +21,13 @@ @media (max-width: 840px) { margin-bottom: 1.5rem; } +} + +.label { + @media (max-width: 840px) { + margin-bottom: 1.5rem; + } + margin-top: 1em; + font-size: 16px; + flex-grow: 1; } \ No newline at end of file From 29b7901efb3b7e60caea65b16e8e36e65351e14c Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 8 Nov 2024 18:27:37 +0000 Subject: [PATCH 089/216] remove zipCityEnabled flag --- .../BackupAddressForm/BackupAddressForm.jsx | 1 - .../EditContactInfoForm/EditContactInfoForm.jsx | 2 -- .../ResidentialAddressForm.jsx | 1 - .../CustomerContactInfoForm.jsx | 2 -- .../EditFacilityInfoModal.jsx | 1 - .../EditPPMHeaderSummaryModal.jsx | 2 -- .../Office/ShipmentForm/ShipmentForm.jsx | 15 --------------- .../StorageFacilityAddress.jsx | 1 - .../form/AddressFields/AddressFields.jsx | 6 +----- 9 files changed, 1 insertion(+), 30 deletions(-) diff --git a/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx b/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx index 10167108559..398abd5fe56 100644 --- a/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx +++ b/src/components/Customer/BackupAddressForm/BackupAddressForm.jsx @@ -56,7 +56,6 @@ const BackupAddressForm = ({ formFieldsName, initialValues, onSubmit, onBack }) labelHint="Required" name={formFieldsName} values={values} - zipCityEnabled handleLocationChange={handleLocationChange} /> diff --git a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx index daf80425cae..88514d003cb 100644 --- a/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx +++ b/src/components/Customer/EditContactInfoForm/EditContactInfoForm.jsx @@ -90,7 +90,6 @@ const EditContactInfoForm = ({ initialValues, onSubmit, onCancel }) => { name={residentialAddressName} values={values} labelHint="Required" - zipCityEnabled handleLocationChange={handleCurrentZipCityChange} /> @@ -106,7 +105,6 @@ const EditContactInfoForm = ({ initialValues, onSubmit, onCancel }) => { name={backupAddressName} values={values} labelHint="Required" - zipCityEnabled handleLocationChange={handleBackupZipCityChange} /> diff --git a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx index 418fd90ac42..0b9e9ab99a2 100644 --- a/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx +++ b/src/components/Customer/ResidentialAddressForm/ResidentialAddressForm.jsx @@ -55,7 +55,6 @@ const ResidentialAddressForm = ({ formFieldsName, initialValues, onSubmit, onBac name={formFieldsName} validators={validators} values={values} - zipCityEnabled handleLocationChange={handleLocationChange} /> diff --git a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx index 5969e15ce40..6a0a8c6752f 100644 --- a/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx +++ b/src/components/Office/CustomerContactInfoForm/CustomerContactInfoForm.jsx @@ -100,14 +100,12 @@ const CustomerContactInfoForm = ({ initialValues, onSubmit, onBack }) => {

Backup Address

diff --git a/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx b/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx index 9fee72538f0..0c841e64336 100644 --- a/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx +++ b/src/components/Office/EditFacilityInfoModal/EditFacilityInfoModal.jsx @@ -114,7 +114,6 @@ export const EditFacilityInfoModal = ({ className={styles.AddressFields} formikFunctionsToValidatePostalCodeOnChange={{ handleChange, setFieldTouched }} values={values} - zipCityEnabled handleLocationChange={handleLocationChange} render={(fields) => ( <> diff --git a/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx b/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx index 0f96f986d4b..9784eded14d 100644 --- a/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx +++ b/src/components/Office/PPM/PPMHeaderSummary/EditPPMHeaderSummaryModal.jsx @@ -129,7 +129,6 @@ const EditPPMHeaderSummaryModal = ({ sectionType, sectionInfo, onClose, onSubmit className={styles.AddressFieldSet} formikFunctionsToValidatePostalCodeOnChange={{ handleChange, setFieldTouched }} values={values} - zipCityEnabled handleLocationChange={handlePickupZipCityChange} /> )} @@ -140,7 +139,6 @@ const EditPPMHeaderSummaryModal = ({ sectionType, sectionInfo, onClose, onSubmit className={styles.AddressFieldSet} formikFunctionsToValidatePostalCodeOnChange={{ handleChange, setFieldTouched }} values={values} - zipCityEnabled handleLocationChange={handleDestinationZipCityChange} /> )} diff --git a/src/components/Office/ShipmentForm/ShipmentForm.jsx b/src/components/Office/ShipmentForm/ShipmentForm.jsx index 730fa1e4db6..6dcf45ce8de 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.jsx @@ -1141,7 +1141,6 @@ const ShipmentForm = (props) => { name="pickup.address" legend="Pickup location" values={values} - zipCityEnabled handleLocationChange={handlePickupLocationChange} render={(fields) => ( <> @@ -1185,7 +1184,6 @@ const ShipmentForm = (props) => { {isTertiaryAddressEnabled && ( @@ -1220,7 +1218,6 @@ const ShipmentForm = (props) => { )} @@ -1302,7 +1299,6 @@ const ShipmentForm = (props) => { { return fields; @@ -1339,7 +1335,6 @@ const ShipmentForm = (props) => { {isTertiaryAddressEnabled && ( @@ -1374,7 +1369,6 @@ const ShipmentForm = (props) => { )} @@ -1455,7 +1449,6 @@ const ShipmentForm = (props) => { ( <> @@ -1499,7 +1492,6 @@ const ShipmentForm = (props) => { {isTertiaryAddressEnabled && ( @@ -1536,7 +1528,6 @@ const ShipmentForm = (props) => { )} @@ -1631,7 +1622,6 @@ const ShipmentForm = (props) => { name="pickup.address" legend="Pickup Address" values={values} - zipCityEnabled handleLocationChange={handlePickupLocationChange} render={(fields) => ( <> @@ -1678,7 +1668,6 @@ const ShipmentForm = (props) => { {isTertiaryAddressEnabled && ( @@ -1716,7 +1705,6 @@ const ShipmentForm = (props) => { )} @@ -1731,7 +1719,6 @@ const ShipmentForm = (props) => { name="destination.address" legend="Delivery Address" values={values} - zipCityEnabled handleLocationChange={handleDestinationLocationChange} address1LabelHint="Optional" render={(fields) => ( @@ -1771,7 +1758,6 @@ const ShipmentForm = (props) => { {isTertiaryAddressEnabled && ( @@ -1809,7 +1795,6 @@ const ShipmentForm = (props) => { )} diff --git a/src/components/Office/StorageFacilityAddress/StorageFacilityAddress.jsx b/src/components/Office/StorageFacilityAddress/StorageFacilityAddress.jsx index d55b8f06194..aa9f272c81f 100644 --- a/src/components/Office/StorageFacilityAddress/StorageFacilityAddress.jsx +++ b/src/components/Office/StorageFacilityAddress/StorageFacilityAddress.jsx @@ -16,7 +16,6 @@ const StorageFacilityAddress = ({ onLocationChange, values }) => { ( <> diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index 035ec7f60a5..b1c471b6fdf 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -34,7 +34,6 @@ export const AddressFields = ({ render, values, validators, - zipCityEnabled, handleLocationChange, formikFunctionsToValidatePostalCodeOnChange, labelHint: labelHintProp, @@ -72,7 +71,7 @@ export const AddressFields = ({ ); - const stateField = zipCityEnabled ? ( + const stateField = handleLocationChange ? ( <>