From c47ad198b1b9f0673a7cf9bcdc418c09f2665665 Mon Sep 17 00:00:00 2001 From: Jae Wu Date: Fri, 4 Mar 2022 01:27:59 -0800 Subject: [PATCH 1/4] change display, currently read only --- components/Judging/TeamMembersSelector.js | 145 ++++++++++++++++++++++ components/projectsCard.js | 6 +- pages/Livesite/judging.js | 12 +- 3 files changed, 157 insertions(+), 6 deletions(-) create mode 100644 components/Judging/TeamMembersSelector.js diff --git a/components/Judging/TeamMembersSelector.js b/components/Judging/TeamMembersSelector.js new file mode 100644 index 00000000..a175f317 --- /dev/null +++ b/components/Judging/TeamMembersSelector.js @@ -0,0 +1,145 @@ +// teamMembers should be array of object: +// +// [ +// { +// discord, +// email, +// id, +// name +// }, +// ... +// ] +import { useEffect, useState } from 'react'; +import styled from 'styled-components'; + +const TeamMembersSelector = (props) => { + const { value, updateValue } = props; + // onChange => ('teamMembers', e) + + const copyValues = () => { + const duplicate = []; + value.forEach((item) => { + duplicate.push(item); + }); + return duplicate; + }; + + const [members, setMembers] = useState(value); + const [renderMembers, setRenderMembers] = useState([]); + const [trigger, setTrigger] = useState(false); + const [isAdding, setIsAdding] = useState(false); + + const InputArea = styled.div` + background: white; + padding: 0.5rem; + border: 1px solid #eeeeee; + display: flex; + gap: 0.5rem; + position: relative; + min-height: calc(1rem + calc(1rem * 1.2)); + `; + + const Member = styled.div` + background: #2d2937; + color: white; + padding: 0.5rem 0.7rem; + border-radius: 5px; + display: inline-flex; + align-items: center; + gap: 0.5rem; + `; + + const AddText = styled.span` + margin: 0.5rem 0.3rem; + cursor: pointer; + font-weight: 600; + position: absolute; + top: 0.5rem; + right: 10px; + `; + + const AddPanel = styled.div` + transition: all 0.2s linear; + background: white; + padding: 0.5rem; + border-style: none solid solid solid; + border-width: 1px; + border-color: #EEEEEE; + `; + + const handleAddMember = () => {}; + + const handleDeleteMember = (index) => { + const currentMembers = members; + currentMembers.splice(index, 1); + setMembers(currentMembers); + setTrigger(!trigger); + }; + + const DeleteIcon = ({ index }) => { + return ( +
handleDeleteMember(index)} + onClick={() => handleDeleteMember(index)} + > + + + + +
+ ); + }; + + useEffect(() => { + const renderArray = []; + + members.forEach((item, index) => { + renderArray.push( + + {item.name} + {/* */} + + ); + }); + + setRenderMembers(renderArray); + }, [trigger]); + + return ( + <> + + {renderMembers} + {/* setIsAdding(!isAdding)}> + {isAdding ? 'Cancel' : 'Add Member'} + */} + + + yuh + + + ); +}; + +export default TeamMembersSelector; diff --git a/components/projectsCard.js b/components/projectsCard.js index 2b64ee83..e0e575ca 100644 --- a/components/projectsCard.js +++ b/components/projectsCard.js @@ -79,7 +79,11 @@ export default ({ Link - {project.teamMembers?.toString()} + + {project.teamMembers.map((item, index) => ( + {item.name} + ))} +