mirror of
https://github.com/nicotsx/zerobyte.git
synced 2026-06-02 13:13:43 -04:00
* feat: pre/post backup webhooks * fix(hooks): run post when cancelled * refactor(webhooks): headers as array * refactor: pr feedback * refactor: simplify hooks ceremonies * chore: pr feedbacks * chore: re-gen migration
26 lines
911 B
TypeScript
26 lines
911 B
TypeScript
import { CodeBlock } from "~/client/components/ui/code-block";
|
|
import { Label } from "~/client/components/ui/label";
|
|
|
|
type WebhookRequestPreviewProps = {
|
|
method: string;
|
|
url?: string;
|
|
contentType?: string;
|
|
headers?: string[];
|
|
body: string;
|
|
};
|
|
|
|
export const WebhookRequestPreview = ({ method, url, contentType, headers, body }: WebhookRequestPreviewProps) => {
|
|
const headerLines = [contentType ? `Content-Type: ${contentType}` : undefined, ...(headers ?? [])].filter(Boolean);
|
|
const previewCode = `${method} ${url || "https://api.example.com/webhook"}${headerLines.length > 0 ? `\n${headerLines.join("\n")}` : ""}
|
|
|
|
${body}`;
|
|
|
|
return (
|
|
<div className="space-y-2 pt-4 border-t">
|
|
<Label>Request Preview</Label>
|
|
<CodeBlock code={previewCode} filename="HTTP Request" />
|
|
<p className="text-[0.8rem] text-muted-foreground">This is a preview of the HTTP request that will be sent.</p>
|
|
</div>
|
|
);
|
|
};
|