-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3104-3105-3106-3107 feature/vertical sidebar, projects, favorites and…
… role based navigation in sidebar (#3199) * fix(web): [Vertical Sidenar] Fix fullwidth switch with vertical sidebar * refactor(web): [Vertical Sidebar] retrieves projects data, get sidebar data based on user roles * refactor(web): [Vertical Sidebar] fix alignments of project sidebar project * refactor(web): [Vertical Sidebar] add sidebar traductions * refactor(web): [Vertical Sidebar] make favorite tasks persistence * refactor(web): [Vertical Sidebar] add favorite feature on card-menu-item * refactor(web): [Favorite] add favorite feature on task detail * fix(web): fix deepscan errors * refactor(web): [Vertical Sidebar] Add TypeScript type definitions to MainSidebarTrigger and improve maintainability. * refactor(web): [Types] Add TypeScript interfaces for role definitions and type safety to PERMISSION_ROLES mapping * refactor(web): [Typo] Fix typo in sidebar translation key. * refactor(web): [Favorite] Consider optimizing toggleFavorite implementation. * refactor(web): [spelling] Fix grammatical error in favorites message.
- Loading branch information
Showing
35 changed files
with
3,353 additions
and
2,785 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use client'; | ||
|
||
import { useOrganizationTeams, useTimer } from '@app/hooks'; | ||
import { useToast } from '@components/ui/use-toast'; | ||
import { useCallback } from 'react'; | ||
import { TeamItem } from '@/lib/features/team/team-item'; | ||
import { useTranslations } from 'next-intl'; | ||
|
||
export const useActiveTeam = () => { | ||
const { activeTeam, setActiveTeam } = useOrganizationTeams(); | ||
const { timerStatus, stopTimer } = useTimer(); | ||
const t = useTranslations(); | ||
const { toast } = useToast(); | ||
const onChangeActiveTeam = useCallback( | ||
(item: TeamItem) => { | ||
if (item.data) { | ||
/** | ||
* If timer started in Teams and user switches the Team, stop the timer | ||
*/ | ||
if ( | ||
timerStatus && | ||
timerStatus?.running && | ||
timerStatus.lastLog && | ||
timerStatus.lastLog.organizationTeamId && | ||
timerStatus.lastLog.source === 'TEAMS' && | ||
activeTeam && | ||
activeTeam?.id && | ||
timerStatus.lastLog.organizationTeamId === activeTeam?.id | ||
) { | ||
toast({ | ||
variant: 'default', | ||
title: t('timer.TEAM_SWITCH.STOPPED_TIMER_TOAST_TITLE'), | ||
description: t('timer.TEAM_SWITCH.STOPPED_TIMER_TOAST_DESCRIPTION') | ||
}); | ||
stopTimer(); | ||
} | ||
|
||
setActiveTeam(item.data); | ||
} | ||
}, | ||
[setActiveTeam, timerStatus, stopTimer, activeTeam, toast, t] | ||
); | ||
return { activeTeam, setActiveTeam, onChangeActiveTeam }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { useTeamTasks } from '@/app/hooks/features/useTeamTasks'; | ||
import { ITeamTask } from '@/app/interfaces/ITask'; | ||
import { useAtom } from 'jotai'; | ||
import { favoriteTasksStorageAtom } from '@/app/stores/team-tasks'; | ||
import { useCallback } from 'react'; | ||
/** | ||
* A React hook that manages a list of favorite tasks for a team. | ||
* | ||
* The `useFavoritesTask` hook returns an object with the following properties: | ||
* | ||
* - `tasks`: The list of all tasks for the team, obtained from the `useTeamTasks` hook. | ||
* - `favoriteTasks`: The list of favorite tasks. | ||
* - `toggleFavorite`: A function that toggles the favorite status of a given task. | ||
* - `isFavorite`: A function that checks if a given task is a favorite. | ||
* - `addFavorite`: A function that adds a task to the list of favorites. | ||
*/ | ||
|
||
export const useFavoritesTask = () => { | ||
const { tasks } = useTeamTasks(); | ||
const [favoriteTasks, setFavoriteTasks] = useAtom(favoriteTasksStorageAtom); | ||
|
||
const toggleFavorite = useCallback((task: ITeamTask) => { | ||
if (!task?.id) { | ||
console.warn('Invalid task provided to toggleFavorite'); | ||
return; | ||
} | ||
setFavoriteTasks((prev) => | ||
prev.some((t) => t.id === task.id) ? prev.filter((t) => t.id !== task.id) : [...prev, task] | ||
); | ||
}, []); | ||
|
||
const isFavorite = useCallback((task: ITeamTask) => favoriteTasks.some((t) => t.id === task.id), [favoriteTasks]); | ||
|
||
const addFavorite = useCallback((task: ITeamTask) => { | ||
if (!isFavorite(task)) { | ||
setFavoriteTasks((prev) => [...prev, task]); | ||
} | ||
}, []); | ||
|
||
return { | ||
tasks, | ||
favoriteTasks, | ||
toggleFavorite, | ||
isFavorite, | ||
addFavorite | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.