Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OSDEV-1129] Implement results page for name address search UI part. #465

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/react/src/Routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import ExternalRedirect from './components/ExternalRedirect';
import Facilities from './components/Facilities';
import ContributeProductionLocation from './components/Contribute/ContributeProductionLocation';
import SearchByOsIdResult from './components/Contribute/SearchByOsIdResult';
import SearchByNameAndAddressResult from './components/Contribute/SearchByNameAndAddressResult';

import { sessionLogin } from './actions/auth';
import { fetchFeatureFlags } from './actions/featureFlags';
Expand All @@ -57,6 +58,7 @@ import {
InfoPaths,
contributeProductionLocationRoute,
searchByOsIdResultRoute,
searchByNameAndAddressResultRoute,
} from './util/constants';

class Routes extends Component {
Expand Down Expand Up @@ -84,7 +86,11 @@ class Routes extends Component {
<Router history={history}>
<div className="App">
{!embed ? <Navbar /> : null}
<main style={mainPanelStyle} className="mainPanel">
<main
style={mainPanelStyle}
className="mainPanel"
id="mainPanel"
>
<Switch>
<Route
exact
Expand Down Expand Up @@ -169,6 +175,11 @@ class Routes extends Component {
path={searchByOsIdResultRoute}
component={SearchByOsIdResult}
/>
<Route
exact
path={searchByNameAndAddressResultRoute}
component={SearchByNameAndAddressResult}
/>
<Route exact path="/about/processing">
<ExternalRedirect
to={`${InfoLink}/${InfoPaths.dataQuality}`}
Expand Down
271 changes: 262 additions & 9 deletions src/react/src/actions/contributeProductionLocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,287 @@ import {
makeGetProductionLocationByOsIdURL,
} from '../util/util';

export const startFetchingSingleProductionLocation = createAction(
'START_FETCHING_SINGLE_PRODUCTION_LOCATION',
export const startFetchSingleProductionLocation = createAction(
'START_FETCH_SINGLE_PRODUCTION_LOCATION',
);
export const failFetchingSingleProductionLocation = createAction(
'FAIL_FETCHING_SINGLE_PRODUCTION_LOCATION',
export const failFetchSingleProductionLocation = createAction(
'FAIL_FETCH_SINGLE_PRODUCTION_LOCATION',
);
export const completeFetchingSingleProductionLocation = createAction(
'COMPLETE_FETCHING_SINGLE_PRODUCTION_LOCATION',
export const completeFetchSingleProductionLocation = createAction(
'COMPLETE_FETCH_SINGLE_PRODUCTION_LOCATION',
);
export const resetSingleProductionLocation = createAction(
'RESET_SINGLE_PRODUCTION_LOCATION',
);
export const startFetchProductionLocations = createAction(
'START_FETCH_PRODUCTION_LOCATIONS',
);
export const failFetchProductionLocations = createAction(
'FAIL_FETCH_PRODUCTION_LOCATIONS',
);
export const completeFetchProductionLocations = createAction(
'COMPLETE_FETCH_PRODUCTION_LOCATIONS',
);

export function fetchProductionLocationByOsId(osID) {
return dispatch => {
dispatch(startFetchingSingleProductionLocation());
dispatch(startFetchSingleProductionLocation());

return apiRequest
.get(makeGetProductionLocationByOsIdURL(osID))
.then(({ data }) =>
dispatch(completeFetchingSingleProductionLocation(data)),
dispatch(completeFetchSingleProductionLocation(data)),
)
.catch(err =>
dispatch(
logErrorAndDispatchFailure(
err,
'An error prevented fetching data about that production location',
failFetchingSingleProductionLocation,
failFetchSingleProductionLocation,
),
),
);
};
}

const mockedProductionLocations = [
{
sector: ['Apparel'],
location_type: ['Contractor', 'Logo Application'],
name: 'Robinson Manufacturing Company Dayton',
parent_company: 'Robinson',
claim_status: 'unclaimed',
number_of_workers: {
max: 53,
min: 53,
},
product_type: ['Accessories', 'Decoration'],
coordinates: {
lat: 35.4872298,
lng: -85.0189463,
},
country: {
name: 'United States',
numeric: '840',
alpha_3: 'USA',
alpha_2: 'US',
},
address: '798 Market Street, Dayton, Dayton, Tennessee 37321',
os_id: 'US2019085AACCK0',
processing_type: ['Contractor', 'Logo Application'],
},
{
sector: ['Apparel'],
location_type: ['Finished Goods'],
name: 'Robinson Manufacturing Company, Dayton',
parent_company: 'ROBINSON',
claim_status: 'unclaimed',
number_of_workers: {
max: 58,
min: 58,
},
product_type: ['APPAREL', 'NIKE'],
coordinates: {
lat: 35.5118656,
lng: -85.0064775,
},
country: {
name: 'United States',
numeric: '840',
alpha_3: 'USA',
alpha_2: 'US',
},
address: '1184 Broadway Dayton Tennessee 37321',
os_id: 'US2022082XJ6DVN',
processing_type: ['Finished Goods'],
},
{
sector: ['Consumer Products', 'General Merchandise'],
location_type: ['Manufacturing', 'Production', 'Logo Application'],
name: 'Robinson Manufacturing',
claim_status: 'unclaimed',
product_type: ['Accessories', 'Loungewear', 'Sleepwear', 'Underwear'],
coordinates: {
lat: 35.4872298,
lng: -85.0189463,
},
country: {
name: 'United States',
numeric: '840',
alpha_3: 'USA',
alpha_2: 'US',
},
address:
'798 S. Market Street, Dayton, Tennessee, 37321, United States',
os_id: 'US2024275MWQQ62',
processing_type: ['Manufacturing', 'Production', 'Logo Application'],
},
{
sector: ['Agriculture', 'Farming'],
name: 'GRUBER MANUFACTURING, INC',
claim_status: 'unclaimed',
coordinates: {
lat: 39.6900755,
lng: -121.8560144,
},
country: {
name: 'United States',
numeric: '840',
alpha_3: 'USA',
alpha_2: 'US',
},
address: '2462 Dayton Road, CHICO, CA, 95928-8225',
os_id: 'US2024299KEN8HK',
},
{
sector: ['Chemicals', 'Commodities', 'Waste Management'],
location_type: [
'Onsite Chemical Disposal',
'Offsite Chemical Disposal',
],
name: 'CPCA MANUFACTURING LLC',
claim_status: 'unclaimed',
coordinates: {
lat: 39.762,
lng: -84.227,
},
country: {
name: 'United States',
numeric: '840',
alpha_3: 'USA',
alpha_2: 'US',
},
address: '750 ROSEDALE DR, DAYTON OHIO 45402 (MONTGOMERY)',
os_id: 'US2024212DV02QP',
processing_type: [
'Onsite Chemical Disposal',
'Offsite Chemical Disposal',
],
},
{
sector: ['Apparel', 'Apparel Accessories'],
name: 'E T Manufacturing & Sales, Inc.',
claim_status: 'unclaimed',
coordinates: {
lat: 40.8727141,
lng: -74.1177198,
},
country: {
name: 'United States',
numeric: '840',
alpha_3: 'USA',
alpha_2: 'US',
},
address: '90 Dayton Ave, Passaic, NJ, 07055',
os_id: 'US2024275HE0B6E',
},
{
sector: ['Chemicals', 'Commodities', 'Waste Management'],
location_type: [
'Offsite Chemical Disposal',
'Onsite Chemical Disposal',
],
name: 'HOHMAN PLATING & MANUFACTURING INC',
claim_status: 'unclaimed',
coordinates: {
lat: 39.784,
lng: -84.185,
},
country: {
name: 'United States',
numeric: '840',
alpha_3: 'USA',
alpha_2: 'US',
},
address: '814 HILLROSE AVE, DAYTON OHIO 45404 (MONTGOMERY)',
os_id: 'US2024212GE5H1A',
processing_type: [
'Offsite Chemical Disposal',
'Onsite Chemical Disposal',
],
},
{
sector: ['Health', 'Medical Equipment & Services'],
name: 'GEM City Enginnering and Manufacturing Corporation',
claim_status: 'unclaimed',
coordinates: {
lat: 39.7842949,
lng: -84.1911605,
},
country: {
name: 'United States',
numeric: '840',
alpha_3: 'USA',
alpha_2: 'US',
},
address: '401 Leo St Dayton, Ohio 45404',
os_id: 'US2024283CJQHGK',
},
{
sector: ['Chemicals', 'Commodities', 'Waste Management'],
location_type: [
'Onsite Chemical Disposal',
'Offsite Chemical Disposal',
],
name: 'MAYDAY MANUFACTURING CO',
claim_status: 'unclaimed',
coordinates: {
lat: 33.22,
lng: -97.174,
},
country: {
name: 'United States',
numeric: '840',
alpha_3: 'USA',
alpha_2: 'US',
},
address: '3100 JIM CHRISTAL RD, DENTON TEXAS 76207 (DENTON)',
os_id: 'US2024213ZB3ZHK',
processing_type: [
'Onsite Chemical Disposal',
'Offsite Chemical Disposal',
],
},
{
sector: ['Health', 'Healthcare', 'Pharmaceuticals'],
name: 'Kobayashi America Manufacturing, LLC',
parent_company: 'Kobayashi Consumer Products LLC',
claim_status: 'unclaimed',
coordinates: {
lat: 34.7045473,
lng: -84.9496968,
},
country: {
name: 'United States',
numeric: '840',
alpha_3: 'USA',
alpha_2: 'US',
},
address: '245 Kraft Dr Dalton, Georgia 30721',
os_id: 'US2023084VCWT7Z',
},
];

export function fetchProductionLocations() {
return async dispatch => {
dispatch(startFetchProductionLocations());

// TODO: Replace the mock implementation with an actual API call as part of https://opensupplyhub.atlassian.net/browse/OSDEV-1175
return new Promise(resolve => {
setTimeout(
() => resolve({ data: mockedProductionLocations }),
1000,
);
})
.then(({ data }) =>
dispatch(completeFetchProductionLocations(data)),
)
.catch(err =>
dispatch(
logErrorAndDispatchFailure(
err,
'An error prevented fetching production locations',
failFetchProductionLocations,
),
),
);
Expand Down
Loading
Loading