From 395bb0bc110704e4413618e3f051553020fecbb5 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Thu, 19 Jan 2023 20:40:11 -0500 Subject: [PATCH] have it adding calls better --- .../src/Call/components/PlaylistBuilder.js | 95 +++++++++++-------- 1 file changed, 54 insertions(+), 41 deletions(-) diff --git a/frontend/src/Call/components/PlaylistBuilder.js b/frontend/src/Call/components/PlaylistBuilder.js index 1ca25cb..bdccc9d 100644 --- a/frontend/src/Call/components/PlaylistBuilder.js +++ b/frontend/src/Call/components/PlaylistBuilder.js @@ -1,49 +1,62 @@ import { useSelector, useDispatch } from 'react-redux' - +import React, { useState } from "react"; import { - Header, - Divider, - List, - Segment, - Statistic, - Icon, - Menu, - Tab - } from "semantic-ui-react"; + Header, + Divider, + List, + ListItem, + Segment, + Statistic, + Icon, + Menu, + Tab +} from "semantic-ui-react"; - function PlaylistBuilder(props) { +function PlaylistBuilder(props) { - const { loading: callsLoading, data: callsData } = useSelector((state) => state.calls); + const { loading: callsLoading, data: callsData } = useSelector((state) => state.calls); + const [playlist, setPlaylist] = useState([]); - const onDragOver = (event) => { - // It also receives a DragEvent. - // Later, we'll read the position - // of the item from event.currentTarget - // and store the updated list state - - // We need to prevent the default behavior - // of this event, in order for the onDrop - // event to fire. - // It may sound weird, but the default is - // to cancel out the drop. - - event.preventDefault(); - } - - const onDrop = (event) => { - // Here, we will: - // - update the rendered list - // - and reset the DnD state - var callId = event.dataTransfer.getData("call-id"); - console.log("Dropping: " + callId); - console.log("Found: " + callsData.entities[callId].freq); - } + const onDragOver = (event) => { + // It also receives a DragEvent. + // Later, we'll read the position + // of the item from event.currentTarget + // and store the updated list state - return ( - -
Placeholder
-
- ) + // We need to prevent the default behavior + // of this event, in order for the onDrop + // event to fire. + // It may sound weird, but the default is + // to cancel out the drop. + + event.preventDefault(); } - export default PlaylistBuilder; \ No newline at end of file + const onDrop = (event) => { + // Here, we will: + // - update the rendered list + // - and reset the DnD state + var callId = event.dataTransfer.getData("call-id"); + console.log("Dropping: " + callId); + console.log("Found: " + callsData.entities[callId].freq); + setPlaylist([...playlist, callId]); + } + let listItems = ""; + + listItems = playlist.map((callId, index) => { + const call = callsData.entities[callId]; + return(
  • {call.time}
  • ) + }) + + + return ( + + + + ) +} + +export default PlaylistBuilder; \ No newline at end of file