@@ -4,19 +4,26 @@ import {
44 RateLimitColumn ,
55} from './components/rate-limit-columns' ;
66import { useRateLimits } from './hooks/use-rate-limits' ;
7+ import { RateLimitWithMetadata } from './hooks/use-rate-limits' ;
78import { DocsButton } from '@/components/v1/docs/docs-button' ;
89import { DataTable } from '@/components/v1/molecules/data-table/data-table' ;
910import { ToolbarType } from '@/components/v1/molecules/data-table/data-table-toolbar' ;
11+ import { useCurrentTenantId } from '@/hooks/use-tenant' ;
12+ import api from '@/lib/api' ;
1013import { docsPages } from '@/lib/generated/docs' ;
14+ import { useApiError } from '@/lib/hooks' ;
15+ import { useMutation } from '@tanstack/react-query' ;
1116import { VisibilityState } from '@tanstack/react-table' ;
12- import { useState } from 'react' ;
17+ import { useMemo , useState } from 'react' ;
1318
1419export default function RateLimits ( ) {
1520 return < RateLimitsTable /> ;
1621}
1722
1823function RateLimitsTable ( ) {
1924 const [ columnVisibility , setColumnVisibility ] = useState < VisibilityState > ( { } ) ;
25+ const { tenantId } = useCurrentTenantId ( ) ;
26+ const { handleApiError } = useApiError ( { } ) ;
2027
2128 const {
2229 data,
@@ -33,11 +40,25 @@ function RateLimitsTable() {
3340 resetFilters,
3441 } = useRateLimits ( { key : 'rate-limits-table' } ) ;
3542
43+ const deleteMutation = useMutation ( {
44+ mutationKey : [ 'rate-limit:delete' , tenantId ] ,
45+ mutationFn : async ( row : RateLimitWithMetadata ) => {
46+ await api . rateLimitDelete ( tenantId , { key : row . key } ) ;
47+ } ,
48+ onSuccess : ( ) => refetch ( ) ,
49+ onError : handleApiError ,
50+ } ) ;
51+
52+ const tableColumns = useMemo (
53+ ( ) => columns ( { onDeleteClick : ( row ) => deleteMutation . mutate ( row ) } ) ,
54+ [ deleteMutation ] ,
55+ ) ;
56+
3657 return (
3758 < DataTable
3859 error = { error }
3960 isLoading = { isLoading }
40- columns = { columns }
61+ columns = { tableColumns }
4162 data = { data }
4263 filters = { [
4364 {
0 commit comments