Skip to content

Commit

Permalink
edited the function for error
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucifer4255 committed Dec 13, 2024
1 parent c30e720 commit 8dd7e41
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const PhonesDisplay = ({ value, isFocused }: PhonesDisplayProps) => {
event.preventDefault(); // Prevent default link behavior

try {
if(phoneNumber != undefined){
if(phoneNumber !== undefined){
await navigator.clipboard.writeText(phoneNumber);
enqueueSnackBar('Phone number copied to clipboard', {
variant: SnackBarVariant.Success,
Expand All @@ -50,7 +50,11 @@ export const PhonesDisplay = ({ value, isFocused }: PhonesDisplayProps) => {
});
}
} catch (error) {
console.error('Failed to copy phone number:', error);
enqueueSnackBar('Error copying to clipboard', {
variant: SnackBarVariant.Error,
icon: <IconClipboard size={16} />,
duration: 2000
});
}
};
const phones = useMemo(
Expand Down Expand Up @@ -99,7 +103,7 @@ export const PhonesDisplay = ({ value, isFocused }: PhonesDisplayProps) => {
label={
parsedPhone ? parsedPhone.formatInternational() : invalidPhone
}
onClick={(event) => handlePhoneClick(event,URI)}
onClick={(event) => handlePhoneClick(event,parsedPhone?.formatInternational())}
/>
);
})}
Expand Down

0 comments on commit 8dd7e41

Please sign in to comment.