import * as React from 'react';
import I18n from 'i18n-js';
import { DangerText, SmallMutedText, SuccessText } from '../common/CustomTexts';
import Button from '../common/Button';
import CopyToClipboardButton from '../common/CopyToClipboardButton';
import buildRequestHeaders from '../../helpers/buildRequestHeaders';
import HttpStatus from '../../constants/http_status';
import ActionLink from '../common/ActionLink';
import { LearnMoreIcon } from '../common/Icons';
interface Props {
currentApiKey?: string;
generateApiKeyEndpoint: string;
authenticityToken: string;
}
const GenerateApiKeyDialog = ({
currentApiKey,
generateApiKeyEndpoint,
authenticityToken,
}: Props) => {
const [hasBeenGenerated, setHasBeenGenerated] = React.useState(false);
const [apiKey, setApiKey] = React.useState('');
const [error, setError] = React.useState('');
return (
<>
{I18n.t('common.forms.api_key.title')}
{
(currentApiKey && !hasBeenGenerated) &&
<>
{I18n.t('common.forms.api_key.current_api_key_help')}
>
}
{
hasBeenGenerated ?
<>
{I18n.t('common.forms.api_key.generated_api_key_help')}
{I18n.t('common.forms.api_key.generated_api_key_successfully')}
>
:
<>
>
}
}
onClick={() => window.open('https://docs.astuto.io/api', '_blank')}
>
{I18n.t('common.forms.api_key.api_key_learn_more')}
{ error && {error} }
>
);
};
export default GenerateApiKeyDialog;