This repository has been archived by the owner on May 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #461 from SELab-2/project_detail_page
Project detail page (add students)
- Loading branch information
Showing
51 changed files
with
2,912 additions
and
1,393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
frontend/src/components/ProjectDetailComponents/AddStudentModal/AddStudentModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { CreateButton } from "../../Common/Buttons"; | ||
import { FormControl } from "../../Common/Forms"; | ||
import { StyledModal, ModalHeader, ModalFooter, Button } from "./styles"; | ||
import FloatingLabel from "react-bootstrap/FloatingLabel"; | ||
import { useState } from "react"; | ||
import { AddStudentRole } from "../../../data/interfaces/projects"; | ||
|
||
export default function AddStudentModal({ | ||
visible, | ||
handleClose, | ||
handleConfirm, | ||
result, | ||
}: { | ||
visible: boolean; | ||
handleClose: () => void; | ||
handleConfirm: (motivation: string, addStudentRole: AddStudentRole) => void; | ||
result: AddStudentRole; | ||
}) { | ||
const [motivation, setMotivation] = useState(""); | ||
return ( | ||
<StyledModal show={visible} onHide={handleClose}> | ||
<ModalHeader closeButton> | ||
<StyledModal.Title>Suggest student for project</StyledModal.Title> | ||
</ModalHeader> | ||
|
||
<StyledModal.Body> | ||
Please motivate your decision | ||
<FloatingLabel label={"Motivation"} className={"mb-1"}> | ||
<FormControl | ||
placeholder={"Good fit!"} | ||
value={motivation} | ||
onChange={e => { | ||
setMotivation(e.target.value); | ||
}} | ||
/> | ||
</FloatingLabel> | ||
</StyledModal.Body> | ||
|
||
<ModalFooter> | ||
<Button | ||
onClick={() => { | ||
handleClose(); | ||
setMotivation(""); | ||
}} | ||
> | ||
Cancel | ||
</Button> | ||
<CreateButton | ||
label="Suggest" | ||
onClick={() => { | ||
handleConfirm(motivation, result); | ||
setMotivation(""); | ||
}} | ||
/> | ||
</ModalFooter> | ||
</StyledModal> | ||
); | ||
} |
1 change: 1 addition & 0 deletions
1
frontend/src/components/ProjectDetailComponents/AddStudentModal/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "./AddStudentModal"; |
28 changes: 28 additions & 0 deletions
28
frontend/src/components/ProjectDetailComponents/AddStudentModal/styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import styled from "styled-components"; | ||
import Modal from "react-bootstrap/Modal"; | ||
|
||
export const StyledModal = styled(Modal)` | ||
color: white; | ||
background-color: #00000060; | ||
margin-top: 5%; | ||
.modal-content { | ||
background-color: #272741; | ||
border-radius: 5px; | ||
border-color: var(--osoc_green); | ||
} | ||
`; | ||
|
||
export const ModalHeader = styled(Modal.Header)` | ||
border-bottom: 1px solid #131329; | ||
`; | ||
export const ModalFooter = styled(Modal.Footer)` | ||
border-top: 1px solid #131329; | ||
`; | ||
|
||
export const Button = styled.button` | ||
border-radius: 5px; | ||
border: none; | ||
padding: 5px 10px; | ||
background-color: #131329; | ||
color: white; | ||
`; |
72 changes: 72 additions & 0 deletions
72
frontend/src/components/ProjectDetailComponents/CoachInput/CoachInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { useEffect, useState } from "react"; | ||
import { useParams } from "react-router-dom"; | ||
import { Project } from "../../../data/interfaces"; | ||
import { User } from "../../../utils/api/users/users"; | ||
|
||
import { getCoaches } from "../../../utils/api/users/coaches"; | ||
import { Input, AddButton } from "../PartnerInput/styles"; | ||
|
||
export default function CoachInput({ | ||
project, | ||
setProject, | ||
}: { | ||
project: Project; | ||
setProject: (project: Project) => void; | ||
}) { | ||
const [coach, setCoach] = useState(""); | ||
const [availableCoaches, setAvailableCoaches] = useState<User[]>([]); | ||
|
||
const params = useParams(); | ||
const editionId = params.editionId!; | ||
|
||
useEffect(() => { | ||
async function callCoaches() { | ||
setAvailableCoaches((await getCoaches(editionId, coach, 0)).users); | ||
} | ||
callCoaches(); | ||
}, [coach, editionId]); | ||
|
||
return ( | ||
<> | ||
<Input | ||
value={coach} | ||
onChange={e => { | ||
setCoach(e.target.value); | ||
}} | ||
list="coaches" | ||
placeholder="Coach" | ||
/> | ||
|
||
<datalist id="coaches"> | ||
{availableCoaches.map((availableCoach, _index) => { | ||
return <option key={_index} value={availableCoach.name} />; | ||
})} | ||
</datalist> | ||
|
||
<AddButton | ||
onClick={() => { | ||
addToCoaches(); | ||
}} | ||
> | ||
Add Coach | ||
</AddButton> | ||
</> | ||
); | ||
|
||
function addToCoaches() { | ||
let coachToAdd = null; | ||
availableCoaches.forEach(availableCoach => { | ||
if (availableCoach.name === coach) { | ||
coachToAdd = availableCoach; | ||
} | ||
}); | ||
if (coachToAdd) { | ||
if (!project.coaches.some(presentCoach => presentCoach.name === coach)) { | ||
const newCoaches = [...project.coaches]; | ||
newCoaches.push(coachToAdd); | ||
setProject({ ...project, coaches: newCoaches }); | ||
} | ||
} | ||
setCoach(""); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
frontend/src/components/ProjectDetailComponents/CoachInput/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "./CoachInput"; |
43 changes: 43 additions & 0 deletions
43
frontend/src/components/ProjectDetailComponents/PartnerInput/PartnerInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useState } from "react"; | ||
import { Project, Partner } from "../../../data/interfaces"; | ||
import { Input, AddButton } from "./styles"; | ||
|
||
export default function PartnerInput({ | ||
project, | ||
setProject, | ||
}: { | ||
project: Project; | ||
setProject: (project: Project) => void; | ||
}) { | ||
const [partner, setPartner] = useState(""); | ||
|
||
return ( | ||
<> | ||
<Input | ||
value={partner} | ||
onChange={e => { | ||
setPartner(e.target.value); | ||
}} | ||
placeholder="Partner" | ||
/> | ||
<AddButton | ||
onClick={() => { | ||
addToPartners(); | ||
}} | ||
> | ||
Add Partner | ||
</AddButton> | ||
</> | ||
); | ||
|
||
function addToPartners() { | ||
if (!project.partners.some(presentPartner => presentPartner.name === partner)) { | ||
const newPartner: Partner = { name: partner }; | ||
const newPartners = [...project.partners]; | ||
newPartners.push(newPartner); | ||
const newProject: Project = { ...project, partners: newPartners }; | ||
setProject(newProject); | ||
} | ||
setPartner(""); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
frontend/src/components/ProjectDetailComponents/PartnerInput/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "./PartnerInput"; |
22 changes: 22 additions & 0 deletions
22
frontend/src/components/ProjectDetailComponents/PartnerInput/styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import styled from "styled-components"; | ||
|
||
export const Input = styled.input` | ||
margin-right: 5px; | ||
padding: 5px 10px; | ||
background-color: #131329; | ||
color: white; | ||
border: none; | ||
border-radius: 5px; | ||
width: 15%; | ||
min-width: 100px; | ||
`; | ||
|
||
export const AddButton = styled.button` | ||
padding: 0 10px; | ||
background-color: #00bfff; | ||
color: white; | ||
border: none; | ||
margin-right: 10px; | ||
border-radius: 5px; | ||
min-height: 34px; | ||
`; |
43 changes: 43 additions & 0 deletions
43
frontend/src/components/ProjectDetailComponents/ProjectCoaches/ProjectCoaches.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { TiDeleteOutline } from "react-icons/ti"; | ||
import { CoachContainer, CoachesContainer, CoachText, RemoveButton } from "./styles"; | ||
import CoachInput from "../CoachInput"; | ||
import { Project } from "../../../data/interfaces"; | ||
|
||
export default function ProjectCoaches({ | ||
project, | ||
editedProject, | ||
setEditedProject, | ||
editing, | ||
}: { | ||
project: Project; | ||
editedProject: Project; | ||
setEditedProject: (project: Project) => void; | ||
editing: boolean; | ||
}) { | ||
return ( | ||
<CoachesContainer> | ||
{editedProject.coaches.map((element, _index) => ( | ||
<CoachContainer key={_index}> | ||
<CoachText>{element.name}</CoachText> | ||
{editing && ( | ||
<RemoveButton | ||
onClick={() => { | ||
const newCoaches = [...editedProject.coaches]; | ||
|
||
newCoaches.splice(_index, 1); | ||
const newProject: Project = { | ||
...project, | ||
coaches: newCoaches, | ||
}; | ||
setEditedProject(newProject); | ||
}} | ||
> | ||
<TiDeleteOutline size={"20px"} /> | ||
</RemoveButton> | ||
)} | ||
</CoachContainer> | ||
))} | ||
{editing && <CoachInput project={editedProject!} setProject={setEditedProject} />} | ||
</CoachesContainer> | ||
); | ||
} |
1 change: 1 addition & 0 deletions
1
frontend/src/components/ProjectDetailComponents/ProjectCoaches/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "./ProjectCoaches"; |
36 changes: 36 additions & 0 deletions
36
frontend/src/components/ProjectDetailComponents/ProjectCoaches/styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import styled from "styled-components"; | ||
|
||
export const CoachesContainer = styled.div` | ||
display: flex; | ||
align-items: center; | ||
margin-top: 20px; | ||
overflow-x: auto; | ||
`; | ||
|
||
export const CoachContainer = styled.div` | ||
background-color: #1a1a36; | ||
border-radius: 5px; | ||
margin-right: 10px; | ||
text-align: center; | ||
padding: 7.5px 15px; | ||
width: fit-content; | ||
max-width: 20vw; | ||
display: flex; | ||
`; | ||
|
||
export const CoachText = styled.div` | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
`; | ||
|
||
export const RemoveButton = styled.button` | ||
padding: 0px 2.5px; | ||
background-color: #f14a3b; | ||
color: white; | ||
border: none; | ||
margin-left: 10px; | ||
border-radius: 1px; | ||
display: flex; | ||
align-items: center; | ||
`; |
43 changes: 43 additions & 0 deletions
43
frontend/src/components/ProjectDetailComponents/ProjectPartners/ProjectPartners.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { TiDeleteOutline } from "react-icons/ti"; | ||
import { Project } from "../../../data/interfaces"; | ||
import PartnerInput from "../PartnerInput"; | ||
|
||
import { ClientContainer, Client, RemoveButton } from "./styles"; | ||
|
||
export default function ProjectPartners({ | ||
project, | ||
editedProject, | ||
setEditedProject, | ||
editing, | ||
}: { | ||
project: Project; | ||
editedProject: Project; | ||
setEditedProject: (project: Project) => void; | ||
editing: boolean; | ||
}) { | ||
return ( | ||
<> | ||
{editedProject.partners.map((element, _index) => ( | ||
<ClientContainer key={_index}> | ||
<Client>{element.name}</Client> | ||
{editing && ( | ||
<RemoveButton | ||
onClick={() => { | ||
const newPartners = [...editedProject.partners]; | ||
newPartners.splice(_index, 1); | ||
const newProject: Project = { | ||
...project, | ||
partners: newPartners, | ||
}; | ||
setEditedProject(newProject); | ||
}} | ||
> | ||
<TiDeleteOutline size={"20px"} /> | ||
</RemoveButton> | ||
)} | ||
</ClientContainer> | ||
))} | ||
{editing && <PartnerInput project={editedProject!} setProject={setEditedProject} />} | ||
</> | ||
); | ||
} |
1 change: 1 addition & 0 deletions
1
frontend/src/components/ProjectDetailComponents/ProjectPartners/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "./ProjectPartners"; |
Oops, something went wrong.