'use client' /** * PendingInvitationCallout — "You've been invited to as " banner * with an Accept button. Apps pass an `onAccept` handler that typically * resolves the invitation token (from the URL) and calls * api.teamInvitations.accept(id, token). * * Optional `teamName` lets apps render the team's display name even though * the invitation row from the backend only carries teamId. startsim-o7s. */ import * as React from 'react' import type { InvitationLite } from './types' import { PENDING_INVITE_DEFAULTS, type PendingInvitationCalloutClassNames, } from './pending-invitation-callout-default-class-names' export interface PendingInvitationCalloutProps { invitation: InvitationLite /** Resolved team name (caller supplies). When omitted we use `team #`. */ teamName?: string /** Called when the user clicks Accept. */ onAccept?: (invitation: InvitationLite) => Promise | void /** Called when the user clicks Decline. Optional — hidden when not provided. */ onDecline?: (invitation: InvitationLite) => Promise | void /** Notification once accept resolves. */ onAccepted?: (invitation: InvitationLite) => void acceptLabel?: string declineLabel?: string classNames?: PendingInvitationCalloutClassNames } export function PendingInvitationCallout({ invitation, teamName, onAccept, onDecline, onAccepted, acceptLabel = 'Accept', declineLabel = 'Decline', classNames, }: PendingInvitationCalloutProps) { const cls = { ...PENDING_INVITE_DEFAULTS, ...(classNames ?? {}) } const [submitting, setSubmitting] = React.useState(false) const [error, setError] = React.useState('') const renderedTeam = teamName ?? `team #${invitation.teamId}` const role = invitation.role async function handleAccept() { setError('') setSubmitting(true) try { await onAccept?.(invitation) onAccepted?.(invitation) } catch (err) { setError(err instanceof Error ? err.message : 'Could not accept invitation') } finally { setSubmitting(false) } } async function handleDecline() { setError('') setSubmitting(true) try { await onDecline?.(invitation) } catch (err) { setError(err instanceof Error ? err.message : 'Could not decline invitation') } finally { setSubmitting(false) } } return (

You've been invited to {renderedTeam} as a{' '} {role}.

{onDecline && ( )}
{error &&

{error}

}
) }