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

[Fix] builds errors and warnings #2982

Merged
merged 22 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3a8d759
Fix warnings in compononents
GedeonTS Sep 2, 2024
1f3d2c5
Fix warnings in kanban
GedeonTS Sep 2, 2024
2b0b4db
Update livekeet componet and fix warning
GedeonTS Sep 2, 2024
d1b839a
Update UserProfileDetail
GedeonTS Sep 2, 2024
6d1c6ea
Fix warnings like unsed vars and non null assertion
GedeonTS Sep 2, 2024
ee1036b
Fix deepscan error
GedeonTS Sep 2, 2024
3e88e5e
Remove empty arrow function
GedeonTS Sep 2, 2024
81ceefd
FIx null check error
GedeonTS Sep 3, 2024
bbedcdc
Fix handling null assertion
GedeonTS Sep 3, 2024
2e65ddc
Fix react-hooks exhaustive-deps warning
GedeonTS Sep 3, 2024
74f5b0b
Simplify integration types retrieval logic
paradoxe35 Sep 9, 2024
b92321e
Add localization support for invalid auth code error
paradoxe35 Sep 9, 2024
2524923
Fix scroll event listener dependency in pagination hook
paradoxe35 Sep 9, 2024
08cbb22
Fix timer reset issue on initial load
paradoxe35 Sep 9, 2024
f16eef5
Optimize callback handling in AuthCodeInputField
paradoxe35 Sep 9, 2024
8592a26
Merge remote-tracking branch 'origin/develop' into fix-builds-errors
paradoxe35 Sep 9, 2024
a90e966
Refactor and cleanup hooks and component logic
paradoxe35 Sep 9, 2024
0e13178
Set default prop values directly in function signatures
paradoxe35 Sep 9, 2024
11427a0
Optimize performance with useMemo & cleanup hooks
paradoxe35 Sep 9, 2024
8fc3720
Optimize state and memoize data in hooks
paradoxe35 Sep 9, 2024
60e8916
Refactor auth hooks and clean up invite modals
paradoxe35 Sep 9, 2024
92e74ad
Simplify conditional rendering in TeamOutstandingNotifications
paradoxe35 Sep 9, 2024
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
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
4 changes: 2 additions & 2 deletions apps/web/app/helpers/drag-and-drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export const handleDragAndDrop = (results: DropResult, plans: IDailyPlan[], setP
const planSourceIndex = newPlans.findIndex(plan => plan.id === source.droppableId);
const planDestinationIndex = newPlans.findIndex(plan => plan.id === destination.droppableId);

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

const [deletedTask] = newSourceTasks.splice(source.index, 1);
Expand Down
130 changes: 66 additions & 64 deletions apps/web/app/hooks/auth/useAuthenticationPasscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,80 +75,82 @@ export function useAuthenticationPasscode() {
/**
* Verify auth request
*/
const verifySignInEmailConfirmRequest = async ({
email,
code,
lastTeamId
}: {
email: string;
code: string;
lastTeamId?: string;
}) => {
signInEmailConfirmQueryCall(email, code)
.then((res) => {
if ('team' in res.data) {
router.replace('/');
return;
}
const verifySignInEmailConfirmRequest = useCallback(
async ({
email,
code,
lastTeamId
}: {
email: string;
code: string;
lastTeamId?: string;
}) => {
signInEmailConfirmQueryCall(email, code)
.then((res) => {
if ('team' in res.data) {
router.replace('/');
return;
}

const checkError: {
message: string;
} = res.data as any;
const checkError: {
message: string;
} = res.data as any;

const isError = checkError.message === 'Unauthorized';
const isError = checkError.message === 'Unauthorized';

if (isError) {
setErrors({
code: 'Invalid code. Please try again.'
});
} else {
setErrors({});
}
if (isError) {
setErrors({
code: 'Invalid code. Please try again.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GedeonTS
Is it possible to separate this text in the translation files?

});
} else {
setErrors({});
}

const data = res.data as ISigninEmailConfirmResponse;
if (!data.workspaces) {
return;
}
const data = res.data as ISigninEmailConfirmResponse;
if (!data.workspaces) {
return;
}

if (data && Array.isArray(data.workspaces) && data.workspaces.length > 0) {
setWorkspaces(data.workspaces);
setDefaultTeamId(data.defaultTeamId);
if (data && Array.isArray(data.workspaces) && data.workspaces.length > 0) {
setWorkspaces(data.workspaces);
setDefaultTeamId(data.defaultTeamId);

setScreen('workspace');
}
setScreen('workspace');
}

// If user tries to login from public Team Page as an Already a Member
// Redirect to the current team automatically
if (pathname === '/team/[teamId]/[profileLink]' && data.workspaces.length) {
if (queryTeamId) {
const currentWorkspace = data.workspaces.find((workspace) =>
workspace.current_teams.map((item) => item.team_id).includes(queryTeamId as string)
);

signInToWorkspaceRequest({
email: email,
code: code,
token: currentWorkspace?.token as string,
selectedTeam: queryTeamId as string,
lastTeamId
});
// If user tries to login from public Team Page as an Already a Member
// Redirect to the current team automatically
if (pathname === '/team/[teamId]/[profileLink]' && data.workspaces.length) {
if (queryTeamId) {
const currentWorkspace = data.workspaces.find((workspace) =>
workspace.current_teams.map((item) => item.team_id).includes(queryTeamId as string)
);

signInToWorkspaceRequest({
email: email,
code: code,
token: currentWorkspace?.token as string,
selectedTeam: queryTeamId as string,
lastTeamId
});
}
}
}

// if (res.data?.status !== 200 && res.data?.status !== 201) {
// setErrors({ code: t('pages.auth.INVALID_INVITE_CODE_MESSAGE') });
// }
})
.catch((err: AxiosError<{ errors: Record<string, any> }, any> | { errors: Record<string, any> }) => {
if (isAxiosError(err)) {
if (err.response?.status === 400) {
setErrors(err.response.data?.errors || {});
// if (res.data?.status !== 200 && res.data?.status !== 201) {
// setErrors({ code: t('pages.auth.INVALID_INVITE_CODE_MESSAGE') });
// }
})
.catch((err: AxiosError<{ errors: Record<string, any> }, any> | { errors: Record<string, any> }) => {
if (isAxiosError(err)) {
if (err.response?.status === 400) {
setErrors(err.response.data?.errors || {});
}
} else {
setErrors(err.errors || {});
}
} else {
setErrors(err.errors || {});
}
});
};
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [signInEmailConfirmQueryCall, router, pathname, queryTeamId]);

const verifyPasscodeRequest = useCallback(
({ email, code }: { email: string; code: string }) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/hooks/features/useEmployee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const useEmployeeUpdate = () => {
.catch((error) => {
console.log(error);
});
}, []);
}, [employeeUpdateQuery]);

return { updateEmployee, isLoading }
}
2 changes: 1 addition & 1 deletion apps/web/app/hooks/features/useGetTasksStatsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function useGetTasksStatsData(employeeId: string | undefined, triggerWith
if (entry?.isIntersecting && supported) {
loadTaskStats();
}
}, [employeeId, triggerWithIObserver, entry]);
}, [employeeId, triggerWithIObserver, entry, getTasksStatsData]);

return IObserverRef;
}
4 changes: 2 additions & 2 deletions apps/web/app/hooks/features/usePagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function useScrollPagination<T>({
setPage(1);
setSlicedItems(items.slice(0, defaultItemsPerPage));
}
}, [enabled, items]);
}, [enabled, items, defaultItemsPerPage]);

