From 88403b6ba9ae2afecb5f0fba1dcc82c5dc5692b1 Mon Sep 17 00:00:00 2001 From: Mayank Bucha Date: Sun, 12 Jun 2022 17:51:38 +0530 Subject: [PATCH] fix: grower tooltip jumping for errors (#678) * fix: grower tooltip * removed error styles --- src/components/Growers/GrowerTooltip.js | 64 +++++++++++-------------- 1 file changed, 27 insertions(+), 37 deletions(-) diff --git a/src/components/Growers/GrowerTooltip.js b/src/components/Growers/GrowerTooltip.js index 05042d7e0..c75cc3de6 100644 --- a/src/components/Growers/GrowerTooltip.js +++ b/src/components/Growers/GrowerTooltip.js @@ -1,10 +1,5 @@ import React from 'react'; -import { - Box, - Card, - CardActionArea, - Divider, -} from '@material-ui/core'; +import { Box, Card, CardActionArea, Divider } from '@material-ui/core'; import { makeStyles } from '@material-ui/core/styles'; import Typography from '@material-ui/core/Typography'; import EmailIcon from '@material-ui/icons/EmailOutlined'; @@ -16,7 +11,8 @@ import OptimizedImage from '../OptimizedImage'; import { useStyle } from './Growers.styles.js'; const GrowerTooltip = ({ grower, growerClick }) => { - const classes = useStyle(); + const classes = useStyle(); + const matches = grower.imageUrl?.match(/\/\/(.*?)\/(.*)/); const useStyles = makeStyles(() => ({ box: { display: 'flex', @@ -24,7 +20,7 @@ const GrowerTooltip = ({ grower, growerClick }) => { }, label: { marginLeft: '12px', - }, + } })); const growerToolTipStyles = useStyles(); @@ -51,30 +47,28 @@ const GrowerTooltip = ({ grower, growerClick }) => { margin: '2px', }} > - {grower.imageUrl && ( + {matches?.length > 1 ? ( - )} - {!grower.imageUrl && ( - - )} + )} - + {grower.firstName} {grower.lastName} @@ -97,9 +91,7 @@ const GrowerTooltip = ({ grower, growerClick }) => { {grower.email && ( - + {grower.email} @@ -107,21 +99,19 @@ const GrowerTooltip = ({ grower, growerClick }) => { {(grower.organizaton || grower.organizationId) && ( - - - + + + )} {grower.phone && ( - - + + {grower.phone}