import type { HttpRequest } from '@yaakapp-internal/models'; import { patchModel } from '@yaakapp-internal/models'; import type { ReactNode } from 'react'; import { useToggle } from '../hooks/useToggle'; import { showConfirm } from '../lib/confirm'; import { Banner } from './core/Banner'; import { Button } from './core/Button'; import { InlineCode } from './core/InlineCode'; import { Link } from './core/Link'; import { SizeTag } from './core/SizeTag'; import { HStack } from './core/Stacks'; interface Props { children: ReactNode; request: HttpRequest; } const LARGE_TEXT_BYTES = 2 * 1000 * 1000; export function ConfirmLargeRequestBody({ children, request }: Props) { const [showLargeResponse, toggleShowLargeResponse] = useToggle(); if (request.body?.text == null) { return children; } const contentLength = request.body.text.length ?? 0; const tooLargeBytes = LARGE_TEXT_BYTES; const isLarge = contentLength > tooLargeBytes; if (!showLargeResponse && isLarge) { return (

Rendering content over{' '} {' '} may impact performance.

See{' '} Working With Large Values {' '} for tips.

); } return <>{children}; }