Remove use-toast.tsx, refactor auth methods, and update UI components

This commit removes the redundant `use-toast.tsx` file and refactors the authentication methods in `personal-accounts-server-actions.ts` to enhance service integration and data handling. UI components like `LanguageDropdownSwitcher` and `site-header-account-section.tsx` have been refined for better readability. Changes in the `config.tsx` file aim to improve the overall code cleanliness. The `schema.sql` file under migrations was updated to cascade delete for 'invited_by' reference.
This commit is contained in:
giancarlo
2024-03-27 01:37:34 +08:00
parent 8a614bd6fc
commit 6699399864
10 changed files with 28 additions and 208 deletions

View File

@@ -2,9 +2,9 @@
import { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useRouter } from 'next/navigation';
import useRefresh from '@kit/shared/hooks/use-refresh';
import { useTranslation } from 'react-i18next';
import {
Select,
@@ -14,11 +14,11 @@ import {
SelectValue,
} from '../shadcn/select';
const LanguageDropdownSwitcher: React.FC<{
export const LanguageDropdownSwitcher: React.FC<{
onChange?: (locale: string) => unknown;
}> = ({ onChange }) => {
const { i18n } = useTranslation();
const refresh = useRefresh();
const router = useRouter();
const { language: currentLanguage, options } = i18n;
@@ -43,9 +43,10 @@ const LanguageDropdownSwitcher: React.FC<{
}
await i18n.changeLanguage(locale);
return refresh();
return router.refresh();
},
[i18n, onChange, refresh],
[i18n, onChange, router],
);
return (
@@ -77,5 +78,3 @@ const LanguageDropdownSwitcher: React.FC<{
function capitalize(lang: string) {
return lang.slice(0, 1).toUpperCase() + lang.slice(1);
}
export default LanguageDropdownSwitcher;