mirror of
https://github.com/Myzel394/kleckrelay-website.git
synced 2025-06-19 07:55:25 +02:00
fix: Fix default settings loaded correctly for global settings form
This commit is contained in:
parent
82a3641a6d
commit
8f925072cc
14
src/constants/admin-settings.ts
Normal file
14
src/constants/admin-settings.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import {AdminSettings} from "~/server-types"
|
||||||
|
|
||||||
|
export const DEFAULT_ADMIN_SETTINGS: AdminSettings = {
|
||||||
|
randomEmailIdMinLength: 6,
|
||||||
|
randomEmailIdChars: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
|
||||||
|
randomEmailLengthIncreaseOnPercentage: 0.0005,
|
||||||
|
customEmailSuffixLength: 4,
|
||||||
|
customEmailSuffixChars: "0123456789",
|
||||||
|
userEmailEnableOtherRelays: true,
|
||||||
|
userEmailEnableDisposableEmails: false,
|
||||||
|
imageProxyStorageLifeTimeInHours: 24,
|
||||||
|
enableImageProxy: true,
|
||||||
|
allowStatistics: true,
|
||||||
|
}
|
@ -1,15 +1,23 @@
|
|||||||
import {ReactElement} from "react"
|
import {ReactElement} from "react"
|
||||||
import {useQuery} from "@tanstack/react-query"
|
|
||||||
import {AdminSettings} from "~/server-types"
|
|
||||||
import {AxiosError} from "axios"
|
import {AxiosError} from "axios"
|
||||||
|
import _ from "lodash"
|
||||||
|
|
||||||
|
import {useQuery} from "@tanstack/react-query"
|
||||||
|
|
||||||
|
import {AdminSettings} from "~/server-types"
|
||||||
import {getAdminSettings} from "~/apis"
|
import {getAdminSettings} from "~/apis"
|
||||||
import {QueryResult} from "~/components"
|
import {QueryResult} from "~/components"
|
||||||
import {useTranslation} from "react-i18next"
|
import {DEFAULT_ADMIN_SETTINGS} from "~/constants/admin-settings"
|
||||||
import SettingsForm from "~/route-widgets/GlobalSettingsRoute/SettingForm"
|
import SettingsForm from "~/route-widgets/GlobalSettingsRoute/SettingsForm"
|
||||||
|
|
||||||
export default function GlobalSettingsRoute(): ReactElement {
|
export default function GlobalSettingsRoute(): ReactElement {
|
||||||
const {t} = useTranslation()
|
const query = useQuery<AdminSettings, AxiosError>(["get_admin_settings"], async () => {
|
||||||
const query = useQuery<AdminSettings, AxiosError>(["get_admin_settings"], getAdminSettings)
|
const settings = getAdminSettings()
|
||||||
|
|
||||||
|
return _.mergeWith({}, DEFAULT_ADMIN_SETTINGS, settings, (o, s) =>
|
||||||
|
_.isNull(s) ? o : s,
|
||||||
|
) as AdminSettings
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<QueryResult<AdminSettings> query={query}>
|
<QueryResult<AdminSettings> query={query}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user