Skip to content

Commit 15c1a17

Browse files
authored
Merge pull request #169 from scientist-softserv/137-accept-sow
137 accept sow
2 parents 48623b4 + f539071 commit 15c1a17

File tree

2 files changed

+55
-19
lines changed

2 files changed

+55
-19
lines changed

src/components/Notice/Notice.jsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@ import React, { useState } from 'react'
33
import PropTypes from 'prop-types'
44
import { Alert, Button, Container } from 'react-bootstrap'
55

6-
const Notice = ({ alert, buttonProps, dismissible, withBackButton }) => {
6+
const Notice = ({ addClass, alert, buttonProps, dismissible, withBackButton }) => {
77
const [show, setShow] = useState(true)
8-
const { title, body, variant } = alert
8+
const { title, body, variant, onClose } = alert
99
let onClick
1010
let text
1111
if (withBackButton) ({ onClick, text } = buttonProps)
1212

1313
return (
1414
show && (
15-
<Container>
16-
<Alert className='my-5 text-break' variant={variant} onClose={() => setShow(false)} dismissible={dismissible}>
15+
<Container className={addClass}>
16+
<Alert
17+
className='text-break'
18+
variant={variant}
19+
onClose={onClose || (() => setShow(false))}
20+
dismissible={dismissible}
21+
>
1722
{title && (
1823
<Alert.Heading>{title}</Alert.Heading>
1924
)}
@@ -55,8 +60,10 @@ const Notice = ({ alert, buttonProps, dismissible, withBackButton }) => {
5560
}
5661

5762
Notice.propTypes = {
63+
addClass: PropTypes.string,
5864
alert: PropTypes.shape({
5965
body: PropTypes.arrayOf(PropTypes.string).isRequired,
66+
onClose: PropTypes.func,
6067
title: PropTypes.string,
6168
variant: PropTypes.string.isRequired,
6269
}).isRequired,
@@ -69,6 +76,7 @@ Notice.propTypes = {
6976
}
7077

7178
Notice.defaultProps = {
79+
addClass: '',
7280
buttonProps: {},
7381
dismissible: true,
7482
withBackButton: false,

src/compounds/Document/Document.jsx

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import React, { useState } from 'react'
22
import PropTypes from 'prop-types'
3-
import { Dropdown, Offcanvas } from 'react-bootstrap'
3+
import { Dropdown, Offcanvas, Row } from 'react-bootstrap'
44
import LineItemsTable from '../../components/LineItemsTable/LineItemsTable'
5+
import Notice from '../../components/Notice/Notice'
6+
import { allowNull } from '../../resources/utilityFunctions'
57
import './document.scss'
68

7-
const Document = ({ document, addClass }) => {
9+
const Document = ({ acceptSOW, addClass, backgroundColor, document }) => {
810
const {
911
adPO, date, documentStatusColor, documentType, documentTypeColor, documentStatus, identifier, lineItems, poNumber,
1012
relatedSOWIdentifier, requestIdentifier, shippingPrice, shipTo, shipFrom, subtotalPrice, taxAmount, terms, totalPrice,
1113
turnaroundTime,
1214
} = document
1315
const [show, setShow] = useState(false)
16+
const [showNotice, setShowNotice] = useState(false)
1417
const handleClose = () => setShow(false)
1518
const handleShow = () => setShow(true)
1619

@@ -35,22 +38,43 @@ const Document = ({ document, addClass }) => {
3538
</div>
3639
</div>
3740
<Offcanvas show={show} onHide={handleClose} placement='end' scroll='true'>
38-
<Offcanvas.Header className='d-flex' closeButton>
41+
<Offcanvas.Header className={`d-flex border-bottom px-3 py-2 bg-${backgroundColor}-8`} closeButton>
3942
<Offcanvas.Title> {documentType}: #{identifier}</Offcanvas.Title>
40-
<div className='ms-auto me-2'>
41-
<Dropdown>
42-
<Dropdown.Toggle variant='light' id='dropdown-basic' size='small' className='border'>
43-
Next Actions
44-
</Dropdown.Toggle>
45-
<Dropdown.Menu>
46-
{/* TODO: @summer-cook Update this menu item so it submits this document for approval &
47-
add more dropdown items depending on what actions we need here. */}
48-
<Dropdown.Item href='#/action-1'>Submit for Approval</Dropdown.Item>
49-
</Dropdown.Menu>
50-
</Dropdown>
51-
</div>
43+
{documentType === 'SOW'
44+
&& (
45+
<div className='ms-auto me-2'>
46+
<Dropdown>
47+
<Dropdown.Toggle id='next-actions-dropdown' size='small' className='btn-outline-dark' variant={`btn-${backgroundColor}`}>
48+
Next Actions
49+
</Dropdown.Toggle>
50+
<Dropdown.Menu>
51+
<Dropdown.Item
52+
href='#/accept-sow'
53+
onClick={() => {
54+
acceptSOW
55+
setShowNotice(true)
56+
}}
57+
>
58+
Submit for Approval
59+
</Dropdown.Item>
60+
</Dropdown.Menu>
61+
</Dropdown>
62+
</div>
63+
)}
5264
</Offcanvas.Header>
5365
<Offcanvas.Body>
66+
{showNotice && (
67+
<Row>
68+
<Notice
69+
addClass='my-3'
70+
alert={{
71+
body: [`SOW ${identifier} has been accepted successfully. Now awaiting purchase order.`],
72+
variant: 'success',
73+
onClose: () => setShowNotice(false),
74+
}}
75+
/>
76+
</Row>
77+
)}
5478
<div className='d-block d-md-flex justify-content-between'>
5579
<div className='details'>
5680
<h5>Details:</h5>
@@ -95,6 +119,8 @@ const Document = ({ document, addClass }) => {
95119

96120
Document.propTypes = {
97121
addClass: PropTypes.string,
122+
backgroundColor: PropTypes.string,
123+
acceptSOW: PropTypes.func.isRequired,
98124
document: PropTypes.shape({
99125
adPO: PropTypes.string,
100126
identifier: PropTypes.string.isRequired,
@@ -116,6 +142,7 @@ Document.propTypes = {
116142
organizationName: PropTypes.string,
117143
text: PropTypes.string,
118144
}).isRequired,
145+
sowID: allowNull(PropTypes.string),
119146
subtotalPrice: PropTypes.string.isRequired,
120147
taxAmount: PropTypes.string.isRequired,
121148
terms: PropTypes.string.isRequired,
@@ -126,6 +153,7 @@ Document.propTypes = {
126153

127154
Document.defaultProps = {
128155
addClass: '',
156+
backgroundColor: 'secondary',
129157
document: {
130158
documentTypeColor: 'bg-dark',
131159
documentStatusColor: 'bg-secondary',

0 commit comments

Comments
 (0)