Skip to content

Commit

Permalink
added resolved middleware text at location management
Browse files Browse the repository at this point in the history
  • Loading branch information
saikiranpatil committed Dec 10, 2024
1 parent 4d2cf0d commit 937e6fd
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/components/Facility/LocationManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface Props {
interface LocationProps extends LocationModel {
facilityId: string;
disabled: boolean;
facilityMiddleware?: string;
setShowDeletePopup: (e: { open: boolean; name: string; id: string }) => void;
}

Expand All @@ -42,6 +43,18 @@ export default function LocationManagement({ facilityId }: Props) {
name: "",
id: "",
});
const [facilityMiddleware, setFacilityMiddleware] = useState<
string | undefined
>(undefined);

useQuery(routes.getPermittedFacility, {
pathParams: { id: facilityId },
onResponse: (res) => {
if (res.data) {
setFacilityMiddleware(res.data?.middleware_address);
}
},
});

const closeDeleteFailModal = () => {
setShowDeleteFailModal({ ...showDeleteFailModal, open: false });
Expand Down Expand Up @@ -121,6 +134,7 @@ export default function LocationManagement({ facilityId }: Props) {
<Location
setShowDeletePopup={setShowDeletePopup}
facilityId={facilityId}
facilityMiddleware={facilityMiddleware}
{...item}
disabled={
["DistrictAdmin", "StateAdmin"].includes(authUser.user_type)
Expand Down Expand Up @@ -221,6 +235,7 @@ const Location = ({
name,
description,
middleware_address,
facilityMiddleware,
location_type,
created_date,
modified_date,
Expand Down Expand Up @@ -268,14 +283,19 @@ const Location = ({
>
{description || "-"}
</p>
<p className="mt-3 text-sm font-semibold text-secondary-700">
<span className="mt-3 text-sm font-semibold text-secondary-700">
Middleware Address:
</p>
</span>
{!middleware_address && facilityMiddleware && (
<span className="ml-1 text-xs text-primary-400 opaticy-70">
Fetched from facility
</span>
)}
<p
className="mt-1 break-all font-mono text-sm font-bold text-secondary-700"
id="view-location-middleware"
>
{middleware_address || "-"}
{middleware_address || facilityMiddleware || "-"}
</p>
<Uptime
route={routes.listFacilityAssetLocationAvailability}
Expand Down

0 comments on commit 937e6fd

Please sign in to comment.