Skip to content

Commit 41281a8

Browse files
authored
Merge pull request #109 from scientist-softserv/93-pass-the-service-name
93 initialize request
2 parents 517c2eb + b63ed41 commit 41281a8

File tree

7 files changed

+39
-15
lines changed

7 files changed

+39
-15
lines changed

src/components/AdditionalInfo/AdditionalInfo.jsx

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

8-
const AdditionalInfo = ({ updateRequestForm }) => {
8+
const AdditionalInfo = ({ defaultRequiredDate, updateRequestForm }) => {
99
const [showProposalDate, setShowProposalDate] = useState(true)
1010
const [files, setFiles] = useState([])
1111
const fileRef = useRef(null)
12-
const oneWeekFromNow = addDays((new Date()), 7).toISOString().slice(0, 10)
1312
const oneDayFromNow = addDays((new Date()), 1).toISOString().slice(0, 10)
1413

1514
const handleChange = (value) => {
@@ -54,7 +53,7 @@ const AdditionalInfo = ({ updateRequestForm }) => {
5453
className='prevent-validation-styles'
5554
type='date'
5655
min={oneDayFromNow}
57-
defaultValue={oneWeekFromNow}
56+
defaultValue={defaultRequiredDate}
5857
placeholder='Proposals Required By'
5958
disabled={showProposalDate === false}
6059
onChange={showProposalDate && ((e) => handleChange(e.target.value))}

src/components/NextLink/NextLink.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Link from 'next/link'
33
import PropTypes from 'prop-types'
44

55
const NextLink = ({ addClass, text, path }) => (
6-
<Link href={path} passHref legacyBehavior>
6+
<Link href={path} passHref>
77
<NextLinkWrapper
88
addClass={addClass}
99
href={path}
@@ -21,7 +21,10 @@ const NextLinkWrapper = React.forwardRef(({ addClass, text, href }, ref) => (
2121
NextLink.propTypes = {
2222
text: PropTypes.string.isRequired,
2323
addClass: PropTypes.string,
24-
path: PropTypes.string.isRequired,
24+
path: PropTypes.exact({
25+
pathname: PropTypes.string.isRequired,
26+
query: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
27+
}).isRequired,
2528
}
2629

2730
NextLink.defaultProps = {

src/compounds/Item/CardBody.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import LinkedButton from '../LinkedButton/LinkedButton'
88
const CardBody = ({ buttonLink, buttonProps, fromItemGroup, item,
99
orientation, titleLink, withButtonLink, withTitleLink }) => {
1010
const { id, description, name } = item
11+
1112
return (
1213
<Card.Body className={withButtonLink && 'd-flex flex-column'}>
1314
<div className={orientation === 'horizontal' ? 'd-block d-md-flex align-items-center justify-content-between' : ''}>
@@ -16,7 +17,7 @@ const CardBody = ({ buttonLink, buttonProps, fromItemGroup, item,
1617
{(withTitleLink && fromItemGroup) && (
1718
<NextLink
1819
text={name}
19-
path={{ pathname: `${titleLink}`, query: { id: `${id}` } }}
20+
path={{ pathname: titleLink, query: { id } }}
2021
addClass='text-decoration-none link-hover'
2122
/>
2223
)}
@@ -38,7 +39,7 @@ const CardBody = ({ buttonLink, buttonProps, fromItemGroup, item,
3839
<LinkedButton
3940
addClass={`item-button-${orientation} item-link mt-auto`}
4041
buttonProps={buttonProps}
41-
path={fromItemGroup ? { pathname: `${buttonLink}`, query: { id: `${id}` } } : buttonLink}
42+
path={{ pathname: buttonLink, query: { id }}}
4243
/>
4344
</div>
4445
)}
@@ -57,7 +58,7 @@ CardBody.propTypes = {
5758
// buttonProps: props => props.withButtonLink
5859
// ? PropTypes.shape(Button.propTypes)
5960
// : PropTypes.shape({ ...Button.propTypes, label: PropTypes.string })
60-
fromItemGroup: PropTypes.string,
61+
fromItemGroup: PropTypes.bool,
6162
item: PropTypes.shape({
6263
description: PropTypes.string,
6364
id: PropTypes.number.isRequired,

src/compounds/Item/Item.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Item.propTypes = {
100100
name: PropTypes.string.isRequired,
101101
slug: PropTypes.string,
102102
}),
103-
fromItemGroup: PropTypes.string,
103+
fromItemGroup: PropTypes.bool,
104104
orientation: PropTypes.oneOf(['horizontal', 'vertical']),
105105
titleLink: PropTypes.string,
106106
withButtonLink: PropTypes.bool,

src/compounds/ItemGroup/ItemGroup.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const ItemGroup = ({ buttonProps, items, isLoading, orientation, withButtonLink,
3838
withButtonLink={withButtonLink}
3939
withTitleLink={withTitleLink}
4040
href={item.href}
41-
fromItemGroup='true'
41+
fromItemGroup={true}
4242
/>
4343
</Col>
4444
))

src/compounds/LinkedButton/LinkedButton.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ import './linked-button.css'
99
*/
1010
// TODO(alishaevn):
1111
// - use this component in Item.jsx instead, but make sure it maintains its current styling
12+
13+
// we are not using the "as" prop in the Link because it removes the ability to access the path query
1214
const LinkedButton = ({ addClass, buttonProps, path }) => (
13-
<Link href={path} passHref legacyBehavior>
15+
<Link href={path} passHref>
1416
<ButtonLinkWrapper
1517
addClass={addClass}
1618
buttonProps={buttonProps}
@@ -29,7 +31,10 @@ const { onClick, ...remainingPropTypes } = Button.propTypes
2931
LinkedButton.propTypes = {
3032
buttonProps: PropTypes.shape(remainingPropTypes).isRequired,
3133
addClass: PropTypes.string,
32-
path: PropTypes.string.isRequired,
34+
path: PropTypes.exact({
35+
pathname: PropTypes.string.isRequired,
36+
query: PropTypes.shape({ id: PropTypes.number }),
37+
}).isRequired,
3338
}
3439

3540
LinkedButton.defaultProps = {

src/compounds/LinkedButton/LinkedButton.stories.jsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,30 @@ export default {
99

1010
const Template = (args) => <LinkedButton {...args} />
1111

12-
export const Default = Template.bind({})
13-
1412
const { onClick, ...remainingDefaultProps } = Button.defaultProps
13+
14+
export const Default = Template.bind({})
1515
Default.args = {
1616
buttonProps: {
1717
...remainingDefaultProps,
1818
label: 'Linked Button',
1919
},
2020
addClass: '',
21-
path: '/',
21+
path: {
22+
pathname: '/',
23+
query: {},
24+
},
25+
}
26+
27+
export const WithQuery = Template.bind({})
28+
WithQuery.args = {
29+
buttonProps: {
30+
...remainingDefaultProps,
31+
label: 'Linked Button',
32+
},
33+
addClass: '',
34+
path: {
35+
pathname: '/test',
36+
query: { id: 123 },
37+
},
2238
}

0 commit comments

Comments
 (0)