Skip to content

Commit

Permalink
prepare trade/single form submit for response (#147)
Browse files Browse the repository at this point in the history
* establish form default values for a few inputs such as 'maxRouteDistance' to simplify the UX

* update the hook we use to fetch data on form submits useGetData to require a response data type to be passed to it
  • Loading branch information
aslink87 authored Jun 3, 2024
1 parent 21d51ad commit 042744a
Show file tree
Hide file tree
Showing 15 changed files with 380 additions and 149 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NEXT_PUBLIC_STAGE=localhost
NEXT_PUBLIC_MOCK_API_URL=http://localhost:3001
NEXT_PUBLIC_STAGING_API_URL=http://duval.edpn.io:8080
NEXT_PUBLIC_STAGING_API_URL=https://duval.edpn.io
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"prettier/prettier": "error",
"prefer-const": "off",
"no-use-before-define": "off",
"react/no-unescaped-entities": "off",
"react/react-in-jsx-scope": "off",
"import/order": "off",
"space-before-function-paren": [
Expand Down
6 changes: 3 additions & 3 deletions app/_components/inputs/Commodities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ const CommoditiesField: React.FC<CommodityProps> = ({

return (
<Controller
name="commodityDisplayName"
name="commodityDisplayNames"
control={control}
rules={{ required: 'Enter at least one commodity' }}
render={({ field: { onChange, onBlur, value, name, ref } }) => (
<Select<CommoditySelectItems, true, GroupBase<CommoditySelectItems>>
id="commodityDisplayName"
instanceId="commodityDisplayName"
id="commodityDisplayNames"
instanceId="commodityDisplayNames"
name={name}
ref={ref}
onInputChange={(input) => {
Expand Down
2 changes: 1 addition & 1 deletion app/_components/inputs/StationTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface Props {

export const checkboxValues = [
{ name: 'Orbital', value: 'includeOrbital', checked: true },
{ name: 'Planetary', value: 'includePlanetary' },
{ name: 'Planetary', value: 'includeSurfaceStations' },
{ name: 'Odyssey', value: 'includeOdyssey' },
{ name: 'Carriers', value: 'includeFleetCarriers' },
];
Expand Down
8 changes: 4 additions & 4 deletions app/_components/inputs/tests/Commodities.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('Commodities Field', () => {

// Check item is selected
expect(getByTestId('form')).toHaveFormValues({
commodityDisplayName: 'Trillium',
commodityDisplayNames: 'Trillium',
});

act(() => {
Expand All @@ -106,7 +106,7 @@ describe('Commodities Field', () => {

// Check both items are selected
expect(getByTestId('form')).toHaveFormValues({
commodityDisplayName: 'Gold',
commodityDisplayNames: 'Gold',
});
});

Expand Down Expand Up @@ -135,7 +135,7 @@ describe('Commodities Field', () => {

// Check item is selected
expect(getByTestId('form')).toHaveFormValues({
commodityDisplayName: 'Trillium',
commodityDisplayNames: 'Trillium',
});

act(() => {
Expand All @@ -149,7 +149,7 @@ describe('Commodities Field', () => {

// Check both items are selected
expect(getByTestId('form')).toHaveFormValues({
commodityDisplayName: ['Trillium', 'Gold'],
commodityDisplayNames: ['Trillium', 'Gold'],
});
});
});
Loading

0 comments on commit 042744a

Please sign in to comment.