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

[Feature] Add project information in task card #3357

Merged
Changes from all commits
Commits
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
28 changes: 22 additions & 6 deletions apps/web/lib/features/task/task-all-status-type.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use client';

import { useCustomEmblaCarousel, useDailyPlan, useSyncRef } from '@app/hooks';
import { ITeamTask, Nullable } from '@app/interfaces';
import { useCustomEmblaCarousel, useDailyPlan, useOrganizationProjects, useSyncRef } from '@app/hooks';
import { IProject, ITeamTask, Nullable } from '@app/interfaces';
import { RoundedButton } from 'lib/components';
import { useEffect, useMemo } from 'react';
import { useEffect, useMemo, useState } from 'react';
import {
TaskStatus,
useTaskLabelsValue,
Expand All @@ -15,6 +15,7 @@ import { clsxm } from '@app/utils';
import { planBadgeContent, planBadgeContPast } from '@app/helpers';
import { CalendarIcon } from '@radix-ui/react-icons';
import { FilterTabs } from '../user-profile-plans';
import ProjectIcon from '@components/ui/svgs/project-icon';

export function TaskAllStatusTypes({
task,
Expand All @@ -35,6 +36,8 @@ export function TaskAllStatusTypes({
const taskSizes = useTaskSizesValue();
const taskLabels = useTaskLabelsValue();
const taskStatus = useTaskStatusValue();
const { getOrganizationProject } = useOrganizationProjects();
const [project, setProject] = useState<IProject>();

const { dailyPlan } = useDailyPlan();

Expand Down Expand Up @@ -68,6 +71,17 @@ export function TaskAllStatusTypes({

const taskId = task ? planBadgeContPast(dailyPlan.items, task.id) : '';

useEffect(() => {
const fetchProject = async () => {
if (task?.projectId) {
const res = await getOrganizationProject(task.projectId);
setProject(res?.data);
}
};

fetchProject();
}, [getOrganizationProject, task?.projectId]);
CREDO23 marked this conversation as resolved.
Show resolved Hide resolved

return (
<div className="relative w-full h-full flex flex-col justify-center">
<div ref={viewportRef} className="overflow-hidden w-full relative">
Expand All @@ -81,7 +95,6 @@ export function TaskAllStatusTypes({
titleClassName={'text-[0.625rem] font-[500]'}
/>
)}

{task?.priority && (
<TaskStatus
{...taskPriorities[task?.priority || 'Low']}
Expand All @@ -91,7 +104,6 @@ export function TaskAllStatusTypes({
titleClassName={'text-[0.625rem] font-[500]'}
/>
)}

{task?.size && !toBlockCard && (
<TaskStatus
{...taskSizes[task?.size || 'Medium']}
Expand All @@ -101,7 +113,11 @@ export function TaskAllStatusTypes({
titleClassName={'text-[0.625rem] font-[500]'}
/>
)}

{project && (
<div className="flex items-center justify-center gap-1 h-full px-2 bg-slate-200">
<ProjectIcon /> <span className=" text-xs truncate">{project.name}</span>
</div>
)}
CREDO23 marked this conversation as resolved.
Show resolved Hide resolved
{planBadgeContent(dailyPlan.items, task?.id ?? '', tab) && (
<div
className={clsxm(
Expand Down
Loading