Skip to content

Commit

Permalink
fix: display issues with icons, columns, and edit form
Browse files Browse the repository at this point in the history
  • Loading branch information
gwynndp committed Jun 20, 2022
1 parent 2458377 commit 6602e0d
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ const useStyles = makeStyles({
},
});

function makeFullName(first, last) {
return `${first} ${last}`;
}

export default function GrowerListItem({ data }) {
const classes = useStyles();

return (
<>
<Grid item xs={5}>
<Typography>{data.fullName}</Typography>
<Typography>{makeFullName(data.first_name, data.last_name)}</Typography>
</Grid>
<Grid item xs={3} className={classes.flex}>
<IdIcon className={classes.pr} />
Expand Down
114 changes: 79 additions & 35 deletions src/components/Stakeholders/StakeholderDetail/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const useStyles = makeStyles({

export default function DialogHeader({ data }) {
const [isEditing, setIsEditing] = useState(false);
const [details, setDetails] = useState({});
const [details, setDetails] = useState({ ...data });

const classes = useStyles();

Expand All @@ -66,29 +66,77 @@ export default function DialogHeader({ data }) {
return (
<Grid container direction="row">
<Grid item xs={1}>
{data.logo && <img src={data.logo} alt="" className={classes.logoLg} />}
{!data.logo && <PersonIcon className={classes.logoLg} />}
{data.logo_url ? (
<img src={data.logo_url} alt="" className={classes.logoLg} />
) : (
<PersonIcon className={classes.logoLg} />
)}
</Grid>

<Grid item container xs={11} className={classes.pl}>
<Grid container justify="space-between" alignItems="flex-start">
{isEditing ? (
<TextField
name="name"
value={details?.name || data.name}
onChange={handleEdit}
variant="standard"
InputProps={{
classes: { root: classes.inputName },
}}
autoFocus
/>
) : (
<Typography variant="h4" className={classes.fields}>
{details?.name || data.name}
</Typography>
)}
</Grid>
{data.type === 'Organization' ? (
<Grid container justify="space-between" alignItems="flex-start">
{isEditing ? (
<TextField
name="org_name"
value={details?.org_name}
onChange={handleEdit}
variant="standard"
InputProps={{
classes: { root: classes.inputName },
}}
autoFocus
/>
) : (
<Typography variant="h4" className={classes.fields}>
{details?.org_name}
</Typography>
)}
</Grid>
) : (
<Grid container justify="start" alignItems="flex-start" xs={11}>
<Grid className={classes.pr}>
{isEditing ? (
<TextField
name="first_name"
value={details?.first_name}
onChange={handleEdit}
variant="standard"
InputProps={{
classes: { root: classes.inputName },
}}
autoFocus
/>
) : (
<Typography variant="h4" className={classes.fields}>
{details?.first_name}
</Typography>
)}
</Grid>
<Grid>
{isEditing ? (
<TextField
name="last_name"
value={details?.last_name}
onChange={handleEdit}
variant="standard"
InputProps={{
classes: { root: classes.inputName },
}}
autoFocus
/>
) : (
<Typography
variant="h4"
className={classes.fields}
// style={{ marginLeft: '0.3em' }}
>
{details?.last_name}
</Typography>
)}
</Grid>
</Grid>
)}
<Grid container direction="row">
<Grid item xs={3}>
<Grid
Expand All @@ -110,7 +158,7 @@ export default function DialogHeader({ data }) {
{isEditing ? (
<TextField
name="type"
value={details?.type || data.type}
value={details?.type}
onChange={handleEdit}
variant="standard"
InputProps={{
Expand All @@ -119,7 +167,7 @@ export default function DialogHeader({ data }) {
/>
) : (
<Typography className={classes.fields}>
{details?.type || data.type}
{details?.type}
</Typography>
)}
</Grid>
Expand All @@ -136,7 +184,7 @@ export default function DialogHeader({ data }) {
{isEditing ? (
<TextField
name="email"
value={details?.email || data.email}
value={details?.email}
onChange={handleEdit}
variant="standard"
InputProps={{
Expand All @@ -145,7 +193,7 @@ export default function DialogHeader({ data }) {
/>
) : (
<Typography className={classes.fields}>
{details?.email || data.email}
{details?.email}
</Typography>
)}
</Grid>
Expand All @@ -159,7 +207,7 @@ export default function DialogHeader({ data }) {
{isEditing ? (
<TextField
name="phone"
value={details?.phone || data.phone}
value={details?.phone}
onChange={handleEdit}
variant="standard"
InputProps={{
Expand All @@ -168,7 +216,7 @@ export default function DialogHeader({ data }) {
/>
) : (
<Typography className={classes.fields}>
{details?.phone || data.phone}
{details?.phone}
</Typography>
)}
</Grid>
Expand All @@ -184,7 +232,7 @@ export default function DialogHeader({ data }) {
{isEditing ? (
<TextField
name="website"
value={details?.website || data.website}
value={details?.website}
onChange={handleEdit}
variant="standard"
InputProps={{
Expand All @@ -193,9 +241,7 @@ export default function DialogHeader({ data }) {
/>
) : (
<Typography className={classes.fields}>
<Link href={details?.website || data.website}>
{details?.website || data.website}
</Link>
<Link href={details?.website}>{details?.website}</Link>
</Typography>
)}
</Grid>
Expand All @@ -209,7 +255,7 @@ export default function DialogHeader({ data }) {
{isEditing ? (
<TextField
name="map"
value={details?.map || data.map}
value={details?.map}
onChange={handleEdit}
variant="standard"
InputProps={{
Expand All @@ -218,9 +264,7 @@ export default function DialogHeader({ data }) {
/>
) : (
<Typography className={classes.fields}>
<Link href={details?.map || data.map}>
{details?.map || data.map}
</Link>
<Link href={details?.map}>{details?.map}</Link>
</Typography>
)}
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function ParentChildListItem({ data }) {
<img src="./logo_192x192.png" alt="" className={classes.logoSm} />
</Grid>
<Grid item xs={6}>
<Typography>{data.name}</Typography>
<Typography>{data.org_name}</Typography>
</Grid>
<Grid item xs={5} className={classes.flex}>
<IdIcon className={classes.pr} />
Expand Down
21 changes: 17 additions & 4 deletions src/components/Stakeholders/StakeholderDetail/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,24 @@ export default function StakeholderDetail({ row, columns, child }) {
className={idx === 0 && child ? classes.pl : ''}
>
<div className={classes.flex}>
{col.value === 'name' && row.logo && (
<img src={row.logo} className={classes.logo} alt="" />
{col.value === 'name' && row.type === 'Organization' && (
<>
<img
src={row.logo_url}
className={classes.logo}
alt={row.org_name}
/>
{row.org_name}
</>
)}
{col.value === 'name' && !row.logo && (
<PersonIcon className={classes.logo} />
{col.value === 'name' && row.type === 'Person' && (
<>
<PersonIcon
className={classes.logo}
alt={`${row.first_name} ${row.last_name}`}
/>
{`${row.first_name} ${row.last_name}`}
</>
)}
{row[col.value]}
</div>
Expand Down

0 comments on commit 6602e0d

Please sign in to comment.