import { formatSize } from "@yaakapp-internal/lib/formatSize"; import { Banner, CONTROL_TOOLTIP_DELAY, EmptyStateText, LoadingIcon, Tooltip, } from "@yaakapp-internal/ui"; import type { HttpBodyResult } from "@yaakapp-internal/ui/httpTypes"; import type { ReactNode } from "react"; import type { FlowBodyData } from "../lib/flowViews"; interface Props { /** The request body as the engine's body RPC returned it */ body: HttpBodyResult; /** The body in the viewer for its type, formatted or raw */ viewer: ReactNode; /** Bytes of the request body on the wire */ requestSize: number; } /** * The request half's Body tab: the body in its viewer, or why it isn't there yet. A body that * failed to load says why, as the response's viewer does, rather than reading as no body. */ export function FlowRequestBody({ body, viewer, requestSize }: Props) { if (body.error != null) { return ( {body.error.message} ); } if (body.isLoading) { return ( ); } if (body.data?.truncated) { return (
First {formatSize(body.data.storedSize)} of {formatSize(requestSize)} kept
{viewer}
); } return viewer; }