Files
5chan/src/components/settings-modal/settings-modal.tsx
T

78 lines
3.2 KiB
TypeScript
Raw Normal View History

import { useState } from 'react';
2024-05-09 16:04:24 +02:00
import { useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import styles from './settings-modal.module.css';
import AccountSettings from './account-settings';
import CryptoAddressSetting from './crypto-address-setting';
2024-05-15 21:20:14 +02:00
import CryptoWalletsSetting from './crypto-wallets-setting';
import InterfaceSettings from './interface-settings';
2024-05-10 17:03:33 +02:00
const SettingsModal = () => {
const { t } = useTranslation();
const navigate = useNavigate();
const closeModal = () => {
navigate(-1);
};
const [showInterfaceSettings, setShowInterfaceSettings] = useState(false);
2024-05-10 17:03:33 +02:00
const [showAccountSettings, setShowAccountSettings] = useState(false);
const [showCryptoAddressSetting, setShowCryptoAddressSetting] = useState(false);
const [showCryptoWalletSettings, setShowCryptoWalletSettings] = useState(false);
2024-05-16 22:00:22 +02:00
const [expandAll, setExpandAll] = useState(false);
const handleExpandAll = () => {
const newExpandState = !expandAll;
setExpandAll(newExpandState);
setShowInterfaceSettings(newExpandState);
2024-05-16 22:00:22 +02:00
setShowAccountSettings(newExpandState);
setShowCryptoAddressSetting(newExpandState);
setShowCryptoWalletSettings(newExpandState);
};
2024-05-10 17:03:33 +02:00
return (
<>
<div className={styles.overlay} onClick={closeModal}></div>
<div className={styles.settingsModal}>
<div className={styles.header}>
<span className={styles.title}>{t('settings')}</span>
<span className={styles.closeButton} title='close' onClick={closeModal} />
</div>
2024-05-16 22:00:22 +02:00
<div className={styles.expandAllSettings}>
2024-05-31 17:09:20 +02:00
[<span onClick={handleExpandAll}>{expandAll ? t('collapse_all_settings') : t('expand_all_settings')}</span>]
2024-05-16 22:00:22 +02:00
</div>
<div className={`${styles.setting} ${styles.category}`}>
<label onClick={() => setShowInterfaceSettings(!showInterfaceSettings)}>
<span className={showInterfaceSettings ? styles.hideButton : styles.showButton} />
2024-05-31 16:51:22 +02:00
{t('interface')}
</label>
</div>
{showInterfaceSettings && <InterfaceSettings />}
2024-05-10 17:03:33 +02:00
<div className={`${styles.setting} ${styles.category}`}>
<label onClick={() => setShowAccountSettings(!showAccountSettings)}>
<span className={showAccountSettings ? styles.hideButton : styles.showButton} />
2024-05-15 22:12:32 +02:00
{t('account')}
2024-05-10 17:03:33 +02:00
</label>
</div>
{showAccountSettings && <AccountSettings />}
<div className={`${styles.setting} ${styles.category}`}>
<label onClick={() => setShowCryptoAddressSetting(!showCryptoAddressSetting)}>
<span className={showCryptoAddressSetting ? styles.hideButton : styles.showButton} />
2024-05-15 22:12:32 +02:00
{t('crypto_address')}
</label>
</div>
{showCryptoAddressSetting && <CryptoAddressSetting />}
<div className={`${styles.setting} ${styles.category}`}>
<label onClick={() => setShowCryptoWalletSettings(!showCryptoWalletSettings)}>
<span className={showCryptoWalletSettings ? styles.hideButton : styles.showButton} />
2024-05-15 22:12:32 +02:00
{t('crypto_wallets')}
</label>
</div>
2024-05-15 21:20:14 +02:00
{showCryptoWalletSettings && <CryptoWalletsSetting />}
</div>
</>
);
};
2024-05-09 16:04:24 +02:00
export default SettingsModal;