2023-06-06 20:26:21 +00:00
|
|
|
// helpers
|
2023-05-30 13:44:35 +00:00
|
|
|
import { getFirstCharacters, truncateText } from "helpers/string.helper";
|
2022-11-29 14:19:39 +00:00
|
|
|
// types
|
2022-12-12 04:49:52 +00:00
|
|
|
import { IWorkspaceMemberInvitation } from "types";
|
2022-11-29 14:19:39 +00:00
|
|
|
|
|
|
|
type Props = {
|
2022-12-12 04:49:52 +00:00
|
|
|
invitation: IWorkspaceMemberInvitation;
|
2022-11-29 14:19:39 +00:00
|
|
|
invitationsRespond: string[];
|
|
|
|
handleInvitation: any;
|
|
|
|
};
|
|
|
|
|
2023-11-08 15:01:46 +00:00
|
|
|
const SingleInvitation: React.FC<Props> = ({ invitation, invitationsRespond, handleInvitation }) => (
|
2023-06-06 20:26:21 +00:00
|
|
|
<li>
|
|
|
|
<label
|
|
|
|
className={`group relative flex cursor-pointer items-start space-x-3 border-2 border-transparent py-4`}
|
|
|
|
htmlFor={invitation.id}
|
|
|
|
>
|
|
|
|
<div className="flex-shrink-0">
|
|
|
|
<span className="inline-flex h-10 w-10 items-center justify-center rounded-lg">
|
|
|
|
{invitation.workspace.logo && invitation.workspace.logo !== "" ? (
|
|
|
|
<img
|
|
|
|
src={invitation.workspace.logo}
|
|
|
|
height="100%"
|
|
|
|
width="100%"
|
|
|
|
className="rounded"
|
|
|
|
alt={invitation.workspace.name}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<span className="flex h-full w-full items-center justify-center rounded-xl bg-gray-700 p-4 uppercase text-white">
|
|
|
|
{getFirstCharacters(invitation.workspace.name)}
|
2022-11-29 14:19:39 +00:00
|
|
|
</span>
|
2023-06-06 20:26:21 +00:00
|
|
|
)}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div className="min-w-0 flex-1">
|
|
|
|
<div className="text-sm font-medium">{truncateText(invitation.workspace.name, 30)}</div>
|
2023-07-10 07:17:00 +00:00
|
|
|
<p className="text-sm text-custom-text-200">
|
2023-06-06 20:26:21 +00:00
|
|
|
Invited by{" "}
|
|
|
|
{invitation.created_by_detail
|
2023-08-08 07:31:43 +00:00
|
|
|
? invitation.created_by_detail.display_name
|
|
|
|
: invitation.workspace.owner.display_name}
|
2023-06-06 20:26:21 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div className="flex-shrink-0 self-center">
|
|
|
|
<button
|
|
|
|
className={`${
|
|
|
|
invitationsRespond.includes(invitation.id)
|
2023-07-10 07:17:00 +00:00
|
|
|
? "bg-custom-background-80 text-custom-text-200"
|
|
|
|
: "bg-custom-primary text-white"
|
2023-07-17 10:58:23 +00:00
|
|
|
} text-sm px-4 py-2 border border-custom-border-200 rounded-3xl`}
|
2023-09-14 10:35:31 +00:00
|
|
|
onClick={() => {
|
2023-11-08 15:01:46 +00:00
|
|
|
handleInvitation(invitation, invitationsRespond.includes(invitation.id) ? "withdraw" : "accepted");
|
2023-06-06 20:26:21 +00:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
{invitationsRespond.includes(invitation.id) ? "Invitation Accepted" : "Accept Invitation"}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</label>
|
|
|
|
</li>
|
|
|
|
);
|
2022-11-29 14:19:39 +00:00
|
|
|
|
|
|
|
export default SingleInvitation;
|