mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-23 11:54:20 +00:00
Co-authored-by: Alan Buscaglia <alanbuscaglia@MacBook-Pro.local> Co-authored-by: alejandrobailo <alejandrobailo94@gmail.com> Co-authored-by: César Arroba <cesar@prowler.com> Co-authored-by: Alejandro Bailo <59607668+alejandrobailo@users.noreply.github.com>
127 lines
3.6 KiB
TypeScript
127 lines
3.6 KiB
TypeScript
"use client";
|
|
|
|
import { Card, CardBody } from "@heroui/card";
|
|
import { Divider } from "@heroui/divider";
|
|
import { Snippet } from "@heroui/snippet";
|
|
|
|
import { AddIcon } from "../icons";
|
|
import { CustomButton } from "../ui/custom";
|
|
import { DateWithTime } from "../ui/entities";
|
|
|
|
interface InvitationDetailsProps {
|
|
attributes: {
|
|
email: string;
|
|
state: string;
|
|
token: string;
|
|
expires_at: string;
|
|
inserted_at: string;
|
|
updated_at: string;
|
|
};
|
|
relationships?: {
|
|
inviter: {
|
|
data: {
|
|
id: string;
|
|
};
|
|
};
|
|
};
|
|
selfLink: string;
|
|
}
|
|
|
|
const InfoField = ({
|
|
label,
|
|
children,
|
|
}: {
|
|
label: string;
|
|
children: React.ReactNode;
|
|
}) => (
|
|
<div className="flex flex-col gap-1">
|
|
<span className="text-xs font-bold text-gray-500">{label}</span>
|
|
<div className="flex items-center rounded-lg bg-gray-50 p-3">
|
|
<span className="text-small text-gray-900">{children}</span>
|
|
</div>
|
|
</div>
|
|
);
|
|
|
|
export const InvitationDetails = ({ attributes }: InvitationDetailsProps) => {
|
|
// window.location.origin to get the current base URL
|
|
const baseUrl =
|
|
typeof window !== "undefined"
|
|
? window.location.origin
|
|
: "http://localhost:3000";
|
|
|
|
const invitationLink = `${baseUrl}/sign-up?invitation_token=${attributes.token}`;
|
|
|
|
return (
|
|
<div className="flex flex-col gap-x-4 gap-y-8">
|
|
<Card
|
|
isBlurred
|
|
className="bg-background/60 dark:bg-prowler-blue-800 border-none"
|
|
shadow="sm"
|
|
>
|
|
<CardBody>
|
|
<h2 className="text-md text-foreground/90 font-bold">
|
|
Invitation details
|
|
</h2>
|
|
<Divider className="my-4" />
|
|
|
|
<div className="flex flex-col gap-3">
|
|
<InfoField label="Email">{attributes.email}</InfoField>
|
|
|
|
<InfoField label="Token">{attributes.token}</InfoField>
|
|
|
|
<div className="grid grid-cols-1 gap-3 md:grid-cols-2">
|
|
<InfoField label="State">
|
|
<span className="capitalize">{attributes.state}</span>
|
|
</InfoField>
|
|
|
|
<InfoField label="Expires At">
|
|
<DateWithTime dateTime={attributes.expires_at} inline />
|
|
</InfoField>
|
|
|
|
<InfoField label="Created At">
|
|
<DateWithTime dateTime={attributes.inserted_at} inline />
|
|
</InfoField>
|
|
|
|
<InfoField label="Updated At">
|
|
<DateWithTime dateTime={attributes.updated_at} inline />
|
|
</InfoField>
|
|
</div>
|
|
</div>
|
|
|
|
<Divider className="my-4" />
|
|
<h3 className="text-small text-foreground/90 pb-2 font-bold">
|
|
Share this link with the user:
|
|
</h3>
|
|
|
|
<div className="flex flex-col items-start justify-between">
|
|
<Snippet
|
|
classNames={{
|
|
base: "mx-auto",
|
|
}}
|
|
hideSymbol
|
|
variant="bordered"
|
|
className="overflow-hidden bg-gray-50 py-1 text-ellipsis whitespace-nowrap dark:bg-slate-800"
|
|
>
|
|
<p className="no-scrollbar text-small w-fit overflow-hidden overflow-x-scroll text-ellipsis whitespace-nowrap">
|
|
{invitationLink}
|
|
</p>
|
|
</Snippet>
|
|
</div>
|
|
</CardBody>
|
|
</Card>
|
|
<div className="flex w-full items-center justify-end">
|
|
<CustomButton
|
|
asLink="/invitations/"
|
|
ariaLabel="Send Invitation"
|
|
variant="solid"
|
|
color="action"
|
|
size="md"
|
|
endContent={<AddIcon size={20} />}
|
|
>
|
|
Back to Invitations
|
|
</CustomButton>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|