2023-03-08 11:43:16 -08:00
|
|
|
|
import React from 'react';
|
2023-04-19 13:51:07 -07:00
|
|
|
|
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
|
2023-03-08 10:20:20 -08:00
|
|
|
|
|
2023-03-08 12:46:24 -08:00
|
|
|
|
import { Avatar, Divider, HStack, Stack, Text, Button } from 'soapbox/components/ui';
|
2023-04-19 13:51:07 -07:00
|
|
|
|
import toast from 'soapbox/toast';
|
2023-04-19 13:44:22 -07:00
|
|
|
|
import copy from 'soapbox/utils/copy';
|
2023-03-08 10:20:20 -08:00
|
|
|
|
|
2023-03-30 12:19:14 -07:00
|
|
|
|
import type { Group } from 'soapbox/schemas';
|
|
|
|
|
|
2023-03-08 11:43:16 -08:00
|
|
|
|
interface IConfirmationStep {
|
2023-04-25 07:03:21 -07:00
|
|
|
|
group: Group | null
|
2023-03-08 10:20:20 -08:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-19 13:51:07 -07:00
|
|
|
|
const messages = defineMessages({
|
|
|
|
|
copied: { id: 'copy.success', defaultMessage: 'Copied to clipboard!' },
|
|
|
|
|
});
|
|
|
|
|
|
2023-03-08 11:43:16 -08:00
|
|
|
|
const ConfirmationStep: React.FC<IConfirmationStep> = ({ group }) => {
|
2023-04-19 13:51:07 -07:00
|
|
|
|
const intl = useIntl();
|
|
|
|
|
|
|
|
|
|
const handleCopyLink = () => {
|
2023-05-03 11:03:13 -07:00
|
|
|
|
copy(group?.url as string, () => {
|
2023-04-19 13:51:07 -07:00
|
|
|
|
toast.success(intl.formatMessage(messages.copied));
|
|
|
|
|
});
|
|
|
|
|
};
|
2023-03-08 12:46:24 -08:00
|
|
|
|
|
|
|
|
|
const handleShare = () => {
|
|
|
|
|
navigator.share({
|
2023-04-25 07:03:21 -07:00
|
|
|
|
text: group?.display_name,
|
|
|
|
|
url: group?.uri,
|
2023-03-08 12:46:24 -08:00
|
|
|
|
}).catch((e) => {
|
|
|
|
|
if (e.name !== 'AbortError') console.error(e);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2023-04-25 07:03:21 -07:00
|
|
|
|
if (!group) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-08 10:20:20 -08:00
|
|
|
|
return (
|
2023-03-08 11:43:16 -08:00
|
|
|
|
<Stack space={9}>
|
|
|
|
|
<Stack space={3}>
|
|
|
|
|
<Stack>
|
|
|
|
|
<label
|
|
|
|
|
className='dark:sm:shadow-inset relative h-24 w-full cursor-pointer overflow-hidden rounded-lg bg-primary-100 text-primary-500 dark:bg-gray-800 dark:text-accent-blue sm:h-36 sm:shadow'
|
|
|
|
|
>
|
|
|
|
|
{group.header && <img className='h-full w-full object-cover' src={group.header} alt='' />}
|
|
|
|
|
</label>
|
|
|
|
|
|
|
|
|
|
<label className='mx-auto -mt-10 cursor-pointer rounded-full bg-primary-500 ring-2 ring-white dark:ring-primary-900'>
|
|
|
|
|
{group.avatar && <Avatar src={group.avatar} size={80} />}
|
|
|
|
|
</label>
|
|
|
|
|
</Stack>
|
|
|
|
|
|
|
|
|
|
<Stack>
|
|
|
|
|
<Text size='2xl' weight='bold' align='center'>{group.display_name}</Text>
|
2023-05-02 10:29:29 -07:00
|
|
|
|
<Text
|
|
|
|
|
size='md'
|
|
|
|
|
className='mx-auto max-w-sm'
|
|
|
|
|
dangerouslySetInnerHTML={{ __html: group.note_emojified }}
|
|
|
|
|
/>
|
2023-03-08 11:43:16 -08:00
|
|
|
|
</Stack>
|
|
|
|
|
</Stack>
|
|
|
|
|
|
|
|
|
|
<Divider />
|
2023-03-08 10:20:20 -08:00
|
|
|
|
|
2023-03-08 12:10:09 -08:00
|
|
|
|
<Stack space={4}>
|
2023-03-08 11:43:16 -08:00
|
|
|
|
<Text size='3xl' weight='bold' align='center'>
|
|
|
|
|
<FormattedMessage id='manage_group.confirmation.title' defaultMessage='You’re all set!' />
|
|
|
|
|
</Text>
|
2023-03-08 12:10:09 -08:00
|
|
|
|
|
|
|
|
|
<Stack space={5}>
|
|
|
|
|
<InfoListItem number={1}>
|
2023-03-30 12:19:14 -07:00
|
|
|
|
<Text theme='muted'>
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
id='manage_group.confirmation.info_1'
|
|
|
|
|
defaultMessage='As the owner of this group, you can assign staff, delete posts and much more.'
|
|
|
|
|
/>
|
|
|
|
|
</Text>
|
2023-03-08 12:10:09 -08:00
|
|
|
|
</InfoListItem>
|
|
|
|
|
|
|
|
|
|
<InfoListItem number={2}>
|
2023-03-30 12:19:14 -07:00
|
|
|
|
<Text theme='muted'>
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
id='manage_group.confirmation.info_2'
|
|
|
|
|
defaultMessage="Post the group's first post and get the conversation started."
|
|
|
|
|
/>
|
|
|
|
|
</Text>
|
2023-03-08 12:10:09 -08:00
|
|
|
|
</InfoListItem>
|
|
|
|
|
|
|
|
|
|
<InfoListItem number={3}>
|
2023-03-30 12:19:14 -07:00
|
|
|
|
<Text theme='muted'>
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
id='manage_group.confirmation.info_3'
|
|
|
|
|
defaultMessage='Share your new group with friends, family and followers to grow its membership.'
|
|
|
|
|
/>
|
|
|
|
|
</Text>
|
2023-03-08 12:10:09 -08:00
|
|
|
|
</InfoListItem>
|
|
|
|
|
</Stack>
|
|
|
|
|
</Stack>
|
2023-03-08 12:46:24 -08:00
|
|
|
|
|
|
|
|
|
<HStack space={2} justifyContent='center'>
|
|
|
|
|
{('share' in navigator) && (
|
|
|
|
|
<Button onClick={handleShare} theme='transparent' icon={require('@tabler/icons/share.svg')} className='text-primary-600'>
|
|
|
|
|
<FormattedMessage id='manage_group.confirmation.share' defaultMessage='Share this group' />
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
|
2023-04-19 13:51:07 -07:00
|
|
|
|
<Button onClick={handleCopyLink} theme='transparent' icon={require('@tabler/icons/link.svg')} className='text-primary-600'>
|
|
|
|
|
<FormattedMessage id='manage_group.confirmation.copy' defaultMessage='Copy link' />
|
|
|
|
|
</Button>
|
2023-03-08 12:46:24 -08:00
|
|
|
|
</HStack>
|
2023-03-08 11:43:16 -08:00
|
|
|
|
</Stack>
|
2023-03-08 10:20:20 -08:00
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2023-03-08 12:10:09 -08:00
|
|
|
|
interface IInfoListNumber {
|
|
|
|
|
number: number
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const InfoListNumber: React.FC<IInfoListNumber> = ({ number }) => {
|
|
|
|
|
return (
|
2023-03-30 12:19:14 -07:00
|
|
|
|
<div className='flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-gray-200 dark:border-gray-800'>
|
2023-03-08 12:10:09 -08:00
|
|
|
|
<Text theme='primary' size='sm' weight='bold'>{number}</Text>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
interface IInfoListItem {
|
|
|
|
|
number: number
|
|
|
|
|
children: React.ReactNode
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const InfoListItem: React.FC<IInfoListItem> = ({ number, children }) => {
|
|
|
|
|
return (
|
2023-03-30 12:19:14 -07:00
|
|
|
|
<HStack alignItems='top' space={3}>
|
|
|
|
|
<InfoListNumber number={number} />
|
|
|
|
|
<div className='mt-0.5'>
|
|
|
|
|
{children}
|
|
|
|
|
</div>
|
2023-03-08 12:10:09 -08:00
|
|
|
|
</HStack>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2023-03-08 10:20:20 -08:00
|
|
|
|
export default ConfirmationStep;
|