Skip to content

Commit 8db53ab

Browse files
committed
chore: webhook ui fixes & rbac
1 parent 28a15ab commit 8db53ab

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

apps/client/pages/admin/webhooks.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { toast } from "@/shadcn/hooks/use-toast";
12
import { hasAccess } from "@/shadcn/lib/hasAccess";
23
import { Switch } from "@headlessui/react";
34
import { getCookie } from "cookies-next";
@@ -15,10 +16,6 @@ async function getHooks() {
1516

1617
hasAccess(res);
1718

18-
if (!res.ok) {
19-
throw new Error("Network response was not ok");
20-
}
21-
2219
return res.json(); // Return the parsed JSON response
2320
}
2421

@@ -53,7 +50,16 @@ export default function Notifications() {
5350
})
5451
.then((res) => res.json())
5552
.then((res) => {
56-
refetch();
53+
if (res.success) {
54+
refetch();
55+
setShow("main");
56+
} else {
57+
toast({
58+
variant: "destructive",
59+
title: "Error -> Unable to add",
60+
description: res.message,
61+
});
62+
}
5763
});
5864
}
5965

@@ -161,7 +167,7 @@ export default function Notifications() {
161167
You currently have no web hooks added
162168
</p>
163169
)}
164-
</div>P
170+
</div>
165171
</>
166172
)}
167173
</div>
@@ -263,7 +269,6 @@ export default function Notifications() {
263269
<button
264270
onClick={() => {
265271
addHook();
266-
setShow("main");
267272
}}
268273
type="button"
269274
className="mt-8 inline-flex items-center px-3 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500"

0 commit comments

Comments
 (0)