diff --git a/src/components/chip/RequireChip.tsx b/src/components/chip/RequireChip.tsx new file mode 100644 index 0000000..8a3e95a --- /dev/null +++ b/src/components/chip/RequireChip.tsx @@ -0,0 +1,10 @@ +import { Chip, ChipProps } from "@mui/material"; + +export type RequireChipProps = { show?: boolean } & ChipProps; +export default function RequireChip(props: RequireChipProps) { + const { show } = props; + if (show === false) { + return null; + } + return ; +} diff --git a/src/components/stack/StackRow.tsx b/src/components/stack/StackRow.tsx new file mode 100644 index 0000000..7b922ff --- /dev/null +++ b/src/components/stack/StackRow.tsx @@ -0,0 +1,18 @@ +import { Stack, StackProps } from "@mui/material"; +import { HasChildren } from "@types"; + +export type StackRowProps = { + show?: boolean; +} & StackProps & + HasChildren; +export default function StackRow(props: StackRowProps) { + const { show } = props; + if (show === false) { + return null; + } + return ( + + {props.children} + + ); +} diff --git a/src/pages/dashboard/receipt-issuing-order/custom/hello-techno/hooks/useInputReceiptStep.tsx b/src/pages/dashboard/receipt-issuing-order/custom/hello-techno/hooks/useInputReceiptStep.tsx index 611d51a..9b10608 100644 --- a/src/pages/dashboard/receipt-issuing-order/custom/hello-techno/hooks/useInputReceiptStep.tsx +++ b/src/pages/dashboard/receipt-issuing-order/custom/hello-techno/hooks/useInputReceiptStep.tsx @@ -1,18 +1,11 @@ import { yupResolver } from "@hookform/resolvers/yup"; -import { Box, Button, Stack, TextField, Typography } from "@mui/material"; +import { Box, Button, Stack, Typography } from "@mui/material"; import { HasChildren } from "@types"; -import { HTAdjustData, getHTAdjustData } from "api/custom/hello-techno"; -import { - FormProvider, - RHFAutoComplete, - RHFTextField, -} from "components/hook-form"; -import { - AutoCompleteOption, - AutoCompleteOptionType, - getValue, -} from "components/hook-form/RHFAutoComplete"; +import { HTAdjustData } from "api/custom/hello-techno"; +import RequireChip from "components/chip/RequireChip"; +import { FormProvider, RHFTextField } from "components/hook-form"; import RHFDatePicker from "components/hook-form/RHFDatePicker"; +import StackRow from "components/stack/StackRow"; import { useEffect, useMemo, useState } from "react"; import { useForm } from "react-hook-form"; import { dateTimeParse } from "utils/datetime"; @@ -21,11 +14,15 @@ import * as Yup from "yup"; type AreaBoxProps = { title: string; + require?: boolean; } & HasChildren; -function AreaBox({ title, children }: AreaBoxProps) { +function AreaBox({ title, children, require }: AreaBoxProps) { return ( - {title} + + {title} + + {children} ); @@ -57,8 +54,16 @@ export default function useInputReceiptStep({ onNext, onPrev }: Props) { date: Yup.date() .required("必須項目です") .typeError("正しく入力してください"), - amount: Yup.number().required("必須項目です"), - tax_amount: Yup.number().required("必須項目です"), + amount: Yup.number() + .typeError("数値を入力してください") + .test("range", "1-50000まで入力できます", function (value) { + return typeof value === "number" && 1 <= value && value <= 50000; + }), + tax_amount: Yup.number() + .typeError("数値を入力してください") + .test("range", "1-50000まで入力できます", function (value) { + return typeof value === "number" && 1 <= value && value <= 50000; + }), memo: Yup.string().nullable(), }) ), @@ -99,10 +104,10 @@ export default function useInputReceiptStep({ onNext, onPrev }: Props) { const element = ( - + - + - +