import { SaveOutlined } from '@ant-design/icons'; import { Col, Divider, Input, Space, Typography } from 'antd'; import AddTags from 'container/NewDashboard/DashboardSettings/General/AddTags'; import { useCallback, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { connect, useSelector } from 'react-redux'; import { bindActionCreators, Dispatch } from 'redux'; import { ThunkDispatch } from 'redux-thunk'; import { UpdateDashboardTitleDescriptionTags, UpdateDashboardTitleDescriptionTagsProps, } from 'store/actions'; import { AppState } from 'store/reducers'; import AppActions from 'types/actions'; import DashboardReducer from 'types/reducer/dashboards'; import { Button } from './styles'; function GeneralDashboardSettings({ updateDashboardTitleDescriptionTags, }: DescriptionOfDashboardProps): JSX.Element { const { dashboards } = useSelector( (state) => state.dashboards, ); const [selectedDashboard] = dashboards; const selectedData = selectedDashboard.data; const { title } = selectedData; const { tags } = selectedData; const { description } = selectedData; const [updatedTitle, setUpdatedTitle] = useState(title); const [updatedTags, setUpdatedTags] = useState(tags || []); const [updatedDescription, setUpdatedDescription] = useState( description || '', ); const { t } = useTranslation('common'); const onSaveHandler = useCallback(() => { const dashboard = selectedDashboard; // @TODO need to update this function to take title,description,tags only updateDashboardTitleDescriptionTags({ dashboard: { ...dashboard, data: { ...dashboard.data, description: updatedDescription, tags: updatedTags, title: updatedTitle, }, }, }); }, [ updatedTitle, updatedTags, updatedDescription, selectedDashboard, updateDashboardTitleDescriptionTags, ]); return (
Name setUpdatedTitle(e.target.value)} />
Description setUpdatedDescription(e.target.value)} />
Tags
); } interface DispatchProps { updateDashboardTitleDescriptionTags: ( props: UpdateDashboardTitleDescriptionTagsProps, ) => (dispatch: Dispatch) => void; } const mapDispatchToProps = ( dispatch: ThunkDispatch, ): DispatchProps => ({ updateDashboardTitleDescriptionTags: bindActionCreators( UpdateDashboardTitleDescriptionTags, dispatch, ), }); type DescriptionOfDashboardProps = DispatchProps; export default connect(null, mapDispatchToProps)(GeneralDashboardSettings);