From 6c18e2bdd95367762bf8db80b74f2a5f8138ce76 Mon Sep 17 00:00:00 2001 From: Gigin George Date: Thu, 22 Aug 2024 10:06:19 -0700 Subject: [PATCH] Enable Facility Cover Image Uploads on Mobile Screens (#8402) * Optimize Facility Cover Image for Reload * Fix Edit Cover Image for Mobile Screens * Revert temp assignment * fixed lint --------- Co-authored-by: Khavin Shankar --- src/Components/Facility/FacilityHome.tsx | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Components/Facility/FacilityHome.tsx b/src/Components/Facility/FacilityHome.tsx index 1b362d9e4f0..82ee82afb22 100644 --- a/src/Components/Facility/FacilityHome.tsx +++ b/src/Components/Facility/FacilityHome.tsx @@ -38,6 +38,10 @@ import { LocationSelect } from "../Common/LocationSelect.js"; import { CameraFeedPermittedUserTypes } from "../../Utils/permissions.js"; import { FacilityStaffList } from "./FacilityStaffList.js"; +type Props = { + facilityId: string; +}; + const Loading = lazy(() => import("../Common/Loading")); export const getFacilityFeatureIcon = (featureId: number) => { @@ -50,12 +54,10 @@ export const getFacilityFeatureIcon = (featureId: number) => { ); }; -export const FacilityHome = (props: any) => { +export const FacilityHome = ({ facilityId }: Props) => { const { t } = useTranslation(); - const { facilityId } = props; const [openDeleteDialog, setOpenDeleteDialog] = useState(false); const [editCoverImage, setEditCoverImage] = useState(false); - const [imageKey, setImageKey] = useState(Date.now()); const authUser = useAuthUser(); useMessageListener((data) => console.log(data)); @@ -112,7 +114,10 @@ export const FacilityHome = (props: any) => { const editCoverImageTooltip = hasPermissionToEditCoverImage && (
setEditCoverImage(true)} > {`${hasCoverImage ? "Edit" : "Upload"}`} @@ -121,7 +126,7 @@ export const FacilityHome = (props: any) => { const CoverImage = () => ( {facilityData?.name} @@ -150,11 +155,7 @@ export const FacilityHome = (props: any) => { /> - facilityData?.read_cover_image_url - ? setImageKey(Date.now()) - : facilityFetch() - } + onSave={() => facilityFetch()} onClose={() => setEditCoverImage(false)} onDelete={() => facilityFetch()} facility={facilityData ?? ({} as FacilityModel)}