Skip to content

Commit 71f594c

Browse files
committed
chore: add callback function to edit webhook button
1 parent 7199274 commit 71f594c

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

Diff for: ui/src/containers/webhooks/columns.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import { DotsVerticalIcon, TrashIcon, UpdateIcon } from "@radix-ui/react-icons";
22
import { ApsaraColumnDef, DropdownMenu, Flex } from "@raystack/apsara";
33
import { V1Beta1Webhook } from "@raystack/frontier";
44

5-
export const getColumns: () => ApsaraColumnDef<V1Beta1Webhook>[] = () => {
5+
interface getColumnsOptions {
6+
openEditPage: (id: string) => void;
7+
}
8+
9+
export const getColumns: (
10+
opt: getColumnsOptions
11+
) => ApsaraColumnDef<V1Beta1Webhook>[] = ({ openEditPage }) => {
612
return [
713
{
814
header: "Description",
@@ -34,7 +40,7 @@ export const getColumns: () => ApsaraColumnDef<V1Beta1Webhook>[] = () => {
3440
{
3541
header: "Action",
3642
accessorKey: "id",
37-
cell: () => (
43+
cell: ({ getValue }) => (
3844
<DropdownMenu style={{ padding: "0 !important" }}>
3945
<DropdownMenu.Trigger asChild style={{ cursor: "pointer" }}>
4046
<DotsVerticalIcon />
@@ -46,12 +52,13 @@ export const getColumns: () => ApsaraColumnDef<V1Beta1Webhook>[] = () => {
4652
style={{ padding: "12px" }}
4753
gap={"small"}
4854
data-test-id="admin-ui-webhook-update-btn"
55+
onClick={() => openEditPage(getValue())}
4956
>
5057
<UpdateIcon />
5158
Update
5259
</Flex>
5360
</DropdownMenu.Item>
54-
<DropdownMenu.Item style={{ padding: 0 }}>
61+
<DropdownMenu.Item style={{ padding: 0 }} disabled>
5562
<Flex
5663
style={{ padding: "12px" }}
5764
gap={"small"}

Diff for: ui/src/containers/webhooks/index.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { useFrontier } from "@raystack/frontier/react";
44
import { useEffect, useState } from "react";
55
import { getColumns } from "./columns";
66
import { WebhooksHeader } from "./header";
7-
import { Outlet } from "react-router-dom";
7+
import { Outlet, useNavigate } from "react-router-dom";
88

99
export default function WebhooksList() {
1010
const tableStyle = { width: "100%" };
11+
const naviagte = useNavigate();
1112
const { client } = useFrontier();
1213
const [webhooks, setWebhooks] = useState<V1Beta1Webhook[]>([]);
1314
const [isLoading, setIsLoading] = useState(false);
@@ -28,7 +29,11 @@ export default function WebhooksList() {
2829
fetchWebhooks();
2930
}, [client]);
3031

31-
const columns = getColumns();
32+
function openEditPage(id: string) {
33+
naviagte(`/webhooks/${id}`);
34+
}
35+
36+
const columns = getColumns({ openEditPage });
3237
return (
3338
<Flex direction="row" style={{ height: "100%", width: "100%" }}>
3439
<DataTable

0 commit comments

Comments
 (0)