fix module links

This commit is contained in:
rahulramesha 2024-02-20 13:56:11 +05:30
parent fdb0563683
commit dfbc2623ca
2 changed files with 72 additions and 64 deletions

View File

@ -58,7 +58,6 @@ export interface IIssueLink {
export interface ILinkDetails { export interface ILinkDetails {
created_at: Date; created_at: Date;
created_by: string; created_by: string;
created_by_detail: IUserLite;
id: string; id: string;
metadata: any; metadata: any;
title: string; title: string;

View File

@ -8,6 +8,9 @@ import { calculateTimeAgo } from "helpers/date-time.helper";
import { ILinkDetails, UserAuth } from "@plane/types"; import { ILinkDetails, UserAuth } from "@plane/types";
// hooks // hooks
import useToast from "hooks/use-toast"; import useToast from "hooks/use-toast";
import { observer } from "mobx-react";
import { useMeasure } from "@nivo/core";
import { useMember } from "hooks/store";
type Props = { type Props = {
links: ILinkDetails[]; links: ILinkDetails[];
@ -16,9 +19,10 @@ type Props = {
userAuth: UserAuth; userAuth: UserAuth;
}; };
export const LinksList: React.FC<Props> = ({ links, handleDeleteLink, handleEditLink, userAuth }) => { export const LinksList: React.FC<Props> = observer(({ links, handleDeleteLink, handleEditLink, userAuth }) => {
// toast // toast
const { setToastAlert } = useToast(); const { setToastAlert } = useToast();
const { getUserDetails } = useMember();
const isNotAllowed = userAuth.isGuest || userAuth.isViewer; const isNotAllowed = userAuth.isGuest || userAuth.isViewer;
@ -33,7 +37,9 @@ export const LinksList: React.FC<Props> = ({ links, handleDeleteLink, handleEdit
return ( return (
<> <>
{links.map((link) => ( {links.map((link) => {
const createdByDetails = getUserDetails(link.created_by);
return (
<div key={link.id} className="relative flex flex-col rounded-md bg-custom-background-90 p-2.5"> <div key={link.id} className="relative flex flex-col rounded-md bg-custom-background-90 p-2.5">
<div className="flex w-full items-start justify-between gap-2"> <div className="flex w-full items-start justify-between gap-2">
<div className="flex items-start gap-2 truncate"> <div className="flex items-start gap-2 truncate">
@ -89,14 +95,17 @@ export const LinksList: React.FC<Props> = ({ links, handleDeleteLink, handleEdit
<p className="mt-0.5 stroke-[1.5] text-xs text-custom-text-300"> <p className="mt-0.5 stroke-[1.5] text-xs text-custom-text-300">
Added {calculateTimeAgo(link.created_at)} Added {calculateTimeAgo(link.created_at)}
<br /> <br />
{createdByDetails && (
<>
by{" "} by{" "}
{link.created_by_detail.is_bot {createdByDetails?.is_bot ? createdByDetails?.first_name + " Bot" : createdByDetails?.display_name}
? link.created_by_detail.first_name + " Bot" </>
: link.created_by_detail.display_name} )}
</p> </p>
</div> </div>
</div> </div>
))} );
})}
</> </>
); );
}; });