diff --git a/src/app/[language]/projetos/[id]/page-content.tsx b/src/app/[language]/projetos/[id]/page-content.tsx
index d47a99e..49522dc 100644
--- a/src/app/[language]/projetos/[id]/page-content.tsx
+++ b/src/app/[language]/projetos/[id]/page-content.tsx
@@ -1,42 +1,113 @@
"use client";
-import { useEffect, useState } from "react";
+import { useState } from "react";
import { useParams } from "next/navigation";
import { useQuery, useQueryClient } from "@tanstack/react-query";
-import { ArrowLeft, Lightbulb, Users } from "lucide-react";
+import { ArrowLeft, Lightbulb, Plus, Users, X } from "lucide-react";
import {
useDeleteProjectInterestService,
+ useDeleteProjectParticipantService,
+ useDeleteProjectRoleService,
useGetMyProjectInterestService,
useGetProjectIdeaService,
- useGetProjectInterestsService,
+ useGetProjectParticipantsService,
+ useGetProjectRolesService,
+ usePostProjectRoleService,
usePutProjectInterestService,
} from "@/services/api/services/projects";
import HTTP_CODES_ENUM from "@/services/api/types/http-codes";
-import {
- ProjectIdea,
- ProjectIdeaStatus,
- ProjectRole,
-} from "@/services/api/types/project";
+import { ProjectIdea, ProjectParticipant } 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";
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 { PROJECT_ROLE_LABELS } from "@/lib/project-labels";
-import { FIELD_CLASS, RoleChip, UserChip } from "../project-components";
+import { projectUserName } from "@/lib/project-labels";
+import { FIELD_CLASS, UserChip } from "../project-components";
+
+const MAX_STACK = 4;
+
+function participantLabel(participant: ProjectParticipant): string {
+ return participant.user?.username
+ ? `@${participant.user.username}`
+ : projectUserName(participant.user);
+}
+
+/** Fotos sobrepostas, no estilo do Instagram; passando do limite vira "+N". */
+function AvatarStack({ participants }: { participants: ProjectParticipant[] }) {
+ const visible = participants.slice(0, MAX_STACK);
+ const extra = participants.length - visible.length;
-function InterestPanel({ idea }: { idea: ProjectIdea }) {
+ return (
+
+ {visible.map((participant) => (
+
+ {participant.user?.photo?.path && (
+
+ )}
+
+ {projectUserName(participant.user).charAt(0).toUpperCase()}
+
+
+ ))}
+ {extra > 0 && (
+
+ +{extra}
+
+ )}
+
+ );
+}
+
+function TeamCard({ idea }: { idea: ProjectIdea }) {
const { user, isLoaded } = useAuth();
const { enqueueSnackbar } = useSnackbar();
const queryClient = useQueryClient();
+ const fetchRoles = useGetProjectRolesService();
+ const fetchParticipants = useGetProjectParticipantsService();
const getMyInterest = useGetMyProjectInterestService();
const putInterest = usePutProjectInterestService();
const deleteInterest = useDeleteProjectInterestService();
+ const postRole = usePostProjectRoleService();
+ const deleteRole = useDeleteProjectRoleService();
+ const deleteParticipant = useDeleteProjectParticipantService();
- const [role, setRole] = useState(ProjectRole.FRONTEND);
- const [message, setMessage] = useState("");
+ const [newRole, setNewRole] = useState("");
const [processing, setProcessing] = useState(false);
+ const [confirmRoleId, setConfirmRoleId] = useState(null);
+
+ const userId = user ? Number(user.id) : null;
+ const roleId = Number(user?.role?.id);
+ const canManage =
+ userId !== null &&
+ (userId === idea.authorId ||
+ roleId === RoleEnum.ADMIN ||
+ roleId === RoleEnum.MODERATOR);
+
+ const { data: roles = [], isLoading: loadingRoles } = useQuery({
+ queryKey: ["project-idea-roles", idea.id],
+ queryFn: async () => {
+ const { status, data } = await fetchRoles({ ideaId: idea.id });
+ return status === HTTP_CODES_ENUM.OK ? data : [];
+ },
+ enabled: !!user,
+ });
+
+ const { data: participants = [] } = useQuery({
+ queryKey: ["project-idea-participants", idea.id],
+ queryFn: async () => {
+ const { status, data } = await fetchParticipants({ ideaId: idea.id });
+ return status === HTTP_CODES_ENUM.OK ? data : [];
+ },
+ enabled: !!user,
+ });
const { data: mine } = useQuery({
queryKey: ["my-project-interest", idea.id],
@@ -47,178 +118,242 @@ function InterestPanel({ idea }: { idea: ProjectIdea }) {
enabled: !!user,
});
- useEffect(() => {
- if (mine?.interested && mine.role) {
- setRole(mine.role);
- setMessage(mine.message ?? "");
- }
- }, [mine]);
-
const refresh = () => {
+ queryClient.invalidateQueries({
+ queryKey: ["project-idea-roles", idea.id],
+ });
+ queryClient.invalidateQueries({
+ queryKey: ["project-idea-participants", idea.id],
+ });
queryClient.invalidateQueries({
queryKey: ["my-project-interest", idea.id],
});
queryClient.invalidateQueries({ queryKey: ["project-idea", idea.id] });
};
- const handleSave = async () => {
+ const run = async (
+ action: () => Promise<{ status: number; data?: unknown }>,
+ okStatuses: number[],
+ errorMessage: string,
+ successMessage?: string
+ ) => {
setProcessing(true);
try {
- const { status, data } = await putInterest({
- ideaId: idea.id,
- role,
- message: message.trim() || undefined,
- });
- if (status === HTTP_CODES_ENUM.OK || status === HTTP_CODES_ENUM.CREATED) {
- enqueueSnackbar(
- mine?.interested ? "Interesse atualizado." : "Interesse registrado!",
- { variant: "success" }
- );
+ const { status, data } = await action();
+ if (okStatuses.includes(status)) {
+ if (successMessage) {
+ enqueueSnackbar(successMessage, { variant: "success" });
+ }
refresh();
- } else {
- enqueueSnackbar(getApiError(data, "Erro ao registrar interesse."), {
- variant: "error",
- });
+ return true;
}
+ enqueueSnackbar(getApiError(data, errorMessage), { variant: "error" });
+ return false;
} finally {
setProcessing(false);
}
};
- const handleRemove = async () => {
- setProcessing(true);
- try {
- const { status } = await deleteInterest({ ideaId: idea.id });
- if (status === HTTP_CODES_ENUM.NO_CONTENT) {
- enqueueSnackbar("Interesse removido.", { variant: "success" });
- setMessage("");
- refresh();
- } else {
- enqueueSnackbar("Erro ao remover interesse.", { variant: "error" });
- }
- } finally {
- setProcessing(false);
+ const handleToggle = (roleName: string, joined: boolean) =>
+ joined
+ ? run(
+ () => deleteInterest({ ideaId: idea.id, role: roleName }),
+ [HTTP_CODES_ENUM.NO_CONTENT],
+ "Erro ao sair do cargo.",
+ "Você saiu do cargo."
+ )
+ : run(
+ () => putInterest({ ideaId: idea.id, role: roleName }),
+ [HTTP_CODES_ENUM.OK, HTTP_CODES_ENUM.CREATED],
+ "Erro ao entrar no cargo.",
+ "Você entrou no time!"
+ );
+
+ const handleAddRole = async () => {
+ const name = newRole.trim();
+ if (name.length < 2) return;
+ const ok = await run(
+ () => postRole({ ideaId: idea.id, name }),
+ [HTTP_CODES_ENUM.OK, HTTP_CODES_ENUM.CREATED],
+ "Erro ao adicionar cargo.",
+ "Cargo adicionado."
+ );
+ if (ok) setNewRole("");
+ };
+
+ const handleRemoveRole = (role: { id: string; name: string }) => {
+ if (confirmRoleId !== role.id) {
+ setConfirmRoleId(role.id);
+ return;
}
+ setConfirmRoleId(null);
+ run(
+ () => deleteRole({ ideaId: idea.id, roleId: role.id }),
+ [HTTP_CODES_ENUM.NO_CONTENT],
+ "Erro ao remover cargo.",
+ "Cargo removido."
+ );
};
+ const handleRemoveParticipant = (participant: ProjectParticipant) =>
+ run(
+ () =>
+ deleteParticipant({
+ ideaId: idea.id,
+ userId: participant.userId,
+ role: participant.role,
+ }),
+ [HTTP_CODES_ENUM.NO_CONTENT],
+ "Erro ao remover participante."
+ );
+
if (!isLoaded) return null;
if (!user) {
return (
-
-
- Entre na sua conta
- {" "}
- para dizer em qual cargo gostaria de participar.
-
+
+
+
+ Time do projeto
+
+
+
+ Entre na sua conta
+ {" "}
+ para ver quem está no time e participar de um cargo.
+
+
);
}
- if (Number(user.id) === idea.authorId) return null;
+ const joinedRoles = new Set(mine?.roles ?? []);
return (
-
+
-
- {mine?.interested
- ? "Você tem interesse neste projeto"
- : "Quero participar"}
+
+
+ Time do projeto
- O autor vê a lista de interessados e escolhe quem entra no time.
+ Escolha um ou mais cargos para participar. Quem propôs o projeto
+ também pode atuar nele.
-
- Em qual cargo?
- setRole(e.target.value as ProjectRole)}
- className={FIELD_CLASS}
- >
- {Object.values(ProjectRole).map((value) => (
-
- {PROJECT_ROLE_LABELS[value]}
-
- ))}
-
-
-
-
-
- Mensagem para o autor (opcional)
-
-
-
-
-
- {mine?.interested ? "Atualizar interesse" : "Tenho interesse"}
-
- {mine?.interested && (
-
- Remover
-
- )}
-
-
- );
-}
-
-function InterestsList({ ideaId }: { ideaId: string }) {
- const fetchInterests = useGetProjectInterestsService();
+ {loadingRoles ? (
+
+ ) : (
+
+ )}
- return (
-
-
-
- Interessados ({interests.length})
-
- {isLoading ? (
-
- ) : interests.length === 0 ? (
-
- Ninguém demonstrou interesse ainda. Compartilhe a ideia com a
- comunidade!
-
- ) : (
-
- {interests.map((interest) => (
-
-
-
-
-
- {interest.message && (
-
- {interest.message}
-
- )}
-
- ))}
+ {canManage && (
+
)}
@@ -228,7 +363,6 @@ function InterestsList({ ideaId }: { ideaId: string }) {
function ProjectIdeaDetailPageContent() {
const params = useParams();
const id = params.id as string;
- const { user } = useAuth();
const fetchIdea = useGetProjectIdeaService();
const { data: idea, isLoading } = useQuery({
@@ -253,16 +387,14 @@ function ProjectIdeaDetailPageContent() {
);
}
- const isAuthor = !!user && Number(user.id) === idea.authorId;
-
return (
{idea.interestCount}{" "}
- {idea.interestCount === 1 ? "interessado" : "interessados"}
+ {idea.interestCount === 1 ? "participante" : "participantes"}
{idea.tags.length > 0 && (
@@ -305,32 +437,14 @@ function ProjectIdeaDetailPageContent() {
{idea.teamId && (
-
Esta ideia já virou um time.
+
Este projeto já tem um time.
}>
Ver time
)}
- {isAuthor && idea.status === ProjectIdeaStatus.APPROVED && (
-
-
-
Pronto para montar o time?
-
- Defina os cargos e escolha entre os interessados.
-
-
-
}>
- Montar time
-
-
- )}
-
- {isAuthor ? (
-
- ) : (
-
- )}
+
);
}
diff --git a/src/app/[language]/projetos/[id]/team/new/page-content.tsx b/src/app/[language]/projetos/[id]/team/new/page-content.tsx
deleted file mode 100644
index abda24e..0000000
--- a/src/app/[language]/projetos/[id]/team/new/page-content.tsx
+++ /dev/null
@@ -1,396 +0,0 @@
-"use client";
-
-import { useEffect, useMemo, useState } from "react";
-import { useParams, useRouter } from "next/navigation";
-import { useQuery } from "@tanstack/react-query";
-import { ArrowLeft, Lightbulb, Sparkles } from "lucide-react";
-import withPageRequiredAuth from "@/services/auth/with-page-required-auth";
-import {
- useGetProjectIdeaForManagementService,
- useGetProjectInterestsService,
- useGetSuggestedVacanciesService,
- usePostProjectTeamService,
-} from "@/services/api/services/projects";
-import HTTP_CODES_ENUM from "@/services/api/types/http-codes";
-import { ProjectIdeaStatus, ProjectRole } from "@/services/api/types/project";
-import { Button } from "@/components/ui/button";
-import Link from "@/components/link";
-import { EmptyState } from "@/components/ui/empty-state";
-import { getApiError } from "@/lib/utils";
-import { PROJECT_ROLE_LABELS } from "@/lib/project-labels";
-import { useSnackbar } from "@/hooks/use-snackbar";
-import { FIELD_CLASS, UserChip } from "../../../project-components";
-import {
- VacancyCounts,
- VacancyEditor,
- emptyVacancyCounts,
- vacancyCountsFromList,
- vacancyCountsToList,
-} from "../../../vacancy-editor";
-
-function NewProjectTeamPageContent() {
- const params = useParams();
- const ideaId = params.id as string;
- const router = useRouter();
- const { enqueueSnackbar } = useSnackbar();
- const fetchIdea = useGetProjectIdeaForManagementService();
- const fetchInterests = useGetProjectInterestsService();
- const fetchSuggestions = useGetSuggestedVacanciesService();
- const postTeam = usePostProjectTeamService();
-
- const { data: idea, isLoading: loadingIdea } = useQuery({
- queryKey: ["project-idea-edit", ideaId],
- queryFn: async () => {
- const { status, data } = await fetchIdea({ id: ideaId });
- return status === HTTP_CODES_ENUM.OK ? data : null;
- },
- });
-
- const { data: interests, isLoading: loadingInterests } = useQuery({
- queryKey: ["project-idea-interests", ideaId],
- queryFn: async () => {
- const { status, data } = await fetchInterests({ ideaId });
- return status === HTTP_CODES_ENUM.OK ? data : [];
- },
- });
-
- const { data: suggestions, isLoading: loadingSuggestions } = useQuery({
- queryKey: ["project-idea-suggestions", ideaId],
- queryFn: async () => {
- const { status, data } = await fetchSuggestions({ ideaId });
- return status === HTTP_CODES_ENUM.OK ? data : [];
- },
- });
-
- const [name, setName] = useState("");
- const [description, setDescription] = useState("");
- const [repoUrl, setRepoUrl] = useState("");
- const [vacancies, setVacancies] =
- useState(emptyVacancyCounts());
- // userId -> cargo no time. Quem não está no mapa não entra no time.
- const [assignments, setAssignments] = useState>(
- {}
- );
- const [initialized, setInitialized] = useState(false);
- const [submitting, setSubmitting] = useState(false);
- const [error, setError] = useState("");
-
- // Pré-preenche vagas com a sugestão e aloca cada interessado no cargo que
- // pediu, enquanto houver vaga — o autor ajusta antes de confirmar.
- useEffect(() => {
- if (initialized || !idea || !interests || !suggestions) return;
-
- const counts = vacancyCountsFromList(suggestions);
- const remaining = { ...counts };
- const initial: Record = {};
- for (const interest of interests) {
- if (remaining[interest.role] > 0) {
- initial[interest.userId] = interest.role;
- remaining[interest.role] -= 1;
- }
- }
-
- setName(idea.title);
- setVacancies(counts);
- setAssignments(initial);
- setInitialized(true);
- }, [initialized, idea, interests, suggestions]);
-
- const assignedPerRole = useMemo(() => {
- const counts = emptyVacancyCounts();
- for (const role of Object.values(assignments)) counts[role] += 1;
- return counts;
- }, [assignments]);
-
- const overbooked = Object.values(ProjectRole).filter(
- (role) => assignedPerRole[role] > vacancies[role]
- );
- const totalVacancies = vacancyCountsToList(vacancies).reduce(
- (sum, v) => sum + v.quantity,
- 0
- );
-
- const toggleUser = (userId: number, requestedRole: ProjectRole) => {
- setAssignments((prev) => {
- const next = { ...prev };
- if (userId in next) {
- delete next[userId];
- } else {
- next[userId] = requestedRole;
- }
- return next;
- });
- };
-
- const handleSubmit = async (e: React.FormEvent) => {
- e.preventDefault();
- setError("");
-
- if (name.trim().length < 3) {
- setError("Dê um nome ao time (mínimo 3 caracteres).");
- return;
- }
- if (totalVacancies === 0) {
- setError("Defina ao menos uma vaga.");
- return;
- }
- if (overbooked.length > 0) {
- setError(
- `Há mais pessoas do que vagas em: ${overbooked
- .map((role) => PROJECT_ROLE_LABELS[role])
- .join(", ")}.`
- );
- return;
- }
-
- setSubmitting(true);
- try {
- const { status, data } = await postTeam({
- ideaId,
- name: name.trim(),
- description: description.trim() || undefined,
- repoUrl: repoUrl.trim() || undefined,
- vacancies: vacancyCountsToList(vacancies),
- members: Object.entries(assignments).map(([userId, role]) => ({
- userId: Number(userId),
- role,
- })),
- });
- if (status === HTTP_CODES_ENUM.CREATED) {
- enqueueSnackbar("Time criado!", { variant: "success" });
- router.push(`/projetos/times/${data.id}`);
- } else {
- setError(getApiError(data, "Erro ao criar o time."));
- }
- } finally {
- setSubmitting(false);
- }
- };
-
- if (loadingIdea || loadingInterests || loadingSuggestions) {
- return (
-
- );
- }
-
- if (!idea) {
- return (
-
-
-
- );
- }
-
- if (idea.status !== ProjectIdeaStatus.APPROVED) {
- return (
-
-
-
- );
- }
-
- const interestList = interests ?? [];
-
- return (
-
-
-
- {idea.title}
-
-
-
-
- Montar time
-
-
- Quem vai construir este projeto?
-
-
-
-
-
- );
-}
-
-export default withPageRequiredAuth(NewProjectTeamPageContent);
diff --git a/src/app/[language]/projetos/[id]/team/new/page.tsx b/src/app/[language]/projetos/[id]/team/new/page.tsx
deleted file mode 100644
index 7bb1108..0000000
--- a/src/app/[language]/projetos/[id]/team/new/page.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import type { Metadata } from "next";
-import NewProjectTeamPageContent from "./page-content";
-
-export const metadata: Metadata = {
- title: "Montar Time",
-};
-
-export default function Page() {
- return ;
-}
diff --git a/src/app/[language]/projetos/mine/page-content.tsx b/src/app/[language]/projetos/mine/page-content.tsx
index febce26..d24bf76 100644
--- a/src/app/[language]/projetos/mine/page-content.tsx
+++ b/src/app/[language]/projetos/mine/page-content.tsx
@@ -71,14 +71,6 @@ function MyIdeaRow({
Ver ideia
)}
- {idea.status === ProjectIdeaStatus.APPROVED && (
- }
- >
- Montar time
-
- )}
{idea.teamId && (
{
const chosen = roles[interest.userId];
if (chosen && openRoles.includes(chosen)) return chosen;
- if (openRoles.includes(interest.role)) return interest.role;
+ const preferred = projectRoleFromLabel(interest.role);
+ if (preferred && openRoles.includes(preferred)) return preferred;
return openRoles[0] ?? "";
};
@@ -259,7 +261,7 @@ function InterestedPanel({
- Pediu: {PROJECT_ROLE_LABELS[interest.role]}
+ Pediu: {interest.role}
{interest.message ? ` · ${interest.message}` : ""}
diff --git a/src/lib/project-labels.ts b/src/lib/project-labels.ts
index 7567e03..93ad882 100644
--- a/src/lib/project-labels.ts
+++ b/src/lib/project-labels.ts
@@ -17,6 +17,13 @@ export const PROJECT_ROLE_LABELS: Record = {
[ProjectRole.PROJECT_MANAGER]: "Gerente de projeto",
};
+/** Cargos da ideia guardam o nome; os padrão voltam ao enum de vaga do time. */
+export function projectRoleFromLabel(name: string): ProjectRole | undefined {
+ return (Object.values(ProjectRole) as ProjectRole[]).find(
+ (role) => PROJECT_ROLE_LABELS[role] === name
+ );
+}
+
export const PROJECT_IDEA_STATUS_LABELS: Record = {
[ProjectIdeaStatus.PENDING]: "Em análise",
[ProjectIdeaStatus.APPROVED]: "Aberta a interessados",
diff --git a/src/services/api/services/projects.ts b/src/services/api/services/projects.ts
index 3f6e4ef..bbeb813 100644
--- a/src/services/api/services/projects.ts
+++ b/src/services/api/services/projects.ts
@@ -7,6 +7,8 @@ import {
MyProjectInterest,
ProjectIdea,
ProjectIdeaInterest,
+ ProjectIdeaRole,
+ ProjectParticipant,
ProjectRole,
ProjectTeam,
ProjectTeamStatus,
@@ -172,7 +174,7 @@ export function usePutProjectInterestService() {
return useCallback(
(
- data: { ideaId: string; role: ProjectRole; message?: string },
+ data: { ideaId: string; role: string; message?: string },
requestConfig?: RequestConfigType
) =>
fetch(buildUrl(`project-ideas/${data.ideaId}/interest`), {
@@ -187,9 +189,78 @@ export function usePutProjectInterestService() {
export function useDeleteProjectInterestService() {
const fetch = useFetch();
+ return useCallback(
+ (
+ data: { ideaId: string; role?: string },
+ requestConfig?: RequestConfigType
+ ) =>
+ fetch(
+ buildUrl(
+ `project-ideas/${data.ideaId}/interest${
+ data.role ? `?role=${encodeURIComponent(data.role)}` : ""
+ }`
+ ),
+ {
+ method: "DELETE",
+ ...requestConfig,
+ }
+ ).then(wrapperFetchJsonResponse),
+ [fetch]
+ );
+}
+
+export function useGetProjectInterestsService() {
+ const fetch = useFetch();
+
return useCallback(
(data: { ideaId: string }, requestConfig?: RequestConfigType) =>
- fetch(buildUrl(`project-ideas/${data.ideaId}/interest`), {
+ fetch(buildUrl(`project-ideas/${data.ideaId}/interests`), {
+ method: "GET",
+ ...requestConfig,
+ }).then(wrapperFetchJsonResponse),
+ [fetch]
+ );
+}
+
+export function useGetProjectRolesService() {
+ const fetch = useFetch();
+
+ return useCallback(
+ (data: { ideaId: string }, requestConfig?: RequestConfigType) =>
+ fetch(buildUrl(`project-ideas/${data.ideaId}/roles`), {
+ method: "GET",
+ ...requestConfig,
+ }).then(wrapperFetchJsonResponse),
+ [fetch]
+ );
+}
+
+export function usePostProjectRoleService() {
+ const fetch = useFetch();
+
+ return useCallback(
+ (
+ data: { ideaId: string; name: string },
+ requestConfig?: RequestConfigType
+ ) =>
+ fetch(buildUrl(`project-ideas/${data.ideaId}/roles`), {
+ method: "POST",
+ body: JSON.stringify({ name: data.name }),
+ ...requestConfig,
+ }).then(wrapperFetchJsonResponse),
+ [fetch]
+ );
+}
+
+export function useDeleteProjectRoleService() {
+ const fetch = useFetch();
+
+ return useCallback(
+ (
+ data: { ideaId: string; roleId: string },
+ requestConfig?: RequestConfigType
+ ) =>
+ fetch(buildUrl(`project-ideas/${data.ideaId}/roles/${data.roleId}`), {
method: "DELETE",
...requestConfig,
}).then(wrapperFetchJsonResponse),
@@ -197,15 +268,38 @@ export function useDeleteProjectInterestService() {
);
}
-export function useGetProjectInterestsService() {
+export function useGetProjectParticipantsService() {
const fetch = useFetch();
return useCallback(
(data: { ideaId: string }, requestConfig?: RequestConfigType) =>
- fetch(buildUrl(`project-ideas/${data.ideaId}/interests`), {
+ fetch(buildUrl(`project-ideas/${data.ideaId}/participants`), {
method: "GET",
...requestConfig,
- }).then(wrapperFetchJsonResponse),
+ }).then(wrapperFetchJsonResponse),
+ [fetch]
+ );
+}
+
+export function useDeleteProjectParticipantService() {
+ const fetch = useFetch();
+
+ return useCallback(
+ (
+ data: { ideaId: string; userId: number; role: string },
+ requestConfig?: RequestConfigType
+ ) =>
+ fetch(
+ buildUrl(
+ `project-ideas/${data.ideaId}/participants/${
+ data.userId
+ }?role=${encodeURIComponent(data.role)}`
+ ),
+ {
+ method: "DELETE",
+ ...requestConfig,
+ }
+ ).then(wrapperFetchJsonResponse),
[fetch]
);
}
diff --git a/src/services/api/types/project.ts b/src/services/api/types/project.ts
index 6859cb4..9be1857 100644
--- a/src/services/api/types/project.ts
+++ b/src/services/api/types/project.ts
@@ -31,6 +31,7 @@ export type ProjectUserSummary = {
firstName: string | null;
lastName: string | null;
photo?: FileEntity | null;
+ username?: string | null;
};
export type ProjectIdea = {
@@ -55,15 +56,23 @@ export type ProjectIdeaInterest = {
ideaId: string;
userId: number;
user?: ProjectUserSummary | null;
- role: ProjectRole;
+ role: string;
message: string | null;
createdAt: string;
};
+export type ProjectParticipant = Omit;
+
+export type ProjectIdeaRole = {
+ id: string;
+ ideaId: string;
+ name: string;
+ position: number;
+};
+
export type MyProjectInterest = {
interested: boolean;
- role: ProjectRole | null;
- message: string | null;
+ roles: string[];
};
export type SuggestedVacancy = {