From c0c41f5c1c31a988143bd73ce92c7b4ee19b0e8d Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Fri, 23 Jun 2023 00:32:26 +0000 Subject: [PATCH] Add filtering Storage by empty, memo'd, and served --- webclient/src/Storage.js | 100 ++++++++++++++++++++++++++++++--------- 1 file changed, 78 insertions(+), 22 deletions(-) diff --git a/webclient/src/Storage.js b/webclient/src/Storage.js index 2d20ec8..6e4e22f 100644 --- a/webclient/src/Storage.js +++ b/webclient/src/Storage.js @@ -3,7 +3,7 @@ import { Link, useParams, useHistory } from 'react-router-dom'; import './light.css'; import { MembersDropdown } from './Members.js'; import { isAdmin, BasicTable, requester, useIsMobile } from './utils.js'; -import { Button, Container, Form, Grid, Header, Icon, Input, Message, Segment, Table } from 'semantic-ui-react'; +import { Button, Checkbox, Container, Form, Grid, Header, Icon, Input, Message, Segment, Table } from 'semantic-ui-react'; export function StorageEditor(props) { const { token, input, setInput, error } = props; @@ -274,11 +274,17 @@ export function StorageSearch(props) { }; let storageListCache = false; +let showEmptyCache = false; +let showMemodCache = false; +let showServedCache = false; export function StorageList(props) { const { token } = props; const [storageList, setStorageList] = useState(storageListCache); const [search, setSearch] = useState(storageSearchCache); + const [showEmpty, setShowEmpty] = useState(showEmptyCache); + const [showMemod, setShowMemod] = useState(showMemodCache); + const [showServed, setShowServed] = useState(showServedCache); const [error, setError] = useState(false); const isMobile = useIsMobile(); @@ -298,11 +304,32 @@ export function StorageList(props) { const filterStorage = (x) => { if (search.length && !x.shelf_id.startsWith(search)) { return false; + } else if (showEmpty && x.member_name) { + return false; + } else if (showMemod && !x.memo) { + return false; + } else if (showServed && !x.memo.toLowerCase().includes('served')) { + return false; } else { return true; } }; + const handleShowEmpty = (e, v) => { + setShowEmpty(v.checked); + showEmptyCache = v.checked; + }; + + const handleShowMemod = (e, v) => { + setShowMemod(v.checked); + showMemodCache = v.checked; + }; + + const handleShowServed = (e, v) => { + setShowServed(v.checked); + showServedCache = v.checked; + }; + return (

@@ -311,31 +338,60 @@ export function StorageList(props) { Large project storage

- +

+ +

+ +

+ + + + + +

{!error ? storageList ? - - {!isMobile && - - Shelf ID - Owner - Memo - - } - - - {storageList.filter(filterStorage).map(x => - - - - {isMobile && 'Owner: '}{x.member_name} - - {isMobile && 'Memo: '}{x.memo} + <> +

{storageList.filter(filterStorage).length} results:

+ +
+ {!isMobile && + + Shelf ID + Owner + Memo - )} - -
+ } + + + {storageList.filter(filterStorage).map(x => + + + + {isMobile && 'Owner: '}{x.member_name} + + {isMobile && 'Memo: '}{x.memo} + + )} + + + :

Loading...

: