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", "Email format is not correct": "Email format is not correct",
"English": "English", "English": "English",
"Go to Reports": "Go to Reports", "Go to Reports": "Go to Reports",
"Handwritten": "Handwritten",
"Inference": "Inference", "Inference": "Inference",
"Invalid image": "Invalid image",
"Is Test": "Is Test", "Is Test": "Is Test",
"Language": "Language", "Language": "Language",
"Login": "Login", "Login": "Login",
"Logout": "Logout", "Logout": "Logout",
"Missing information": "Missing information",
"New Report": "New Report", "New Report": "New Report",
"Only characters (a-z), (A-Z), (0-9), @, ., +, -, _ are available": "Only characters (a-z), (A-Z), (0-9), @, ., +, -, _ are available", "Only characters (a-z), (A-Z), (0-9), @, ., +, -, _ are available": "Only characters (a-z), (A-Z), (0-9), @, ., +, -, _ are available",
"Password": "Password", "Password": "Password",
@ -28,8 +31,11 @@
"Please enter a valid domain": "Please enter a valid domain", "Please enter a valid domain": "Please enter a valid domain",
"Please specify a password": "Please specify a password", "Please specify a password": "Please specify a password",
"Please specify a username": "Please specify a username", "Please specify a username": "Please specify a username",
"Reason for bad quality:": "Reason for bad quality:",
"Recheck": "Recheck",
"Report Details": "Report Details", "Report Details": "Report Details",
"Report Filters": "Report Filters", "Report Filters": "Report Filters",
"Report Type": "Report Type",
"Reports": "Reports", "Reports": "Reports",
"Retry": "Retry", "Retry": "Retry",
"Review": "Review", "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_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_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", "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.", "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", "User log in successfully": "User log in successfully",
"Username": "Username", "Username": "Username",

View File

@ -11,11 +11,14 @@
"Email format is not correct": "Định dạng email không hợp lệ", "Email format is not correct": "Định dạng email không hợp lệ",
"English": "Tiếng Anh", "English": "Tiếng Anh",
"Go to Reports": "", "Go to Reports": "",
"Handwritten": "",
"Inference": "", "Inference": "",
"Invalid image": "",
"Is Test": "", "Is Test": "",
"Language": "Ngôn ngữ", "Language": "Ngôn ngữ",
"Login": "Đăng nhập", "Login": "Đăng nhập",
"Logout": "Đăng xuất", "Logout": "Đăng xuất",
"Missing information": "",
"New Report": "", "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), @, ., +, -, _", "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", "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 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 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", "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 Details": "",
"Report Filters": "", "Report Filters": "",
"Report Type": "",
"Reports": "", "Reports": "",
"Retry": "Thử lại", "Retry": "Thử lại",
"Review": "", "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_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_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ự", "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.": "", "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", "User log in successfully": "Đăng nhập thành công",
"Username": "Tên tài khoản", "Username": "Tên tài khoản",

View File

@ -13,10 +13,31 @@ export interface ReportFormValues {
reportType: string; 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 ReportsPage = () => {
const [form] = Form.useForm<ReportFormValues>(); const [form] = Form.useForm<ReportFormValues>();
const [isModalOpen, setIsModalOpen] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false);
const makeReportMutation = useMakeReport(); 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 = () => { const showModal = () => {
setIsModalOpen(true); setIsModalOpen(true);
@ -113,15 +134,7 @@ const ReportsPage = () => {
<Select <Select
placeholder='Select a subsidiary' placeholder='Select a subsidiary'
style={{ width: 200 }} style={{ width: 200 }}
options={[ options={subsidiaryOptions}
{ 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' },
]}
/> />
</Form.Item> </Form.Item>
@ -137,6 +150,7 @@ const ReportsPage = () => {
initialValue={'accuracy'} initialValue={'accuracy'}
> >
<Select <Select
onSelect={onReportTypeChange}
placeholder='Select a report type' placeholder='Select a report type'
style={{ width: 200 }} style={{ width: 200 }}
options={[ options={[