diff options
Diffstat (limited to 'apps/Settings')
-rw-r--r-- | apps/Settings/api.js | 3 | ||||
-rw-r--r-- | apps/Settings/components/Settings.js | 51 |
2 files changed, 27 insertions, 27 deletions
diff --git a/apps/Settings/api.js b/apps/Settings/api.js index 559486f..f538368 100644 --- a/apps/Settings/api.js +++ b/apps/Settings/api.js @@ -4,7 +4,6 @@ export const saveSettings = async (data) => { fetchJson('/api/settings', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(data), + body: JSON.stringify(data) }) } - diff --git a/apps/Settings/components/Settings.js b/apps/Settings/components/Settings.js index c09a1bd..b4a5619 100644 --- a/apps/Settings/components/Settings.js +++ b/apps/Settings/components/Settings.js @@ -1,36 +1,36 @@ import styles from '../styles/Settings.module.scss' import React from 'react' -import {close} from 'helpers/windowActions' +import { close } from 'helpers/windowActions' import useUser from 'hooks/useUser' import usePopup from 'hooks/usePopup' import useSettings from 'hooks/useSettings' import useApps from 'hooks/useApps' -import {saveSettings} from '../api' +import { saveSettings } from '../api' const Settings = () => { - const {setPopup} = usePopup() - const {setApps} = useApps() - const {settings: {theme, language}, setSettings, t} = useSettings() - const {user} = useUser() + const { setPopup } = usePopup() + const { setApps } = useApps() + const { settings: { theme, language }, setSettings, t } = useSettings() + const { user } = useUser() const handleSave = e => { - e.preventDefault; + e.preventDefault() - saveSettings({_id: user._id, theme, language}) - .then(() => { - setPopup({ - content: t('settings_saved'), - time: 2000, + saveSettings({ _id: user._id, theme, language }) + .then(() => { + setPopup({ + content: t('settings_saved'), + time: 2000 + }) + close('Settings', setApps) }) - close('Settings', setApps) - }) - .catch(() => { - setpopup({ - content: t('settings_save_error'), - time: 2000, - error: true, + .catch(() => { + setPopup({ + content: t('settings_save_error'), + time: 2000, + error: true + }) }) - }) } return ( @@ -41,8 +41,9 @@ const Settings = () => { <span key={l} className={language === l ? styles.settings__langactive : ''} - onClick={()=>{setSettings(prev => ({...prev, language: l}))}} - >{l.toUpperCase()}</span> + onClick={() => { setSettings(prev => ({ ...prev, language: l })) }} + >{l.toUpperCase()} + </span> ))} </div> <div>{t('color_theme')}</div> @@ -50,14 +51,14 @@ const Settings = () => { {['green', 'blue', 'black'].map(c => ( <span key={c} - onClick={()=>{setSettings(prev => ({...prev, theme: c}))}} + onClick={() => { setSettings(prev => ({ ...prev, theme: c })) }} className={theme === c ? styles.settings__active : ''} /> ))} </div> <input - type="button" - className="window__button" + type='button' + className='window__button' value={t('save')} onClick={handleSave} /> |