Skip to content

Commit

Permalink
Adding/Deactivating ORGS working
Browse files Browse the repository at this point in the history
  • Loading branch information
adityadeshlahre committed Jun 13, 2024
1 parent f0bf5a1 commit 8b17536
Show file tree
Hide file tree
Showing 7 changed files with 288 additions and 112 deletions.
14 changes: 14 additions & 0 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import PrintBarcode from "./components/printBarcode/Index";
import NonConformIndex from "./components/nonconform/index";
import SampleBatchEntrySetup from "./components/batchOrderEntry/SampleBatchEntrySetup.js";
import AuditTrailReportIndex from "./components/reports/auditTrailReport/Index.js";
import AddOrganization from "./components/admin/OrganizationManagament/AddOrganization.js";
import ModifyOrganization from "./components/admin/OrganizationManagament/ModifyOrganization.js";

export default function App() {
let i18nConfig = {
Expand Down Expand Up @@ -226,6 +228,18 @@ export default function App() {
component={() => <Admin />}
role="Global Administrator"
/>
<SecureRoute
path="/AddOrganization"
exact
component={() => <AddOrganization />}
role="Global Administrator"
/>
<SecureRoute
path="/ModifyOrganization"
exact
component={() => <ModifyOrganization />}
role="Global Administrator"
/>
<SecureRoute
path="/PathologyDashboard"
exact
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import {
getFromOpenElisServer,
postToOpenElisServerFullResponse,
postToOpenElisServerJsonResponse,
} from "../../utils/Utils.js";
import { NotificationContext } from "../../layout/Layout.js";
import {
Expand All @@ -47,18 +48,57 @@ function AddOrganization() {
const intl = useIntl();
const [loading, setLoading] = useState(true);
const [page, setPage] = useState(1);
const [pageSize, setPageSize] = useState(5);
const [pageSize, setPageSize] = useState(20);
const [selectedRowIds, setSelectedRowIds] = useState([]);
const [saveButton, setSaveButton] = useState(true);
const [newOrganizationsData, setNewOrganizationsData] = useState(null);
const [typeOfActivity, setTypeOfActivity] = useState(null);
const [typeOfActivityShow, setTypeOfActivityShow] = useState([]);

const handlePageChange = ({ page, pageSize }) => {
setPage(page);
setPageSize(pageSize);
setSelectedRowIds([]);
};
// const handlePageChange = ({ page, pageSize }) => {
// setPage(page);
// setPageSize(pageSize);
// setSelectedRowIds([]);
// };

function handleOrgNameChange(e) {
setSaveButton(false);
setNewOrganizationsData((alreadyOrgInfoToPost) => ({
...alreadyOrgInfoToPost,
organizationName: e.target.value,
}));
}

function handleOrgPrefixChange(e) {
setSaveButton(false);
setNewOrganizationsData((alreadyOrgInfoToPost) => ({
...alreadyOrgInfoToPost,
shortName: e.target.value,
}));
}

function handleIsActiveChange(e) {
setSaveButton(false);
setNewOrganizationsData((alreadyOrgInfoToPost) => ({
...alreadyOrgInfoToPost,
isActive: e.target.value,
}));
}

function handleInternetAddressChange(e) {
setSaveButton(false);
setNewOrganizationsData((alreadyOrgInfoToPost) => ({
...alreadyOrgInfoToPost,
internetAddress: e.target.value,
}));
}

useEffect(() => {
setNewOrganizationsData((alreadyOrgInfoToPost) => ({
...alreadyOrgInfoToPost,
selectedTypes: selectedRowIds,
}));
}, [selectedRowIds, typeOfActivity, typeOfActivityShow]);

useEffect(() => {
if (typeOfActivity) {
Expand All @@ -75,6 +115,15 @@ function AddOrganization() {
newOrganizationsManagementList,
);
setTypeOfActivityShow(newOrganizationsManagementListArray);

const newOrganizationsManagementDataPost = {
id: typeOfActivity.id,
organizationName: typeOfActivity.organizationName || "",
shortName: typeOfActivity.shortName || "",
isActive: typeOfActivity.isActive || "",
internetAddress: typeOfActivity.internetAddress || "",
};
setNewOrganizationsData(newOrganizationsManagementDataPost);
}
}, [typeOfActivity]);

Expand Down Expand Up @@ -102,26 +151,30 @@ function AddOrganization() {
function newOrganizationsSavePost(event) {
event.preventDefault();
setLoading(true);
postToOpenElisServerFullResponse(
postToOpenElisServerJsonResponse(
`/rest/Organization?ID=0&startingRecNo=1`,
newOrganizationsData, // need to check against the form of restController [mentor]
setLoading(false),
addNotification({
title: intl.formatMessage({
id: "notification.title",
}),
message: intl.formatMessage({
id: "notification.organization.post.save.success",
}),
kind: NotificationKinds.success,
}),
setNotificationVisible(true),
setTimeout(() => {
window.location.reload();
}, 2000),
JSON.stringify(newOrganizationsData),
newOrganizationsSavePostCallback(),
);
}

function newOrganizationsSavePostCallback() {
setLoading(false);
setNotificationVisible(true);
addNotification({
title: intl.formatMessage({
id: "notification.title",
}),
message: intl.formatMessage({
id: "notification.organization.post.save.success",
}),
kind: NotificationKinds.success,
});
// setTimeout(() => {
// window.location.reload();
// }, 2000);
}

const renderCell = (cell, row) => {
if (cell.info.header === "select") {
return (
Expand Down Expand Up @@ -196,10 +249,7 @@ function AddOrganization() {
id: "organization.add.placeholder",
})}
required
// invalid={errors.order && touched.order}
// invalidText={errors.order}
// value={values.numDefaultOrderLabels}
// onChange={(e) => handleDefaultOrderLablesValue(e)}
onChange={(e) => handleOrgNameChange(e)}
/>
</Column>
</Grid>
Expand All @@ -218,10 +268,7 @@ function AddOrganization() {
placeholder={intl.formatMessage({
id: "organization.add.placeholder",
})}
// invalid={errors.order && touched.order}
// invalidText={errors.order}
// value={values.numDefaultOrderLabels}
// onChange={(e) => handleDefaultOrderLablesValue(e)}
onChange={(e) => handleOrgPrefixChange(e)}
/>
</Column>
</Grid>
Expand All @@ -242,10 +289,7 @@ function AddOrganization() {
id: "organization.add.placeholder.active",
})}
required
// invalid={errors.order && touched.order}
// invalidText={errors.order}
// value={values.numDefaultOrderLabels}
// onChange={(e) => handleDefaultOrderLablesValue(e)}
onChange={(e) => handleIsActiveChange(e)}
/>
</Column>
</Grid>
Expand All @@ -265,10 +309,7 @@ function AddOrganization() {
placeholder={intl.formatMessage({
id: "organization.add.placeholder",
})}
// invalid={errors.order && touched.order}
// invalidText={errors.order}
// value={values.numDefaultOrderLabels}
// onChange={(e) => handleDefaultOrderLablesValue(e)}
onChange={(e) => handleInternetAddressChange(e)}
/>
</Column>
</Grid>
Expand All @@ -295,6 +336,7 @@ function AddOrganization() {
<br />
<Grid fullWidth={true} className="gridBoundary">
<Column lg={16} md={8} sm={4}>
<br />
<DataTable
rows={typeOfActivityShow.slice(
// need a change
Expand Down Expand Up @@ -419,7 +461,7 @@ function AddOrganization() {
</TableContainer>
)}
</DataTable>
<Pagination
{/* <Pagination
onChange={handlePageChange}
page={page}
pageSize={pageSize}
Expand Down Expand Up @@ -461,7 +503,8 @@ function AddOrganization() {
{ page: pagesUnknown ? "" : page },
)
}
/>
/> */}
<br />
</Column>
</Grid>
<br />
Expand Down Expand Up @@ -493,12 +536,16 @@ function AddOrganization() {
>
sdf
</button>
<button
onClick={() => {
console.error(newOrganizationsData);
}}
>
postData
</button>
</div>
</>
);
}

export default injectIntl(AddOrganization);

// post request need to fix
// save button fix needed
Loading

0 comments on commit 8b17536

Please sign in to comment.