Merge pull request #72 from SDSRV-IDP/fix/fe-issues

Fix report creation form
This commit is contained in:
Đỗ Xuân Tân 2024-03-07 13:05:35 +07:00 committed by GitHub Enterprise
commit b02f4fba3d
3 changed files with 43 additions and 16 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);
@ -35,7 +56,6 @@ const ReportsPage = () => {
})
.then((data) => {
if (!!data && data?.report_id) {
form.resetFields();
setIsModalOpen(false);
window.location.reload();
}
@ -53,8 +73,6 @@ const ReportsPage = () => {
setIsModalOpen(false);
};
form.setFieldsValue({reportType: "accuracy"})
return (
<>
<SbtPageHeader
@ -111,19 +129,12 @@ const ReportsPage = () => {
message: 'Please select a subsidiary',
},
]}
initialValue={'SEAO'}
>
<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>
@ -136,16 +147,16 @@ const ReportsPage = () => {
message: 'Please select a type',
},
]}
initialValue={'accuracy'}
>
<Select
onSelect={onReportTypeChange}
placeholder='Select a report type'
style={{ width: 200 }}
options={[
{ value: 'billing', label: 'billing' },
{ value: 'accuracy', label: 'accuracy' },
{ value: 'billing', label: 'Billing' },
{ value: 'accuracy', label: 'Accuracy' },
]}
// defaultValue='accuracy'
/>
</Form.Item>
</Form>