import PropTypes from 'prop-types'; import React, { useCallback } from 'react'; import { PageContainerFooter } from '../../../../components/ui/page-container'; import { useI18nContext } from '../../../../hooks/useI18nContext'; import Box from '../../../../components/ui/box/box'; import { AlignItems, BLOCK_SIZES, BorderStyle, FLEX_DIRECTION, FONT_WEIGHT, JustifyContent, TextVariant, TEXT_ALIGN, } from '../../../../helpers/constants/design-system'; import { Text } from '../../../../components/component-library'; import PulseLoader from '../../../../components/ui/pulse-loader/pulse-loader'; import InstallError from '../../../../components/app/flask/install-error/install-error'; import SnapAuthorship from '../../../../components/app/flask/snap-authorship'; import { getSnapName } from '../../../../helpers/utils/util'; export default function SnapResult({ request, requestState, approveSnapResult, targetSubjectMetadata, }) { const t = useI18nContext(); const onSubmit = useCallback( () => approveSnapResult(request.metadata.id), [request, approveSnapResult], ); const hasError = !requestState.loading && requestState.error; const isLoading = requestState.loading; const snapName = getSnapName(targetSubjectMetadata.origin); return ( {isLoading && ( )} {!isLoading && !hasError && ( {t('snapResultSuccess')} {t('snapResultSuccessDescription', [{snapName}])} )} {hasError && ( )} ); } SnapResult.propTypes = { request: PropTypes.object.isRequired, requestState: PropTypes.object.isRequired, approveSnapResult: PropTypes.func.isRequired, targetSubjectMetadata: PropTypes.shape({ iconUrl: PropTypes.string, name: PropTypes.string, origin: PropTypes.string.isRequired, sourceCode: PropTypes.string, version: PropTypes.string, }).isRequired, };