Skip to content

Commit

Permalink
Merge pull request #1787 from hackforla/1784-styling-ResultsList.js
Browse files Browse the repository at this point in the history
1784 styling ResultsList.js
  • Loading branch information
andyarensman authored Aug 29, 2023
2 parents b862bd1 + 773a0a1 commit e7f79ab
Showing 1 changed file with 33 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,84 +1,74 @@
import React, { useEffect } from "react";
import PropTypes from "prop-types";
import { Button, CircularProgress, Stack } from "@mui/material";
import makeStyles from "@mui/styles/makeStyles";
import {
Box,
Button,
CircularProgress,
Stack,
Typography,
} from "@mui/material";
import StakeholderPreview from "../StakeholderPreview/StakeholderPreview";
import StakeholderDetails from "../StakeholderDetails/StakeholderDetails";
import * as analytics from "services/analytics";
import { useSelectedOrganization } from "../../../../appReducer";
import { Virtuoso } from "react-virtuoso";

const useStyles = makeStyles((theme) => ({
listContainer: {
textAlign: "center",
width: "100%",
height: "100%",
display: "flex",
flexDirection: "column",
alignItems: "center",
[theme.breakpoints.down("sm")]: {
fontSize: 12,
},
padding: "1px", // This keeps the control width from infintely switching widths back and forth - have no idea why
},
list: {
width: "100%",
margin: 0,
flex: 1,
},
preview: {
width: "100%",
borderBottom: " .2em solid #f1f1f1",
padding: "0",
},
emptyResult: {
padding: "1em 0",
display: "flex",
flexDirection: "column",
alignContent: "center",
},
}));

const ResultsList = ({ stakeholders, loading, handleReset }) => {
const classes = useStyles();
const selectedOrganization = useSelectedOrganization();

useEffect(() => {
analytics.postEvent("showList");
}, []);

return (
<div className={classes.listContainer}>
<Stack
alignItems="center"
sx={{
width: 1,
height: 1,
padding: "1px",
textAlign: "center",
fontSize: { sm: 12 },
}}
>
{loading && (
<Stack justifyContent="center" alignContent="center">
<CircularProgress />
</Stack>
)}
{!loading && stakeholders.length === 0 && (
<div className={classes.emptyResult}>
<p>Sorry, we don&apos;t have any results for this area.</p>
<Stack sx={{ padding: "1em 0", alignContent: "center" }}>
<Typography>
Sorry, we don&apos;t have any results for this area.
</Typography>
<Button variant="outlined" onClick={handleReset} disableElevation>
Click here to reset the search
</Button>
</div>
</Stack>
)}
{stakeholders &&
selectedOrganization &&
!selectedOrganization.inactive ? (
<StakeholderDetails />
) : (
<div className={classes.list}>
<Box sx={{ width: 1, margin: 0, flex: 1 }}>
<Virtuoso
data={stakeholders}
itemContent={(index) => (
<div className={classes.preview}>
<Box
sx={{
width: 1,
borderBottom: ".2em solid #f1f1f1",
padding: "0",
}}
>
<StakeholderPreview stakeholder={stakeholders[index]} />
</div>
</Box>
)}
/>
</div>
</Box>
)}
</div>
</Stack>
);
};

Expand Down

0 comments on commit e7f79ab

Please sign in to comment.