PersonalSettings.jsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import React, { useMemo } from 'react';
  2. import { useTranslation } from 'next-i18next';
  3. import CustomNavAndContents from '../CustomNavigation/CustomNavAndContents';
  4. import ApiSettings from './ApiSettings';
  5. // import { EditorSettings } from './EditorSettings';
  6. import ExternalAccountLinkedMe from './ExternalAccountLinkedMe';
  7. import InAppNotificationSettings from './InAppNotificationSettings';
  8. import OtherSettings from './OtherSettings';
  9. import PasswordSettings from './PasswordSettings';
  10. import UserSettings from './UserSettings';
  11. const PersonalSettings = () => {
  12. const { t } = useTranslation();
  13. const navTabMapping = useMemo(() => {
  14. return {
  15. user_infomation: {
  16. Icon: () => <span className="material-symbols-outlined">person</span>,
  17. Content: UserSettings,
  18. i18n: t('User Information'),
  19. },
  20. external_accounts: {
  21. Icon: () => <span className="material-symbols-outlined">ungroup</span>,
  22. Content: ExternalAccountLinkedMe,
  23. i18n: t('admin:user_management.external_accounts'),
  24. },
  25. password_settings: {
  26. Icon: () => <span className="material-symbols-outlined">password</span>,
  27. Content: PasswordSettings,
  28. i18n: t('Password Settings'),
  29. },
  30. api_settings: {
  31. Icon: () => <span className="material-symbols-outlined">api</span>,
  32. Content: ApiSettings,
  33. i18n: t('API Settings'),
  34. },
  35. // editor_settings: {
  36. // Icon: () => <span className="material-symbols-outlined">edit</span>,
  37. // Content: EditorSettings,
  38. // i18n: t('editor_settings.editor_settings'),
  39. // },
  40. in_app_notification_settings: {
  41. Icon: () => <span className="material-symbols-outlined">notifications</span>,
  42. Content: InAppNotificationSettings,
  43. i18n: t('in_app_notification_settings.in_app_notification_settings'),
  44. },
  45. other_settings: {
  46. Icon: () => <span className="material-symbols-outlined">settings</span>,
  47. Content: OtherSettings,
  48. i18n: t('Other Settings'),
  49. },
  50. };
  51. }, [t]);
  52. const getDefaultTabIndex = () => {
  53. // e.g) '/me#password_settings' sets password settings tab as default
  54. const tab = window.location.hash?.substring(1);
  55. let defaultTabIndex;
  56. Object.keys(navTabMapping).forEach((key, i) => {
  57. if (key === tab) { defaultTabIndex = i }
  58. });
  59. return defaultTabIndex;
  60. };
  61. return (
  62. <div data-testid="grw-personal-settings">
  63. <CustomNavAndContents defaultTabIndex={getDefaultTabIndex()} navTabMapping={navTabMapping} navigationMode="both" tabContentClasses={['px-0']} />
  64. </div>
  65. );
  66. };
  67. export default PersonalSettings;