// React import React, { useState } from "react"; // next import Link from "next/link"; import useSWR from "swr"; // hooks import useUser from "lib/hooks/useUser"; // Services import projectService from "lib/services/project.service"; // fetch keys import { PROJECT_MEMBERS } from "constants/fetch-keys"; // commons import { renderShortNumericDateFormat } from "constants/common"; // icons import { CalendarDaysIcon, CheckIcon, EyeIcon, MinusIcon, PencilIcon, PlusIcon, TrashIcon, } from "@heroicons/react/24/outline"; // types import type { IProject } from "types"; type Props = { project: IProject; slug: string; invitationsRespond: string[]; handleInvitation: (project_invitation: any, action: "accepted" | "withdraw") => void; setDeleteProject: (id: string | null) => void; }; const ProjectMemberInvitations: React.FC = ({ project, slug, invitationsRespond, handleInvitation, setDeleteProject, }) => { const { user } = useUser(); const { data: members } = useSWR(PROJECT_MEMBERS(project.id), () => projectService.projectMembers(slug, project.id) ); const isMember = members?.some((item: any) => item.member.id === (user as any)?.id); const [selected, setSelected] = useState(false); if (!members) { return (
); } return ( <>
{!isMember ? ( { setSelected(e.target.checked); handleInvitation( project, invitationsRespond.includes(project.id) ? "withdraw" : "accepted" ); }} type="checkbox" /> ) : null} {project.name} ({project.identifier})
{isMember ? (
) : null}

{project.description}

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