1
1
import React , { useState } from 'react'
2
2
import PropTypes from 'prop-types'
3
- import { Dropdown , Offcanvas } from 'react-bootstrap'
3
+ import { Dropdown , Offcanvas , Row } from 'react-bootstrap'
4
4
import LineItemsTable from '../../components/LineItemsTable/LineItemsTable'
5
+ import Notice from '../../components/Notice/Notice'
6
+ import { allowNull } from '../../resources/utilityFunctions'
5
7
import './document.scss'
6
8
7
- const Document = ( { document , addClass } ) => {
9
+ const Document = ( { acceptSOW , addClass, backgroundColor , document } ) => {
8
10
const {
9
11
adPO, date, documentStatusColor, documentType, documentTypeColor, documentStatus, identifier, lineItems, poNumber,
10
12
relatedSOWIdentifier, requestIdentifier, shippingPrice, shipTo, shipFrom, subtotalPrice, taxAmount, terms, totalPrice,
11
13
turnaroundTime,
12
14
} = document
13
15
const [ show , setShow ] = useState ( false )
16
+ const [ showNotice , setShowNotice ] = useState ( false )
14
17
const handleClose = ( ) => setShow ( false )
15
18
const handleShow = ( ) => setShow ( true )
16
19
@@ -35,22 +38,43 @@ const Document = ({ document, addClass }) => {
35
38
</ div >
36
39
</ div >
37
40
< 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 >
39
42
< 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
+ ) }
52
64
</ Offcanvas . Header >
53
65
< 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
+ ) }
54
78
< div className = 'd-block d-md-flex justify-content-between' >
55
79
< div className = 'details' >
56
80
< h5 > Details:</ h5 >
@@ -95,6 +119,8 @@ const Document = ({ document, addClass }) => {
95
119
96
120
Document . propTypes = {
97
121
addClass : PropTypes . string ,
122
+ backgroundColor : PropTypes . string ,
123
+ acceptSOW : PropTypes . func . isRequired ,
98
124
document : PropTypes . shape ( {
99
125
adPO : PropTypes . string ,
100
126
identifier : PropTypes . string . isRequired ,
@@ -116,6 +142,7 @@ Document.propTypes = {
116
142
organizationName : PropTypes . string ,
117
143
text : PropTypes . string ,
118
144
} ) . isRequired ,
145
+ sowID : allowNull ( PropTypes . string ) ,
119
146
subtotalPrice : PropTypes . string . isRequired ,
120
147
taxAmount : PropTypes . string . isRequired ,
121
148
terms : PropTypes . string . isRequired ,
@@ -126,6 +153,7 @@ Document.propTypes = {
126
153
127
154
Document . defaultProps = {
128
155
addClass : '' ,
156
+ backgroundColor : 'secondary' ,
129
157
document : {
130
158
documentTypeColor : 'bg-dark' ,
131
159
documentStatusColor : 'bg-secondary' ,
0 commit comments