diff --git a/src/components/User/Client/ClientProfile.jsx b/src/components/User/Client/ClientProfile.jsx index 0e6322b..b1cdddc 100644 --- a/src/components/User/Client/ClientProfile.jsx +++ b/src/components/User/Client/ClientProfile.jsx @@ -3,10 +3,18 @@ import { connect } from "react-redux"; import { Link } from "react-router-dom"; import { Card, Button, Label } from "semantic-ui-react"; +import { deleteWorktypeRequest } from "../../../actions/worktype/saga.actions"; + class ClientProfile extends Component { + deleteWorkType = uuid => { + this.props.dispatch(deleteWorktypeRequest(uuid)); + }; + render() { const { selfUser } = this.props; - return ; + return ( + + ); } } @@ -14,7 +22,7 @@ function mapStateToProps(state) { return { ...state.user }; } -const ClientProfileView = ({ user }) => ( +const ClientProfileView = ({ user, deleteWorkType }) => (
@@ -33,41 +41,51 @@ const ClientProfileView = ({ user }) => ( - {(user.client.work_types || []).length && + {(user.client.work_types || []).filter(worktype => !worktype.deleted) + .length > 0 && - {user.client.work_types.map((worktype, index) => ( - - - - - - Worktype - - - - - - - - - - ))} + {user.client.work_types + .filter(worktype => !worktype.deleted) + .map((worktype, index) => ( + + + + + + Worktype + + + + + + + + + + ))} }
); diff --git a/src/components/User/Client/CreateWorkTypeForm.jsx b/src/components/User/Client/CreateWorkTypeForm.jsx index c8b68e0..281cece 100644 --- a/src/components/User/Client/CreateWorkTypeForm.jsx +++ b/src/components/User/Client/CreateWorkTypeForm.jsx @@ -16,6 +16,8 @@ class CreateWorkTypeForm extends Component { componentWillUnmount = () => { this.props.dispatch(clearWorktypeRequestError()); this.props.dispatch(clearWorktypeRequestSuccess()); + this.props.dispatch(setFormWorktypeColor("")); + this.props.dispatch(setFormWorktypeLabel("")); }; changeLabel = event => { diff --git a/src/components/User/Client/UpdateWorkTypeForm.jsx b/src/components/User/Client/UpdateWorkTypeForm.jsx index 95a3850..c4122bc 100644 --- a/src/components/User/Client/UpdateWorkTypeForm.jsx +++ b/src/components/User/Client/UpdateWorkTypeForm.jsx @@ -6,7 +6,8 @@ import { Container, Form, Header, Label, Message } from "semantic-ui-react"; import { clearWorktypeRequestError, clearWorktypeRequestSuccess, - setFormWorktypeColor + setFormWorktypeColor, + setFormWorktypeLabel } from "../../../actions/worktype/reducer.actions"; import { updateWorktypeRequest, readWorktypeRequest } from "../../../actions/worktype/saga.actions"; import Error from "../../Shared/Error"; @@ -20,6 +21,8 @@ class UpdateWorkTypeForm extends Component { componentWillUnmount = () => { this.props.dispatch(clearWorktypeRequestError()); this.props.dispatch(clearWorktypeRequestSuccess()); + this.props.dispatch(setFormWorktypeColor("")); + this.props.dispatch(setFormWorktypeLabel("")); }; changeColor = color => { diff --git a/src/components/User/Profile.jsx b/src/components/User/Profile.jsx index 9aedb8b..5bd0b39 100644 --- a/src/components/User/Profile.jsx +++ b/src/components/User/Profile.jsx @@ -4,6 +4,7 @@ import { Link } from "react-router-dom"; import { Card, Container, Header, Label, List } from "semantic-ui-react"; import ClientProfile from "./Client/ClientProfile"; +import ProviderProfile from "./Provider/ProviderProfile"; class Profile extends Component { render() { @@ -37,16 +38,11 @@ const ProfileView = ({ user }) => ( "User Registration Not Completed"} {user.first_name} {user.last_name} - {user.userinfo && - - {Object.keys(user.userinfo).map(function(key) { - return ( - - {key}: {user.userinfo[key]} - - ); - })} - } + + + Phone Number: {user.userinfo.phone_number} + + @@ -54,7 +50,7 @@ const ProfileView = ({ user }) => ( {user.client && } - {user.provider &&
} + {user.provider && } ); diff --git a/src/components/User/Provider/ProviderProfile.jsx b/src/components/User/Provider/ProviderProfile.jsx new file mode 100644 index 0000000..318361d --- /dev/null +++ b/src/components/User/Provider/ProviderProfile.jsx @@ -0,0 +1,29 @@ +import React, { Component } from "react"; +import { connect } from "react-redux"; +import { Card } from "semantic-ui-react"; + +class ProviderProfile extends Component { + render() { + const { selfUser } = this.props; + return ( + + ); + } +} + +function mapStateToProps(state) { + return { ...state.user }; +} + +const ProviderProfileView = ({ user }) => ( +
+ + + Provider Information + Social Insurance Number: {user.provider.sin} + + +
+); + +export default connect(mapStateToProps)(ProviderProfile); diff --git a/src/sagas/index.js b/src/sagas/index.js index 2d187c4..e319e0b 100644 --- a/src/sagas/index.js +++ b/src/sagas/index.js @@ -38,12 +38,14 @@ import { import { CREATE_WORKTYPE_REQUEST, READ_WORKTYPE_REQUEST, - UPDATE_WORKTYPE_REQUEST + UPDATE_WORKTYPE_REQUEST, + DELETE_WORKTYPE_REQUEST } from "../constants/worktype.constants"; import { createWorktypeFlow, readWorktypeFlow, - updateWorktypeFlow + updateWorktypeFlow, + deleteWorktypeFlow } from "./worktype.sagas"; export default function* rootSaga() { @@ -64,4 +66,5 @@ export default function* rootSaga() { yield takeLatest(CREATE_WORKTYPE_REQUEST, createWorktypeFlow); yield takeLatest(READ_WORKTYPE_REQUEST, readWorktypeFlow); yield takeLatest(UPDATE_WORKTYPE_REQUEST, updateWorktypeFlow); + yield takeLatest(DELETE_WORKTYPE_REQUEST, deleteWorktypeFlow); } diff --git a/src/sagas/worktype.sagas.js b/src/sagas/worktype.sagas.js index 03f7293..ca8152b 100644 --- a/src/sagas/worktype.sagas.js +++ b/src/sagas/worktype.sagas.js @@ -55,6 +55,18 @@ function* updateWorktypeCall(payload) { } } +function* deleteWorktypeCall(uuid) { + yield effects.put(isSendingWorktypeRequest(true)); + try { + return yield effects.call(deleteWorktype, uuid); + } catch (exception) { + yield effects.put(setWorktypeRequestError(exception)); + return false; + } finally { + yield effects.put(isSendingWorktypeRequest(false)); + } +} + export function* createWorktypeFlow(request) { yield effects.put(clearWorktypeRequestSuccess()); yield effects.put(clearWorktypeRequestError()); @@ -86,3 +98,8 @@ export function* updateWorktypeFlow(request) { yield effects.put(setWorktypeRequestSuccess(wasSuccessful)); } } + +export function* deleteWorktypeFlow(request) { + yield effects.call(deleteWorktypeCall, request.data); + yield effects.put(getSelfUserRequest()); +}