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

Enable Facility Cover Image Uploads on Mobile Screens #8402

Merged
merged 4 commits into from
Aug 22, 2024
Merged
Changes from all commits
Commits
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
21 changes: 11 additions & 10 deletions src/Components/Facility/FacilityHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,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) => {
Expand All @@ -45,12 +49,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));
Expand Down Expand Up @@ -107,7 +109,10 @@ export const FacilityHome = (props: any) => {
const editCoverImageTooltip = hasPermissionToEditCoverImage && (
<div
id="facility-coverimage"
className="absolute right-0 top-0 z-10 flex h-full w-full flex-col items-center justify-center rounded-t-lg bg-black text-sm text-secondary-300 opacity-0 transition-opacity hover:opacity-60 md:h-[88px]"
className={
"absolute right-0 top-0 z-10 flex h-full w-full cursor-pointer flex-col items-center justify-center rounded-t-lg bg-black text-sm text-secondary-300 opacity-0 transition-opacity hover:opacity-60 md:h-[88px]"
}
onClick={() => setEditCoverImage(true)}
>
<CareIcon icon="l-pen" className="text-lg" />
<span className="mt-2">{`${hasCoverImage ? "Edit" : "Upload"}`}</span>
Expand All @@ -116,7 +121,7 @@ export const FacilityHome = (props: any) => {

const CoverImage = () => (
<img
src={`${facilityData?.read_cover_image_url}?imgKey=${imageKey}`}
src={`${facilityData?.read_cover_image_url}`}
alt={facilityData?.name}
className="h-full w-full rounded-lg object-cover"
/>
Expand Down Expand Up @@ -145,11 +150,7 @@ export const FacilityHome = (props: any) => {
/>
<CoverImageEditModal
open={editCoverImage}
onSave={() =>
facilityData?.read_cover_image_url
? setImageKey(Date.now())
: facilityFetch()
}
onSave={() => facilityFetch()}
onClose={() => setEditCoverImage(false)}
onDelete={() => facilityFetch()}
facility={facilityData ?? ({} as FacilityModel)}
Expand Down
Loading