useEffect(() => {
const container = $scrollableElement.current;
Expand All @@ -68,7 +68,7 @@ export function useScrollPagination<T>({
return () => {
container.removeEventListener('scroll', handleScroll);
};
}, [$scrollableElement.current, enabled]);
}, [enabled]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should leave the useEffect dependencies as they were, since we need to re-execute the useEffact function if scrollableElement has changed. $scrollableElement.current can be equal to scrollableElement

Check the line 44

Let's keep it like this

[$scrollableElement.current, enabled] 


useEffect(() => {
const newItems = items.slice(0, defaultItemsPerPage * page);
Expand Down
18 changes: 14 additions & 4 deletions apps/web/app/hooks/features/useTeamTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export function useTeamTasks() {
return res;
});
},
[getTasksByIdQueryCall, setDetailedTask]
[getTasksByIdQueryCall, setDetailedTask, tasksRef]
);

const getTasksByEmployeeId = useCallback(
Expand Down Expand Up @@ -285,8 +285,8 @@ export function useTeamTasks() {
// TODO: Make it dynamic when we add Dropdown in Navbar
...(activeTeam?.projects && activeTeam?.projects.length > 0
? {
projectId: activeTeam.projects[0].id
}
projectId: activeTeam.projects[0].id
}
: {}),
...(description ? { description: `<p>${description}</p>` } : {}),
...(members ? { members } : {}),
Expand Down Expand Up @@ -451,7 +451,17 @@ export function useTeamTasks() {
}
}
},
[setActiveTeamTask, setActiveUserTaskCookieCb, updateOrganizationTeamEmployeeActiveTask, activeTeam, authUser]
[
setActiveTeamTask,
setActiveUserTaskCookieCb,
updateOrganizationTeamEmployeeActiveTask,
activeTeam,
authUser,
$memberActiveTaskId,
$user,
tasksRef,
updateTask
]
);

