bigbuffet-rw/app/soapbox/features/ui/components/panels/new-group-panel.tsx
marcin mikołajczak 0879222aa2 Improve permissions check
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2022-12-19 14:10:13 +01:00

44 lines
1.3 KiB
TypeScript

import React from 'react';
import { FormattedMessage } from 'react-intl';
import { openModal } from 'soapbox/actions/modals';
import { Button, Stack, Text } from 'soapbox/components/ui';
import { useAppDispatch, useAppSelector } from 'soapbox/hooks';
import { PERMISSION_CREATE_GROUPS, hasPermission } from 'soapbox/utils/permissions';
const NewGroupPanel = () => {
const dispatch = useAppDispatch();
const canCreateGroup = useAppSelector((state) => hasPermission(state, PERMISSION_CREATE_GROUPS));
const createGroup = () => {
dispatch(openModal('MANAGE_GROUP'));
};
if (!canCreateGroup) return null;
return (
<Stack space={2}>
<Stack>
<Text size='lg' weight='bold'>
<FormattedMessage id='new_group_panel.title' defaultMessage='Create New Group' />
</Text>
<Text theme='muted' size='sm'>
<FormattedMessage id='new_group_panel.subtitle' defaultMessage="Can't find what you're looking for? Start your own private or public group." />
</Text>
</Stack>
<Button
icon={require('@tabler/icons/circles.svg')}
onClick={createGroup}
theme='secondary'
block
>
<FormattedMessage id='new_group_panel.action' defaultMessage='Create group' />
</Button>
</Stack>
);
};
export default NewGroupPanel;