mirror of
https://github.com/Myzel394/kleckrelay-website.git
synced 2025-06-19 15:55: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."
|
"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.",
|
"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"
|
import {AdminSettings} from "~/server-types"
|
||||||
|
|
||||||
export type GetAdminSettingsResponse =
|
export type GetAdminSettingsResponse =
|
||||||
| Partial<AdminSettings>
|
| Partial<AdminSettings> & {
|
||||||
| {
|
|
||||||
detail: string
|
detail: string
|
||||||
code: "error:settings:global_settings_disabled"
|
code: "error:settings:global_settings_disabled"
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,11 @@
|
|||||||
import {SimpleDetailResponse} from "~/server-types"
|
|
||||||
import {client} from "~/constants/axios-client"
|
import {client} from "~/constants/axios-client"
|
||||||
|
import {SimpleDetailResponse} from "~/server-types"
|
||||||
|
|
||||||
export interface ResendEmailLoginCodeData {
|
export interface ResendEmailLoginCodeData {
|
||||||
email: string
|
email: string
|
||||||
sameRequestToken: string
|
sameRequestToken: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ResendEmailLoginCodeResponse =
|
|
||||||
| SimpleDetailResponse
|
|
||||||
| {
|
|
||||||
detail: string
|
|
||||||
code: "ok:email_already_verified"
|
|
||||||
}
|
|
||||||
|
|
||||||
export default async function resendEmailLoginCode({
|
export default async function resendEmailLoginCode({
|
||||||
email,
|
email,
|
||||||
sameRequestToken,
|
sameRequestToken,
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
import {SimpleDetailResponse} from "~/server-types"
|
import {SimpleDetailResponse} from "~/server-types"
|
||||||
import {client} from "~/constants/axios-client"
|
import {client} from "~/constants/axios-client"
|
||||||
|
|
||||||
|
export type ResendEmailVerificationCodeResponse =
|
||||||
|
| SimpleDetailResponse & {
|
||||||
|
detail: string
|
||||||
|
code: "ok:email_already_verified"
|
||||||
|
}
|
||||||
|
|
||||||
export default async function resendEmailVerificationCode(
|
export default async function resendEmailVerificationCode(
|
||||||
email: string,
|
email: string,
|
||||||
): Promise<SimpleDetailResponse> {
|
): Promise<ResendEmailVerificationCodeResponse> {
|
||||||
const {data} = await client.post(
|
const {data} = await client.post(
|
||||||
`${import.meta.env.VITE_SERVER_BASE_URL}/v1/auth/resend-email`,
|
`${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"
|
import {AdminSettings} from "~/server-types"
|
||||||
|
|
||||||
export type UpdateAdminSettingsResponse =
|
export type UpdateAdminSettingsResponse =
|
||||||
| Partial<AdminSettings>
|
| Partial<AdminSettings> & {
|
||||||
| {
|
|
||||||
detail: string
|
detail: string
|
||||||
code: "error:settings:global_settings_disabled"
|
code: "error:settings:global_settings_disabled"
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function updateAdminSettings(
|
export default async function updateAdminSettings(
|
||||||
settings: Partial<AdminSettings>,
|
settings: Partial<AdminSettings>,
|
||||||
): Promise<AdminSettings> {
|
): Promise<UpdateAdminSettingsResponse> {
|
||||||
const {data} = await client.patch(
|
const {data} = await client.patch(
|
||||||
`${import.meta.env.VITE_SERVER_BASE_URL}/v1/admin/settings`,
|
`${import.meta.env.VITE_SERVER_BASE_URL}/v1/admin/settings`,
|
||||||
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 {AdminSettings} from "~/server-types"
|
||||||
import {StringPoolField, createPool} from "~/components"
|
import {StringPoolField, createPool} from "~/components"
|
||||||
import {updateAdminSettings} from "~/apis"
|
import {UpdateAdminSettingsResponse, updateAdminSettings} from "~/apis"
|
||||||
import {useErrorSuccessSnacks} from "~/hooks"
|
import {useErrorSuccessSnacks} from "~/hooks"
|
||||||
import {queryClient} from "~/constants/react-query"
|
import {queryClient} from "~/constants/react-query"
|
||||||
import {parseFastAPIError} from "~/utils"
|
import {parseFastAPIError} from "~/utils"
|
||||||
@ -85,7 +85,11 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) {
|
|||||||
.label(t("routes.AdminRoute.forms.settings.allowStatistics.label")),
|
.label(t("routes.AdminRoute.forms.settings.allowStatistics.label")),
|
||||||
})
|
})
|
||||||
|
|
||||||
const {mutateAsync} = useMutation<AdminSettings, AxiosError, Partial<AdminSettings>>(
|
const {mutateAsync} = useMutation<
|
||||||
|
UpdateAdminSettingsResponse,
|
||||||
|
AxiosError,
|
||||||
|
Partial<AdminSettings>
|
||||||
|
>(
|
||||||
async settings => {
|
async settings => {
|
||||||
// Set values to `null` that are their defaults
|
// Set values to `null` that are their defaults
|
||||||
const strippedSettings = Object.fromEntries(
|
const strippedSettings = Object.fromEntries(
|
||||||
@ -102,10 +106,14 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
onError: showError,
|
onError: showError,
|
||||||
onSuccess: newSettings => {
|
onSuccess: ({code, detail, ...newSettings}) => {
|
||||||
|
if (code === "error:settings:global_settings_disabled") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
showSuccess(t("routes.AdminRoute.settings.successMessage"))
|
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 {useMutation} from "@tanstack/react-query"
|
||||||
|
|
||||||
import {resendEmailLoginCode} from "~/apis"
|
import {ResendEmailLoginCodeResponse, resendEmailLoginCode} from "~/apis"
|
||||||
import {MutationStatusSnackbar, TimedButton} from "~/components"
|
import {MutationStatusSnackbar, TimedButton} from "~/components"
|
||||||
import {ServerSettings, SimpleDetailResponse} from "~/server-types"
|
import {ServerSettings} from "~/server-types"
|
||||||
|
|
||||||
export interface ResendMailButtonProps {
|
export interface ResendMailButtonProps {
|
||||||
email: string
|
email: string
|
||||||
@ -22,7 +22,7 @@ export default function ResendMailButton({
|
|||||||
const settings = useLoaderData() as ServerSettings
|
const settings = useLoaderData() as ServerSettings
|
||||||
const {t} = useTranslation()
|
const {t} = useTranslation()
|
||||||
|
|
||||||
const mutation = useMutation<SimpleDetailResponse, AxiosError, void>(() =>
|
const mutation = useMutation<ResendEmailLoginCodeResponse, AxiosError, void>(() =>
|
||||||
resendEmailLoginCode({
|
resendEmailLoginCode({
|
||||||
email,
|
email,
|
||||||
sameRequestToken,
|
sameRequestToken,
|
||||||
|
@ -6,20 +6,31 @@ import React, {ReactElement} from "react"
|
|||||||
|
|
||||||
import {useMutation} from "@tanstack/react-query"
|
import {useMutation} from "@tanstack/react-query"
|
||||||
|
|
||||||
import {resendEmailVerificationCode} from "~/apis"
|
import {ResendEmailVerificationCodeResponse, resendEmailVerificationCode} from "~/apis"
|
||||||
import {MutationStatusSnackbar, TimedButton} from "~/components"
|
import {MutationStatusSnackbar, TimedButton} from "~/components"
|
||||||
import {ServerSettings, SimpleDetailResponse} from "~/server-types"
|
import {ServerSettings} from "~/server-types"
|
||||||
|
|
||||||
export interface ResendMailButtonProps {
|
export interface ResendMailButtonProps {
|
||||||
email: string
|
email: string
|
||||||
|
onEmailAlreadyVerified: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ResendMailButton({email}: ResendMailButtonProps): ReactElement {
|
export default function ResendMailButton({
|
||||||
|
email,
|
||||||
|
onEmailAlreadyVerified,
|
||||||
|
}: ResendMailButtonProps): ReactElement {
|
||||||
const {t} = useTranslation()
|
const {t} = useTranslation()
|
||||||
const settings = useLoaderData() as ServerSettings
|
const settings = useLoaderData() as ServerSettings
|
||||||
|
|
||||||
const mutation = useMutation<SimpleDetailResponse, AxiosError, void>(() =>
|
const mutation = useMutation<ResendEmailVerificationCodeResponse, AxiosError, void>(
|
||||||
resendEmailVerificationCode(email),
|
() => resendEmailVerificationCode(email),
|
||||||
|
{
|
||||||
|
onSuccess: ({code}: any) => {
|
||||||
|
if (code === "ok:email_already_verified") {
|
||||||
|
onEmailAlreadyVerified()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
)
|
)
|
||||||
const {mutate} = mutation
|
const {mutate} = mutation
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ export default function YouGotMail({email, onGoBack}: YouGotMailProps): ReactEle
|
|||||||
<OpenMailButton domain={domain} />
|
<OpenMailButton domain={domain} />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<ResendMailButton email={email} />
|
<ResendMailButton email={email} onEmailAlreadyVerified={onGoBack} />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</MultiStepFormElement>
|
</MultiStepFormElement>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user