Files
twenty_crm/front/src/modules/workspace/components/WorkspaceInviteLink.tsx
Charles Bochet ade5e52e55 Clean and re-organize post table refactoring (#1000)
* Clean and re-organize post table refactoring

* Fix tests
2023-07-30 18:26:32 -07:00

50 lines
1.3 KiB
TypeScript

import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { Button, ButtonVariant } from '@/ui/button/components/Button';
import { IconCopy, IconLink } from '@/ui/icon';
import { TextInput } from '@/ui/input/text/components/TextInput';
import { useSnackBar } from '@/ui/snack-bar/hooks/useSnackBar';
const StyledContainer = styled.div`
align-items: center;
display: flex;
flex-direction: row;
`;
const StyledLinkContainer = styled.div`
flex: 1;
margin-right: ${({ theme }) => theme.spacing(2)};
`;
type OwnProps = {
inviteLink: string;
};
export function WorkspaceInviteLink({ inviteLink }: OwnProps) {
const theme = useTheme();
const { enqueueSnackBar } = useSnackBar();
return (
<StyledContainer>
<StyledLinkContainer>
<TextInput value={inviteLink} disabled fullWidth />
</StyledLinkContainer>
<Button
icon={<IconLink size={theme.icon.size.md} />}
variant={ButtonVariant.Primary}
title="Copy link"
onClick={() => {
enqueueSnackBar('Link copied to clipboard', {
variant: 'success',
icon: <IconCopy size={theme.icon.size.md} />,
duration: 2000,
});
navigator.clipboard.writeText(inviteLink);
}}
/>
</StyledContainer>
);
}