forked from github/plane
refactor: not making calls to member's endpoint to get membership status (#1831)
* refactor: not making call to members endpoint to get membership status * refactor: type for IProject
This commit is contained in:
parent
9ce85cdf21
commit
8c8668a3e6
@ -8,10 +8,9 @@ import { mutate } from "swr";
|
||||
// services
|
||||
import projectService from "services/project.service";
|
||||
// hooks
|
||||
import useProjectMembers from "hooks/use-project-members";
|
||||
import useToast from "hooks/use-toast";
|
||||
// ui
|
||||
import { CustomMenu, Loader, Tooltip } from "components/ui";
|
||||
import { CustomMenu, Tooltip } from "components/ui";
|
||||
// icons
|
||||
import {
|
||||
CalendarDaysIcon,
|
||||
@ -46,11 +45,8 @@ export const SingleProjectCard: React.FC<ProjectCardProps> = ({
|
||||
|
||||
const { setToastAlert } = useToast();
|
||||
|
||||
// fetching project members information
|
||||
const { members, hasJoined, isOwner, isMember } = useProjectMembers(
|
||||
workspaceSlug as string,
|
||||
project.id
|
||||
);
|
||||
const isOwner = project.member_role === 20;
|
||||
const isMember = project.member_role === 15;
|
||||
|
||||
const handleAddToFavorites = () => {
|
||||
if (!workspaceSlug) return;
|
||||
@ -125,7 +121,6 @@ export const SingleProjectCard: React.FC<ProjectCardProps> = ({
|
||||
|
||||
return (
|
||||
<>
|
||||
{members ? (
|
||||
<div className="flex flex-col rounded-[10px] bg-custom-background-90 shadow">
|
||||
<Link href={`/${workspaceSlug as string}/projects/${project.id}/issues`}>
|
||||
<a>
|
||||
@ -139,7 +134,7 @@ export const SingleProjectCard: React.FC<ProjectCardProps> = ({
|
||||
className="absolute top-0 left-0 h-full w-full object-cover rounded-t-[10px]"
|
||||
/>
|
||||
<div className="absolute bottom-4 left-4 flex items-center gap-3 text-white">
|
||||
{!hasJoined ? (
|
||||
{!project.is_member ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => {
|
||||
@ -194,7 +189,7 @@ export const SingleProjectCard: React.FC<ProjectCardProps> = ({
|
||||
{renderShortDateWithYearFormat(project.created_at)}
|
||||
</div>
|
||||
</Tooltip>
|
||||
{hasJoined ? (
|
||||
{project.is_member ? (
|
||||
<div className="flex items-center">
|
||||
{(isOwner || isMember) && (
|
||||
<Link href={`/${workspaceSlug}/projects/${project.id}/settings`}>
|
||||
@ -239,11 +234,6 @@ export const SingleProjectCard: React.FC<ProjectCardProps> = ({
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<Loader>
|
||||
<Loader.Item height="144px" />
|
||||
</Loader>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
2
apps/app/types/projects.d.ts
vendored
2
apps/app/types/projects.d.ts
vendored
@ -40,6 +40,8 @@ export interface IProject {
|
||||
id: string;
|
||||
identifier: string;
|
||||
is_favorite: boolean;
|
||||
is_member: boolean;
|
||||
member_role: 5 | 10 | 15 | 20 | null;
|
||||
issue_views_view: boolean;
|
||||
module_view: boolean;
|
||||
name: string;
|
||||
|
Loading…
Reference in New Issue
Block a user