@@ -9,6 +9,7 @@ import Tooltip from '@mui/material/Tooltip';
99import { NumberField } from '../common/NumberField' ;
1010import { DialogContentText , Typography } from '@mui/material' ;
1111import { copyToClipboard } from '../clipboard' ;
12+ import { useStores } from '../stores' ;
1213
1314interface IProps {
1415 fClose : VoidFunction ;
@@ -19,7 +20,7 @@ const AddClientDialog = ({fClose, fOnSubmit}: IProps) => {
1920 const [ returnToken , setReturnToken ] = useState ( '' ) ;
2021 const [ name , setName ] = useState ( '' ) ;
2122 const [ expiresAfter , setExpiresAfter ] = useState ( 0 ) ;
22-
23+ const { snackManager } = useStores ( ) ;
2324 const submitEnabled = name . length !== 0 ;
2425 const submitAndNext = async ( ) => {
2526 const token = await fOnSubmit ( name , Math . max ( 0 , expiresAfter ) ) ;
@@ -72,7 +73,15 @@ const AddClientDialog = ({fClose, fOnSubmit}: IProps) => {
7273 </ DialogContent >
7374 < DialogActions >
7475 { returnToken ? (
75- < Button onClick = { ( ) => copyToClipboard ( returnToken ) } > Copy to clipboard</ Button >
76+ < Button
77+ onClick = { ( ) =>
78+ copyToClipboard ( returnToken ) . then (
79+ ( ) => snackManager . snack ( 'Copied to clipboard' ) ,
80+ ( ) => snackManager . snack ( 'Cannot access clipboard.' )
81+ )
82+ } >
83+ Copy to clipboard
84+ </ Button >
7685 ) : (
7786 < Button onClick = { fClose } > Cancel</ Button >
7887 ) }
0 commit comments