mirror of
https://github.com/stonith404/pingvin-share.git
synced 2024-11-15 11:50:34 +01:00
fix: error message for invalid max use count of reverse share
This commit is contained in:
parent
2e692241c5
commit
613bae9033
@ -9,11 +9,13 @@ import {
|
|||||||
Switch,
|
Switch,
|
||||||
Text,
|
Text,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useForm } from "@mantine/form";
|
import { useForm, yupResolver } from "@mantine/form";
|
||||||
import { useModals } from "@mantine/modals";
|
import { useModals } from "@mantine/modals";
|
||||||
import { ModalsContextProps } from "@mantine/modals/lib/context";
|
import { ModalsContextProps } from "@mantine/modals/lib/context";
|
||||||
|
import { getCookie, setCookie } from "cookies-next";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { FormattedMessage } from "react-intl";
|
import { FormattedMessage } from "react-intl";
|
||||||
|
import * as yup from "yup";
|
||||||
import useTranslate, {
|
import useTranslate, {
|
||||||
translateOutsideContext,
|
translateOutsideContext,
|
||||||
} from "../../../hooks/useTranslate.hook";
|
} from "../../../hooks/useTranslate.hook";
|
||||||
@ -22,7 +24,6 @@ import { getExpirationPreview } from "../../../utils/date.util";
|
|||||||
import toast from "../../../utils/toast.util";
|
import toast from "../../../utils/toast.util";
|
||||||
import FileSizeInput from "../FileSizeInput";
|
import FileSizeInput from "../FileSizeInput";
|
||||||
import showCompletedReverseShareModal from "./showCompletedReverseShareModal";
|
import showCompletedReverseShareModal from "./showCompletedReverseShareModal";
|
||||||
import { getCookie, setCookie } from "cookies-next";
|
|
||||||
|
|
||||||
const showCreateReverseShareModal = (
|
const showCreateReverseShareModal = (
|
||||||
modals: ModalsContextProps,
|
modals: ModalsContextProps,
|
||||||
@ -65,6 +66,16 @@ const Body = ({
|
|||||||
simplified: !!(getCookie("reverse-share.simplified") ?? false),
|
simplified: !!(getCookie("reverse-share.simplified") ?? false),
|
||||||
publicAccess: !!(getCookie("reverse-share.public-access") ?? true),
|
publicAccess: !!(getCookie("reverse-share.public-access") ?? true),
|
||||||
},
|
},
|
||||||
|
validate: yupResolver(
|
||||||
|
yup.object().shape({
|
||||||
|
maxUseCount: yup
|
||||||
|
.number()
|
||||||
|
.typeError(t("common.error.invalid-number"))
|
||||||
|
.min(1, t("common.error.number-too-small", { min: 1 }))
|
||||||
|
.max(1000, t("common.error.number-too-large", { max: 1000 }))
|
||||||
|
.required(t("common.error.field-required")),
|
||||||
|
}),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
const onSubmit = form.onSubmit(async (values) => {
|
const onSubmit = form.onSubmit(async (values) => {
|
||||||
|
@ -649,6 +649,8 @@ export default {
|
|||||||
"common.error.invalid-email": "Invalid email address",
|
"common.error.invalid-email": "Invalid email address",
|
||||||
"common.error.too-short": "Must be at least {length} characters",
|
"common.error.too-short": "Must be at least {length} characters",
|
||||||
"common.error.too-long": "Must be at most {length} characters",
|
"common.error.too-long": "Must be at most {length} characters",
|
||||||
|
"common.error.number-too-small": "Must be at least {min}",
|
||||||
|
"common.error.number-too-large": "Must be at most {max}",
|
||||||
"common.error.exact-length": "Must be exactly {length} characters",
|
"common.error.exact-length": "Must be exactly {length} characters",
|
||||||
"common.error.invalid-number": "Must be a number",
|
"common.error.invalid-number": "Must be a number",
|
||||||
"common.error.field-required": "This field is required",
|
"common.error.field-required": "This field is required",
|
||||||
|
Loading…
Reference in New Issue
Block a user