'use client';

/**
 * OpenReturnDialogIsland
 *
 * Thin Astro-island wrapper around OpenReturnDialog.
 * On successful return creation, navigates the buyer to the return detail page.
 * Required because Astro cannot pass function props to React islands from
 * frontmatter — the callback lives here in client JS.
 */

import { OpenReturnDialog } from './OpenReturnDialog';

interface OpenReturnDialogIslandProps {
  purchaseId: string;
}

export function OpenReturnDialogIsland({ purchaseId }: OpenReturnDialogIslandProps) {
  return (
    <OpenReturnDialog
      purchaseId={purchaseId}
      onSuccess={() => {
        location.href = `/purchases/${purchaseId}/return`;
      }}
    />
  );
}
