From 344551ae5e925859357ba7397dade85f3c895a95 Mon Sep 17 00:00:00 2001 From: Cedric Karungu Date: Thu, 5 Dec 2024 11:52:22 +0200 Subject: [PATCH 1/3] fix: Screenshot Details Card shiw twice --- .../components/screenshoots-per-hour.tsx | 13 +++++++++-- .../components/screenshot-details.tsx | 22 +++++++++---------- 2 files changed, 22 insertions(+), 13 deletions(-) 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..55f511b84 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..e31939e12 100644 --- a/apps/web/lib/features/activity/components/screenshot-details.tsx +++ b/apps/web/lib/features/activity/components/screenshot-details.tsx @@ -12,7 +12,7 @@ const ScreenshotDetailsModal = ({ }: { open: boolean; closeModal: () => void; - slot: ITimerSlot; + slot?: ITimerSlot; }) => { const t = useTranslations(); return ( @@ -24,14 +24,14 @@ const ScreenshotDetailsModal = ({ >

- {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')} From 373519efe91fb6877d79c01a57222d01607c57ac Mon Sep 17 00:00:00 2001 From: Cedric Karungu Date: Thu, 5 Dec 2024 12:23:25 +0200 Subject: [PATCH 2/3] fix: dark theme --- .../lib/features/activity/components/screenshot-details.tsx | 2 +- apps/web/lib/features/activity/components/screenshot-item.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/web/lib/features/activity/components/screenshot-details.tsx b/apps/web/lib/features/activity/components/screenshot-details.tsx index e31939e12..aa7305cd9 100644 --- a/apps/web/lib/features/activity/components/screenshot-details.tsx +++ b/apps/web/lib/features/activity/components/screenshot-details.tsx @@ -20,7 +20,7 @@ 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] m-8" >

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 ? ( From 9c1e9dfac6f348588cfe447b6f1f615ae476f2eb Mon Sep 17 00:00:00 2001 From: Cedric Karungu Date: Thu, 5 Dec 2024 12:36:17 +0200 Subject: [PATCH 3/3] fix: coderrabit suggestions --- .../activity/components/screenshoots-per-hour.tsx | 2 +- .../features/activity/components/screenshot-details.tsx | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) 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 55f511b84..7220d7c62 100644 --- a/apps/web/lib/features/activity/components/screenshoots-per-hour.tsx +++ b/apps/web/lib/features/activity/components/screenshoots-per-hour.tsx @@ -41,7 +41,7 @@ export const ScreenshootPerHour = ({ />
))} - +

); diff --git a/apps/web/lib/features/activity/components/screenshot-details.tsx b/apps/web/lib/features/activity/components/screenshot-details.tsx index aa7305cd9..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,13 +21,13 @@ const ScreenshotDetailsModal = ({ isOpen={open} title="Screenshots detail" closeModal={closeModal} - className="bg-white dark:border-[#26272C] dark:bg-[#191a20] dark:border 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]" >

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

- +

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

@@ -98,4 +99,4 @@ const ScreenshotDetailsModal = ({ ); }; -export default ScreenshotDetailsModal; +export default React.memo(ScreenshotDetailsModal);