🐛 fix(site): Se ref to store site configuration for updates

This commit is contained in:
web@ppanel 2025-03-15 22:47:19 +07:00
parent db0d9e003e
commit 0c8f0911c7

View File

@ -9,15 +9,17 @@ import { JSONEditor } from '@workspace/ui/custom-components/editor';
import { EnhancedInput } from '@workspace/ui/custom-components/enhanced-input';
import { UploadImage } from '@workspace/ui/custom-components/upload-image';
import { useTranslations } from 'next-intl';
import { useRef } from 'react';
import { toast } from 'sonner';
export default function Site() {
const t = useTranslations('system.site');
const ref = useRef<API.SiteConfig | undefined>(undefined);
const { data, refetch } = useQuery({
queryKey: ['getSiteConfig'],
queryFn: async () => {
const { data } = await getSiteConfig();
ref.current = data.data;
return data.data;
},
});
@ -26,7 +28,7 @@ export default function Site() {
if (data?.[key] === value) return;
try {
await updateSiteConfig({
...data,
...ref.current,
[key]: value,
} as API.SiteConfig);
toast.success(t('saveSuccess'));