import React, { useState } from 'react'; import PropTypes from 'prop-types'; import { useSelector, useDispatch } from 'react-redux'; import { redux } from '@ohif/core'; import { TabFooter, useSnackbarContext } from '@ohif/ui'; import { useTranslation } from 'react-i18next'; const { actions } = redux; import './WindowLevelPreferences.styl'; function WindowLevelPreferences({ onClose }) { const dispatch = useDispatch(); const windowLevelData = useSelector(state => { const { preferences = {} } = state; const { windowLevelData } = preferences; return windowLevelData; }); const [state, setState] = useState({ values: { ...windowLevelData }, }); const { t } = useTranslation('UserPreferencesModal'); const onResetPreferences = () => {}; const hasErrors = false; const onSave = () => { dispatch(actions.setUserPreferences({ windowLevelData: state.values })); onClose(); snackbar.show({ message: t('SaveMessage'), type: 'success', }); }; const snackbar = useSnackbarContext(); const handleInputChange = event => { const $target = event.target; const { key, inputname } = $target.dataset; const inputValue = $target.value; if (!state.values[key] || !state.values[key][inputname]) { return; } setState(prevState => ({ ...prevState, values: { ...prevState.values, [key]: { ...prevState.values[key], [inputname]: inputValue, }, }, })); }; return (
Preset
Description
Window
Level
{Object.keys(state.values).map((key, index) => { return (
{key}
); })}
); } WindowLevelPreferences.propTypes = { onClose: PropTypes.func, }; export { WindowLevelPreferences };