Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to authorize user to register patient #9000

Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
80a8168
Add function to authorize user to register patient
JavidSumra Nov 5, 2024
314b50c
Merge branch 'develop' into issues/8988/fix-infinite-rendering-non-ho…
JavidSumra Nov 6, 2024
fdb7940
Merge branch 'develop' into issues/8988/fix-infinite-rendering-non-ho…
JavidSumra Nov 6, 2024
bd34bcb
Add Requested Changes
JavidSumra Nov 6, 2024
7a399b6
fix merger conflict
JavidSumra Nov 6, 2024
088f675
Merge branch 'issues/8988/fix-infinite-rendering-non-home-facility' o…
JavidSumra Nov 6, 2024
6c32072
Merge branch 'ohcnetwork:develop' into issues/8988/fix-infinite-rende…
JavidSumra Nov 7, 2024
7976cea
Reuse Existing Function
JavidSumra Nov 7, 2024
6c87511
Merge branch 'develop' into issues/8988/fix-infinite-rendering-non-ho…
JavidSumra Nov 8, 2024
0c2465e
Merge branch 'develop' into issues/8988/fix-infinite-rendering-non-ho…
JavidSumra Nov 8, 2024
33fc126
Merge branch 'develop' into issues/8988/fix-infinite-rendering-non-ho…
JavidSumra Nov 9, 2024
c43182b
Merge branch 'develop' into issues/8988/fix-infinite-rendering-non-ho…
JavidSumra Nov 9, 2024
8a1f1e9
Merge branch 'develop' into issues/8988/fix-infinite-rendering-non-ho…
JavidSumra Nov 11, 2024
db937ee
Merge branch 'develop' into issues/8988/fix-infinite-rendering-non-ho…
JavidSumra Nov 19, 2024
b4e86a0
Update Resource Forms to Enhance Validation
JavidSumra Nov 8, 2024
07d67ee
fix resource update test suit
JavidSumra Nov 9, 2024
f538481
Updated Handle Input to avoid Negative Value
JavidSumra Nov 19, 2024
9bb8300
Remove Unnecessary Comments
JavidSumra Nov 19, 2024
fae34fa
Resolve Merge Conflicts
JavidSumra Nov 19, 2024
c82b232
Apply suggestions from code review
rithviknishad Nov 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 37 additions & 11 deletions src/components/Facility/FacilityHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,30 @@ export const FacilityHome = ({ facilityId }: Props) => {
}
};

const isAuthorizedToRegisterPatientsterAuth = () => {
const showAllFacilityUsers = ["DistrictAdmin", "StateAdmin"];
if (
!showAllFacilityUsers.includes(authUser.user_type) &&
authUser.home_facility_object?.id === facilityId
) {
return true;
}
if (
authUser.user_type === "DistrictAdmin" &&
authUser.district === facilityData?.district
) {
return true;
}
if (
authUser.user_type === "StateAdmin" &&
authUser.state === facilityData?.state
) {
return true;
}

return false;
};
JavidSumra marked this conversation as resolved.
Show resolved Hide resolved

if (isLoading) {
return <Loading />;
}
Expand Down Expand Up @@ -461,17 +485,19 @@ export const FacilityHome = ({ facilityId }: Props) => {
{CameraFeedPermittedUserTypes.includes(authUser.user_type) && (
<LiveMonitoringButton />
)}
<ButtonV2
variant="primary"
ghost
border
className="mt-2 flex w-full flex-row justify-center md:w-auto"
onClick={() => navigate(`/facility/${facilityId}/patient`)}
authorizeFor={NonReadOnlyUsers}
>
<CareIcon icon="l-plus" className="text-lg" />
<span className="text-sm">{t("add_details_of_patient")}</span>
</ButtonV2>
{isAuthorizedToRegisterPatientsterAuth() && (
<ButtonV2
variant="primary"
ghost
border
className="mt-2 flex w-full flex-row justify-center md:w-auto"
onClick={() => navigate(`/facility/${facilityId}/patient`)}
authorizeFor={NonReadOnlyUsers}
>
<CareIcon icon="l-plus" className="text-lg" />
<span className="text-sm">{t("add_details_of_patient")}</span>
</ButtonV2>
)}
<ButtonV2
id="view-patient-facility-list"
variant="primary"
Expand Down
Loading