| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import React, { useMemo } from 'react';
- import { useTranslation } from 'next-i18next';
- import CustomNavAndContents from '../CustomNavigation/CustomNavAndContents';
- import ApiSettings from './ApiSettings';
- // import { EditorSettings } from './EditorSettings';
- import ExternalAccountLinkedMe from './ExternalAccountLinkedMe';
- import InAppNotificationSettings from './InAppNotificationSettings';
- import OtherSettings from './OtherSettings';
- import PasswordSettings from './PasswordSettings';
- import UserSettings from './UserSettings';
- const PersonalSettings = () => {
- const { t } = useTranslation();
- const navTabMapping = useMemo(() => {
- return {
- user_infomation: {
- Icon: () => <span className="material-symbols-outlined fs-5 me-1">person</span>,
- Content: UserSettings,
- i18n: t('User Information'),
- },
- external_accounts: {
- Icon: () => <span className="material-symbols-outlined fs-5 me-1">ungroup</span>,
- Content: ExternalAccountLinkedMe,
- i18n: t('admin:user_management.external_accounts'),
- },
- password_settings: {
- Icon: () => <span className="material-symbols-outlined fs-5 me-1">password</span>,
- Content: PasswordSettings,
- i18n: t('Password Settings'),
- },
- api_settings: {
- Icon: () => <span className="material-symbols-outlined fs-5 me-1">api</span>,
- Content: ApiSettings,
- i18n: t('API Settings'),
- },
- // editor_settings: {
- // Icon: () => <span className="material-symbols-outlined fs-5 me-1">edit</span>,
- // Content: EditorSettings,
- // i18n: t('editor_settings.editor_settings'),
- // },
- in_app_notification_settings: {
- Icon: () => <span className="material-symbols-outlined fs-5 me-1">notifications</span>,
- Content: InAppNotificationSettings,
- i18n: t('in_app_notification_settings.in_app_notification_settings'),
- },
- other_settings: {
- Icon: () => <span className="material-symbols-outlined fs-5 me-1">settings</span>,
- Content: OtherSettings,
- i18n: t('Other Settings'),
- },
- };
- }, [t]);
- const getDefaultTabIndex = () => {
- // e.g) '/me#password_settings' sets password settings tab as default
- const tab = window.location.hash?.substring(1);
- let defaultTabIndex;
- Object.keys(navTabMapping).forEach((key, i) => {
- if (key === tab) { defaultTabIndex = i }
- });
- return defaultTabIndex;
- };
- return (
- <div data-testid="grw-personal-settings">
- <CustomNavAndContents defaultTabIndex={getDefaultTabIndex()} navTabMapping={navTabMapping} navigationMode="both" tabContentClasses={['px-0']} />
- </div>
- );
- };
- export default PersonalSettings;
|