Refactor content viewer components and use for multpart and request body (#333)

This commit is contained in:
Gregory Schier
2025-12-28 13:25:24 -08:00
committed by GitHub
parent 6869aa49ec
commit 394fbbd55d
16 changed files with 325 additions and 116 deletions

View File

@@ -1,21 +1,15 @@
import type { HttpResponse } from '@yaakapp-internal/models';
import classNames from 'classnames';
import { useResponseBodyText } from '../../hooks/useResponseBodyText';
import { JsonAttributeTree } from '../core/JsonAttributeTree';
interface Props {
response: HttpResponse;
text: string;
className?: string;
}
export function JsonViewer({ response, className }: Props) {
const rawBody = useResponseBodyText({ response, filter: null });
if (rawBody.isLoading || rawBody.data == null) return null;
export function JsonViewer({ text, className }: Props) {
let parsed = {};
try {
parsed = JSON.parse(rawBody.data);
parsed = JSON.parse(text);
} catch {
// Nothing yet
}