improvements

This commit is contained in:
Myzel394 2022-11-03 08:28:23 +01:00
parent 7cedb6ab94
commit 6f06a55467
7 changed files with 20 additions and 27 deletions

View File

@ -1,4 +1,4 @@
import {Alias, AliasType, ImageProxyFormatType, ProxyUserAgentType} from "~/server-types"
import {Alias, AliasType, ImageProxyFormatType, ImageProxyUserAgentType} from "~/server-types"
import {client} from "~/constants/axios-client"
interface CreateAliasDataOther {
@ -9,7 +9,7 @@ interface CreateAliasDataOther {
prefCreateMailReport?: boolean
prefProxyImages?: boolean
prefImageProxyFormat?: ImageProxyFormatType
prefImageProxyUserAgent?: ProxyUserAgentType
prefImageProxyUserAgent?: ImageProxyUserAgentType
}
interface CreateAliasDataBase extends CreateAliasDataOther {

View File

@ -1,4 +1,4 @@
import {Alias, ImageProxyFormatType, ProxyUserAgentType} from "~/server-types"
import {Alias, ImageProxyFormatType, ImageProxyUserAgentType} from "~/server-types"
import {client} from "~/constants/axios-client"
export interface UpdateAliasData {
@ -8,13 +8,10 @@ export interface UpdateAliasData {
prefCreateMailReport?: boolean | null
prefProxyImages?: boolean | null
prefImagProxyFormat?: ImageProxyFormatType | null
prefImageProxyUserAgent?: ProxyUserAgentType | null
prefImageProxyUserAgent?: ImageProxyUserAgentType | null
}
export default async function updateAlias(
id: string,
updateData: UpdateAliasData,
): Promise<Alias> {
export default async function updateAlias(id: string, updateData: UpdateAliasData): Promise<Alias> {
const {data} = await client.patch(
`${import.meta.env.VITE_SERVER_BASE_URL}/alias/${id}`,
updateData,

View File

@ -1,8 +1,4 @@
import {
ImageProxyFormatType,
ProxyUserAgentType,
SimpleDetailResponse,
} from "~/server-types"
import {ImageProxyFormatType, ImageProxyUserAgentType, SimpleDetailResponse} from "~/server-types"
import {client} from "~/constants/axios-client"
export interface UpdatePreferencesData {
@ -10,7 +6,7 @@ export interface UpdatePreferencesData {
aliasCreateMailReport?: boolean
aliasProxyImages?: boolean
aliasImageProxyFormat?: ImageProxyFormatType
aliasImageProxyUserAgent?: ProxyUserAgentType
aliasImageProxyUserAgent?: ImageProxyUserAgentType
}
export default async function updatePreferences(

View File

@ -1,4 +1,4 @@
import {ImageProxyFormatType, ProxyUserAgentType} from "~/server-types"
import {ImageProxyFormatType, ImageProxyUserAgentType} from "~/server-types"
import {createEnumMapFromTranslation} from "~/utils"
export const IMAGE_PROXY_FORMAT_TYPE_NAME_MAP = createEnumMapFromTranslation(
@ -7,5 +7,5 @@ export const IMAGE_PROXY_FORMAT_TYPE_NAME_MAP = createEnumMapFromTranslation(
)
export const IMAGE_PROXY_USER_AGENT_TYPE_NAME_MAP = createEnumMapFromTranslation(
"relations.alias.settings.imageProxyUserAgent.enumTexts",
ProxyUserAgentType,
ImageProxyUserAgentType,
)

View File

@ -13,7 +13,7 @@ import {mdiTextBoxMultiple} from "@mdi/js/commonjs/mdi"
import {useMutation} from "@tanstack/react-query"
import Icon from "@mdi/react"
import {Alias, DecryptedAlias, ImageProxyFormatType, ProxyUserAgentType} from "~/server-types"
import {Alias, DecryptedAlias, ImageProxyFormatType, ImageProxyUserAgentType} from "~/server-types"
import {UpdateAliasData, updateAlias} from "~/apis"
import {parseFastAPIError} from "~/utils"
import {
@ -37,7 +37,7 @@ interface Form {
createMailReport: boolean | null
proxyImages: boolean | null
imageProxyFormat: ImageProxyFormatType | null
imageProxyUserAgent: ProxyUserAgentType | null
imageProxyUserAgent: ImageProxyUserAgentType | null
detail?: string
}
@ -65,8 +65,8 @@ export default function AliasPreferencesForm({
.oneOf([null, ...Object.values(ImageProxyFormatType)])
.label(t("relations.alias.settings.imageProxyFormat.label")),
imageProxyUserAgent: yup
.mixed<ProxyUserAgentType>()
.oneOf([null, ...Object.values(ProxyUserAgentType)])
.mixed<ImageProxyUserAgentType>()
.oneOf([null, ...Object.values(ImageProxyUserAgentType)])
.label(t("relations.alias.settings.imageProxyUserAgent.label")),
})

View File

@ -22,7 +22,7 @@ import {
} from "@mui/material"
import {LoadingButton} from "@mui/lab"
import {ImageProxyFormatType, ProxyUserAgentType, SimpleDetailResponse} from "~/server-types"
import {ImageProxyFormatType, ImageProxyUserAgentType, SimpleDetailResponse} from "~/server-types"
import {UpdatePreferencesData, updatePreferences} from "~/apis"
import {useErrorSuccessSnacks, useUser} from "~/hooks"
import {parseFastAPIError} from "~/utils"
@ -37,7 +37,7 @@ interface Form {
createMailReport: boolean
proxyImages: boolean
imageProxyFormat: ImageProxyFormatType
imageProxyUserAgent: ProxyUserAgentType
imageProxyUserAgent: ImageProxyUserAgentType
detail?: string
}
@ -58,8 +58,8 @@ export default function AliasesPreferencesForm(): ReactElement {
.required()
.label(t("relations.alias.settings.imageProxyFormat.label")),
imageProxyUserAgent: yup
.mixed<ProxyUserAgentType>()
.oneOf(Object.values(ProxyUserAgentType))
.mixed<ImageProxyUserAgentType>()
.oneOf(Object.values(ImageProxyUserAgentType))
.required()
.label(t("relations.alias.settings.imageProxyUserAgent.label")),
})

View File

@ -4,7 +4,7 @@ export enum ImageProxyFormatType {
JPEG = "jpeg",
}
export enum ProxyUserAgentType {
export enum ImageProxyUserAgentType {
APPLE_MAIL = "apple-mail",
GOOGLE_MAIL = "google-mail",
OUTLOOK_WINDOWS = "outlook-windows",
@ -48,7 +48,7 @@ export interface ServerUser {
aliasCreateMailReport: boolean
aliasProxyImages: boolean
aliasImageProxyFormat: ImageProxyFormatType
aliasImageProxyUserAgent: ProxyUserAgentType
aliasImageProxyUserAgent: ImageProxyUserAgentType
}
}
@ -89,7 +89,7 @@ export interface Alias {
prefCreateMailReport: boolean | null
prefProxyImages: boolean | null
prefImageProxyFormat: ImageProxyFormatType | null
prefImageProxyUserAgent: ProxyUserAgentType | null
prefImageProxyUserAgent: ImageProxyUserAgentType | null
}
export interface AliasNote {