Add constraints for input

This commit is contained in:
Viet Anh Nguyen 2024-03-07 11:27:53 +07:00
parent 01596e3222
commit b3fd8c22c9
3 changed files with 39 additions and 9 deletions

View File

@ -11,11 +11,14 @@
"Email format is not correct": "Email format is not correct",
"English": "English",
"Go to Reports": "Go to Reports",
"Handwritten": "Handwritten",
"Inference": "Inference",
"Invalid image": "Invalid image",
"Is Test": "Is Test",
"Language": "Language",
"Login": "Login",
"Logout": "Logout",
"Missing information": "Missing information",
"New Report": "New Report",
"Only characters (a-z), (A-Z), (0-9), @, ., +, -, _ are available": "Only characters (a-z), (A-Z), (0-9), @, ., +, -, _ are available",
"Password": "Password",
@ -28,8 +31,11 @@
"Please enter a valid domain": "Please enter a valid domain",
"Please specify a password": "Please specify a password",
"Please specify a username": "Please specify a username",
"Reason for bad quality:": "Reason for bad quality:",
"Recheck": "Recheck",
"Report Details": "Report Details",
"Report Filters": "Report Filters",
"Report Type": "Report Type",
"Reports": "Reports",
"Retry": "Retry",
"Review": "Review",
@ -43,6 +49,8 @@
"This field must not have more than {MAX_EMAIL_LENGTH} characters": "This field must not have more than {MAX_EMAIL_LENGTH} characters",
"This field must not have more than {MAX_STRING_LENGTH} characters": "This field must not have more than {MAX_STRING_LENGTH} characters",
"This field must not have more than {MAX_USERNAME_LENGTH} characters": "This field must not have more than {MAX_USERNAME_LENGTH} characters",
"Too blurry text": "Too blurry text",
"Too small text": "Too small text",
"Upload files to process. The requests here will not be used in accuracy or payment calculations.": "Upload files to process. The requests here will not be used in accuracy or payment calculations.",
"User log in successfully": "User log in successfully",
"Username": "Username",

View File

@ -11,11 +11,14 @@
"Email format is not correct": "Định dạng email không hợp lệ",
"English": "Tiếng Anh",
"Go to Reports": "",
"Handwritten": "",
"Inference": "",
"Invalid image": "",
"Is Test": "",
"Language": "Ngôn ngữ",
"Login": "Đăng nhập",
"Logout": "Đăng xuất",
"Missing information": "",
"New Report": "",
"Only characters (a-z), (A-Z), (0-9), @, ., +, -, _ are available": "Chỉ cho phép các ký tự (a-z), (A-Z), (0-9), @, ., +, -, _",
"Password": "Mật khẩu",
@ -28,8 +31,11 @@
"Please enter a valid domain": "Vui lòng nhập một tên miền hợp lệ",
"Please specify a password": "Vui lòng nhập một mật khẩu",
"Please specify a username": "Vui lòng nhập một tên tài khoản",
"Reason for bad quality:": "",
"Recheck": "",
"Report Details": "",
"Report Filters": "",
"Report Type": "",
"Reports": "",
"Retry": "Thử lại",
"Review": "",
@ -43,6 +49,8 @@
"This field must not have more than {MAX_EMAIL_LENGTH} characters": "Độ dài chuỗi không được vượt quá {MAX_EMAIL_LENGTH} kí tự",
"This field must not have more than {MAX_STRING_LENGTH} characters": "Độ dài chuỗi không được vượt quá {MAX_STRING_LENGTH} kí tự",
"This field must not have more than {MAX_USERNAME_LENGTH} characters": "Độ dài chuỗi không được vượt quá {MAX_USERNAME_LENGTH} kí tự",
"Too blurry text": "",
"Too small text": "",
"Upload files to process. The requests here will not be used in accuracy or payment calculations.": "",
"User log in successfully": "Đăng nhập thành công",
"Username": "Tên tài khoản",

View File

@ -13,10 +13,31 @@ export interface ReportFormValues {
reportType: string;
}
const DEFAULT_SUBSIDIARY_OPTIONS = [
{ value: 'SEAO', label: 'SEAO' },
{ value: 'SEAU', label: 'SEAU' },
{ value: 'SESP', label: 'SESP' },
{ value: 'SME', label: 'SME' },
{ value: 'SEPCO', label: 'SEPCO' },
{ value: 'TSE', label: 'TSE' },
{ value: 'SEIN', label: 'SEIN' },
];
const ReportsPage = () => {
const [form] = Form.useForm<ReportFormValues>();
const [isModalOpen, setIsModalOpen] = useState(false);
const makeReportMutation = useMakeReport();
const [subsidiaryOptions, setSubsidiaryOptions] = useState(DEFAULT_SUBSIDIARY_OPTIONS);
const onReportTypeChange = (value: string) => {
if (value === 'billing') {
setSubsidiaryOptions([DEFAULT_SUBSIDIARY_OPTIONS[0]]);
form.setFieldValue('subsidiary', 'SEAO');
} else if (value === 'payment') {
} else {
setSubsidiaryOptions(DEFAULT_SUBSIDIARY_OPTIONS);
}
};
const showModal = () => {
setIsModalOpen(true);
@ -113,15 +134,7 @@ const ReportsPage = () => {
<Select
placeholder='Select a subsidiary'
style={{ width: 200 }}
options={[
{ value: 'SEAO', label: 'SEAO' },
{ value: 'SEAU', label: 'SEAU' },
{ value: 'SESP', label: 'SESP' },
{ value: 'SME', label: 'SME' },
{ value: 'SEPCO', label: 'SEPCO' },
{ value: 'TSE', label: 'TSE' },
{ value: 'SEIN', label: 'SEIN' },
]}
options={subsidiaryOptions}
/>
</Form.Item>
@ -137,6 +150,7 @@ const ReportsPage = () => {
initialValue={'accuracy'}
>
<Select
onSelect={onReportTypeChange}
placeholder='Select a report type'
style={{ width: 200 }}
options={[