diff --git a/src/app/(dashboard)/settings/components/GeneralActions/GeneralActions.test.tsx b/src/app/(dashboard)/settings/components/GeneralActions/GeneralActions.test.tsx
deleted file mode 100644
index 8f1ed860..00000000
--- a/src/app/(dashboard)/settings/components/GeneralActions/GeneralActions.test.tsx
+++ /dev/null
@@ -1,61 +0,0 @@
-import React from 'react';
-import { getTRPCMock, getTRPCMockError } from '@/client/mocks/getTrpcMock';
-import { server } from '@/client/mocks/server';
-import { StatusProvider } from '@/components/hoc/StatusProvider';
-import { renderHook } from '@testing-library/react';
-import { useSystemStore } from '@/client/state/systemStore';
-import { GeneralActions } from './GeneralActions';
-import { fireEvent, render, screen, waitFor } from '../../../../../../tests/test-utils';
-
-describe('Test: GeneralActions', () => {
- it('should render without error', () => {
- render();
-
- expect(screen.getByText('Actions')).toBeInTheDocument();
- });
-
- it('should show toast if restart mutation fails', async () => {
- // arrange
- server.use(getTRPCMockError({ path: ['system', 'restart'], type: 'mutation', status: 500, message: 'Something went badly' }));
- render();
- const restartButton = screen.getByRole('button', { name: /Restart/i });
-
- // act
- fireEvent.click(restartButton);
- const restartButtonModal = screen.getByRole('button', { name: /Restart/i });
- fireEvent.click(restartButtonModal);
-
- // assert
- await waitFor(() => {
- expect(screen.getByText(/Something went badly/)).toBeInTheDocument();
- });
- });
-
- it('should set poll status to true if restart mutation succeeds', async () => {
- // arrange
- server.use(getTRPCMock({ path: ['system', 'restart'], type: 'mutation', response: true }));
- const { result } = renderHook(() => useSystemStore());
- result.current.setStatus('RUNNING');
-
- render(
-
-
- ,
- );
-
- const restartButton = screen.getByRole('button', { name: /Restart/i });
-
- // act
- fireEvent.click(restartButton);
- const restartButtonModal = screen.getByRole('button', { name: /Restart/i });
- fireEvent.click(restartButtonModal);
-
- result.current.setStatus('RESTARTING');
-
- // assert
- await waitFor(() => {
- expect(screen.getByText('Your system is restarting...')).toBeInTheDocument();
- });
- expect(result.current.pollStatus).toBe(true);
- });
-});
diff --git a/src/app/(dashboard)/settings/components/SettingsContainer/SettingsContainer.tsx b/src/app/(dashboard)/settings/components/SettingsContainer/SettingsContainer.tsx
new file mode 100644
index 00000000..0e667c07
--- /dev/null
+++ b/src/app/(dashboard)/settings/components/SettingsContainer/SettingsContainer.tsx
@@ -0,0 +1,38 @@
+'use client';
+
+import React from 'react';
+import { toast } from 'react-hot-toast';
+import { useTranslations } from 'next-intl';
+import { useAction } from 'next-safe-action/hook';
+import { updateSettingsAction } from '@/actions/settings/update-settings';
+import { Locale } from '@/shared/internationalization/locales';
+import { SettingsForm, SettingsFormValues } from '../SettingsForm';
+
+type Props = {
+ initialValues?: SettingsFormValues;
+ currentLocale: Locale;
+};
+
+export const SettingsContainer = ({ initialValues, currentLocale }: Props) => {
+ const t = useTranslations();
+
+ const updateSettingsMutation = useAction(updateSettingsAction, {
+ onSuccess: (data) => {
+ if (!data.success) {
+ toast.error(data.failure.reason);
+ } else {
+ toast.success(t('settings.settings.settings-updated'));
+ }
+ },
+ });
+
+ const onSubmit = (values: SettingsFormValues) => {
+ updateSettingsMutation.execute(values);
+ };
+
+ return (
+
+
+
+ );
+};
diff --git a/src/client/modules/Settings/containers/SettingsContainer/index.ts b/src/app/(dashboard)/settings/components/SettingsContainer/index.ts
similarity index 100%
rename from src/client/modules/Settings/containers/SettingsContainer/index.ts
rename to src/app/(dashboard)/settings/components/SettingsContainer/index.ts
diff --git a/src/client/modules/Settings/components/SettingsForm/SettingsForm.test.tsx b/src/app/(dashboard)/settings/components/SettingsForm/SettingsForm.test.tsx
similarity index 100%
rename from src/client/modules/Settings/components/SettingsForm/SettingsForm.test.tsx
rename to src/app/(dashboard)/settings/components/SettingsForm/SettingsForm.test.tsx
diff --git a/src/client/modules/Settings/components/SettingsForm/SettingsForm.tsx b/src/app/(dashboard)/settings/components/SettingsForm/SettingsForm.tsx
similarity index 95%
rename from src/client/modules/Settings/components/SettingsForm/SettingsForm.tsx
rename to src/app/(dashboard)/settings/components/SettingsForm/SettingsForm.tsx
index 490d4f0a..cf644a37 100644
--- a/src/client/modules/Settings/components/SettingsForm/SettingsForm.tsx
+++ b/src/app/(dashboard)/settings/components/SettingsForm/SettingsForm.tsx
@@ -1,4 +1,3 @@
-import { LanguageSelector } from '@/components/LanguageSelector';
import { Button } from '@/components/ui/Button';
import { Input } from '@/components/ui/Input';
import { IconAdjustmentsAlt, IconUser } from '@tabler/icons-react';
@@ -8,6 +7,8 @@ import React, { useEffect } from 'react';
import { useForm } from 'react-hook-form';
import { Tooltip } from 'react-tooltip';
import validator from 'validator';
+import { Locale } from '@/shared/internationalization/locales';
+import { LanguageSelector } from '../../../../components/LanguageSelector';
export type SettingsFormValues = {
dnsIp?: string;
@@ -19,6 +20,7 @@ export type SettingsFormValues = {
};
interface IProps {
+ currentLocale?: Locale;
onSubmit: (values: SettingsFormValues) => void;
initalValues?: Partial;
loading?: boolean;
@@ -26,7 +28,7 @@ interface IProps {
}
export const SettingsForm = (props: IProps) => {
- const { onSubmit, initalValues, loading, submitErrors } = props;
+ const { onSubmit, initalValues, loading, currentLocale = 'en-US', submitErrors } = props;
const t = useTranslations('settings.settings');
const validateFields = (values: SettingsFormValues) => {
@@ -104,7 +106,7 @@ export const SettingsForm = (props: IProps) => {
{t('user-settings-title')}
-
+