Skip to content

Commit 517c2eb

Browse files
authored
Merge pull request #115 from scientist-softserv/114-default-to-one-week-out
Add minimum date of a day and default date of a week
2 parents f0dd95d + 391bc50 commit 517c2eb

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/components/AdditionalInfo/AdditionalInfo.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import PropTypes from 'prop-types'
33
import {
44
Card, CloseButton, Form, ListGroup,
55
} from 'react-bootstrap'
6-
import { convertToBase64, apiV2CompatibleStrings } from '../../resources/utilityFunctions'
6+
import { addDays, apiV2CompatibleStrings, convertToBase64 } from '../../resources/utilityFunctions'
77

88
const AdditionalInfo = ({ updateRequestForm }) => {
99
const [showProposalDate, setShowProposalDate] = useState(true)
1010
const [files, setFiles] = useState([])
11-
const today = new Date().toISOString().slice(0, 10)
1211
const fileRef = useRef(null)
12+
const oneWeekFromNow = addDays((new Date()), 7).toISOString().slice(0, 10)
13+
const oneDayFromNow = addDays((new Date()), 1).toISOString().slice(0, 10)
1314

1415
const handleChange = (value) => {
1516
updateRequestForm(value, 'proposedDeadline')
@@ -52,7 +53,8 @@ const AdditionalInfo = ({ updateRequestForm }) => {
5253
<Form.Control
5354
className='prevent-validation-styles'
5455
type='date'
55-
min={today}
56+
min={oneDayFromNow}
57+
defaultValue={oneWeekFromNow}
5658
placeholder='Proposals Required By'
5759
disabled={showProposalDate === false}
5860
onChange={showProposalDate && ((e) => handleChange(e.target.value))}

src/resources/utilityFunctions.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ export const convertToBase64 = (fileArray) => fileArray.map((file) => new Promis
99
fileReader.onload = () => resolve(fileReader.result)
1010
fileReader.onerror = (error) => reject(new Error(error))
1111
}))
12+
13+
// used to add days to a new Date() in the AdditionalInfo component
14+
export const addDays = (date, days) => {
15+
date.setDate(date.getDate() + days)
16+
return date
17+
}

0 commit comments

Comments
 (0)