2017-09-21 21:01:49 +00:00
|
|
|
import React, { Component } from "react";
|
|
|
|
import { connect } from "react-redux";
|
|
|
|
import { Link } from "react-router-dom";
|
|
|
|
import { Card, Button, Label } from "semantic-ui-react";
|
|
|
|
|
2017-09-21 21:40:46 +00:00
|
|
|
import { deleteWorktypeRequest } from "../../../actions/worktype/saga.actions";
|
|
|
|
|
2017-09-21 21:01:49 +00:00
|
|
|
class ClientProfile extends Component {
|
2017-09-21 21:40:46 +00:00
|
|
|
deleteWorkType = uuid => {
|
|
|
|
this.props.dispatch(deleteWorktypeRequest(uuid));
|
|
|
|
};
|
|
|
|
|
2017-09-21 21:01:49 +00:00
|
|
|
render() {
|
|
|
|
const { selfUser } = this.props;
|
2017-09-21 21:40:46 +00:00
|
|
|
return (
|
|
|
|
<ClientProfileView user={selfUser} deleteWorkType={this.deleteWorkType} />
|
|
|
|
);
|
2017-09-21 21:01:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapStateToProps(state) {
|
|
|
|
return { ...state.user };
|
|
|
|
}
|
|
|
|
|
2017-09-21 21:40:46 +00:00
|
|
|
const ClientProfileView = ({ user, deleteWorkType }) => (
|
2017-09-21 21:01:49 +00:00
|
|
|
<div>
|
|
|
|
<Card fluid={true}>
|
|
|
|
<Card.Content>
|
|
|
|
<Card.Header>Client Information</Card.Header>
|
|
|
|
<Card.Meta>Business Number: {user.client.business_number}</Card.Meta>
|
|
|
|
<Card.Description>
|
|
|
|
<Button
|
|
|
|
basic
|
|
|
|
color="green"
|
|
|
|
size="small"
|
|
|
|
as={Link}
|
|
|
|
to="/user/profile/client/create-worktype"
|
|
|
|
>
|
|
|
|
Create Worktype
|
|
|
|
</Button>
|
|
|
|
</Card.Description>
|
|
|
|
</Card.Content>
|
|
|
|
</Card>
|
2017-09-21 21:40:46 +00:00
|
|
|
{(user.client.work_types || []).filter(worktype => !worktype.deleted)
|
|
|
|
.length > 0 &&
|
2017-09-21 21:01:49 +00:00
|
|
|
<Card.Group>
|
2017-09-21 21:40:46 +00:00
|
|
|
{user.client.work_types
|
|
|
|
.filter(worktype => !worktype.deleted)
|
|
|
|
.map((worktype, index) => (
|
|
|
|
<Card key={index}>
|
|
|
|
<Card.Content>
|
|
|
|
<Card.Header as="h4">
|
|
|
|
<Label
|
|
|
|
circular
|
|
|
|
empty
|
|
|
|
style={{
|
|
|
|
backgroundColor: worktype.color,
|
|
|
|
borderColor: worktype.color
|
|
|
|
}}
|
|
|
|
/>{" " + worktype.label}
|
|
|
|
</Card.Header>
|
|
|
|
<Card.Meta>
|
|
|
|
Worktype
|
|
|
|
</Card.Meta>
|
|
|
|
</Card.Content>
|
|
|
|
<Card.Content extra>
|
|
|
|
<Button.Group>
|
|
|
|
<Button
|
|
|
|
basic
|
|
|
|
color="yellow"
|
|
|
|
size="small"
|
|
|
|
as={Link}
|
|
|
|
to={`/user/profile/client/update-worktype/${worktype.uuid}`}
|
|
|
|
>
|
|
|
|
Edit
|
|
|
|
</Button>
|
|
|
|
<Button
|
|
|
|
basic
|
|
|
|
color="red"
|
|
|
|
size="small"
|
|
|
|
onClick={() => deleteWorkType(worktype.uuid)}
|
|
|
|
>
|
|
|
|
Delete
|
|
|
|
</Button>
|
|
|
|
</Button.Group>
|
|
|
|
</Card.Content>
|
|
|
|
</Card>
|
|
|
|
))}
|
2017-09-21 21:01:49 +00:00
|
|
|
</Card.Group>}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default connect(mapStateToProps)(ClientProfile);
|