Skip to content

Commit

Permalink
added synchronize parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Kiprotich committed Jan 17, 2025
1 parent e468097 commit cb069e2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import styles from './facility-info.scss';
import { useTranslation } from 'react-i18next';
import { showNotification, showSnackbar } from '@openmrs/esm-framework';
import { FacilityData } from '../../types';

const FacilityInfo: React.FC = () => {
const { t } = useTranslation();
const { defaultFacility, isLoading: defaultFacilityLoading, error, refetch } = useFacilityInfo();
const [shouldSynchronize, setshouldSynchronize] = useState<boolean>(false);
const { defaultFacility, isLoading: defaultFacilityLoading, error, refetch } = useFacilityInfo(shouldSynchronize);

const [facilityData, setFacilityData] = useState<FacilityData>(defaultFacility);
useEffect(() => {
Expand All @@ -19,7 +21,7 @@ const FacilityInfo: React.FC = () => {

const synchronizeFacilityData = async () => {
try {
// Trigger manual refetch
setshouldSynchronize(true);
await refetch();
showSnackbar({
title: t('syncingHieSuccess', 'Synchronization Complete'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { FetchResponse, openmrsFetch, restBaseUrl, useSession } from '@openmrs/e
import useSWR from 'swr';
import { FacilityData } from '../../types';

export function useFacilityInfo() {
export function useFacilityInfo(shouldSynchronize: boolean = false) {
const { authenticated } = useSession();
const url = `${restBaseUrl}/kenyaemr/default-facility`;
const url = `${restBaseUrl}/kenyaemr/default-facility?synchronize=${shouldSynchronize}`;

const { data, isLoading, error, mutate } = useSWR<FetchResponse<FacilityData>>(
authenticated ? url : null,
Expand Down
6 changes: 3 additions & 3 deletions packages/esm-billing-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
"delete": "Delete",
"deleteBill": "Delete Bill",
"description": "Description",
"diagnoses": "Diagnoses",
"discard": "Discard",
"discardClaim": "Discard Claim",
"discount": "Discount",
Expand Down Expand Up @@ -109,6 +108,7 @@
"enterRegExp": "Enter regular expression",
"error": "Error",
"errored": "Errored",
"errorEndingVisit": "Error ending visit",
"errorFetchingPackages": "Error fetching packeges",
"errorLoadingBillServices": "Error loading bill services",
"errorLoadingPaymentModes": "Payment modes error",
Expand Down Expand Up @@ -201,7 +201,6 @@
"payments": "Payments",
"paymentType": "Payment Type",
"pendingHIEVerification": "Pending HIE verification",
"pendingVerificationReason": "",
"Phone Number": "Phone Number",
"pickLabRequest": "Pick Lab Request",
"policyNumber": "Policy number",
Expand Down Expand Up @@ -282,8 +281,9 @@
"unsettledBill": "Unsettled bill",
"updateRegistration": "Update registration",
"valuated": "Valuated",
"verify": "Verify",
"verifyingBillStatus": "Verifying bill status...",
"visitEnded": "Visit ended",
"visitEndSuccessfully": "",
"visitTime": "Visit time",
"visittype": "Visit Type",
"waiveBill": "Waive Bill",
Expand Down

0 comments on commit cb069e2

Please sign in to comment.