/** * A failed call's message, for a toast or a form. * * When RazorBooking refused a save because the workspace's subscription has * lapsed (`subscription_inactive`, a 402: its API is read-only then), a link * to renew follows the message. Reads keep working, so only saves show it. */ import type { ReactNode } from 'react'; import { ApiError, messageOf } from './api'; import { handoffUrl } from './handoff'; /** RazorBooking's code for a save refused over a lapsed subscription. */ export const SUBSCRIPTION_INACTIVE = 'subscription_inactive'; export function errorOf( caught: unknown, fallback: string ): ReactNode { const message = messageOf( caught, fallback ); if ( ! ( caught instanceof ApiError ) || caught.code !== SUBSCRIPTION_INACTIVE ) { return message; } return ( <> { message }{ ' ' } Renew in RazorBooking ); }