mirror of
https://github.com/perfect-panel/ppanel-web.git
synced 2026-02-15 12:51:11 -05:00
🐛 fix(site): Se ref to store site configuration for updates
This commit is contained in:
parent
db0d9e003e
commit
0c8f0911c7
@ -9,15 +9,17 @@ import { JSONEditor } from '@workspace/ui/custom-components/editor';
|
|||||||
import { EnhancedInput } from '@workspace/ui/custom-components/enhanced-input';
|
import { EnhancedInput } from '@workspace/ui/custom-components/enhanced-input';
|
||||||
import { UploadImage } from '@workspace/ui/custom-components/upload-image';
|
import { UploadImage } from '@workspace/ui/custom-components/upload-image';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
|
import { useRef } from 'react';
|
||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
|
|
||||||
export default function Site() {
|
export default function Site() {
|
||||||
const t = useTranslations('system.site');
|
const t = useTranslations('system.site');
|
||||||
|
const ref = useRef<API.SiteConfig | undefined>(undefined);
|
||||||
const { data, refetch } = useQuery({
|
const { data, refetch } = useQuery({
|
||||||
queryKey: ['getSiteConfig'],
|
queryKey: ['getSiteConfig'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data } = await getSiteConfig();
|
const { data } = await getSiteConfig();
|
||||||
|
ref.current = data.data;
|
||||||
return data.data;
|
return data.data;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -26,7 +28,7 @@ export default function Site() {
|
|||||||
if (data?.[key] === value) return;
|
if (data?.[key] === value) return;
|
||||||
try {
|
try {
|
||||||
await updateSiteConfig({
|
await updateSiteConfig({
|
||||||
...data,
|
...ref.current,
|
||||||
[key]: value,
|
[key]: value,
|
||||||
} as API.SiteConfig);
|
} as API.SiteConfig);
|
||||||
toast.success(t('saveSuccess'));
|
toast.success(t('saveSuccess'));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user