Skip to content

Commit

Permalink
Merge branch 'release-1.0.64'
Browse files Browse the repository at this point in the history
  • Loading branch information
entrotech committed Dec 23, 2021
2 parents 55b9b84 + 47bcc07 commit 3de4453
Show file tree
Hide file tree
Showing 32 changed files with 1,793 additions and 36 deletions.
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "foodoasis-client",
"description": "React Client for Food Oasis",
"version": "1.0.63",
"version": "1.0.64",
"author": "Hack for LA",
"license": "GPL-2.0",
"private": true,
Expand Down
15 changes: 15 additions & 0 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import VerificationDashboard from "components/Admin/VerificationDashboard";
import SecurityAdminDashboard from "components/Account/SecurityAdminDashboard/SecurityAdminDashboard";
import OrganizationEdit from "components/Admin/OrganizationEdit";
import ParentOrganizations from "components/Admin/ParentOrganizations";
import TagAdmin from "components/Admin/TagAdmin";
import Donate from "components/StaticPages/Donate";
import About from "components/StaticPages/About";
import Faq from "components/StaticPages/Faq";
Expand Down Expand Up @@ -62,6 +63,7 @@ import ImportFile from "components/Admin/ImportOrganizations/ImportFile";
import adminTheme from "./theme/adminTheme";
import * as analytics from "../src/services/analytics";
import Suggestions from "components/Admin/Suggestions";
import Logins from "components/Admin/Logins";

