Skip to content

Commit

Permalink
Refactor queues to queueCounts
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Campbell committed Nov 20, 2020
1 parent cd85eee commit 2de2d34
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/components/QueueSelector/QueueSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { useToken } from "../AuthProvider/";

export default function QueueSelector({ selectedQueues, setSelectedQueues }) {
const [open, setOpen] = useState(false);
const [queues, setQueues] = useState([]);
const [queueCounts, setQueueCounts] = useState([]);
const access_token = useToken();
const loading = open && queues.length === 0;
const loading = open && queueCounts.length === 0;

useEffect( _ => {
const getQueueCounts = async _ => {
Expand All @@ -25,7 +25,7 @@ export default function QueueSelector({ selectedQueues, setSelectedQueues }) {

const apiResponse = await fetch(`/api/get_queues`, requestOptions);
const queueCountJson = await apiResponse.json();
setQueues(queueCountJson);
setQueueCounts(queueCountJson);
};

if (loading) {
Expand All @@ -36,9 +36,9 @@ export default function QueueSelector({ selectedQueues, setSelectedQueues }) {

useEffect(() => {
if (!open) {
setQueues([]);
setQueueCounts([]);
}
}, [open]);
}, [open]);

const theme = useTheme();

Expand Down Expand Up @@ -90,7 +90,7 @@ export default function QueueSelector({ selectedQueues, setSelectedQueues }) {
/>
)}

options={queues}
options={queueCounts}
onChange={handleChange}
getOptionLabel={(option) => `${option.name} (${option.number_of_items})`}
renderOption={optionRenderer}
Expand Down

0 comments on commit 2de2d34

Please sign in to comment.