Merge branch 'dev' into add-umami
This commit is contained in:
@@ -21,6 +21,7 @@ import { ConfigProvider } from '~/config/provider';
|
||||
import { env } from '~/env.js';
|
||||
import { ColorSchemeProvider } from '~/hooks/use-colorscheme';
|
||||
import { modals } from '~/modals';
|
||||
import { usePackageAttributesStore } from '~/tools/client/zustands/usePackageAttributesStore';
|
||||
import { ColorTheme } from '~/tools/color';
|
||||
import { getLanguageByCode } from '~/tools/language';
|
||||
import {
|
||||
@@ -92,6 +93,11 @@ function App(
|
||||
};
|
||||
}, [props.pageProps]);
|
||||
|
||||
const { setInitialPackageAttributes } = usePackageAttributesStore();
|
||||
useEffect(() => {
|
||||
setInitialPackageAttributes(props.pageProps.packageAttributes);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<CommonHead />
|
||||
|
||||
@@ -130,6 +130,7 @@ export default function CustomizationPage({
|
||||
color: 'green',
|
||||
icon: <IconCheck />,
|
||||
});
|
||||
form.resetDirty();
|
||||
},
|
||||
onError() {
|
||||
updateNotification({
|
||||
@@ -193,12 +194,12 @@ export default function CustomizationPage({
|
||||
<Button
|
||||
onClick={() => {
|
||||
if (!form.isValid()) {
|
||||
form.validate();
|
||||
return;
|
||||
}
|
||||
|
||||
handleSubmit(form.values);
|
||||
}}
|
||||
disabled={!form.isValid()}
|
||||
loading={isLoading}
|
||||
color="green"
|
||||
>
|
||||
|
||||
@@ -11,9 +11,11 @@ import {
|
||||
} from '@mantine/core';
|
||||
import { createFormContext } from '@mantine/form';
|
||||
import { IconArrowLeft } from '@tabler/icons-react';
|
||||
import { changeLanguage } from 'i18next';
|
||||
import { GetServerSideProps } from 'next';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import Head from 'next/head';
|
||||
import { useRouter } from 'next/router';
|
||||
import { forwardRef } from 'react';
|
||||
import { z } from 'zod';
|
||||
import { AccessibilitySettings } from '~/components/User/Preferences/AccessibilitySettings';
|
||||
@@ -76,9 +78,10 @@ const SettingsComponent = ({
|
||||
country: language.country,
|
||||
}));
|
||||
|
||||
const { t } = useTranslation(['user/preferences', 'common']);
|
||||
const { t, i18n } = useTranslation(['user/preferences', 'common']);
|
||||
|
||||
const { i18nZodResolver } = useI18nZodResolver();
|
||||
const { pathname, query, asPath, push } = useRouter();
|
||||
|
||||
const form = useForm({
|
||||
initialValues: {
|
||||
@@ -105,7 +108,22 @@ const SettingsComponent = ({
|
||||
});
|
||||
|
||||
const handleSubmit = (values: z.infer<typeof updateSettingsValidationSchema>) => {
|
||||
mutate(values);
|
||||
mutate(values, {
|
||||
onSuccess: () => {
|
||||
if (values.language !== settings.language) {
|
||||
i18n.changeLanguage(values.language).then(() => {
|
||||
push(
|
||||
{
|
||||
pathname,
|
||||
query,
|
||||
},
|
||||
asPath,
|
||||
{ locale: values.language }
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user