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

View File

@ -1,8 +1,4 @@
import { import {ImageProxyFormatType, ImageProxyUserAgentType, SimpleDetailResponse} from "~/server-types"
ImageProxyFormatType,
ProxyUserAgentType,
SimpleDetailResponse,
} from "~/server-types"
import {client} from "~/constants/axios-client" import {client} from "~/constants/axios-client"
export interface UpdatePreferencesData { export interface UpdatePreferencesData {
@ -10,7 +6,7 @@ export interface UpdatePreferencesData {
aliasCreateMailReport?: boolean aliasCreateMailReport?: boolean
aliasProxyImages?: boolean aliasProxyImages?: boolean
aliasImageProxyFormat?: ImageProxyFormatType aliasImageProxyFormat?: ImageProxyFormatType
aliasImageProxyUserAgent?: ProxyUserAgentType aliasImageProxyUserAgent?: ImageProxyUserAgentType
} }
export default async function updatePreferences( 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" import {createEnumMapFromTranslation} from "~/utils"
export const IMAGE_PROXY_FORMAT_TYPE_NAME_MAP = createEnumMapFromTranslation( 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( export const IMAGE_PROXY_USER_AGENT_TYPE_NAME_MAP = createEnumMapFromTranslation(
"relations.alias.settings.imageProxyUserAgent.enumTexts", "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 {useMutation} from "@tanstack/react-query"
import Icon from "@mdi/react" 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 {UpdateAliasData, updateAlias} from "~/apis"
import {parseFastAPIError} from "~/utils" import {parseFastAPIError} from "~/utils"
import { import {
@ -37,7 +37,7 @@ interface Form {
createMailReport: boolean | null createMailReport: boolean | null
proxyImages: boolean | null proxyImages: boolean | null
imageProxyFormat: ImageProxyFormatType | null imageProxyFormat: ImageProxyFormatType | null
imageProxyUserAgent: ProxyUserAgentType | null imageProxyUserAgent: ImageProxyUserAgentType | null
detail?: string detail?: string
} }
@ -65,8 +65,8 @@ export default function AliasPreferencesForm({
.oneOf([null, ...Object.values(ImageProxyFormatType)]) .oneOf([null, ...Object.values(ImageProxyFormatType)])
.label(t("relations.alias.settings.imageProxyFormat.label")), .label(t("relations.alias.settings.imageProxyFormat.label")),
imageProxyUserAgent: yup imageProxyUserAgent: yup
.mixed<ProxyUserAgentType>() .mixed<ImageProxyUserAgentType>()
.oneOf([null, ...Object.values(ProxyUserAgentType)]) .oneOf([null, ...Object.values(ImageProxyUserAgentType)])
.label(t("relations.alias.settings.imageProxyUserAgent.label")), .label(t("relations.alias.settings.imageProxyUserAgent.label")),
}) })

View File

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

View File

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