Skip to content

Commit 3a38614

Browse files
committed
adds addClass to the alert, makes onClose a prop, adds an alert to the document
1 parent 7dd8baf commit 3a38614

File tree

2 files changed

+59
-27
lines changed

2 files changed

+59
-27
lines changed

src/components/Notice/Notice.jsx

Lines changed: 15 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,10 @@ Notice.propTypes = {
6976
}
7077

7178
Notice.defaultProps = {
79+
addClass: '',
80+
alert: {
81+
onClose: () => {}
82+
},
7283
buttonProps: {},
7384
dismissible: true,
7485
withBackButton: false,

src/compounds/Document/Document.jsx

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
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'
56
import './document.scss'
67

7-
const Document = ({ accessToken, addClass, acceptSOW, document, request }) => {
8+
const Document = ({ accessToken, addClass, acceptSOW, backgroundColor, document, request }) => {
89
const { identifier, date, documentStatusColor, documentType,
910
documentTypeColor, documentStatus, lineItems, requestIdentifier,
1011
shippingPrice, shipTo, shipFrom, sowID, subtotalPrice,
1112
taxAmount, terms, totalPrice } = document
1213
const [show, setShow] = useState(false)
14+
const [sowAccepted, setSowAccepted] = useState(false)
1315
const handleClose = () => setShow(false)
1416
const handleShow = () => setShow(true)
1517

@@ -34,30 +36,47 @@ const Document = ({ accessToken, addClass, acceptSOW, document, request }) => {
3436
</div>
3537
</div>
3638
<Offcanvas show={show} onHide={handleClose} placement='end' scroll='true'>
37-
<Offcanvas.Header className='d-flex' closeButton>
39+
<Offcanvas.Header className={`d-flex border-bottom px-3 py-2 bg-${backgroundColor}-8`} closeButton>
3840
<Offcanvas.Title> {documentType}: #{identifier}</Offcanvas.Title>
39-
<div className='ms-auto me-2'>
40-
<Dropdown>
41-
<Dropdown.Toggle variant='light' id='dropdown-basic' size='small' className='border'>
42-
Next Actions
43-
</Dropdown.Toggle>
44-
<Dropdown.Menu>
45-
{/* TODO: @summer-cook SOW should have submit for approval. It should also ONLY show the submit for approval when the SOW has not yet been submitted. Need to figure out a way to tell if it has been submitted or not. . */}
46-
<Dropdown.Item
47-
href='#/action-1'
48-
onClick={() => {acceptSOW({
49-
request: request,
50-
sowID: sowID,
51-
accessToken: accessToken,
52-
})}}
53-
>
54-
Submit for Approval
55-
</Dropdown.Item>
56-
</Dropdown.Menu>
57-
</Dropdown>
58-
</div>
41+
{documentType === 'SOW' &&
42+
<div className='ms-auto me-2'>
43+
<Dropdown>
44+
<Dropdown.Toggle id='next-actions-dropdown' size='small' className='btn-outline-dark' variant={`btn-${backgroundColor}`}>
45+
Next Actions
46+
</Dropdown.Toggle>
47+
<Dropdown.Menu>
48+
{/* TODO: @summer-cook SOW should have submit for approval. It should also ONLY show the submit for approval when the SOW has not yet been submitted. Need to figure out a way to tell if it has been submitted or not. . */}
49+
<Dropdown.Item
50+
href='#/action-1'
51+
onClick={() => {
52+
acceptSOW({
53+
request: request,
54+
sowID: sowID,
55+
accessToken: accessToken,
56+
})
57+
setSowAccepted(true)
58+
}}
59+
>
60+
Submit for Approval
61+
</Dropdown.Item>
62+
</Dropdown.Menu>
63+
</Dropdown>
64+
</div>
65+
}
5966
</Offcanvas.Header>
6067
<Offcanvas.Body>
68+
{sowAccepted &&
69+
<Row>
70+
<Notice
71+
addClass='my-3'
72+
alert={{
73+
body: [`SOW ${identifier} has been accepted successfully. Now awaiting purchase order.`],
74+
variant: 'success',
75+
onClose: () => setSowAccepted(false)
76+
}}
77+
/>
78+
</Row>
79+
}
6180
<div className='d-block d-md-flex justify-content-between'>
6281
<div className='details'>
6382
<h6>Details:</h6>
@@ -98,6 +117,7 @@ const Document = ({ accessToken, addClass, acceptSOW, document, request }) => {
98117

99118
Document.propTypes = {
100119
addClass: PropTypes.string,
120+
backgroundColor: PropTypes.string,
101121
accessToken: PropTypes.string.isRequired,
102122
acceptSOW: PropTypes.func.isRequired,
103123
document: PropTypes.shape({
@@ -127,6 +147,7 @@ Document.propTypes = {
127147

128148
Document.defaultProps = {
129149
addClass: '',
150+
backgroundColor: 'secondary',
130151
document: {
131152
documentTypeColor: 'bg-dark',
132153
documentStatusColor: 'bg-secondary',

0 commit comments

Comments
 (0)