// React import React, { useState } from "react"; // next import Link from "next/link"; import useSWR from "swr"; import { useRouter } from "next/router"; // services import projectService from "lib/services/project.service"; // hooks import useUser from "lib/hooks/useUser"; // ui import { Button } from "ui"; // icons import { CalendarDaysIcon, CheckIcon, MinusIcon, PencilIcon, PlusIcon, TrashIcon, ClipboardDocumentListIcon, } from "@heroicons/react/24/outline"; // types import type { IProject } from "types"; // fetch-keys import { PROJECT_MEMBERS } from "constants/fetch-keys"; // common import { renderShortNumericDateFormat } from "constants/common"; type TProjectCardProps = { workspaceSlug: string; project: IProject; setToJoinProject: (id: string | null) => void; setDeleteProject: (id: string | null) => void; }; const ProjectMemberInvitations: React.FC = (props) => { const { workspaceSlug, project, setToJoinProject, setDeleteProject } = props; const { user } = useUser(); const router = useRouter(); const { data: members } = useSWR(PROJECT_MEMBERS(project.id), () => projectService.projectMembers(workspaceSlug, project.id) ); const isMember = members?.some((item: any) => item.member.id === (user as any)?.id); const canEdit = members?.some( (item) => (item.member.id === (user as any)?.id && item.role === 20) || item.role === 15 ); const canDelete = members?.some( (item) => item.member.id === (user as any)?.id && item.role === 20 ); if (!members) { return (
); } return ( <>
{project.icon && ( {String.fromCodePoint(parseInt(project.icon))} )} {project.name} {project.identifier}
{isMember ? (
{canEdit && ( )} {canDelete && ( )}
) : null}

{project.description}

{!isMember ? ( ) : ( )}
{renderShortNumericDateFormat(project.created_at)}
); }; export default ProjectMemberInvitations;