feat(frontend): Webhook-Verwaltung fuer Administratoren (Modul 28)
/settings/webhooks: Liste, Anlage-Dialog mit Ereignis-Auswahl und einmaliger Secret-Anzeige (Kopieren), Loeschen. Sidebar-Eintrag unter Verwaltung. Live in Chrome verifiziert (Anlegen/Kopieren/Loeschen, SSRF-Ablehnung, Mobile-Breakpoint); dabei einen Reset-Bug im Anlage-Dialog gefunden und behoben (Fertig-Button loeschte den Dialogzustand nicht, da onOpenChange bei programmatischem Schliessen nicht feuert).
This commit is contained in:
1 parent
79010a926b
commit
e4d5af5fa7
6 files changed
+334
-2
No files matched your search
@@ -0,0 +1,17 @@
|
||||
import { apiFetch } from "@/lib/auth/api-client";
|
||||
import { CreateWebhookInput, WebhookSubscription, WebhookSubscriptionWithSecret } from "./types";
|
||||
|
||||
export function fetchWebhooks(): Promise<WebhookSubscription[]> {
|
||||
return apiFetch<WebhookSubscription[]>("/webhooks");
|
||||
}
|
||||
|
||||
export function createWebhook(input: CreateWebhookInput): Promise<WebhookSubscriptionWithSecret> {
|
||||
return apiFetch<WebhookSubscriptionWithSecret>("/webhooks", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
}
|
||||
|
||||
export function deleteWebhook(id: string): Promise<void> {
|
||||
return apiFetch<void>(`/webhooks/${id}`, { method: "DELETE" });
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
export const WEBHOOK_EVENTS = [
|
||||
"colony.created",
|
||||
"inspection.created",
|
||||
"queen.created",
|
||||
"queen.replaced",
|
||||
"harvest.created",
|
||||
"batch.created",
|
||||
"batch.updated",
|
||||
"product.stock_changed",
|
||||
"task.created",
|
||||
"task.completed",
|
||||
] as const;
|
||||
|
||||
export type WebhookEvent = (typeof WEBHOOK_EVENTS)[number];
|
||||
|
||||
export interface WebhookSubscription {
|
||||
id: string;
|
||||
url: string;
|
||||
events: WebhookEvent[];
|
||||
active: boolean;
|
||||
createdByUserId: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface WebhookSubscriptionWithSecret extends WebhookSubscription {
|
||||
secret: string;
|
||||
}
|
||||
|
||||
export interface CreateWebhookInput {
|
||||
url: string;
|
||||
events: WebhookEvent[];
|
||||
}
|
||||
Reference in new issue
Block a user