2020-05-13 23:58:36 +02:00
|
|
|
// This component is a work in progress
|
|
|
|
|
// It's made to be used when the users API is ready
|
2020-05-13 19:44:22 +02:00
|
|
|
import React from 'react';
|
2020-05-18 10:06:00 +02:00
|
|
|
import { Flex, Text } from '@buffetjs/core';
|
|
|
|
|
import { Duplicate } from '@buffetjs/icons';
|
|
|
|
|
import { useIntl } from 'react-intl';
|
2020-05-13 19:44:22 +02:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
2020-05-19 06:55:06 +02:00
|
|
|
import basename from '../../../utils/basename';
|
2020-05-18 10:06:00 +02:00
|
|
|
import IconWrapper from './IconWrapper';
|
2020-05-13 19:44:22 +02:00
|
|
|
import Envelope from './Envelope';
|
2020-05-18 10:06:00 +02:00
|
|
|
import Wrapper from './Wrapper';
|
2020-05-13 19:44:22 +02:00
|
|
|
|
2020-05-19 06:55:06 +02:00
|
|
|
const MagicLink = ({ registrationToken }) => {
|
2020-05-18 10:06:00 +02:00
|
|
|
const { formatMessage } = useIntl();
|
2020-05-13 19:44:22 +02:00
|
|
|
const handleCopy = () => {
|
|
|
|
|
strapi.notification.info('notification.link-copied');
|
|
|
|
|
};
|
|
|
|
|
|
2020-05-19 06:55:06 +02:00
|
|
|
const link = `${window.location.origin}${basename}auth/register?code=${registrationToken}`;
|
|
|
|
|
|
2020-05-13 19:44:22 +02:00
|
|
|
return (
|
|
|
|
|
<Wrapper>
|
2020-05-18 10:06:00 +02:00
|
|
|
<IconWrapper>
|
2020-05-13 19:44:22 +02:00
|
|
|
<Envelope />
|
2020-05-18 10:06:00 +02:00
|
|
|
</IconWrapper>
|
|
|
|
|
<Flex flexDirection="column" justifyContent="center">
|
2020-05-13 19:44:22 +02:00
|
|
|
<Text fontWeight="semiBold" color="black" fontSize="md" lineHeight="18px">
|
|
|
|
|
{link}
|
|
|
|
|
<CopyToClipboard onCopy={handleCopy} text={link}>
|
|
|
|
|
<Duplicate fill="#8B91A0" className="icon-duplicate" />
|
|
|
|
|
</CopyToClipboard>
|
|
|
|
|
</Text>
|
|
|
|
|
<Text fontWeight="regular" color="grey" fontSize="sm" lineHeight="18px">
|
2020-05-18 10:06:00 +02:00
|
|
|
{formatMessage({ id: 'app.components.Users.MagicLink.connect' })}
|
2020-05-13 19:44:22 +02:00
|
|
|
</Text>
|
2020-05-18 10:06:00 +02:00
|
|
|
</Flex>
|
2020-05-13 19:44:22 +02:00
|
|
|
</Wrapper>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
MagicLink.defaultProps = {
|
2020-05-19 06:55:06 +02:00
|
|
|
registrationToken: '',
|
2020-05-13 19:44:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
MagicLink.propTypes = {
|
2020-05-19 06:55:06 +02:00
|
|
|
registrationToken: PropTypes.string,
|
2020-05-13 19:44:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default MagicLink;
|