bugfix: copy/regenerate link for invitation action added to connection request lis in orgs feature.
This commit is contained in:
@@ -43,8 +43,8 @@ export function Badge({
|
||||
);
|
||||
}
|
||||
|
||||
/** Map organization link / invitation row status to badge variant. */
|
||||
export function organizationLinkStatusVariant(status: string): BadgeVariant {
|
||||
/** Map organization connection / invitation row status to badge variant. */
|
||||
export function organizationConnectionStatusVariant(status: string): BadgeVariant {
|
||||
switch (status) {
|
||||
case 'ACTIVE':
|
||||
return 'success';
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
'use client';
|
||||
|
||||
import { Check, Copy } from 'lucide-react';
|
||||
import {
|
||||
canShareOrganizationInviteLink,
|
||||
type InvitationLinkTarget,
|
||||
} from '@/components/invitations/organizationInviteLinks';
|
||||
|
||||
type CopyInvitationLinkButtonProps = {
|
||||
invitation: InvitationLinkTarget;
|
||||
copied: boolean;
|
||||
copying: boolean;
|
||||
onCopy: () => void;
|
||||
};
|
||||
|
||||
export function CopyInvitationLinkButton({
|
||||
invitation,
|
||||
copied,
|
||||
copying,
|
||||
onCopy,
|
||||
}: CopyInvitationLinkButtonProps) {
|
||||
if (!canShareOrganizationInviteLink(invitation)) {
|
||||
return <span className="text-xs text-text-muted">—</span>;
|
||||
}
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className="p-2 rounded-md text-text-secondary hover:bg-background-card/80 hover:text-text-primary disabled:opacity-50"
|
||||
disabled={copying}
|
||||
onClick={onCopy}
|
||||
aria-label="Copy invitation link"
|
||||
title="Copy invitation link (generates a new link if needed)"
|
||||
>
|
||||
{copied ? <Check className="w-4 h-4" /> : <Copy className="w-4 h-4" />}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
'use client';
|
||||
|
||||
import { Check, Copy } from 'lucide-react';
|
||||
import { DialogCloseButton } from '@/components/ui/common/DialogCloseButton';
|
||||
import type { OrganizationInvitationHistoryItemDto } from '@/lib/api/organization';
|
||||
import { canShareOrganizationInviteLink } from '@/components/invitations/organizationInviteLinks';
|
||||
import { Badge, organizationLinkStatusVariant } from '@/components/ui/common/Badge';
|
||||
import { Badge, organizationConnectionStatusVariant } from '@/components/ui/common/Badge';
|
||||
import { Table } from '@/components/ui/common/Table';
|
||||
import { CopyInvitationLinkButton } from '@/components/ui/organizations/CopyInvitationLinkButton';
|
||||
|
||||
function formatInvitationStatusLabel(status: OrganizationInvitationHistoryItemDto['status']): string {
|
||||
if (status === 'PENDING') return 'Invitation pending';
|
||||
if (status === 'ACTIVE') return 'Invitation Accepted';
|
||||
if (status === 'ACTIVE') return 'Invitation accepted';
|
||||
if (status === 'REJECTED') return 'Invitation rejected';
|
||||
if (status === 'EXPIRED') return 'Invitation expired';
|
||||
return status;
|
||||
@@ -94,7 +93,7 @@ export function InvitationHistoryDialog({
|
||||
Status
|
||||
</th>
|
||||
<th className="px-6 py-3 text-right text-xs font-medium text-text-muted uppercase tracking-wider">
|
||||
Action
|
||||
Invitation link
|
||||
</th>
|
||||
</tr>
|
||||
}
|
||||
@@ -108,29 +107,17 @@ export function InvitationHistoryDialog({
|
||||
{formatTableDate(inv.createdAt)}
|
||||
</td>
|
||||
<td className="px-6 py-1.5 text-center align-middle">
|
||||
<Badge variant={organizationLinkStatusVariant(inv.status)} fixedWidth={false}>
|
||||
<Badge variant={organizationConnectionStatusVariant(inv.status)} fixedWidth={false}>
|
||||
{formatInvitationStatusLabel(inv.status)}
|
||||
</Badge>
|
||||
</td>
|
||||
<td className="px-6 py-1.5 text-right align-middle">
|
||||
{canShareOrganizationInviteLink(inv) ? (
|
||||
<button
|
||||
type="button"
|
||||
className="p-2 rounded-md text-text-secondary hover:bg-background-card/80 hover:text-text-primary disabled:opacity-50"
|
||||
disabled={copyingInvitationId === inv.id}
|
||||
onClick={() => onCopy(inv)}
|
||||
aria-label="Copy invitation link"
|
||||
title="Copy invitation link (generates a new link if needed)"
|
||||
>
|
||||
{copiedId === inv.id ? (
|
||||
<Check className="w-4 h-4" />
|
||||
) : (
|
||||
<Copy className="w-4 h-4" />
|
||||
)}
|
||||
</button>
|
||||
) : (
|
||||
<span className="text-xs text-text-muted">—</span>
|
||||
)}
|
||||
<CopyInvitationLinkButton
|
||||
invitation={inv}
|
||||
copied={copiedId === inv.id}
|
||||
copying={copyingInvitationId === inv.id}
|
||||
onCopy={() => onCopy(inv)}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user