diff --git a/mpwo_client/src/actions/activities.js b/mpwo_client/src/actions/activities.js index d3c0d93a..0a5467a4 100644 --- a/mpwo_client/src/actions/activities.js +++ b/mpwo_client/src/actions/activities.js @@ -1,3 +1,4 @@ +import mpwoGenericApi from '../mwpoApi' import mpwoApi from '../mwpoApi/activities' import { history } from '../index' import { setError } from './index' @@ -46,3 +47,13 @@ export const getActivityGpx = activityId => dispatch => { } dispatch(setGpx(null)) } + +export const deleteActivity = id => dispatch => mpwoGenericApi + .deleteData('activities', id) + .then(ret => { + if (ret.status === 204) { + history.push('/') + } + dispatch(setError(`activities: ${ret.status}`)) + }) + .catch(error => dispatch(setError(`activities: ${error}`))) diff --git a/mpwo_client/src/components/Activities/ActivityDisplay.jsx b/mpwo_client/src/components/Activities/ActivityDisplay.jsx index 6775dc86..aee0f88c 100644 --- a/mpwo_client/src/components/Activities/ActivityDisplay.jsx +++ b/mpwo_client/src/components/Activities/ActivityDisplay.jsx @@ -3,16 +3,27 @@ import { Helmet } from 'react-helmet' import { connect } from 'react-redux' import ActivityMap from './ActivityMap' +import CustomModal from './../Others/CustomModal' import { getData } from '../../actions/index' +import { deleteActivity } from '../../actions/activities' class ActivityDisplay extends React.Component { + constructor(props, context) { + super(props, context) + this.state = { + displayModal: false, + } + } + componentDidMount() { this.props.loadActivity( this.props.location.pathname.replace('/activities/', '') ) } + render() { - const { activities, message, sports } = this.props + const { activities, message, onDeleteActivity, sports } = this.props + const { displayModal } = this.state const [activity] = activities return (
{message}
) : (
@@ -103,6 +130,9 @@ export default connect( user: state.user, }), dispatch => ({ + onDeleteActivity: activityId => { + dispatch(deleteActivity(activityId)) + }, loadActivity: activityId => { dispatch(getData('activities', activityId)) dispatch(getData('sports')) diff --git a/mpwo_client/src/components/App.css b/mpwo_client/src/components/App.css index d69bdd1f..731e28bc 100644 --- a/mpwo_client/src/components/App.css +++ b/mpwo_client/src/components/App.css @@ -23,15 +23,15 @@ } .App-nav-profile-img { - max-width: 35px; - max-height: 35px; - border-radius: 50%; + max-width: 35px; + max-height: 35px; + border-radius: 50%; } .App-profile-img-small { - max-width: 150px; - max-height: 150px; - border-radius: 50%; + max-width: 150px; + max-height: 150px; + border-radius: 50%; } @keyframes App-logo-spin { @@ -72,3 +72,22 @@ input, textarea { .radioLabel { text-align: center; } + +.custom-modal { + background-color: #fff; + border-radius: 5px; + max-width: 500px; + margin: 20% auto; + z-index: 1050; +} + +.custom-modal-backdrop { + position: fixed; + top: 0; + bottom: 0; + left: 0; + right: 0; + background-color: rgba(0,0,0,0.3); + padding: 50px; + z-index: 1040; +} diff --git a/mpwo_client/src/components/Others/CustomModal.jsx b/mpwo_client/src/components/Others/CustomModal.jsx new file mode 100644 index 00000000..58ac9817 --- /dev/null +++ b/mpwo_client/src/components/Others/CustomModal.jsx @@ -0,0 +1,42 @@ +import React from 'react' + +export default function CustomModal(props) { + return ( +
{props.text}
+