Skip to content

Commit 01621c4

Browse files
authored
Merge pull request #202 from scientist-softserv/345-webstore
Make all fields disabled when disabled prop is passed
2 parents 78d91b9 + 4254eed commit 01621c4

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/components/AdditionalInfo/AdditionalInfo.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
} from 'react-bootstrap'
66
import { addDays, apiV2CompatibleStrings, convertToBase64 } from '../../resources/utilityFunctions'
77

8-
const AdditionalInfo = ({ backgroundColor, defaultRequiredDate, updateRequestForm }) => {
8+
const AdditionalInfo = ({ backgroundColor, defaultRequiredDate, disabled, updateRequestForm, }) => {
99
const [showProposalDate, setShowProposalDate] = useState(true)
1010
const [files, setFiles] = useState([])
1111
const fileRef = useRef(null)
@@ -55,7 +55,7 @@ const AdditionalInfo = ({ backgroundColor, defaultRequiredDate, updateRequestFor
5555
min={oneDayFromNow}
5656
defaultValue={defaultRequiredDate}
5757
placeholder='Proposals Required By'
58-
disabled={showProposalDate === false}
58+
disabled={(showProposalDate === false) || disabled}
5959
onChange={showProposalDate && ((e) => handleChange(e.target.value))}
6060
required
6161
/>
@@ -70,6 +70,7 @@ const AdditionalInfo = ({ backgroundColor, defaultRequiredDate, updateRequestFor
7070
>
7171
<Form.Check
7272
className='prevent-validation-styles'
73+
disabled={disabled}
7374
type='checkbox'
7475
label='Proposals can be submitted at any time.'
7576
onChange={() => {
@@ -84,6 +85,7 @@ const AdditionalInfo = ({ backgroundColor, defaultRequiredDate, updateRequestFor
8485
<Form.Label>Attachments:</Form.Label>
8586
<Form.Control
8687
className='prevent-validation-styles'
88+
disabled={disabled}
8789
multiple
8890
type='file'
8991
onChange={handleAddFile}
@@ -110,6 +112,7 @@ const AdditionalInfo = ({ backgroundColor, defaultRequiredDate, updateRequestFor
110112
AdditionalInfo.propTypes = {
111113
backgroundColor: PropTypes.string,
112114
updateRequestForm: PropTypes.func.isRequired,
115+
disabled: PropTypes.bool.isRequired,
113116
}
114117

115118
AdditionalInfo.defaultProps = {

src/components/ShippingDetails/ShippingDetails.jsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import { CountryDropdown } from 'react-country-region-selector'
99
import PropTypes from 'prop-types'
1010

11-
const AddressForm = ({ addressType, billingCountry, shippingCountry, setShowBilling,
11+
const AddressForm = ({ addressType, billingCountry, disabled, shippingCountry, setShowBilling,
1212
showBilling, updateRequestForm }) => {
1313
const handleChange = (value) => {
1414
updateRequestForm(value, 'billingSameAsShipping')
@@ -31,6 +31,7 @@ const AddressForm = ({ addressType, billingCountry, shippingCountry, setShowBill
3131
name='address1'
3232
type='text'
3333
className='prevent-validation-styles'
34+
disabled={disabled}
3435
required
3536
/>
3637
<Form.Control.Feedback type='invalid'>
@@ -43,6 +44,7 @@ const AddressForm = ({ addressType, billingCountry, shippingCountry, setShowBill
4344
placeholder='Address Line 2 (optional)'
4445
onChange={(e) => updateRequestForm(e.target.value, `${addressType}.street2`)}
4546
className='prevent-validation-styles'
47+
disabled={disabled}
4648
/>
4749
</Form.Group>
4850

@@ -53,6 +55,7 @@ const AddressForm = ({ addressType, billingCountry, shippingCountry, setShowBill
5355
type='text'
5456
required
5557
className='prevent-validation-styles'
58+
disabled={disabled}
5659
/>
5760
<Form.Control.Feedback type='invalid'>
5861
Please enter your city or region.
@@ -67,6 +70,7 @@ const AddressForm = ({ addressType, billingCountry, shippingCountry, setShowBill
6770
type='text'
6871
required
6972
className='prevent-validation-styles'
73+
disabled={disabled}
7074
/>
7175
<Form.Control.Feedback type='invalid'>
7276
Please enter your state or province.
@@ -80,6 +84,7 @@ const AddressForm = ({ addressType, billingCountry, shippingCountry, setShowBill
8084
type='text'
8185
required
8286
className='prevent-validation-styles'
87+
disabled={disabled}
8388
/>
8489
<Form.Control.Feedback type='invalid'>
8590
Please enter your zip or postal code.
@@ -94,6 +99,7 @@ const AddressForm = ({ addressType, billingCountry, shippingCountry, setShowBill
9499
onChange={(e) => updateRequestForm(e, `${addressType}.country`)}
95100
className='form-select mb-3 form-control prevent-validation-styles'
96101
id={`country-${addressType}`}
102+
disabled={disabled}
97103
required
98104
/>
99105
<Form.Control.Feedback type='invalid'>
@@ -106,6 +112,7 @@ const AddressForm = ({ addressType, billingCountry, shippingCountry, setShowBill
106112
className='prevent-validation-styles'
107113
type='checkbox'
108114
label='My shipping address is the same as my billing address.'
115+
disabled={disabled}
109116
onChange={() => {
110117
setShowBilling(!showBilling)
111118
if (showBilling) handleChange(true)
@@ -118,7 +125,7 @@ const AddressForm = ({ addressType, billingCountry, shippingCountry, setShowBill
118125
)
119126
}
120127

121-
const ShippingDetails = ({ backgroundColor, billingCountry, shippingCountry, updateRequestForm }) => {
128+
const ShippingDetails = ({ backgroundColor, billingCountry, disabled, shippingCountry, updateRequestForm }) => {
122129
const [showBilling, setShowBilling] = useState(true)
123130

124131
return (
@@ -131,13 +138,15 @@ const ShippingDetails = ({ backgroundColor, billingCountry, shippingCountry, upd
131138
showBilling={showBilling}
132139
setShowBilling={setShowBilling}
133140
updateRequestForm={updateRequestForm}
141+
disabled={disabled}
134142
/>
135143
{showBilling && (
136144
<AddressForm
137145
addressType='billing'
138146
billingCountry={billingCountry}
139147
shippingCountry={shippingCountry}
140148
updateRequestForm={updateRequestForm}
149+
disabled={disabled}
141150
/>
142151
)}
143152
</Card>
@@ -147,6 +156,7 @@ const ShippingDetails = ({ backgroundColor, billingCountry, shippingCountry, upd
147156
AddressForm.propTypes = {
148157
addressType: PropTypes.string.isRequired,
149158
billingCountry: PropTypes.string.isRequired,
159+
disabled: PropTypes.bool.isRequired,
150160
showBilling: PropTypes.bool,
151161
setShowBilling: PropTypes.func,
152162
shippingCountry: PropTypes.string.isRequired,
@@ -156,6 +166,7 @@ AddressForm.propTypes = {
156166
ShippingDetails.propTypes = {
157167
backgroundColor: PropTypes.string,
158168
billingCountry: PropTypes.string.isRequired,
169+
disabled: PropTypes.bool.isRequired,
159170
shippingCountry: PropTypes.string.isRequired,
160171
updateRequestForm: PropTypes.func.isRequired,
161172
}

0 commit comments

Comments
 (0)