Skip to content

Commit

Permalink
[Fix] builds errors and warnings (#2982)
Browse files Browse the repository at this point in the history
* Fix warnings in compononents

* Fix warnings in kanban

* Update livekeet componet and fix warning

* Update UserProfileDetail

* Fix warnings like unsed vars and non null assertion

* Fix deepscan error

* Remove empty arrow function

* FIx null check error

* Fix handling null assertion

* Fix  react-hooks exhaustive-deps warning

* Simplify integration types retrieval logic

* Add localization support for invalid auth code error

* Fix scroll event listener dependency in pagination hook

* Fix timer reset issue on initial load

* Optimize callback handling in AuthCodeInputField

* Refactor and cleanup hooks and component logic

* Set default prop values directly in function signatures

* Optimize performance with useMemo & cleanup hooks

Enhanced performance by wrapping heavy computations and sort/filter operations with `useMemo` in `useDailyPlan` and `useUserProfilePage` to avoid unnecessary recalculations on re-renders. Refined hook dependencies and cleaned up redundant `useState` and `useEffect` usages to streamline state management logic. Adjusted drag-and-drop handlers for simpler plan updates.

* Optimize state and memoize data in hooks

* Refactor auth hooks and clean up invite modals

* Simplify conditional rendering in TeamOutstandingNotifications

---------

Co-authored-by: Paradoxe Ngwasi <paradoxngwasi@gmail.com>
  • Loading branch information
GedeonTS and paradoxe35 authored Sep 9, 2024
1 parent bff7251 commit cee7a8e
Show file tree
Hide file tree
Showing 64 changed files with 762 additions and 630 deletions.
2 changes: 2 additions & 0 deletions apps/web/app/[locale]/auth/password/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function WorkSpaceScreen({ form, className }: { form: TAuthenticationPassword }
[form.workspaces]
);


useEffect(() => {
if (form.workspaces.length === 1 && !hasMultipleTeams) {
setTimeout(() => {
Expand All @@ -149,6 +150,7 @@ function WorkSpaceScreen({ form, className }: { form: TAuthenticationPassword }
);
setSelectedTeam(lastSelectedTeamId);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [form.workspaces]);

useEffect(() => {
Expand Down
14 changes: 10 additions & 4 deletions apps/web/app/[locale]/calendar/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,16 @@ export function HeadTimeSheet({ timesheet, isOpen, openModal, closeModal }: { ti
return (

<div>
<TimeSheetFilter
closeModal={closeModal!}
isOpen={isOpen!}
/>
{
closeModal ? (
<TimeSheetFilter
closeModal={closeModal}
isOpen={isOpen ?? false}
/>
) :
<></>
}

<div className='flex items-center justify-between w-full dark:!bg-dark--theme h-28'>
{timesheet === 'TimeSheet' && (
<div className="flex justify-between items-center w-full p-2 gap-x-3">
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/[locale]/kanban/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const Kanban = () => {
{ title: activeTeam?.name || '', href: '/' },
{ title: t('common.KANBAN'), href: `/${currentLocale}/kanban` }
],
[activeTeam?.name, currentLocale]
[activeTeam?.name, currentLocale, t]
);

const activeTeamMembers = activeTeam?.members ? activeTeam.members : [];
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/[locale]/meet/livekit/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function LiveKitPage() {
<div >
<Meta title="Meet" />
{token && roomName && <LiveKit
token={token!}
token={token}
roomName={roomName}
liveKitUrl={process.env.NEXT_PUBLIC_LIVEKIT_URL || ''}
onLeave={onLeave}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function UserProfileDetail({ member }: { member?: OT_Member }) {
{user?.firstName} {user?.lastName}
</Text.Heading>
<div className="h-8 w-8">
<TableActionPopover member={member!} status="profile" />
{member ? <TableActionPopover member={member} status="profile" /> : <></>}
</div>
</div>
<Text className="text-lg text-gray-500">{user?.email}</Text>
Expand Down
5 changes: 3 additions & 2 deletions apps/web/app/helpers/daily-plan-estimated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ export const dailyPlanCompareEstimated = (plans: IDailyPlan[]): IDailyPlanCompar
};
}

const workTimePlanned = convertHourToSeconds(plan.workTimePlanned!);
const workTimePlanned = plan.workTimePlanned ? convertHourToSeconds(plan.workTimePlanned) : 0;
const times = plan.tasks?.map((task) => task.estimate).filter((time): time is number => typeof time === 'number') ?? [];
const estimated = plan.tasks?.map((task) => task.estimate! > 0);
const estimated = plan.tasks?.map((task) => (task.estimate ?? 0) > 0);


let estimatedTime = 0;
if (times.length > 0) {
Expand Down
70 changes: 37 additions & 33 deletions apps/web/app/helpers/drag-and-drop.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,52 @@
import { IDailyPlan, ITeamTask } from "@app/interfaces";
import { DropResult } from "react-beautiful-dnd";
import { IDailyPlan, ITeamTask } from '@app/interfaces';
import { DropResult } from 'react-beautiful-dnd';

export const handleDragAndDrop = (results: DropResult, plans: IDailyPlan[], setPlans: React.Dispatch<React.SetStateAction<IDailyPlan[]>>) => {
const { source, destination } = results;
export const handleDragAndDrop = (
results: DropResult,
plans: IDailyPlan[],
setPlans: React.Dispatch<React.SetStateAction<IDailyPlan[]>>
) => {
const { source, destination } = results;

if (!destination || (source.droppableId === destination.droppableId && source.index === destination.index)) return;
if (!destination || (source.droppableId === destination.droppableId && source.index === destination.index)) return;

const newPlans = [...plans];
const newPlans = [...plans];

const planSourceIndex = newPlans.findIndex(plan => plan.id === source.droppableId);
const planDestinationIndex = newPlans.findIndex(plan => plan.id === destination.droppableId);
const planSourceIndex = newPlans.findIndex((plan) => plan.id === source.droppableId);
const planDestinationIndex = newPlans.findIndex((plan) => plan.id === destination.droppableId);

const newSourceTasks = [...newPlans[planSourceIndex].tasks!];
const newDestinationTasks = source.droppableId !== destination.droppableId
? [...newPlans[planDestinationIndex].tasks!]
: newSourceTasks;
const newSourceTasks = [...(newPlans[planSourceIndex].tasks ?? [])];
const newDestinationTasks =
source.droppableId !== destination.droppableId
? [...(newPlans[planDestinationIndex].tasks ?? [])]
: newSourceTasks;

const [deletedTask] = newSourceTasks.splice(source.index, 1);
newDestinationTasks.splice(destination.index, 0, deletedTask);
const [deletedTask] = newSourceTasks.splice(source.index, 1);
newDestinationTasks.splice(destination.index, 0, deletedTask);

newPlans[planSourceIndex] = {
...newPlans[planSourceIndex],
tasks: newSourceTasks,
};
newPlans[planDestinationIndex] = {
...newPlans[planDestinationIndex],
tasks: newDestinationTasks,
};
setPlans(newPlans);
newPlans[planSourceIndex] = {
...newPlans[planSourceIndex],
tasks: newSourceTasks
};
newPlans[planDestinationIndex] = {
...newPlans[planDestinationIndex],
tasks: newDestinationTasks
};
setPlans(newPlans);
};


export const handleDragAndDropDailyOutstandingAll = (
results: DropResult,
tasks: ITeamTask[],
setTasks: React.Dispatch<React.SetStateAction<ITeamTask[]>>
results: DropResult,
tasks: ITeamTask[],
setTasks: React.Dispatch<React.SetStateAction<ITeamTask[]>>
) => {
const { source, destination } = results;
const { source, destination } = results;

if (!destination || (source.droppableId === destination.droppableId && source.index === destination.index)) return;
if (!destination || (source.droppableId === destination.droppableId && source.index === destination.index)) return;

const newTasks = [...tasks];
const [movedTask] = newTasks.splice(source.index, 1);
newTasks.splice(destination.index, 0, movedTask);
const newTasks = [...tasks];
const [movedTask] = newTasks.splice(source.index, 1);
newTasks.splice(destination.index, 0, movedTask);

setTasks(newTasks);
setTasks(newTasks);
};
31 changes: 15 additions & 16 deletions apps/web/app/helpers/plan-day-badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,25 @@ export const planBadgeContent = (
}
};


export const planBadgeContPast = (
dailyPlan: IDailyPlan[],
taskId: ITeamTask['id']
): string | null => {
export const planBadgeContPast = (dailyPlan: IDailyPlan[], taskId: ITeamTask['id']): string | null => {
const today = new Date().toISOString().split('T')[0];
const dailyPlanDataPast = dailyPlan.filter(plan => new Date(plan.date) < new Date(today));
const allTasks = dailyPlanDataPast.flatMap(plan => plan.tasks);
const taskCount: { [key: string]: number } = allTasks?.reduce((acc, task) => {
if (task && task.id) { acc[task.id] = (acc[task.id] || 0) + 1; }
return acc;
}, {} as { [key: string]: number });

const dailyPlanPast = allTasks?.filter(task => task && taskCount[task.id] === 1);
const dailyPlanDataPast = dailyPlan.filter((plan) => new Date(plan.date) < new Date(today));
const allTasks = dailyPlanDataPast.flatMap((plan) => plan.tasks);
const taskCount: { [key: string]: number } = allTasks?.reduce(
(acc, task) => {
if (task && task.id) {
acc[task.id] = (acc[task.id] || 0) + 1;
}
return acc;
},
{} as { [key: string]: number }
);

const dailyPlanPast = allTasks?.filter((task) => task && taskCount[task.id] === 1);
const filterDailyPlan = dailyPlanPast.filter((plan) => plan?.id === taskId);
if (filterDailyPlan.length > 0) {
return 'Planned';
} else {
return null;
}


}
};
Loading

0 comments on commit cee7a8e

Please sign in to comment.