-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated the phonedisplay adding a prop
- Loading branch information
1 parent
2ceb1c8
commit 0ff225c
Showing
2 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
32 changes: 31 additions & 1 deletion
32
...c/modules/object-record/record-field/meta-types/display/components/PhonesFieldDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,41 @@ | ||
import { useFieldFocus } from '@/object-record/record-field/hooks/useFieldFocus'; | ||
import { usePhonesFieldDisplay } from '@/object-record/record-field/meta-types/hooks/usePhonesFieldDisplay'; | ||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar'; | ||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar'; | ||
import { PhonesDisplay } from '@/ui/field/display/components/PhonesDisplay'; | ||
import React from 'react'; | ||
import { useIcons } from 'twenty-ui'; | ||
|
||
export const PhonesFieldDisplay = () => { | ||
const { fieldValue } = usePhonesFieldDisplay(); | ||
|
||
const { isFocused } = useFieldFocus(); | ||
|
||
return <PhonesDisplay value={fieldValue} isFocused={isFocused} />; | ||
const {enqueueSnackBar} = useSnackBar(); | ||
|
||
const {getIcon} = useIcons(); | ||
|
||
const IconClipboard = getIcon('IconClipboard'); | ||
|
||
const handleClick = async(phoneNumber:string,event: React.MouseEvent<HTMLElement>) =>{ | ||
event.preventDefault(); | ||
try{ | ||
await navigator.clipboard.writeText(phoneNumber); | ||
enqueueSnackBar('Phone number copied to clipboard', { | ||
variant: SnackBarVariant.Success, | ||
icon: <IconClipboard size={16} />, | ||
duration: 2000 | ||
}); | ||
}catch(err){ | ||
enqueueSnackBar('Error copying to clipboard', { | ||
variant: SnackBarVariant.Error, | ||
icon: <IconClipboard size={16} />, | ||
duration: 2000 | ||
}); | ||
} | ||
|
||
|
||
} | ||
|
||
return <PhonesDisplay value={fieldValue} isFocused={isFocused} onPhoneNumberClick={handleClick}/>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters