import { useEffect, useState } from 'react'; import { useParams, useNavigate } from 'react-router-dom'; // @ts-ignore import { Stack, Table, Button } from '@carbon/react'; import HttpService from '../services/HttpService'; import { Secret } from '../interfaces'; import ButtonWithConfirmation from '../components/ButtonWithConfirmation'; export default function SecretShow() { const navigate = useNavigate(); const params = useParams(); const [secret, setSecret] = useState(null); const [secretValue, setSecretValue] = useState(secret?.value); useEffect(() => { HttpService.makeCallToBackend({ path: `/secrets/${params.key}`, successCallback: setSecret, }); }, [params]); const handleSecretValueChange = (event: any) => { if (secret) { setSecretValue(event.target.value); } }; const updateSecretValue = () => { if (secret && secretValue) { secret.value = secretValue; HttpService.makeCallToBackend({ path: `/secrets/${secret.key}`, successCallback: () => { setSecret(secret); }, httpMethod: 'PUT', postBody: { value: secretValue, creator_user_id: secret.creator_user_id, }, }); } }; const navigateToSecrets = (_result: any) => { navigate(`/admin/configuration/secrets`); }; const deleteSecret = () => { if (secret === null) { return; } HttpService.makeCallToBackend({ path: `/secrets/${secret.key}`, successCallback: navigateToSecrets, httpMethod: 'DELETE', }); }; if (secret) { return ( <>

Secret Key: {secret.key}

Key Value
{params.key}
); } return null; }