fix: Settings file

This commit is contained in:
samturner3
2024-08-24 18:58:45 +10:00
parent 2937d7d5bc
commit e3175723ea

View File

@@ -5,6 +5,7 @@ import { useGetSettings, useSetSetting } from "../../utils/querySettings";
export function GeneralSettings() { export function GeneralSettings() {
const settings = useGetSettings(); const settings = useGetSettings();
const setQrCodeUrl = useSetSetting("qr_code_url");
const setCurrency = useSetSetting("currency"); const setCurrency = useSetSetting("currency");
const [form] = Form.useForm(); const [form] = Form.useForm();
const [messageApi, contextHolder] = message.useMessage(); const [messageApi, contextHolder] = message.useMessage();
@@ -28,17 +29,14 @@ export function GeneralSettings() {
}, [setCurrency.isSuccess, messageApi, t]); }, [setCurrency.isSuccess, messageApi, t]);
// Handle form submit // Handle form submit
const onFinish = (values: { currency: string, qr_code_url: string }) => { const onFinish = (values: { currency: string; qr_code_url: string }) => {
// Check if the currency has changed // Check if the currency has changed
if (settings.data?.currency.value !== JSON.stringify(values.currency)) { if (settings.data?.currency.value !== JSON.stringify(values.currency)) {
setCurrency.mutate(values.currency); setCurrency.mutate(values.currency);
} }
// Check if the QR code URL has changed // Check if the QR code URL has changed
if (settings.data?.qr_code_url.value !== JSON.stringify(values.qr_code_url)) { if (settings.data?.qr_code_url.value !== JSON.stringify(values.qr_code_url)) {
setSetting.mutate({ setQrCodeUrl.mutate(values.qr_code_url);
key: "qr_code_url",
value: JSON.stringify(values.qr_code_url),
});
} }
}; };
@@ -85,9 +83,7 @@ export function GeneralSettings() {
}, },
]} ]}
> >
<Input <Input placeholder="https://example.com:8000/" />
placeholder="https://example.com:8000/"
/>
</Form.Item> </Form.Item>
<Form.Item wrapperCol={{ offset: 8, span: 16 }}> <Form.Item wrapperCol={{ offset: 8, span: 16 }}>