const useStyles = makeStyles({
app: () => ({
Expand Down Expand Up @@ -210,6 +212,9 @@ function App() {
<Route path="/suggestion">
<Suggestion />
</Route>
<Route path="/logins">
<Logins />
</Route>
<Route path="/organizationedit/:id?">
<ThemeProvider theme={adminTheme}>
<div className={classes.organizationEditWrapper}>
Expand Down Expand Up @@ -237,11 +242,21 @@ function App() {
<ParentOrganizations />
</div>
</Route>
<Route path="/tags">
<div className={classes.organizationEditWrapper}>
<TagAdmin />
</div>
</Route>
<Route path="/suggestions">
<div className={classes.organizationEditWrapper}>
<Suggestions />
</div>
</Route>
<Route path="/logins">
<div className={classes.organizationEditWrapper}>
<Logins />
</div>
</Route>
<Route path="/securityadmindashboard">
<div className={classes.verificationAdminWrapper}>
<SecurityAdminDashboard
Expand Down
141 changes: 141 additions & 0 deletions client/src/components/Admin/Logins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import React, { useState, useEffect, useMemo } from "react";
import { makeStyles } from "@material-ui/core/styles";
import Container from "@material-ui/core/Container";
import Paper from "@material-ui/core/Paper";
import Table from "@material-ui/core/Table";
import TableBody from "@material-ui/core/TableBody";
import TableCell from "@material-ui/core/TableCell";
import TableContainer from "@material-ui/core/TableContainer";
import TableHead from "@material-ui/core/TableHead";
import TablePagination from "@material-ui/core/TablePagination";
import TableRow from "@material-ui/core/TableRow";
import FormControl from "@material-ui/core/FormControl";
import { TextField } from "../UI";
import { useLogins } from "hooks/useLogins";
import debounce from "lodash.debounce";

const columns = [
{ id: "name", label: "Name", minWidth: 100 },
{ id: "email", label: "Email", minWidth: 10 },
{ id: "loginTime", label: "Login Time", minWidth: 10 },
];

const useStyles = makeStyles((theme) => ({
container: {
maxHeight: "500px",
},
heading: {
marginBottom: theme.spacing(1),
display: "flex",
justifyContent: "space-between",
},
formControl: {
margin: theme.spacing(1),
minWidth: 180,
},
}));

const Logins = () => {
const classes = useStyles();
const [logins, setLogins] = useState([]);
const [page, setPage] = React.useState(0);
const [rowsPerPage, setRowsPerPage] = React.useState(10);
let { data, refetch } = useLogins();

useEffect(() => {
if (data) {
setLogins(data);
}
}, [data]);

const handleChangePage = (event, newPage) => {
setPage(newPage);
};

const handleChangeRowsPerPage = (event) => {
setRowsPerPage(+event.target.value);
setPage(0);
};

const debouncedChangeHandler = useMemo(() => {
const changeHandler = (event) => {
refetch(event.target.value.toLowerCase());
};
return debounce(changeHandler, 300);
}, [refetch]);

return (
<Container>
<div className={classes.heading}>
<h2>User Logins</h2>
<FormControl className={classes.formControl}>
<TextField
variant="outlined"
margin="none"
placeholder="Find by Email"
size="small"
className={classes.textInput}
onChange={debouncedChangeHandler}
/>
</FormControl>
</div>

<Paper>
<TableContainer className={classes.container}>
<Table stickyHeader aria-label="sticky table">
<TableHead>
<TableRow>
{columns.map((column) => (
<TableCell
key={column.id}
align={column.align}
style={{ minWidth: column.minWidth }}
>
{column.label}
</TableCell>
))}
</TableRow>
</TableHead>
<TableBody>
{logins
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
.map((logins) => {
return (
<TableRow
hover
role="checkbox"
tabIndex={-1}
key={logins.id}
>
{columns.map((column) => {
const value =
column.id === "name"
? `${logins["lastName"]}, ${logins["firstName"]}`
: logins[column.id];
return (
<TableCell key={column.id} align={column.align}>
{value}
</TableCell>
);
})}
</TableRow>
);
})}
</TableBody>
</Table>
</TableContainer>
<TablePagination
rowsPerPageOptions={[10, 25, 100]}
component="div"
count={logins.length}
rowsPerPage={rowsPerPage}
page={page}
onPageChange={handleChangePage}
onRowsPerPageChange={handleChangeRowsPerPage}
/>
</Paper>
</Container>
);
};

export default Logins;
81 changes: 81 additions & 0 deletions client/src/components/Admin/OrganizationEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
} from "@material-ui/core";
import * as stakeholderService from "services/stakeholder-service";
import { useCategories } from "hooks/useCategories/useCategories";
import { useTags } from "hooks/useTags";
import * as geocoder from "services/geocode-tamu-service";
import OpenTimeForm from "components/Admin/OpenTimeForm";
import { TabPanel, a11yProps } from "components/Admin/ui/TabPanel";
Expand Down Expand Up @@ -200,6 +201,9 @@ const emptyOrganization = {
foodDairy: false,
foodPrepared: false,
foodMeat: false,
hoursNotes: "",
allowWalkins: false,
tags: [],
};

const FOOD_TYPES = [
Expand Down Expand Up @@ -260,6 +264,7 @@ const OrganizationEdit = (props) => {
const { setToast } = useToasterContext();

const { data: categories } = useCategories();
const { data: allTags } = useTags();

useEffect(() => {
const fetchData = async () => {
Expand Down Expand Up @@ -1038,6 +1043,52 @@ const OrganizationEdit = (props) => {
</div>
</Grid>
</Grid>
<Grid item xs={12} sm={6}>
<div className={classes.confirmableGroupWrapper}>
<FormControl className={classes.formControl} fullWidth>
<InputLabel id="selectedTags-label">Tags</InputLabel>

<Select
labelId="selectedTags-label"
id="tags"
variant="outlined"
name="tags"
multiple
fullWidth
value={values.tags || []}
onChange={handleChange}
input={<Input />}
renderValue={(tags) => {
if (!allTags) {
return "Loading tags...";
}
if (tags.length === 0) {
return "(Select Tags)";
}
return tags.join(", ");
}}
MenuProps={MenuProps}
>
{!allTags || allTags.length === 0
? null
: allTags.map((t) => (
<MenuItem key={t.name} value={t.name}>
<Checkbox
checked={
values.tags &&
values.tags.find((tt) => tt === t.name)
}
/>
<ListItemText primary={t.name} />
</MenuItem>
))}
</Select>
<FormHelperText>
{touched.tags ? errors.tags : ""}
</FormHelperText>
</FormControl>
</div>
</Grid>
</Grid>
</TabPanel>
<TabPanel value={tabPage} index={1} className={classes.tabPanel}>
Expand Down Expand Up @@ -1078,6 +1129,36 @@ const OrganizationEdit = (props) => {
value={values.hours}
/>
</Grid>
<Grid item xs={12}>
<FormControlLabel
control={
<Checkbox
margin="normal"
name="allowWalkins"
value={values.allowWalkins}
checked={values.allowWalkins}
onChange={() =>
setFieldValue("allowWalkins", !values.allowWalkins)
}
onBlur={handleBlur}
/>
}
label="Allow Walk-Ins"
/>
<TextInput
tooltip="Notes and caveats about hours"
name="hoursNotes"
label="Notes about hours"
value={values.hoursNotes}
multiline
minRows={2}
maxRows={12}
onChange={handleChange}
onBlur={handleBlur}
helperText={touched.hoursNotes ? errors.hoursNotes : ""}
error={touched.hoursNotes && Boolean(errors.hoursNotes)}
/>
</Grid>
</Grid>
</TabPanel>
<TabPanel value={tabPage} index={2} className={classes.tabPanel}>
Expand Down
27 changes: 27 additions & 0 deletions client/src/components/Admin/SearchCriteria.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const SearchCriteria = ({
userLongitude,
categories,
neighborhoods,
tags,
criteria,
setCriteria,
}) => {
Expand Down Expand Up @@ -347,6 +348,32 @@ const SearchCriteria = ({
</Select>
</FormControl>
</Grid>
<Grid item xs={12} sm={6}>
<FormControl variant="outlined" size="small" fullWidth>
<FormLabel id="tag-label" className={classes.formLabel}>
Tag
</FormLabel>
<Select
labelId="tag-label"
name="tag"
value={criteria.tag}
onChange={setCriterion}
>
<MenuItem key="1" value="">
<em>(Any)</em>
</MenuItem>
{tags
? tags.map((n) => {
return (
<MenuItem key={n.name} value={n.name}>
{n.name}
</MenuItem>
);
})
: null}
</Select>
</FormControl>
</Grid>
</Grid>
<Grid item xs={12} sm={6}>
<Grid container>
Expand Down
14 changes: 13 additions & 1 deletion client/src/components/Admin/SearchCriteriaDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function SearchCriteriaDisplay({
criteria,
neighborhoods,
categories,
tags,
isLoading,
}) {
const classes = useStyles();
Expand All @@ -59,7 +60,8 @@ function SearchCriteriaDisplay({
criteria.minCompleteCriticalPercent !==
defaultCriteria.minCompleteCriticalPercent ||
criteria.maxCompleteCriticalPercent !==
defaultCriteria.maxCompleteCriticalPercent
defaultCriteria.maxCompleteCriticalPercent ||
criteria.tag !== defaultCriteria.tag
// TODO: latituted and longitude are omitted because they are buggy
// criteria.latitude != defaultCriteria.latitude ||
// criteria.longitude != defaultCriteria.longitude ||
Expand Down Expand Up @@ -93,6 +95,16 @@ function SearchCriteriaDisplay({
);
}

if (criteria.tag !== defaultCriteria.tag) {
criterias.push(
<CriteriaChip
key={"CriteriaChip_Tag"}
value={criteria.tag}
label="Tag"
/>
);
}

if (criteria.radius !== defaultCriteria.radius) {
criterias.push(
<CriteriaChip
Expand Down
Loading

0 comments on commit 3de4453

Please sign in to comment.