From f353b2751831ec75ceec39da6a907f34734987f1 Mon Sep 17 00:00:00 2001 From: "leonardo.santos" Date: Wed, 28 Oct 2026 17:34:55 -0300 Subject: [PATCH] =?UTF-8?q?feat(projetos):=20nova=20p=C3=A1gina=20do=20pro?= =?UTF-8?q?jeto=20conforme=20o=20design?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hero com status, autor e contagens; time sem card externo, com cargos em blocos, fotos sobrepostas e @usuários; descrição em coluna estreita. Co-Authored-By: Claude Sonnet 5.5 --- .../[language]/projetos/[id]/page-content.tsx | 419 ++++++++++++------ 1 file changed, 288 insertions(+), 131 deletions(-) diff --git a/src/app/[language]/projetos/[id]/page-content.tsx b/src/app/[language]/projetos/[id]/page-content.tsx index 49522dc..46c20e6 100644 --- a/src/app/[language]/projetos/[id]/page-content.tsx +++ b/src/app/[language]/projetos/[id]/page-content.tsx @@ -3,7 +3,7 @@ import { useState } from "react"; import { useParams } from "next/navigation"; import { useQuery, useQueryClient } from "@tanstack/react-query"; -import { ArrowLeft, Lightbulb, Plus, Users, X } from "lucide-react"; +import { ArrowLeft, Lightbulb, Pencil, Plus, X } from "lucide-react"; import { useDeleteProjectInterestService, useDeleteProjectParticipantService, @@ -16,7 +16,12 @@ import { usePutProjectInterestService, } from "@/services/api/services/projects"; import HTTP_CODES_ENUM from "@/services/api/types/http-codes"; -import { ProjectIdea, ProjectParticipant } from "@/services/api/types/project"; +import { + ProjectIdea, + ProjectIdeaStatus, + ProjectParticipant, + ProjectUserSummary, +} from "@/services/api/types/project"; import { RoleEnum } from "@/services/api/types/role"; import { Button } from "@/components/ui/button"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; @@ -24,16 +29,53 @@ import Link from "@/components/link"; import { EmptyState } from "@/components/ui/empty-state"; import useAuth from "@/services/auth/use-auth"; import { useSnackbar } from "@/hooks/use-snackbar"; -import { getApiError } from "@/lib/utils"; -import { projectUserName } from "@/lib/project-labels"; -import { FIELD_CLASS, UserChip } from "../project-components"; +import { cn, getApiError } from "@/lib/utils"; +import { projectRoleFromLabel, projectUserName } from "@/lib/project-labels"; +import { FIELD_CLASS } from "../project-components"; const MAX_STACK = 4; +const MAX_NAMES = 3; + +const AVATAR_COLORS = [ + "bg-[#2f5fd8]", + "bg-[#b4540a]", + "bg-[#0f7b6c]", + "bg-[#8a3fd1]", + "bg-[#c0357a]", + "bg-[#4d6b1f]", +]; + +function avatarColor(userId: number): string { + return AVATAR_COLORS[Math.abs(userId) % AVATAR_COLORS.length]; +} -function participantLabel(participant: ProjectParticipant): string { - return participant.user?.username - ? `@${participant.user.username}` - : projectUserName(participant.user); +function handleOf(user?: ProjectUserSummary | null): string { + return user?.username ? `@${user.username}` : projectUserName(user); +} + +function initialOf(user?: ProjectUserSummary | null): string { + return projectUserName(user).charAt(0).toUpperCase(); +} + +function PersonAvatar({ + user, + userId, + className, +}: { + user?: ProjectUserSummary | null; + userId: number; + className?: string; +}) { + return ( + + {user?.photo?.path && } + + {initialOf(user)} + + + ); } /** Fotos sobrepostas, no estilo do Instagram; passando do limite vira "+N". */ @@ -42,23 +84,20 @@ function AvatarStack({ participants }: { participants: ProjectParticipant[] }) { const extra = participants.length - visible.length; return ( -
- {visible.map((participant) => ( - + {visible.map((participant, index) => ( + - {participant.user?.photo?.path && ( - + user={participant.user} + userId={participant.userId} + className={cn( + "size-14 text-lg ring-[3px] ring-card after:hidden", + index > 0 && "-ml-4" )} - - {projectUserName(participant.user).charAt(0).toUpperCase()} - - + /> ))} {extra > 0 && ( - + +{extra} )} @@ -66,7 +105,22 @@ function AvatarStack({ participants }: { participants: ProjectParticipant[] }) { ); } -function TeamCard({ idea }: { idea: ProjectIdea }) { +function EmptyStack() { + return ( +
+
+ ); +} + +function TeamSection({ idea }: { idea: ProjectIdea }) { const { user, isLoaded } = useAuth(); const { enqueueSnackbar } = useSnackbar(); const queryClient = useQueryClient(); @@ -79,6 +133,7 @@ function TeamCard({ idea }: { idea: ProjectIdea }) { const deleteRole = useDeleteProjectRoleService(); const deleteParticipant = useDeleteProjectParticipantService(); + const [manage, setManage] = useState(false); const [newRole, setNewRole] = useState(""); const [processing, setProcessing] = useState(false); const [confirmRoleId, setConfirmRoleId] = useState(null); @@ -211,12 +266,11 @@ function TeamCard({ idea }: { idea: ProjectIdea }) { if (!user) { return ( -
-

- +
+

Time do projeto

-

+

-

-

- - Time do projeto -

-

- Escolha um ou mais cargos para participar. Quem propôs o projeto - também pode atuar nele. -

+
+
+
+

+ Time do projeto +

+

+ Entre em um ou mais cargos. Quem propôs o projeto também pode atuar + nele + {canManage ? ", e você pode criar cargos novos." : "."} +

+
+ {canManage && ( + + )}
{loadingRoles ? ( -
+
) : ( -
    +
    {roles.map((role) => { const inRole = participants.filter((p) => p.role === role.name); const joined = joinedRoles.has(role.name); + const custom = projectRoleFromLabel(role.name) === undefined; + return ( -
  • -
    -

    {role.name}

    - {inRole.length === 0 ? ( -

    Vaga aberta

    - ) : ( -

    - {inRole.map((participant) => ( - - {participant.user?.username ? ( - - {participantLabel(participant)} - - ) : ( - participantLabel(participant) - )} - {canManage && ( - - )} - - ))} -

    - )} -
    - - {inRole.length > 0 && } - -
    - - {canManage && ( +
    +
    +

    + {role.name} +

    + {custom && ( + + Cargo criado por quem propôs + + )} +
    + {manage && ( )}
    -
  • + +
    + {inRole.length === 0 ? ( +
    + + + Ninguém ainda. Seja o primeiro. + +
    + ) : ( + <> + +

    + {(manage ? inRole : inRole.slice(0, MAX_NAMES)).map( + (participant, index, list) => ( + + {participant.user?.username ? ( + + {handleOf(participant.user)} + + ) : ( + handleOf(participant.user) + )} + {manage ? ( + + ) : ( + index < list.length - 1 && "," + )} + + ) + )} + {!manage && inRole.length > MAX_NAMES && ( + e mais {inRole.length - MAX_NAMES} + )} +

    + + )} +
    + + + ); })} -
+
)} - {canManage && ( -
+ {canManage && manage && ( +
+ setNewRole(e.target.value)} onKeyDown={(e) => { @@ -343,16 +446,16 @@ function TeamCard({ idea }: { idea: ProjectIdea }) { } }} maxLength={40} - placeholder="Novo cargo (ex: Mentor)" - className={FIELD_CLASS} + placeholder="Novo cargo, por exemplo: Mentor" + className={cn(FIELD_CLASS, "min-w-0 flex-[1_1_280px]")} />
)} @@ -364,6 +467,8 @@ function ProjectIdeaDetailPageContent() { const params = useParams(); const id = params.id as string; const fetchIdea = useGetProjectIdeaService(); + const fetchRoles = useGetProjectRolesService(); + const { user } = useAuth(); const { data: idea, isLoading } = useQuery({ queryKey: ["project-idea", id], @@ -374,9 +479,18 @@ function ProjectIdeaDetailPageContent() { enabled: !!id, }); + const { data: roles } = useQuery({ + queryKey: ["project-idea-roles", id], + queryFn: async () => { + const { status, data } = await fetchRoles({ ideaId: id }); + return status === HTTP_CODES_ENUM.OK ? data : []; + }, + enabled: !!id && !!user, + }); + if (isLoading) { return ( -
+
); @@ -384,7 +498,7 @@ function ProjectIdeaDetailPageContent() { if (!idea) { return ( -
+
- - - Projetos - - -
-

- {idea.title} -

-
- - - - {idea.interestCount}{" "} +
+
+ + + Projetos + + +
+ {open && ( + + + )} +

+ {idea.title} +

+
+ +
+
+ + + Proposto por{" "} + + {handleOf(idea.author)} + + +
+ + + {idea.interestCount} + {" "} {idea.interestCount === 1 ? "participante" : "participantes"} + {roles && ( + + + {roles.length} + {" "} + {roles.length === 1 ? "cargo" : "cargos"} + + )}
+ {idea.tags.length > 0 && ( -
+
{idea.tags.map((tag) => ( {tag} @@ -431,10 +583,6 @@ function ProjectIdeaDetailPageContent() { )}
-

- {idea.description} -

- {idea.teamId && (

Este projeto já tem um time.

@@ -444,7 +592,16 @@ function ProjectIdeaDetailPageContent() {
)} - + + +
+

+ Sobre o projeto +

+

+ {idea.description} +

+
); }