import React from 'react';
import {
Alert,
Spinner,
Content,
ContentVariants,
} from '@patternfly/react-core';
import { Button, Popover } from '@patternfly/react-core';
import { HelpIcon } from '@patternfly/react-icons';
import { Table, Tbody, Td, Th, Thead, Tr } from '@patternfly/react-table';
import { useAppSelector } from '../../../../store/hooks';
import { useShowActivationKeyQuery } from '../../../../store/rhsmApi';
import { selectActivationKey } from '../../../../store/wizardSlice';
const ActivationKeyInformation = (): JSX.Element => {
const activationKey = useAppSelector(selectActivationKey);
const {
data: activationKeyInfo,
isFetching: isFetchingActivationKeyInfo,
isSuccess: isSuccessActivationKeyInfo,
isError: isErrorActivationKeyInfo,
} = useShowActivationKeyQuery(
{ name: activationKey! },
{
skip: !activationKey,
}
);
return (
<>
{isFetchingActivationKeyInfo && }
{isSuccessActivationKeyInfo && (
Name:
{activationKey}
Role:
{activationKeyInfo?.body?.role || 'Not defined'}
SLA:
{activationKeyInfo?.body?.serviceLevel || 'Not defined'}
Usage:
{activationKeyInfo?.body?.usage || 'Not defined'}
Additional repositories:
The core repositories for your operating system version
are always enabled and do not need to be explicitly added
to the activation key.
}
>
}
variant="plain"
aria-label="About additional repositories"
className="pf-v6-u-pl-sm pf-v6-u-pt-0 pf-v6-u-pb-0"
/>
{activationKeyInfo?.body?.additionalRepositories &&
activationKeyInfo?.body?.additionalRepositories?.length > 0 ? (
Additional repositories
Name
{activationKeyInfo.body?.additionalRepositories?.map(
(repo, index) => (
{repo.repositoryLabel}
)
)}
}
>
{activationKeyInfo.body?.additionalRepositories?.length}{' '}
repositories
) : (
'None'
)}
)}
{isErrorActivationKeyInfo && (
Name:
{activationKey}
Information about the activation key cannot be loaded. Please check
the key was not removed and try again later.
)}
>
);
};
export default ActivationKeyInformation;