Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
fixup! Add parent company to claim a facility
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelly Innes committed Jun 24, 2019
1 parent efee42f commit 364ce9d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/app/src/components/ClaimFacilityFacilityInfoStep.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ function ClaimFacilityFacilityInfoStep({
{parentCompanyFormField.label}
</Typography>
</InputLabel>
<aside style={claimAFacilityFormStyles.asideStyles}>
{parentCompanyFormField.aside}
</aside>
<div style={claimAFacilityFormStyles.textFieldStyles}>
<Select
options={contributorOptions}
Expand Down
24 changes: 24 additions & 0 deletions src/app/src/components/ClaimedFacilitiesDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import find from 'lodash/find';
import stubFalse from 'lodash/stubFalse';
import isEmpty from 'lodash/isEmpty';
import get from 'lodash/get';
import isNull from 'lodash/isNull';
import Select from 'react-select';
import { isEmail } from 'validator';
import { toast } from 'react-toastify';
Expand Down Expand Up @@ -57,6 +58,14 @@ import {
mapDjangoChoiceTuplesToSelectOptions,
} from '../util/util';

import { claimAFacilityFormFields } from '../util/constants';

const {
parentCompany: {
aside: parentCompanyAside,
},
} = claimAFacilityFormFields;

const claimedFacilitiesDetailsStyles = Object.freeze({
containerStyles: Object.freeze({
display: 'flex',
Expand Down Expand Up @@ -109,6 +118,9 @@ const claimedFacilitiesDetailsStyles = Object.freeze({
padding: '10px 0',
color: 'red',
}),
asideStyles: Object.freeze({
padding: '5px 20px 20px 0',
}),
});

const selectStyles = Object.freeze({
Expand Down Expand Up @@ -136,7 +148,16 @@ const InputSection = ({
isSelect = false,
selectOptions = null,
hasValidationErrorFn = stubFalse,
aside = null,
}) => {
const asideNode = (
<ShowOnly when={!isNull(aside)}>
<aside style={claimedFacilitiesDetailsStyles.asideStyles}>
{aside}
</aside>
</ShowOnly>
);

if (isSelect) {
return (
<div style={claimedFacilitiesDetailsStyles.inputSectionStyles}>
Expand All @@ -147,6 +168,7 @@ const InputSection = ({
>
{label}
</InputLabel>
{asideNode}
<Select
onChange={onChange}
value={find(selectOptions, ['value', value])}
Expand Down Expand Up @@ -180,6 +202,7 @@ const InputSection = ({
</span>
) : null}
</InputLabel>
{asideNode}
<TextField
variant="outlined"
style={claimedFacilitiesDetailsStyles.inputSectionFieldStyles}
Expand Down Expand Up @@ -322,6 +345,7 @@ function ClaimedFacilitiesDetails({
<ShowOnly when={!isEmpty(contributorOptions)}>
<InputSection
label="Parent Company"
aside={parentCompanyAside}
value={get(data, 'facility_parent_company.id', null)}
onChange={updateParentCompany}
disabled={updating}
Expand Down
4 changes: 3 additions & 1 deletion src/app/src/util/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,9 @@ export const claimAFacilityFormFields = Object.freeze({
}),
parentCompany: Object.freeze({
id: 'parent-company',
label: 'Parent company of facility, selected from contributors list',
label: 'Parent company',
aside: `If you cannot find the parent company in this list consider
inviting them to register with the Open Apparel Registry.`,
}),
website: Object.freeze({
id: 'website',
Expand Down
3 changes: 3 additions & 0 deletions src/app/src/util/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,7 @@ export const claimAFacilityFormStyles = Object.freeze({
width: '100%',
padding: '5px 0 5px',
}),
asideStyles: Object.freeze({
padding: '5px 20px 5px 0',
}),
});

0 comments on commit 364ce9d

Please sign in to comment.