Skip to content

Commit

Permalink
DBC22-3293: added missing event handler for camera details page
Browse files Browse the repository at this point in the history
DBC22-3293: added missing event handler for camera details page
  • Loading branch information
bcgov-brwang authored and ray-oxd committed Jan 16, 2025
1 parent 519fc56 commit c7b7298
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/frontend/src/pages/CameraDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ export default function CameraDetailsPage() {
const [show, setShow] = useState(true);
const [isUpdated, setIsUpdated] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [activeIndex, setActiveIndex] = useState(0);
const handleCameraImageClick = (event) => {
const container = event.currentTarget.closest(".camera-orientations");
const buttons = container.querySelectorAll(".camera-direction-btn");
let currentIndex = Array.from(buttons).findIndex(
(button) => button.classList.contains("current")
);
if (currentIndex === -1) {
currentIndex = activeIndex;
}
const nextIndex = (currentIndex + 1) % buttons.length;
buttons[nextIndex].focus();
setActiveIndex(nextIndex);
const nextCamera = camera.camGroup[nextIndex];
setCamera(nextCamera);
trackEvent("click", "camera-list", "camera", nextCamera.name);
};

useEffect(() => {
if (showLoader) {
Expand Down Expand Up @@ -575,6 +592,8 @@ export default function CameraDetailsPage() {
src={colocatedCamIcon}
role="presentation"
alt="colocated cameras icon"
onClick={handleCameraImageClick}
style={{ cursor: "pointer" }}
/>
<span>Direction</span>
</span>
Expand Down

0 comments on commit c7b7298

Please sign in to comment.