diff --git a/apps/web/lib/features/activity/components/screenshoots-per-hour.tsx b/apps/web/lib/features/activity/components/screenshoots-per-hour.tsx index 1a617c2f8..7220d7c62 100644 --- a/apps/web/lib/features/activity/components/screenshoots-per-hour.tsx +++ b/apps/web/lib/features/activity/components/screenshoots-per-hour.tsx @@ -1,8 +1,11 @@ +"use client" + import { ITimerSlot } from '@app/interfaces/timer/ITimerSlot'; import { clsxm } from '@app/utils'; import ScreenshotDetailsModal from './screenshot-details'; import { useModal } from '@app/hooks'; import ScreenshotItem from './screenshot-item'; +import React, { useCallback } from 'react'; export const ScreenshootPerHour = ({ timeSlots, @@ -14,6 +17,12 @@ export const ScreenshootPerHour = ({ stoppedAt: string; }) => { const { isOpen, closeModal, openModal } = useModal(); + const [selectedElement, setSelectedELement]= React.useState(null) + + const openScreenModal = useCallback((el: ITimerSlot) => { + setSelectedELement(el) + openModal() + }, [openModal]) return (

@@ -27,12 +36,12 @@ export const ScreenshootPerHour = ({ startTime={el.startedAt} percent={el.percentage} imageUrl={el.screenshots[0]?.thumbUrl} - onShow={() => openModal()} + onShow={() => openScreenModal(el)} idSlot={el.id} /> -

))} + ); diff --git a/apps/web/lib/features/activity/components/screenshot-details.tsx b/apps/web/lib/features/activity/components/screenshot-details.tsx index 240890c51..9b9a0014d 100644 --- a/apps/web/lib/features/activity/components/screenshot-details.tsx +++ b/apps/web/lib/features/activity/components/screenshot-details.tsx @@ -4,6 +4,7 @@ import { Modal, ProgressBar, Tooltip } from 'lib/components'; import { ITimerSlot } from '@app/interfaces/timer/ITimerSlot'; import ScreenshotItem from './screenshot-item'; import { useTranslations } from 'next-intl'; +import React from 'react'; const ScreenshotDetailsModal = ({ open, @@ -12,7 +13,7 @@ const ScreenshotDetailsModal = ({ }: { open: boolean; closeModal: () => void; - slot: ITimerSlot; + slot?: ITimerSlot| null; }) => { const t = useTranslations(); return ( @@ -20,18 +21,18 @@ const ScreenshotDetailsModal = ({ isOpen={open} title="Screenshots detail" closeModal={closeModal} - className="bg-white dark:bg-[#343434d4] p-4 rounded-lg lg:w-[60vw] xl:w-[50vw] 2xl:w-[40vw] m-8" + className="bg-white dark:border-[#26272C] dark:bg-[#191a20] dark:border p-4 rounded-lg lg:w-[60vw] xl:w-[50vw] 2xl:w-[40vw]" >

- {new Date(slot.startedAt).toLocaleTimeString()} - {new Date(slot.stoppedAt).toLocaleTimeString()} + {slot ? new Date(slot?.startedAt).toLocaleTimeString() + '-' + new Date(slot?.stoppedAt).toLocaleTimeString(): null}

- +

- {slot.percentage} {t('timer.PERCENT_OF_MINUTES')} + {slot?.percentage} {t('timer.PERCENT_OF_MINUTES')}

- {slot.screenshots.map((screenshot, i) => ( + {slot?.screenshots.map((screenshot, i) => (
{t('timer.KEYBOARD')} - {t('timer.TIMES')} : {slot.keyboard} {slot.keyboardPercentage}% + {t('timer.TIMES')} : {slot?.keyboard} {slot?.keyboardPercentage}%

{t('timer.MOUSE')} - {t('timer.TIMES')} : {slot.mouse} {slot.mousePercentage}% + {t('timer.TIMES')} : {slot?.mouse} {slot?.mousePercentage}%

- {slot.isActive ? ( + {slot?.isActive ? ( {t('timer.ACTIVE')} ) : ( {t('timer.INACTIVE')} )}

- {slot.isArchived ? ( + {slot?.isArchived ? ( {t('timer.ARCHIVED')} ) : ( {t('timer.NOT_ARCHIVED')} @@ -98,4 +99,4 @@ const ScreenshotDetailsModal = ({ ); }; -export default ScreenshotDetailsModal; +export default React.memo(ScreenshotDetailsModal); diff --git a/apps/web/lib/features/activity/components/screenshot-item.tsx b/apps/web/lib/features/activity/components/screenshot-item.tsx index 64657bf62..a64fde709 100644 --- a/apps/web/lib/features/activity/components/screenshot-item.tsx +++ b/apps/web/lib/features/activity/components/screenshot-item.tsx @@ -24,7 +24,7 @@ const ScreenshotItem = ({ return (

{showProgress ? (