mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-28 00:06:53 +01:00
Merge pull request #633 from Unleash/update/remove-snackbar
fix: remove snackbar from addUser
This commit is contained in:
commit
c09efc39dc
@ -1,35 +1,22 @@
|
|||||||
import { useState } from 'react';
|
|
||||||
import { IconButton } from '@material-ui/core';
|
import { IconButton } from '@material-ui/core';
|
||||||
import CopyIcon from '@material-ui/icons/FileCopy';
|
import CopyIcon from '@material-ui/icons/FileCopy';
|
||||||
import { Snackbar } from '@material-ui/core';
|
import useToast from '../../../../../../hooks/useToast';
|
||||||
import { Alert } from '@material-ui/lab';
|
|
||||||
|
|
||||||
interface IInviteLinkProps {
|
interface IInviteLinkProps {
|
||||||
inviteLink: string;
|
inviteLink: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ISnackbar {
|
|
||||||
show: boolean;
|
|
||||||
type: 'success' | 'error';
|
|
||||||
text: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const UserInviteLink = ({ inviteLink }: IInviteLinkProps) => {
|
const UserInviteLink = ({ inviteLink }: IInviteLinkProps) => {
|
||||||
const [snackbar, setSnackbar] = useState<ISnackbar>({
|
const { setToastData } = useToast();
|
||||||
show: false,
|
|
||||||
type: 'success',
|
|
||||||
text: '',
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleCopy = () => {
|
const handleCopy = () => {
|
||||||
try {
|
try {
|
||||||
return navigator.clipboard
|
return navigator.clipboard
|
||||||
.writeText(inviteLink)
|
.writeText(inviteLink)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setSnackbar({
|
setToastData({
|
||||||
show: true,
|
|
||||||
type: 'success',
|
type: 'success',
|
||||||
text: 'Successfully copied invite link.',
|
title: 'Successfully copied invite link.',
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@ -41,10 +28,9 @@ const UserInviteLink = ({ inviteLink }: IInviteLinkProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const setError = () =>
|
const setError = () =>
|
||||||
setSnackbar({
|
setToastData({
|
||||||
show: true,
|
|
||||||
type: 'error',
|
type: 'error',
|
||||||
text: 'Could not copy invite link.',
|
title: 'Could not copy invite link.',
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -64,15 +50,6 @@ const UserInviteLink = ({ inviteLink }: IInviteLinkProps) => {
|
|||||||
<IconButton onClick={handleCopy}>
|
<IconButton onClick={handleCopy}>
|
||||||
<CopyIcon />
|
<CopyIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<Snackbar
|
|
||||||
open={snackbar.show}
|
|
||||||
autoHideDuration={6000}
|
|
||||||
onClose={() =>
|
|
||||||
setSnackbar({ show: false, type: 'success', text: '' })
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Alert severity={snackbar.type}>{snackbar.text}</Alert>
|
|
||||||
</Snackbar>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user