Skip to content

Commit

Permalink
Merge pull request #13 from openimis/develop
Browse files Browse the repository at this point in the history
MERGING RELEASE branches
  • Loading branch information
dragos-dobre authored Apr 24, 2023
2 parents 6c38eb1 + 56d6745 commit 3db3427
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/components/PayerForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const PayerForm = (props) => {
Panels={[FundingPanel]}
save={onSave}
back={onBack}
openDirty={onSave}
actions={[
{
doIt: onReset,
Expand Down
2 changes: 2 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ export const RIGHT_PAYERS_ADD = 121802;
export const RIGHT_PAYERS_DELETE = 121804;
export const RIGHT_PAYERS_EDIT = 121803;

export const MODULE_NAME = "payer";

export const PAYER_TYPES = ["C", "D", "G", "L", "O", "P"];
21 changes: 17 additions & 4 deletions src/pages/PayersPage.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import React from "react";
import { useTranslations, useModulesManager, historyPush, withTooltip, withHistory } from "@openimis/fe-core";
import React, { useEffect } from "react";
import {
useTranslations,
useModulesManager,
historyPush,
withTooltip,
withHistory,
clearCurrentPaginationPage,
} from "@openimis/fe-core";
import { makeStyles } from "@material-ui/styles";
import { useSelector } from "react-redux";
import { RIGHT_PAYERS_ADD, RIGHT_PAYERS_DELETE } from "../constants";
import { useSelector, useDispatch } from "react-redux";
import { RIGHT_PAYERS_ADD, RIGHT_PAYERS_DELETE, MODULE_NAME } from "../constants";
import { usePayerDeleteMutation } from "../hooks";
import { Fab } from "@material-ui/core";
import AddIcon from "@material-ui/icons/Add";
Expand All @@ -15,9 +22,11 @@ const useStyles = makeStyles((theme) => ({

const PayersPage = (props) => {
const { history } = props;
const dispatch = useDispatch();
const modulesManager = useModulesManager();
const { formatMessage, formatMessageWithValues } = useTranslations("payer", modulesManager);
const rights = useSelector((state) => state.core?.user?.i_user?.rights ?? []);
const module = useSelector((state) => state.core?.savedPagination?.module);
const classes = useStyles();
const deleteMutation = usePayerDeleteMutation();
const onDoubleClick = (payer, newTab) =>
Expand All @@ -32,6 +41,10 @@ const PayersPage = (props) => {

const canDelete = (payer) => rights.includes(RIGHT_PAYERS_DELETE) && !payer.validityTo;

useEffect(() => {
if (module !== MODULE_NAME) dispatch(clearCurrentPaginationPage());
}, [module]);

return (
<div className={classes.page}>
<PayerSearcher onDelete={onDelete} canDelete={canDelete} onDoubleClick={onDoubleClick} />
Expand Down

0 comments on commit 3db3427

Please sign in to comment.