diff --git a/frontend/src/components/reports/common/ReportByDate.js b/frontend/src/components/reports/common/ReportByDate.js index 2c089446a2..9b3b603ee7 100644 --- a/frontend/src/components/reports/common/ReportByDate.js +++ b/frontend/src/components/reports/common/ReportByDate.js @@ -15,7 +15,7 @@ import "../../Style.css"; import { AlertDialog } from "../../common/CustomNotification"; import CustomDatePicker from "../../common/CustomDatePicker"; import config from "../../../config.json"; -import { encodeDate } from "../../utils/Utils"; +import { encodeDate, Roles } from "../../utils/Utils"; import { getFromOpenElisServer } from "../../utils/Utils"; const ReportByDate = (props) => { const intl = useIntl(); @@ -122,7 +122,7 @@ const ReportByDate = (props) => { getFromOpenElisServer("/rest/panels", setTempData); break; case "activityReportByTestSection": - getFromOpenElisServer("/rest/test-sections", setTempData); + getFromOpenElisServer("/rest/user-test-sections/"+ Roles.REPORTS, setTempData); break; default: break; diff --git a/frontend/src/components/reports/routine/ActivityReport.js b/frontend/src/components/reports/routine/ActivityReport.js deleted file mode 100644 index ee0c9cd9c1..0000000000 --- a/frontend/src/components/reports/routine/ActivityReport.js +++ /dev/null @@ -1,214 +0,0 @@ -import React, { useEffect, useState, useRef } from "react"; -import { FormattedMessage, useIntl } from "react-intl"; -import { - Form, - FormLabel, - Grid, - Column, - Section, - Button, - Loading, - Select, - SelectItem, - Row, -} from "@carbon/react"; -import CustomDatePicker from "../../common/CustomDatePicker"; -import { AlertDialog } from "../../common/CustomNotification"; -import TestSelectForm from "../../workplan/TestSelectForm"; -import TestSectionSelectForm from "../../workplan/TestSectionSelectForm"; -import PanelSelectForm from "../../workplan/PanelSelectForm"; -import "../../Style.css"; -import { getFromOpenElisServer } from "../../utils/Utils"; -import { encodeDate } from "../../utils/Utils"; -import config from "../../../config.json"; - -const ActivityReport = ({ report }) => { - const intl = useIntl(); - const [loading, setLoading] = useState(true); - const [notificationVisible, setNotificationVisible] = useState(false); - const [reportFormValues, setReportFormValues] = useState({ - startDate: null, - endDate: null, - value: null, - error: null, - }); - const [list, setList] = useState([]); - - const handleDatePickerChangeDate = (datePicker, date) => { - let updatedDate = encodeDate(date); - let obj = null; - switch (datePicker) { - case "startDate": - obj = { - ...reportFormValues, - startDate: updatedDate, - }; - break; - case "endDate": - obj = { - ...reportFormValues, - endDate: updatedDate, - }; - break; - default: - } - setReportFormValues(obj); - }; - - const handleSubmit = () => { - setLoading(true); - let reportType = ""; - let additionalParams = ""; - switch (selectedReportType) { - case "byTest": - reportType = "activityReportByTest"; - additionalParams = "report=activityReportByTest"; - break; - case "byPanel": - reportType = "activityReportByPanel"; - additionalParams = "report=activityReportByPanel"; - break; - case "byUnit": - reportType = "activityReportByTestSection"; - additionalParams = "report=activityReportByTestSection"; - break; - default: - break; - } - const baseParams = `${additionalParams}&type=indicator&report=${reportType}`; - const baseUrl = `${config.serverBaseUrl}/ReportPrint`; - const url = `${baseUrl}?${baseParams}&lowerDateRange=${reportFormValues.startDate}&upperDateRange=${reportFormValues.endDate}`; - window.open(url, "_blank"); - setLoading(false); - setNotificationVisible(true); - }; - - const setDataList = (data) => { - setList(data); - console.log("data: ", data); - setLoading(false); - }; - - useEffect(() => { - switch (report) { - case "activityReportByTest": - getFromOpenElisServer("/rest/test-list", setDataList); - console.log("list: ", list); - break; - case "activityReportByPanel": - getFromOpenElisServer("/rest/panels", setDataList); - break; - case "activityReportByTestSection": - getFromOpenElisServer("/rest/test-sections", setDataList); - break; - default: - break; - } - }, [report]); - - return ( - <> - -
-
-

- -

-
-
-
- {notificationVisible && } - {loading && } - - -
- - -
-
-
- -
-
-
- - handleDatePickerChangeDate("startDate", date) - } - /> - - handleDatePickerChangeDate("endDate", date) - } - /> -
-
-
hihih
- - - {list && list.length > 0 && ( - - )} - -
- -
-
-
- -
-
-
-
- - ); -}; - -export default ActivityReport;