Skip to content

Commit

Permalink
[Feat] Team's tasks | Assigned / Unassigned option (#3532)
Browse files Browse the repository at this point in the history
* fix assigned / unassigned in teams tasks

* add toast message
  • Loading branch information
CREDO23 authored Jan 21, 2025
1 parent e0f2730 commit 25d0024
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 25 deletions.
28 changes: 17 additions & 11 deletions apps/web/components/pages/team/tasks/DropdownMenuTask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,32 @@ import { useFavoritesTask } from '@/app/hooks/features/useFavoritesTask';
import { ITeamTask } from '@app/interfaces';
import { FC, useCallback } from 'react';
import { useRouter } from 'next/navigation';
import { useToast } from '@components/ui/use-toast';

const DropdownMenuTask: FC<{ task: ITeamTask }> = ({ task }) => {
const { activeTeam } = useOrganizationTeams();
const router = useRouter();
const { user } = useAuthenticateUser();
const member = activeTeam?.members.find((m) => m?.employee?.user?.id === user?.id);
const isAssigned = task?.members?.some((m) => m?.user?.id === user?.id);
const member = activeTeam?.members?.find((m) => m?.employee?.user?.id === user?.id);
const memberInfo = useTeamMemberCard(member);
const taskEdition = useTMCardTaskEdit(task);
const { toast } = useToast();

const { toggleFavorite, isFavorite } = useFavoritesTask();
const t = useTranslations();

const handleAssignment = useCallback(() => {
if (memberInfo.member?.employee?.user?.id === user?.id) {
memberInfo.unassignTask(task);
const handleAssignment = useCallback(async () => {
if (isAssigned) {
await memberInfo.unassignTask(task);
toast({
variant: 'default',
title: t('task.toastMessages.TASK_UNASSIGNED')
});
} else {
memberInfo.assignTask(task);
}
}, [memberInfo, task]);
}, [isAssigned, memberInfo, t, task, toast]);

return (
<DropdownMenu>
Expand Down Expand Up @@ -65,24 +72,23 @@ const DropdownMenuTask: FC<{ task: ITeamTask }> = ({ task }) => {
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem
className=" cursor-pointer"
onClick={() => taskEdition?.task?.id && navigator.clipboard.writeText(taskEdition.task.id)}
>
Copy Task ID
</DropdownMenuItem>
<DropdownMenuSeparator />

<DropdownMenuItem className="relative" onClick={() => router.push(`/task/${task.id}`)}>
<DropdownMenuItem className="relative cursor-pointer" onClick={() => router.push(`/task/${task.id}`)}>
{t('common.TASK_DETAILS')}
</DropdownMenuItem>

<DropdownMenuItem onClick={() => toggleFavorite(task)}>
<DropdownMenuItem className=" cursor-pointer" onClick={() => toggleFavorite(task)}>
{isFavorite(task) ? t('common.REMOVE_FAVORITE_TASK') : t('common.ADD_FAVORITE_TASK')}
</DropdownMenuItem>

<DropdownMenuItem onClick={handleAssignment}>
{memberInfo.member?.employee?.user?.id !== user?.id
? t('common.ASSIGN_TASK')
: t('common.UNASSIGN_TASK')}
<DropdownMenuItem className=" cursor-pointer" onClick={handleAssignment}>
{isAssigned ? t('common.UNASSIGN_TASK') : t('common.ASSIGN_TASK')}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
Expand Down
5 changes: 4 additions & 1 deletion apps/web/locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,10 @@
"TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "كم ساعة عمل الموظف اليوم والإجمالي في المهمة",
"WORKED_ON_TASK_HEADER_TOOLTIP": "كم ساعة عمل الموظف اليوم في جميع المهام للفريق المحدد"
},
"CONFIRM_CLOSE_TASK": "يرجى تأكيد رغبتك في إغلاق المهمة"
"CONFIRM_CLOSE_TASK": "يرجى تأكيد رغبتك في إغلاق المهمة",
"toastMessages": {
"TASK_UNASSIGNED": "لم يتم تعيين المهمة"
}
},
"dailyPlan": {
"PLAN_FOR_TODAY": "خطة اليوم",
Expand Down
5 changes: 4 additions & 1 deletion apps/web/locales/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,10 @@
"TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "Колко часа работил служителят общо и днес по задача",
"WORKED_ON_TASK_HEADER_TOOLTIP": "Колко часа е работил служителят днес по всички задачи за избрания екип"
},
"CONFIRM_CLOSE_TASK": "Моля, потвърдете ако искате да затворите задачата"
"CONFIRM_CLOSE_TASK": "Моля, потвърдете ако искате да затворите задачата",
"toastMessages": {
"TASK_UNASSIGNED": "Задачата не е възложена"
}
},
"dailyPlan": {
"PLAN_FOR_TODAY": "План за днес",
Expand Down
5 changes: 4 additions & 1 deletion apps/web/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,10 @@
"TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "Wie viele Stunden hat der Mitarbeiter heute und insgesamt an der Aufgabe gearbeitet",
"WORKED_ON_TASK_HEADER_TOOLTIP": "Wie viele Stunden hat der Mitarbeiter heute an allen Aufgaben für das ausgewählte Team gearbeitet"
},
"CONFIRM_CLOSE_TASK": "Bitte bestätigen Sie, ob Sie die Aufgabe schließen möchten"
"CONFIRM_CLOSE_TASK": "Bitte bestätigen Sie, ob Sie die Aufgabe schließen möchten",
"toastMessages": {
"TASK_UNASSIGNED": "Aufgabe nicht zugewiesen"
}
},
"dailyPlan": {
"PLAN_FOR_TODAY": "Plan für heute",
Expand Down
5 changes: 4 additions & 1 deletion apps/web/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,10 @@
"TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "How many hours an employee worked for total and today on task",
"WORKED_ON_TASK_HEADER_TOOLTIP": "How many hours did employees work today on all tasks for the selected Team"
},
"CONFIRM_CLOSE_TASK": "Please confirm if you want to close the task"
"CONFIRM_CLOSE_TASK": "Please confirm if you want to close the task",
"toastMessages": {
"TASK_UNASSIGNED": "Task unassigned"
}
},
"dailyPlan": {
"PLAN_FOR_TODAY": "Plan for today",
Expand Down
5 changes: 4 additions & 1 deletion apps/web/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,10 @@
"TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "Cuántas horas trabajó el empleado en total y hoy en la tarea",
"WORKED_ON_TASK_HEADER_TOOLTIP": "Cuántas horas trabajó el empleado hoy en todas las tareas para el equipo seleccionado"
},
"CONFIRM_CLOSE_TASK": "Por favor, confirma si deseas cerrar la tarea"
"CONFIRM_CLOSE_TASK": "Por favor, confirma si deseas cerrar la tarea",
"toastMessages": {
"TASK_UNASSIGNED": "Tarea no asignada"
}
},
"dailyPlan": {
"PLAN_FOR_TODAY": "Plan para hoy",
Expand Down
5 changes: 4 additions & 1 deletion apps/web/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,10 @@
"TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "Combien d'heures l'employé a-t-il travaillé au total et aujourd'hui sur la tâche",
"WORKED_ON_TASK_HEADER_TOOLTIP": "Combien d'heures l'employé a-t-il travaillé aujourd'hui sur toutes les tâches pour l'équipe sélectionnée"
},
"CONFIRM_CLOSE_TASK": "Veuillez confirmer si vous voulez fermer la tâche"
"CONFIRM_CLOSE_TASK": "Veuillez confirmer si vous voulez fermer la tâche",
"toastMessages": {
"TASK_UNASSIGNED": "Tâche non attribuée"
}
},
"dailyPlan": {
"PLAN_FOR_TODAY": "Plan pour aujourd'hui",
Expand Down
5 changes: 4 additions & 1 deletion apps/web/locales/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,10 @@
"TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "כמה שעות עבד העובד בסך הכול והיום על המשימה",
"WORKED_ON_TASK_HEADER_TOOLTIP": "כמה שעות עבד העובד היום בכל המשימות לצוות שנבחר"
},
"CONFIRM_CLOSE_TASK": "אנא אשר אם ברצונך לסגור את המשימה"
"CONFIRM_CLOSE_TASK": "אנא אשר אם ברצונך לסגור את המשימה",
"toastMessages": {
"TASK_UNASSIGNED": "משימה לא הוקצתה"
}
},
"dailyPlan": {
"PLAN_FOR_TODAY": "תוכנית להיום",
Expand Down
5 changes: 4 additions & 1 deletion apps/web/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,10 @@
"TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "Quante ore ha lavorato l'impiegato in totale e oggi sul compito",
"WORKED_ON_TASK_HEADER_TOOLTIP": "Quante ore ha lavorato l'impiegato oggi su tutte le attività per il team selezionato"
},
"CONFIRM_CLOSE_TASK": "Conferma se desideri chiudere il compito"
"CONFIRM_CLOSE_TASK": "Conferma se desideri chiudere il compito",
"toastMessages": {
"TASK_UNASSIGNED": "Attività non assegnata"
}
},
"dailyPlan": {
"PLAN_FOR_TODAY": "Piano per oggi",
Expand Down
5 changes: 4 additions & 1 deletion apps/web/locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,10 @@
"TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "Hoeveel uur heeft de werknemer in totaal en vandaag aan de taak gewerkt",
"WORKED_ON_TASK_HEADER_TOOLTIP": "Hoeveel uur heeft de werknemer vandaag gewerkt aan alle taken voor het geselecteerde team"
},
"CONFIRM_CLOSE_TASK": "Bevestig als u de taak wilt sluiten"
"CONFIRM_CLOSE_TASK": "Bevestig als u de taak wilt sluiten",
"toastMessages": {
"TASK_UNASSIGNED": "Taak niet toegewezen"
}
},
"dailyPlan": {
"PLAN_FOR_TODAY": "Plan voor vandaag",
Expand Down
5 changes: 4 additions & 1 deletion apps/web/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,10 @@
"TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "Ile godzin pracowano ogółem i dzisiaj nad zadaniem",
"WORKED_ON_TASK_HEADER_TOOLTIP": "Ile godzin pracowano dzisiaj nad wszystkimi zadaniami dla wybranego zespołu"
},
"CONFIRM_CLOSE_TASK": "Potwierdź, czy chcesz zamknąć zadanie"
"CONFIRM_CLOSE_TASK": "Potwierdź, czy chcesz zamknąć zadanie",
"toastMessages": {
"TASK_UNASSIGNED": "Zadanie nieprzypisane"
}
},
"dailyPlan": {
"PLAN_FOR_TODAY": "Plan na dzisiaj",
Expand Down
5 changes: 4 additions & 1 deletion apps/web/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,10 @@
"TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "Quantas horas o funcionário trabalhou no total e hoje na tarefa",
"WORKED_ON_TASK_HEADER_TOOLTIP": "Quantas horas o funcionário trabalhou hoje em todas as tarefas para a equipe selecionada"
},
"CONFIRM_CLOSE_TASK": "Por favor, confirme se deseja fechar a tarefa"
"CONFIRM_CLOSE_TASK": "Por favor, confirme se deseja fechar a tarefa",
"toastMessages": {
"TASK_UNASSIGNED": "Tarefa não atribuída"
}
},
"dailyPlan": {
"PLAN_FOR_TODAY": "Plano para hoje",
Expand Down
5 changes: 4 additions & 1 deletion apps/web/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,10 @@
"TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "Сколько часов сотрудник поработал всего и сегодня по задаче",
"WORKED_ON_TASK_HEADER_TOOLTIP": "Сколько часов сотрудник поработал сегодня по всем задачам для выбранной команды"
},
"CONFIRM_CLOSE_TASK": "Пожалуйста, подтвердите, что вы хотите закрыть задачу"
"CONFIRM_CLOSE_TASK": "Пожалуйста, подтвердите, что вы хотите закрыть задачу",
"toastMessages": {
"TASK_UNASSIGNED": "Задача не назначена"
}
},
"dailyPlan": {
"PLAN_FOR_TODAY": "План на сегодня",
Expand Down
5 changes: 4 additions & 1 deletion apps/web/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,10 @@
"TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "员工今天和总共在任务上工作了多少小时",
"WORKED_ON_TASK_HEADER_TOOLTIP": "员工今天在所选团队的所有任务上工作了多少小时"
},
"CONFIRM_CLOSE_TASK": "请确认您是否要关闭此任务"
"CONFIRM_CLOSE_TASK": "请确认您是否要关闭此任务",
"toastMessages": {
"TASK_UNASSIGNED": "任务未分配"
}
},
"dailyPlan": {
"PLAN_FOR_TODAY": "今日计划",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23653,7 +23653,7 @@ runtime-required@^1.1.0:
resolved "https://registry.npmjs.org/runtime-required/-/runtime-required-1.1.0.tgz"
integrity sha512-yX97f5E0WfNpcQnfVjap6vzQcvErkYYCx6eTK4siqGEdC8lglwypUFgZVTX7ShvIlgfkC4XGFl9O1KTYcff0pw==

rxjs@*, rxjs@7.8.1, rxjs@^7.5.1, rxjs@^7.5.5, rxjs@^7.8.0, rxjs@^7.8.1:
rxjs@7.8.1, rxjs@^7.5.1, rxjs@^7.5.2, rxjs@^7.5.5, rxjs@^7.8.0, rxjs@^7.8.1:
version "7.8.1"
resolved "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz"
integrity sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==
Expand Down

0 comments on commit 25d0024

Please sign in to comment.