This commit was merged in pull request #75.
This commit is contained in:
@@ -6,6 +6,7 @@ import { calendarDate } from "@/shared/lib";
|
|||||||
import { bankToday } from "./form-validation";
|
import { bankToday } from "./form-validation";
|
||||||
import { moneyCents } from "./money";
|
import { moneyCents } from "./money";
|
||||||
const MAX_CARD_NAME_LENGTH = 100;
|
const MAX_CARD_NAME_LENGTH = 100;
|
||||||
|
const paymentSystemValues = ["mir", "visa", "mastercard"] as const;
|
||||||
const MIN_BALANCE_KOPECKS = -9_223_372_036_854_775_808n;
|
const MIN_BALANCE_KOPECKS = -9_223_372_036_854_775_808n;
|
||||||
const MAX_BALANCE_KOPECKS = 9_223_372_036_854_775_807n;
|
const MAX_BALANCE_KOPECKS = 9_223_372_036_854_775_807n;
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@ const bankCardSchema = z.object({
|
|||||||
openingBalance: moneySchema,
|
openingBalance: moneySchema,
|
||||||
openingDate: bankDateSchema,
|
openingDate: bankDateSchema,
|
||||||
paymentSystem: z
|
paymentSystem: z
|
||||||
.enum(["", "mir", "visa", "mastercard"], {
|
.enum(["", ...paymentSystemValues], {
|
||||||
error: validationMessage("bank.validation.paymentSystem"),
|
error: validationMessage("bank.validation.paymentSystem"),
|
||||||
})
|
})
|
||||||
.optional(),
|
.optional(),
|
||||||
@@ -75,5 +76,6 @@ export {
|
|||||||
bankCardSchema,
|
bankCardSchema,
|
||||||
type BankCardValues,
|
type BankCardValues,
|
||||||
bankDateSchema,
|
bankDateSchema,
|
||||||
|
paymentSystemValues,
|
||||||
positiveMoneySchema,
|
positiveMoneySchema,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { useController, useFormContext } from "react-hook-form";
|
import { useController, useFormContext } from "react-hook-form";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import type { BankCardValues } from "../../model/form.schema";
|
import { type BankCardValues, paymentSystemValues } from "../../model/form.schema";
|
||||||
|
|
||||||
import { bankDateField } from "../bankDateField";
|
import { bankDateField } from "../bankDateField";
|
||||||
|
|
||||||
function useBankCardFieldsVm() {
|
function useBankCardFieldsVm() {
|
||||||
@@ -16,7 +15,7 @@ function useBankCardFieldsVm() {
|
|||||||
const { field: openingDateField } = useController({ control, name: "openingDate" });
|
const { field: openingDateField } = useController({ control, name: "openingDate" });
|
||||||
const { field: paymentSystemField } = useController({ control, name: "paymentSystem" });
|
const { field: paymentSystemField } = useController({ control, name: "paymentSystem" });
|
||||||
|
|
||||||
const paymentSystems = ["mir", "visa", "mastercard"].map(value => ({
|
const paymentSystems = paymentSystemValues.map(value => ({
|
||||||
label: t(`bank.paymentSystems.${value}`),
|
label: t(`bank.paymentSystems.${value}`),
|
||||||
value,
|
value,
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user