53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { useTheme } from '@emotion/react';
|
|
import styled from '@emotion/styled';
|
|
import { IconCopy, IconLink } from 'twenty-ui';
|
|
|
|
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
|
import { Button } from '@/ui/input/button/components/Button';
|
|
import { TextInput } from '@/ui/input/components/TextInput';
|
|
|
|
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 WorkspaceInviteLinkProps = {
|
|
inviteLink: string;
|
|
};
|
|
|
|
export const WorkspaceInviteLink = ({
|
|
inviteLink,
|
|
}: WorkspaceInviteLinkProps) => {
|
|
const theme = useTheme();
|
|
|
|
const { enqueueSnackBar } = useSnackBar();
|
|
|
|
return (
|
|
<StyledContainer>
|
|
<StyledLinkContainer>
|
|
<TextInput value={inviteLink} disabled fullWidth />
|
|
</StyledLinkContainer>
|
|
<Button
|
|
Icon={IconLink}
|
|
variant="primary"
|
|
accent="blue"
|
|
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>
|
|
);
|
|
};
|