From c4b371507d909a018fad2fef9c88e4188dfc2435 Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Thu, 5 May 2022 14:31:53 +0200 Subject: [PATCH] change(ui) - project delete moved to modal --- .../components/Client/Sites/NewSiteForm.js | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/frontend/app/components/Client/Sites/NewSiteForm.js b/frontend/app/components/Client/Sites/NewSiteForm.js index e58e95d4e..e7cd88f12 100644 --- a/frontend/app/components/Client/Sites/NewSiteForm.js +++ b/frontend/app/components/Client/Sites/NewSiteForm.js @@ -1,10 +1,11 @@ import { connect } from 'react-redux'; -import { Input, Button, Label } from 'UI'; -import { save, edit, update , fetchList } from 'Duck/site'; +import { Input, Button, Icon } from 'UI'; +import { save, edit, update , fetchList, remove } from 'Duck/site'; import { pushNewSite } from 'Duck/user'; import { setSiteId } from 'Duck/site'; import { withRouter } from 'react-router-dom'; import styles from './siteForm.css'; +import { confirm } from 'UI/Confirmation'; @connect(state => ({ site: state.getIn([ 'site', 'instance' ]), @@ -13,6 +14,7 @@ import styles from './siteForm.css'; loading: state.getIn([ 'site', 'save', 'loading' ]), }), { save, + remove, edit, update, pushNewSite, @@ -52,6 +54,17 @@ export default class NewSiteForm extends React.PureComponent { } } + remove = async (site) => { + if (await confirm({ + header: 'Projects', + confirmation: `Are you sure you want to delete this Project? We won't be able to record anymore sessions.` + })) { + this.props.remove(site.id).then(() => { + this.props.onClose(null) + }); + } + }; + edit = ({ target: { name, value } }) => { this.setState({ existsError: false }); this.props.edit({ [ name ]: value }); @@ -72,7 +85,7 @@ export default class NewSiteForm extends React.PureComponent { className={ styles.input } /> -
+
+ +
{ this.state.existsError &&
{ "Site exists already. Please choose another one." }