refresh button

This commit is contained in:
Pallavi Kumari
2025-10-05 12:30:01 +05:30
parent b1e212721e
commit cd27f6459c
2 changed files with 27 additions and 1 deletions

View File

@@ -8,12 +8,16 @@ interface DataTableProps<TData, TValue> {
columns: ColumnDef<TData, TValue>[];
data: TData[];
addApiKey?: () => void;
onRefresh?: () => void;
isRefreshing?: boolean;
}
export function OrgApiKeysDataTable<TData, TValue>({
addApiKey,
columns,
data
data,
onRefresh,
isRefreshing
}: DataTableProps<TData, TValue>) {
const t = useTranslations();
@@ -27,6 +31,8 @@ export function OrgApiKeysDataTable<TData, TValue>({
searchPlaceholder={t('searchApiKeys')}
searchColumn="name"
onAdd={addApiKey}
onRefresh={onRefresh}
isRefreshing={isRefreshing}
addButtonText={t('apiKeysAdd')}
/>
);

View File

@@ -46,6 +46,24 @@ export default function OrgApiKeysTable({
const api = createApiClient(useEnvContext());
const t = useTranslations();
const [isRefreshing, setIsRefreshing] = useState(false);
const refreshData = async () => {
console.log("Data refreshed");
setIsRefreshing(true);
try {
await new Promise((resolve) => setTimeout(resolve, 200));
router.refresh();
} catch (error) {
toast({
title: t("error"),
description: t("refreshError"),
variant: "destructive"
});
} finally {
setIsRefreshing(false);
}
};
const deleteSite = (apiKeyId: string) => {
api.delete(`/org/${orgId}/api-key/${apiKeyId}`)
@@ -195,6 +213,8 @@ export default function OrgApiKeysTable({
addApiKey={() => {
router.push(`/${orgId}/settings/api-keys/create`);
}}
onRefresh={refreshData}
isRefreshing={isRefreshing}
/>
</>
);