diff --git a/src/app/[language]/moderation/page-content.tsx b/src/app/[language]/moderation/page-content.tsx index 6d167bc..9825ec0 100644 --- a/src/app/[language]/moderation/page-content.tsx +++ b/src/app/[language]/moderation/page-content.tsx @@ -40,6 +40,7 @@ import { import { Course } from "@/services/api/types/course"; import { Event, EventModality } from "@/services/api/types/event"; import { TRACK_ITEM_TYPE_BADGE } from "@/lib/track-colors"; +import { ProjectIdeasTab } from "./project-ideas-tab"; import { EVENT_CATEGORY_LABELS, EVENT_MODALITY_LABELS, @@ -73,6 +74,7 @@ import { Gift, Coins, CalendarDays, + Lightbulb, MapPin, Video, } from "lucide-react"; @@ -344,20 +346,49 @@ function DetailModal({

O que foi enviado

- {submission.description ? ( -
- -
- ) : ( + {!submission.description && + !submission.proofUrl && + !submission.customTitle ? (

- Sem descrição enviada. + Nenhum detalhe enviado.

- )} - {submission.proofUrl && ( - + ) : ( + <> + {submission.customTitle && ( +
+

+ {submission.customTitle} +

+ {(submission.githubRepo || submission.issueCategory) && ( +
+ {submission.githubRepo && ( + + {submission.githubRepo === "FRONT" + ? "Site / Front-end" + : "API / Backend"} + + )} + {submission.issueCategory && ( + + {submission.issueCategory} + + )} +
+ )} +
+ )} + {submission.description && ( +
+ +
+ )} + {submission.proofUrl && ( + + )} + )} @@ -1692,7 +1723,13 @@ function EventosTab() { // ─── Page ───────────────────────────────────────────────────────────────────── -type Tab = "atividades" | "trilhas" | "cursos" | "missoes" | "eventos"; +type Tab = + | "atividades" + | "trilhas" + | "cursos" + | "missoes" + | "eventos" + | "projetos"; const TAB_CONFIG: Record = { atividades: { label: "Atividades", icon: ShieldCheck }, @@ -1700,6 +1737,7 @@ const TAB_CONFIG: Record = { cursos: { label: "Cursos", icon: GraduationCap }, missoes: { label: "Missões", icon: Target }, eventos: { label: "Eventos", icon: CalendarDays }, + projetos: { label: "Projetos", icon: Lightbulb }, }; function ModerationPageContent() { @@ -1715,7 +1753,7 @@ function ModerationPageContent() { {/* Tabs */} -
+
{(Object.keys(TAB_CONFIG) as Tab[]).map((t) => { const { label, icon: Icon } = TAB_CONFIG[t]; return ( @@ -1743,6 +1781,8 @@ function ModerationPageContent() { ) : tab === "eventos" ? ( + ) : tab === "projetos" ? ( + ) : ( )} diff --git a/src/app/[language]/moderation/project-ideas-tab.tsx b/src/app/[language]/moderation/project-ideas-tab.tsx new file mode 100644 index 0000000..22ae044 --- /dev/null +++ b/src/app/[language]/moderation/project-ideas-tab.tsx @@ -0,0 +1,201 @@ +"use client"; + +import { useState } from "react"; +import { useQuery, useQueryClient } from "@tanstack/react-query"; +import { CheckCircle2, Lightbulb, User, XCircle } from "lucide-react"; +import { + useGetPendingProjectIdeasService, + usePatchReviewProjectIdeaService, +} from "@/services/api/services/projects"; +import HTTP_CODES_ENUM from "@/services/api/types/http-codes"; +import { ProjectIdea } from "@/services/api/types/project"; +import { Button } from "@/components/ui/button"; +import { Badge } from "@/components/ui/badge"; +import { EmptyState } from "@/components/ui/empty-state"; +import { useSnackbar } from "@/hooks/use-snackbar"; +import { getApiError } from "@/lib/utils"; +import { projectUserName } from "@/lib/project-labels"; + +function ProjectIdeaRow({ + idea, + onReviewed, +}: { + idea: ProjectIdea; + onReviewed: () => void; +}) { + const { enqueueSnackbar } = useSnackbar(); + const reviewIdea = usePatchReviewProjectIdeaService(); + const [rejectOpen, setRejectOpen] = useState(false); + const [rejectionReason, setRejectionReason] = useState(""); + const [processing, setProcessing] = useState(false); + + const review = async (decision: "APPROVED" | "REJECTED") => { + setProcessing(true); + try { + const { status, data } = await reviewIdea({ + id: idea.id, + status: decision, + rejectionReason: + decision === "REJECTED" ? rejectionReason.trim() : undefined, + }); + if (status === HTTP_CODES_ENUM.OK) { + enqueueSnackbar( + decision === "APPROVED" ? "Ideia aprovada!" : "Ideia rejeitada.", + { variant: "success" } + ); + onReviewed(); + } else { + enqueueSnackbar(getApiError(data, "Erro ao revisar a ideia."), { + variant: "error", + }); + } + } finally { + setProcessing(false); + } + }; + + return ( +
+
+
+ {idea.title} +

+ + Autor: {projectUserName(idea.author)} +

+
+ + Pendente + +
+ +

+ {idea.description} +

+ + {idea.tags.length > 0 && ( +
+ {idea.tags.map((tag) => ( + + {tag} + + ))} +
+ )} + +
+ + +
+ + {rejectOpen && ( +
+