Files
twenty/packages/twenty-front/src/modules/workspace/components/WorkspaceInviteLink.tsx
T
Nabhag Motivaras 316f2ec38c refactor: to useCopyToClipboard to catch errors - when user has disable copy clipboard permission in browser (#13330)
as discussed here
https://github.com/twentyhq/twenty/issues/13292#issuecomment-3092215050
with @prastoin

- [x] introduce optional message param to `copyToClipboard` method in
`useCopyToClipboard` and refactor it across app, as in case if user has
disallowed clipboard permission in BROWSER unprotected clipboard access
breaks without catch.

- [x] Email copied to clipboard

- [x] run lingui extract
2025-07-30 11:13:55 +02:00

53 lines
1.2 KiB
TypeScript

import styled from '@emotion/styled';
import { TextInput } from '@/ui/input/components/TextInput';
import { useLingui } from '@lingui/react/macro';
import { IconLink } from 'twenty-ui/display';
import { Button } from 'twenty-ui/input';
import { useCopyToClipboard } from '~/hooks/useCopyToClipboard';
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 { t } = useLingui();
const { copyToClipboard } = useCopyToClipboard();
return (
<StyledContainer data-chromatic="ignore">
<StyledLinkContainer>
<TextInput
instanceId="workspace-invite-link"
value={inviteLink}
disabled
fullWidth
/>
</StyledLinkContainer>
<Button
Icon={IconLink}
variant="primary"
accent="blue"
title={t`Copy link`}
onClick={() => {
copyToClipboard(inviteLink, t`Link copied to clipboard`);
}}
/>
</StyledContainer>
);
};