mirror of
https://github.com/Myzel394/kleckrelay-website.git
synced 2025-06-18 23:45:26 +02:00
fix: Update API to upstream
This commit is contained in:
parent
646a646eb0
commit
a367e93c55
@ -407,7 +407,11 @@
|
||||
"helperText": "This is just a preview. Those are not real aliases."
|
||||
},
|
||||
"randomAliasesIncreaseExplanation": "Random aliases' length will be increased from {{originalLength}} to {{increasedLength}} characters after {{amount}} aliases have been created.",
|
||||
"resetLabel": "Reset to defaults"
|
||||
"resetLabel": "Reset to defaults",
|
||||
"disabled": {
|
||||
"title": "Global settings are disabled",
|
||||
"description": "Global settings have been disabled. You can enable them in the configuration file."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -2,8 +2,7 @@ import {client} from "~/constants/axios-client"
|
||||
import {AdminSettings} from "~/server-types"
|
||||
|
||||
export type GetAdminSettingsResponse =
|
||||
| Partial<AdminSettings>
|
||||
| {
|
||||
| Partial<AdminSettings> & {
|
||||
detail: string
|
||||
code: "error:settings:global_settings_disabled"
|
||||
}
|
||||
|
@ -1,18 +1,11 @@
|
||||
import {SimpleDetailResponse} from "~/server-types"
|
||||
import {client} from "~/constants/axios-client"
|
||||
import {SimpleDetailResponse} from "~/server-types"
|
||||
|
||||
export interface ResendEmailLoginCodeData {
|
||||
email: string
|
||||
sameRequestToken: string
|
||||
}
|
||||
|
||||
export type ResendEmailLoginCodeResponse =
|
||||
| SimpleDetailResponse
|
||||
| {
|
||||
detail: string
|
||||
code: "ok:email_already_verified"
|
||||
}
|
||||
|
||||
export default async function resendEmailLoginCode({
|
||||
email,
|
||||
sameRequestToken,
|
||||
|
@ -1,9 +1,15 @@
|
||||
import {SimpleDetailResponse} from "~/server-types"
|
||||
import {client} from "~/constants/axios-client"
|
||||
|
||||
export type ResendEmailVerificationCodeResponse =
|
||||
| SimpleDetailResponse & {
|
||||
detail: string
|
||||
code: "ok:email_already_verified"
|
||||
}
|
||||
|
||||
export default async function resendEmailVerificationCode(
|
||||
email: string,
|
||||
): Promise<SimpleDetailResponse> {
|
||||
): Promise<ResendEmailVerificationCodeResponse> {
|
||||
const {data} = await client.post(
|
||||
`${import.meta.env.VITE_SERVER_BASE_URL}/v1/auth/resend-email`,
|
||||
{
|
||||
|
@ -2,15 +2,14 @@ import {client} from "~/constants/axios-client"
|
||||
import {AdminSettings} from "~/server-types"
|
||||
|
||||
export type UpdateAdminSettingsResponse =
|
||||
| Partial<AdminSettings>
|
||||
| {
|
||||
| Partial<AdminSettings> & {
|
||||
detail: string
|
||||
code: "error:settings:global_settings_disabled"
|
||||
}
|
||||
|
||||
export default async function updateAdminSettings(
|
||||
settings: Partial<AdminSettings>,
|
||||
): Promise<AdminSettings> {
|
||||
): Promise<UpdateAdminSettingsResponse> {
|
||||
const {data} = await client.patch(
|
||||
`${import.meta.env.VITE_SERVER_BASE_URL}/v1/admin/settings`,
|
||||
settings,
|
||||
|
38
src/route-widgets/GlobalSettingsRoute/SettingsDisabled.tsx
Normal file
38
src/route-widgets/GlobalSettingsRoute/SettingsDisabled.tsx
Normal file
@ -0,0 +1,38 @@
|
||||
import {RiAlertFill} from "react-icons/ri"
|
||||
import {ReactElement} from "react"
|
||||
import {useTranslation} from "react-i18next"
|
||||
|
||||
import {Container, Grid, Typography} from "@mui/material"
|
||||
|
||||
export default function SettingsDisabled(): ReactElement {
|
||||
console.log("asdas")
|
||||
const {t} = useTranslation()
|
||||
|
||||
return (
|
||||
<Container maxWidth="xs">
|
||||
<Grid
|
||||
container
|
||||
spacing={4}
|
||||
direction="column"
|
||||
alignItems="center"
|
||||
maxWidth="80%"
|
||||
alignSelf="center"
|
||||
marginX="auto"
|
||||
>
|
||||
<Grid item>
|
||||
<Typography variant="h6" component="h2">
|
||||
{t("routes.AdminRoute.settings.disabled.title")}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<RiAlertFill size={40} />
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<Typography variant="body1">
|
||||
{t("routes.AdminRoute.settings.disabled.description")}
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Container>
|
||||
)
|
||||
}
|
@ -21,7 +21,7 @@ import {useMutation} from "@tanstack/react-query"
|
||||
|
||||
import {AdminSettings} from "~/server-types"
|
||||
import {StringPoolField, createPool} from "~/components"
|
||||
import {updateAdminSettings} from "~/apis"
|
||||
import {UpdateAdminSettingsResponse, updateAdminSettings} from "~/apis"
|
||||
import {useErrorSuccessSnacks} from "~/hooks"
|
||||
import {queryClient} from "~/constants/react-query"
|
||||
import {parseFastAPIError} from "~/utils"
|
||||
@ -85,7 +85,11 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) {
|
||||
.label(t("routes.AdminRoute.forms.settings.allowStatistics.label")),
|
||||
})
|
||||
|
||||
const {mutateAsync} = useMutation<AdminSettings, AxiosError, Partial<AdminSettings>>(
|
||||
const {mutateAsync} = useMutation<
|
||||
UpdateAdminSettingsResponse,
|
||||
AxiosError,
|
||||
Partial<AdminSettings>
|
||||
>(
|
||||
async settings => {
|
||||
// Set values to `null` that are their defaults
|
||||
const strippedSettings = Object.fromEntries(
|
||||
@ -102,10 +106,14 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) {
|
||||
},
|
||||
{
|
||||
onError: showError,
|
||||
onSuccess: newSettings => {
|
||||
onSuccess: ({code, detail, ...newSettings}) => {
|
||||
if (code === "error:settings:global_settings_disabled") {
|
||||
return
|
||||
}
|
||||
|
||||
showSuccess(t("routes.AdminRoute.settings.successMessage"))
|
||||
|
||||
queryClient.setQueryData<AdminSettings>(queryKey, newSettings)
|
||||
queryClient.setQueryData<Partial<AdminSettings>>(queryKey, newSettings)
|
||||
},
|
||||
},
|
||||
)
|
||||
|
@ -6,9 +6,9 @@ import React, {ReactElement} from "react"
|
||||
|
||||
import {useMutation} from "@tanstack/react-query"
|
||||
|
||||
import {resendEmailLoginCode} from "~/apis"
|
||||
import {ResendEmailLoginCodeResponse, resendEmailLoginCode} from "~/apis"
|
||||
import {MutationStatusSnackbar, TimedButton} from "~/components"
|
||||
import {ServerSettings, SimpleDetailResponse} from "~/server-types"
|
||||
import {ServerSettings} from "~/server-types"
|
||||
|
||||
export interface ResendMailButtonProps {
|
||||
email: string
|
||||
@ -22,7 +22,7 @@ export default function ResendMailButton({
|
||||
const settings = useLoaderData() as ServerSettings
|
||||
const {t} = useTranslation()
|
||||
|
||||
const mutation = useMutation<SimpleDetailResponse, AxiosError, void>(() =>
|
||||
const mutation = useMutation<ResendEmailLoginCodeResponse, AxiosError, void>(() =>
|
||||
resendEmailLoginCode({
|
||||
email,
|
||||
sameRequestToken,
|
||||
|
@ -6,20 +6,31 @@ import React, {ReactElement} from "react"
|
||||
|
||||
import {useMutation} from "@tanstack/react-query"
|
||||
|
||||
import {resendEmailVerificationCode} from "~/apis"
|
||||
import {ResendEmailVerificationCodeResponse, resendEmailVerificationCode} from "~/apis"
|
||||
import {MutationStatusSnackbar, TimedButton} from "~/components"
|
||||
import {ServerSettings, SimpleDetailResponse} from "~/server-types"
|
||||
import {ServerSettings} from "~/server-types"
|
||||
|
||||
export interface ResendMailButtonProps {
|
||||
email: string
|
||||
onEmailAlreadyVerified: () => void
|
||||
}
|
||||
|
||||
export default function ResendMailButton({email}: ResendMailButtonProps): ReactElement {
|
||||
export default function ResendMailButton({
|
||||
email,
|
||||
onEmailAlreadyVerified,
|
||||
}: ResendMailButtonProps): ReactElement {
|
||||
const {t} = useTranslation()
|
||||
const settings = useLoaderData() as ServerSettings
|
||||
|
||||
const mutation = useMutation<SimpleDetailResponse, AxiosError, void>(() =>
|
||||
resendEmailVerificationCode(email),
|
||||
const mutation = useMutation<ResendEmailVerificationCodeResponse, AxiosError, void>(
|
||||
() => resendEmailVerificationCode(email),
|
||||
{
|
||||
onSuccess: ({code}: any) => {
|
||||
if (code === "ok:email_already_verified") {
|
||||
onEmailAlreadyVerified()
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
const {mutate} = mutation
|
||||
|
||||
|
@ -67,7 +67,7 @@ export default function YouGotMail({email, onGoBack}: YouGotMailProps): ReactEle
|
||||
<OpenMailButton domain={domain} />
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<ResendMailButton email={email} />
|
||||
<ResendMailButton email={email} onEmailAlreadyVerified={onGoBack} />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</MultiStepFormElement>
|
||||
|
Loading…
x
Reference in New Issue
Block a user