import { useEffect, useState } from 'react'; import { Link, useSearchParams } from 'react-router-dom'; // @ts-ignore import { Button, Table } from '@carbon/react'; import { MdDelete } from 'react-icons/md'; import PaginationForTable from '../components/PaginationForTable'; import HttpService from '../services/HttpService'; import { getPageInfoFromSearchParams } from '../helpers'; export default function SecretList() { const [searchParams] = useSearchParams(); const [secrets, setSecrets] = useState([]); const [pagination, setPagination] = useState(null); useEffect(() => { const setSecretsFromResult = (result: any) => { setSecrets(result.results); setPagination(result.pagination); }; const { page, perPage } = getPageInfoFromSearchParams(searchParams); HttpService.makeCallToBackend({ path: `/secrets?per_page=${perPage}&page=${page}`, successCallback: setSecretsFromResult, }); }, [searchParams]); const reloadSecrets = (_result: any) => { window.location.reload(); }; const handleDeleteSecret = (key: any) => { HttpService.makeCallToBackend({ path: `/secrets/${key}`, successCallback: reloadSecrets, httpMethod: 'DELETE', }); }; const buildTable = () => { const rows = secrets.map((row) => { return (
ID | Secret Key | Creator | Delete |
---|
No Secrets to Display
; } return displayText; }; if (pagination) { return (