Skip to content

Commit

Permalink
fix: clear selected from Redux when editing a new dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo committed Mar 2, 2023
1 parent b777a0d commit 440f7c4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/pages/edit/NewDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import i18n from '@dhis2/d2-i18n'
import cx from 'classnames'
import PropTypes from 'prop-types'
import React, { useState, useEffect } from 'react'
import { connect } from 'react-redux'
import { connect, useDispatch } from 'react-redux'
import { Redirect } from 'react-router-dom'
import { acSetEditNewDashboard } from '../../actions/editDashboard.js'
import { acClearSelected } from '../../actions/selected.js'
import DashboardContainer from '../../components/DashboardContainer.js'
import Notice from '../../components/Notice.js'
import { useWindowDimensions } from '../../components/WindowDimensionsProvider.js'
Expand All @@ -18,6 +19,7 @@ import classes from './styles/NewDashboard.module.css'
import TitleBar from './TitleBar.js'

const NewDashboard = (props) => {
const dispatch = useDispatch()
const { width } = useWindowDimensions()
const [redirectUrl, setRedirectUrl] = useState(null)

Expand All @@ -27,7 +29,9 @@ const NewDashboard = (props) => {
return
}
setHeaderbarVisible(true)
props.setNewDashboard()

dispatch(acSetEditNewDashboard())
dispatch(acClearSelected())
}, [])

if (redirectUrl) {
Expand Down Expand Up @@ -63,13 +67,10 @@ const NewDashboard = (props) => {

NewDashboard.propTypes = {
isPrintPreviewView: PropTypes.bool,
setNewDashboard: PropTypes.func,
}

const mapStateToProps = (state) => ({
isPrintPreviewView: sGetIsPrintPreviewView(state),
})

export default connect(mapStateToProps, {
setNewDashboard: acSetEditNewDashboard,
})(NewDashboard)
export default connect(mapStateToProps)(NewDashboard)

0 comments on commit 440f7c4

Please sign in to comment.