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

108 lines
4.9 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';
2024-07-12 20:22:09 +02:00
import AvatarSettings from './avatar-settings';
import BlockedAddressesSetting from './blocked-addresses-setting';
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-06-18 11:50:17 +02:00
import PlebbitOptions from './plebbit-options';
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);
2024-07-12 20:22:09 +02:00
const [showAvatarSettings, setShowAvatarSettings] = useState(false);
const [showCryptoAddressSetting, setShowCryptoAddressSetting] = useState(false);
const [showCryptoWalletSettings, setShowCryptoWalletSettings] = useState(false);
const [showBlockedAddressesSetting, setShowBlockedAddressesSetting] = useState(false);
2024-06-18 11:50:17 +02:00
const [showPlebbitOptionsSettings, setShowPlebbitOptionsSettings] = 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);
2024-07-12 20:22:09 +02:00
setShowAvatarSettings(newExpandState);
2024-05-16 22:00:22 +02:00
setShowCryptoAddressSetting(newExpandState);
setShowCryptoWalletSettings(newExpandState);
setShowBlockedAddressesSetting(newExpandState);
2024-06-18 11:50:17 +02:00
setShowPlebbitOptionsSettings(newExpandState);
2024-05-16 22:00:22 +02:00
};
2024-05-10 17:03:33 +02:00
return (
<>
<div className={styles.overlay} onClick={closeModal} />
<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 />}
2024-07-12 20:22:09 +02:00
<div className={`${styles.setting} ${styles.category}`}>
<label onClick={() => setShowAvatarSettings(!showAvatarSettings)}>
<span className={showAvatarSettings ? styles.hideButton : styles.showButton} />
{t('avatar')}
</label>
</div>
{showAvatarSettings && <AvatarSettings />}
<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 className={`${styles.setting} ${styles.category}`}>
<label onClick={() => setShowBlockedAddressesSetting(!showBlockedAddressesSetting)}>
<span className={showBlockedAddressesSetting ? styles.hideButton : styles.showButton} />
{t('blocked_addresses')}
</label>
</div>
{showBlockedAddressesSetting && <BlockedAddressesSetting />}
2024-06-18 11:50:17 +02:00
<div className={`${styles.setting} ${styles.category}`}>
<label onClick={() => setShowPlebbitOptionsSettings(!showPlebbitOptionsSettings)}>
<span className={showPlebbitOptionsSettings ? styles.hideButton : styles.showButton} />
{t('plebbit_options')}
</label>
</div>
{showPlebbitOptionsSettings && <PlebbitOptions />}
</div>
</>
);
};
2024-05-09 16:04:24 +02:00
export default SettingsModal;