File tree Expand file tree Collapse file tree
src/admin/client/modules/apps Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { Link } from 'react-router-dom' ;
3+ import messages from 'lib/text' ;
4+ import DeleteConfirmation from 'modules/shared/deleteConfirmation' ;
5+ import FontIcon from 'material-ui/FontIcon' ;
6+ import IconButton from 'material-ui/IconButton' ;
7+ import FlatButton from 'material-ui/FlatButton' ;
8+ const Fragment = React . Fragment ;
9+
10+ export default class Buttons extends React . Component {
11+ constructor ( props ) {
12+ super ( props ) ;
13+ this . state = {
14+ openDelete : false
15+ } ;
16+ }
17+
18+ openDelete = ( ) => {
19+ this . setState ( { openDelete : true } ) ;
20+ } ;
21+
22+ closeDelete = ( ) => {
23+ this . setState ( { openDelete : false } ) ;
24+ } ;
25+
26+ deleteOrder = ( ) => {
27+ this . closeDelete ( ) ;
28+ this . props . onDelete ( ) ;
29+ } ;
30+
31+ render ( ) {
32+ const { customer } = this . props ;
33+ const customerName =
34+ customer && customer . full_name && customer . full_name . length > 0
35+ ? customer . full_name
36+ : 'Draft' ;
37+
38+ return (
39+ < Fragment >
40+ < IconButton
41+ touch = { true }
42+ tooltipPosition = "bottom-left"
43+ tooltip = { messages . actions_delete }
44+ onClick = { this . openDelete }
45+ >
46+ < FontIcon color = "#fff" className = "material-icons" >
47+ delete
48+ </ FontIcon >
49+ </ IconButton >
50+ < DeleteConfirmation
51+ open = { this . state . openDelete }
52+ isSingle = { true }
53+ itemsCount = { 1 }
54+ itemName = { customerName }
55+ onCancel = { this . closeDelete }
56+ onDelete = { this . props . onDelete }
57+ />
58+ </ Fragment >
59+ ) ;
60+ }
61+ }
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { connect } from 'react-redux' ;
3+ import { withRouter } from 'react-router' ;
4+ import { deleteCurrentCustomer } from '../actions' ;
5+ import Buttons from './components/buttons' ;
6+
7+ const mapStateToProps = ( state , ownProps ) => {
8+ return {
9+ customer : state . customers . editCustomer
10+ } ;
11+ } ;
12+
13+ const mapDispatchToProps = ( dispatch , ownProps ) => {
14+ return {
15+ onDelete : ( ) => {
16+ dispatch ( deleteCurrentCustomer ( ) ) ;
17+ ownProps . history . push ( '/admin/customers' ) ;
18+ }
19+ } ;
20+ } ;
21+
22+ export default withRouter (
23+ connect (
24+ mapStateToProps ,
25+ mapDispatchToProps
26+ ) ( Buttons )
27+ ) ;
You can’t perform that action at this time.
0 commit comments