mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-17 23:14:03 +01:00
* Update environment model to get ready for request/folder environments * Folder environments in UI * Folder environments working * Tweaks and fixes * Tweak environment encryption UX * Tweak environment encryption UX * Address comments * Update fn name * Add tsc back to lint rules * Update src-web/components/EnvironmentEditor.tsx * Merge remote-tracking branch 'origin/folder-environments' into folder…
31 lines
846 B
TypeScript
31 lines
846 B
TypeScript
import type { HttpResponse } from '@yaakapp-internal/models';
|
|
import React, { useEffect, useState } from 'react';
|
|
import { useResponseBodyText } from '../../hooks/useResponseBodyText';
|
|
|
|
interface Props {
|
|
response: HttpResponse;
|
|
}
|
|
|
|
export function SvgViewer({ response }: Props) {
|
|
const rawTextBody = useResponseBodyText({ response, filter: null });
|
|
const [src, setSrc] = useState<string | null>(null);
|
|
|
|
useEffect(() => {
|
|
if (!rawTextBody.data) {
|
|
return setSrc(null);
|
|
}
|
|
|
|
const blob = new Blob([rawTextBody.data], { type: 'image/svg+xml;charset=utf-8' });
|
|
const url = URL.createObjectURL(blob);
|
|
setSrc(url);
|
|
|
|
return () => URL.revokeObjectURL(url);
|
|
}, [rawTextBody.data]);
|
|
|
|
if (src == null) {
|
|
return null;
|
|
}
|
|
|
|
return <img src={src} alt="Response preview" className="max-w-full max-h-full pb-2" />;
|
|
}
|