const deleteEmployeeFromTasks = useCallback(
Expand Down
1 change: 0 additions & 1 deletion apps/web/app/hooks/features/useTimeLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export function useTimeLogs() {
profile.member?.employeeId,
queryTimerLogsDailyReport,
setTimerLogsDailyReport,
user?.employee.id,
evereq marked this conversation as resolved.
Show resolved Hide resolved
user?.employee.organizationId,
user?.tenantId,
]
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/hooks/features/useTimer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function useLocalTimeCounter(timerStatus: ITimerStatus | null, activeTeamTask: I
return 0;
}
return timerSecondsRef.current;
}, [seconds, firstLoad, timerStatusRef]);
}, [seconds, timerStatusRef]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's uncomment the line 107 and add firstLoad as a useMemo dependency, we only need to change timerSecondsRef.current when firstLoad is true.

107 // if (!firstLoad) return 0;


useEffect(() => {
if (firstLoad) {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/stores/employee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export const workingEmployeesEmailState = atom<string[]>({

export const employeeUpdateState = atom<IUpdateEmployee>({
key: 'employeeUpdateState',
default: null!,
default: undefined,
})
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import { SixSquareGridIcon } from 'assets/svg';
import { useTranslations } from 'next-intl';
import React, { useState } from 'react';
import { DragDropContext, Droppable, Draggable, DropResult } from 'react-beautiful-dnd';
import { useRecoilState } from 'recoil';
import { useSetRecoilState } from 'recoil';

const SortTasksStatusSettings = ({ arr, onClose }: { arr: ITaskStatusItemList[]; onClose: () => void }) => {
const [items, setItems] = useState(arr);
const [saveLoader, setSaveLoader] = useState(false);
const [saveCheck, setSaveCheck] = useState(false);
const organizationId = getOrganizationIdCookie();
const [_, setState] = useRecoilState(taskStatusListState);
const setState = useSetRecoilState(taskStatusListState);

const t = useTranslations();
const { reOrderQueryCall } = useTaskStatus();
const onDragEnd = (result: DropResult) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useModal, useSyncRef, useTeamTasks } from '@app/hooks';
import { useModal, useTeamTasks } from '@app/hooks';
import { ITaskVersionCreate, ITeamTask } from '@app/interfaces';
import { detailedTaskState, taskVersionListState } from '@app/stores';
import { detailedTaskState } from '@app/stores';
import { PlusIcon } from '@heroicons/react/20/solid';
import { Button, Card, Modal, Tooltip } from 'lib/components';
import {
Expand All @@ -27,8 +27,6 @@ type StatusType = 'version' | 'epic' | 'status' | 'label' | 'size' | 'priority';

const TaskSecondaryInfo = () => {
const task = useRecoilValue(detailedTaskState);
const taskVersion = useRecoilValue(taskVersionListState);
const $taskVersion = useSyncRef(taskVersion);
const { updateTask } = useTeamTasks();

const { handleStatusUpdate } = useTeamTasks();
Expand All @@ -52,7 +50,7 @@ const TaskSecondaryInfo = () => {
(version: ITaskVersionCreate) => {
handleStatusUpdate(version.value || version.name, 'version', task?.taskStatusId, task);
},
[$taskVersion, task, handleStatusUpdate]
[task, handleStatusUpdate]
);

const onTaskSelect = useCallback(
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/ui/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function Calendar({ className, classNames, showOutsideDays = true, ...props }: C
...classNames
}}
components={{
Dropdown: ({ value, onChange, children, ...props }: DropdownProps) => {
Dropdown: ({ value, onChange, children }: DropdownProps) => {
const options = React.Children.toArray(children) as React.ReactElement<
React.HTMLProps<HTMLOptionElement>
>[];
Expand Down
2 changes: 1 addition & 1 deletion apps/web/lib/components/custom-select/multi-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function MultiSelect<T>({
if (triggerRef.current) {
setPopoverWidth(triggerRef.current.offsetWidth);
}
}, [triggerRef.current]);
}, []);

return (
<div className="relative w-full overflow-hidden">
Expand Down
Loading
Loading