Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Everything Projects #395

Merged
merged 95 commits into from
May 21, 2022
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
1533196
basics of editing a project
Tiebe-Vercoutter May 3, 2022
2b30fef
Update name of a project
Tiebe-Vercoutter May 3, 2022
48551df
delete project on project detail page
Tiebe-Vercoutter May 3, 2022
10cc981
Added remove and add button for coaches and partners
Tiebe-Vercoutter May 6, 2022
4567e60
move a component to a separate file
Tiebe-Vercoutter May 7, 2022
285188d
function to convert project to an editable project
Tiebe-Vercoutter May 8, 2022
067602f
Delete partner and coach form project
Tiebe-Vercoutter May 8, 2022
c849d4c
add and delete partners and coaches
Tiebe-Vercoutter May 10, 2022
0764670
Merge branch 'develop' into project_detail_page
Tiebe-Vercoutter May 10, 2022
ed75aa5
drag and drop baby
Tiebe-Vercoutter May 10, 2022
eec7037
Merge branch 'develop' into project_detail_page
Tiebe-Vercoutter May 11, 2022
1d746a4
ProjectRoles dnd styling
Tiebe-Vercoutter May 11, 2022
43d64d7
More seperate components
Tiebe-Vercoutter May 11, 2022
df30bcf
only show edit and delete buttons to admin (projects)
Tiebe-Vercoutter May 11, 2022
d3a8bb9
Merge branch 'develop' into project_detail_page
Tiebe-Vercoutter May 12, 2022
4438ebc
remove number of students input
Tiebe-Vercoutter May 12, 2022
6b6175c
updated interfaces to new skill format
Tiebe-Vercoutter May 12, 2022
61871fb
Add skills (projectRoles) to project
Tiebe-Vercoutter May 12, 2022
d1c9326
Merge branch 'develop' into create_project_skills
Tiebe-Vercoutter May 12, 2022
5fb4100
Used new skill api calls and interfaces
Tiebe-Vercoutter May 12, 2022
f449459
Fixes and toasts
Tiebe-Vercoutter May 12, 2022
3db3f9a
prettier
Tiebe-Vercoutter May 12, 2022
cab255e
Merge branch 'create_project_skills' into project_detail_page
Tiebe-Vercoutter May 13, 2022
fd2d699
adapt project detail page to new backend
Tiebe-Vercoutter May 13, 2022
3d51279
Show correct project roles in the project detail page
Tiebe-Vercoutter May 13, 2022
cdd6ce8
get and patch calls for projectroles and interface docs
Tiebe-Vercoutter May 13, 2022
2cb60f0
API calls to suggest students for a project role
Tiebe-Vercoutter May 14, 2022
4f025a5
add and delete students from projects via dnd
Tiebe-Vercoutter May 14, 2022
a7269a6
Updates to a project role suggestion
Tiebe-Vercoutter May 15, 2022
b659dc4
Merge branch 'develop' into project_detail_page
Tiebe-Vercoutter May 16, 2022
e0deb55
small fix
Tiebe-Vercoutter May 16, 2022
4434339
Merge branch 'websockets' into project_detail_page
Tiebe-Vercoutter May 16, 2022
0158609
Started working on an add modal to give motivation when adding a student
Tiebe-Vercoutter May 16, 2022
a332da1
add motivation modal functional
Tiebe-Vercoutter May 16, 2022
8569104
Merge branch 'develop' into project_detail_page
Tiebe-Vercoutter May 17, 2022
b1d8e2d
removed some leftover prints
Tiebe-Vercoutter May 17, 2022
a22d2ac
changed delete button and other style
Tiebe-Vercoutter May 17, 2022
a21662e
Merge branch 'develop' into create_project_skills
Tiebe-Vercoutter May 17, 2022
4fd22ba
use common create button
Tiebe-Vercoutter May 17, 2022
511fa8e
update cancel button
Tiebe-Vercoutter May 17, 2022
540501a
Add better placeholders + toast for invalid skill
Tiebe-Vercoutter May 17, 2022
69e3b6a
update add skills to make it more clear to the user
Tiebe-Vercoutter May 17, 2022
15cb6a6
prettier
Tiebe-Vercoutter May 17, 2022
a50fb9f
Merge branch 'develop' into project_detail_page
Tiebe-Vercoutter May 17, 2022
5b6f223
fix merge and add delete project role api call
Tiebe-Vercoutter May 17, 2022
2e9b41f
Merge remote-tracking branch 'origin/return_suggestion' into project_…
Tiebe-Vercoutter May 17, 2022
d0412f7
delete project role and other fixes
Tiebe-Vercoutter May 17, 2022
6b25c8c
update on adding a skill
Tiebe-Vercoutter May 17, 2022
9730180
Merge branch 'create_project_skills' into project_detail_page
Tiebe-Vercoutter May 17, 2022
bb0db6e
skill select form
Tiebe-Vercoutter May 17, 2022
2a19e24
only show delete sug button to admins and the coach who suggested
Tiebe-Vercoutter May 18, 2022
6b385cc
add new projectrole to existing project
Tiebe-Vercoutter May 18, 2022
b758d63
fix student undefined
Tiebe-Vercoutter May 18, 2022
556f028
Merge branch 'develop' into project_detail_page
Tiebe-Vercoutter May 19, 2022
4a78ba7
Switch student between roles
Tiebe-Vercoutter May 19, 2022
8ddd93e
refresh project when deleting items
Tiebe-Vercoutter May 19, 2022
0018436
fix dragging a student to a role it is already assigned to
Tiebe-Vercoutter May 19, 2022
9bcc2b9
Only use delete button to delete a student from a project role
Tiebe-Vercoutter May 19, 2022
24b9977
added and improved some toasts
Tiebe-Vercoutter May 19, 2022
2da8052
Added links to go to a student page
Tiebe-Vercoutter May 19, 2022
9d48706
Merge branch 'develop' into create_project_skills
Tiebe-Vercoutter May 19, 2022
5f337b4
Merge remote-tracking branch 'origin/info_url' into create_project_sk…
Tiebe-Vercoutter May 19, 2022
eee0ef7
add info url to project
Tiebe-Vercoutter May 19, 2022
8c29216
Bugfix: use info_url instead of infoUrl in payload
Tiebe-Vercoutter May 19, 2022
3fc0cb5
url validator frontend
Tiebe-Vercoutter May 19, 2022
f721bb3
prettier
Tiebe-Vercoutter May 19, 2022
7471290
some style fixes
Tiebe-Vercoutter May 19, 2022
b0ae29e
add color to number of students in a role
Tiebe-Vercoutter May 20, 2022
7c33425
align edit and delete buttons to the right
Tiebe-Vercoutter May 20, 2022
22ebecc
Merge branch 'develop' into project_detail_page
Tiebe-Vercoutter May 20, 2022
f196afe
fix merge
Tiebe-Vercoutter May 20, 2022
564560d
use common comps for input field and create project button
Tiebe-Vercoutter May 20, 2022
afe8dc5
use common delete button
Tiebe-Vercoutter May 20, 2022
c5a82cb
Merge branch 'create_project_skills' into project_page_enhancements
Tiebe-Vercoutter May 20, 2022
2a32478
Merge branch 'develop' into project_detail_page
Tiebe-Vercoutter May 20, 2022
47a5294
use student list for dnd
Tiebe-Vercoutter May 20, 2022
da40c19
fix dragdropcontext
Tiebe-Vercoutter May 20, 2022
53f50cd
another fix for dragdrop context
Tiebe-Vercoutter May 20, 2022
0144e30
Merge branch 'create_project_skills' into project_detail_page
Tiebe-Vercoutter May 20, 2022
9aab648
show project link and deleted old studentlist
Tiebe-Vercoutter May 20, 2022
d9eef83
delete import
Tiebe-Vercoutter May 20, 2022
413e962
Merge branch 'project_detail_page' into project_page_enhancements
Tiebe-Vercoutter May 20, 2022
d1dfdbb
Merge branch 'develop' into project_page_enhancements
Tiebe-Vercoutter May 20, 2022
d5562b1
show assigned / needed students
Tiebe-Vercoutter May 20, 2022
9a5d864
Merge branch 'develop' into create_project_skills
Tiebe-Vercoutter May 20, 2022
047dd8b
info_url can be null
Tiebe-Vercoutter May 21, 2022
4a4056c
only show more info button when there is an info url
Tiebe-Vercoutter May 21, 2022
6a21c20
removed debug print
Tiebe-Vercoutter May 21, 2022
61a8e21
Merge branch 'create_project_skills' into project_detail_page
Tiebe-Vercoutter May 21, 2022
f4db862
prettier
Tiebe-Vercoutter May 21, 2022
45547e4
Merge pull request #461 from SELab-2/project_detail_page
Tiebe-Vercoutter May 21, 2022
b8266ff
Merge branch 'develop' into create_project_skills
Tiebe-Vercoutter May 21, 2022
c4c2350
Merge branch 'project_page_enhancements' into create_project_skills
Tiebe-Vercoutter May 21, 2022
a132908
Merge branch 'develop' into create_project_skills
Tiebe-Vercoutter May 21, 2022
c213a5c
merge
Tiebe-Vercoutter May 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function AddedSkills({
if (event.target.valueAsNumber < 1) return item;
return {
...item,
amount: event.target.valueAsNumber,
slots: event.target.valueAsNumber,
};
}
return {
Expand All @@ -62,17 +62,18 @@ export default function AddedSkills({
<SkillContainer key={index}>
<TopContainer>
<TopLeftContainer>
<SkillName>{skill.skill}</SkillName>
<SkillName>{skill.skill.name}</SkillName>

<AmountInput
type="number"
value={skill.amount.toString()}
value={skill.slots.toString()}
placeholder="Amount"
min={1}
onChange={event => {
updateSkills(event, index, true);
}}
/>
{skill.slots === 1 ? <div>student</div> : <div>students</div>}
</TopLeftContainer>
<Delete
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ export const DescriptionInput = styled.input`
`;

export const AmountInput = styled.input`
margin: 5px;
margin: 5px 10px;
padding: 2px 10px;
background-color: #131329;
color: white;
border: none;
border-radius: 5px;
width: 100px;
direction: rtl;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function Coach({
if (e.key === "Enter") addCoach();
}}
list="users"
placeholder="Coach"
placeholder="Ex. Michael Scott"
/>
<datalist id="users">
{availableCoaches.map((availableCoach, _index) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Input } from "../../styles";

export default function InfoUrl({
infoUrl,
setInfoUrl,
}: {
infoUrl: string;
setInfoUrl: (infoUrl: string) => void;
}) {
return (
<Input
value={infoUrl}
onChange={e => setInfoUrl(e.target.value)}
placeholder="Ex. https://osoc.be/"
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./InfoUrl";
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { Input } from "../../styles";

export default function Name({ name, setName }: { name: string; setName: (name: string) => void }) {
return (
<Input value={name} onChange={e => setName(e.target.value)} placeholder="Project name" />
<Input
value={name}
onChange={e => setName(e.target.value)}
placeholder="Ex. UGent project"
/>
);
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function Partner({
if (e.key === "Enter") addPartner();
}}
list="partners"
placeholder="Partner"
placeholder="Ex. Open Knowledge Belgium"
/>

<datalist id="partners">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { useEffect, useState } from "react";
import { SkillProject } from "../../../../../data/interfaces/projects";
import { Skill } from "../../../../../data/interfaces/skills";
import { getSkills } from "../../../../../utils/api/skills";
import { Input, AddButton } from "../../styles";

export default function Skill({
export default function SkillInput({
skill,
setSkill,
skills,
Expand All @@ -12,7 +15,14 @@ export default function Skill({
skills: SkillProject[];
setSkills: (skills: SkillProject[]) => void;
}) {
const availableSkills = ["Frontend", "Backend", "Database", "Design"];
const [availableSkills, setAvailableSkills] = useState<Skill[]>([]);

useEffect(() => {
async function callCoaches() {
setAvailableSkills((await getSkills())?.skills || []);
}
callCoaches();
}, []);

return (
<div>
Expand All @@ -22,12 +32,12 @@ export default function Skill({
onKeyDown={e => {
if (e.key === "Enter") addSkill();
}}
placeholder="Skill"
placeholder="Ex. Front-end Developer"
list="skills"
/>
<datalist id="skills">
{availableSkills.map((availableCoach, _index) => {
return <option key={_index} value={availableCoach} />;
{availableSkills.map((availableSkill, _index) => {
return <option key={availableSkill.skillId} value={availableSkill.name} />;
})}
</datalist>

Expand All @@ -36,12 +46,18 @@ export default function Skill({
);

function addSkill() {
if (availableSkills.some(availableSkill => availableSkill === skill)) {
let skillToAdd: Skill | undefined;
availableSkills.forEach(availableSkill => {
if (availableSkill.name === skill) {
skillToAdd = availableSkill;
}
});
if (skillToAdd) {
const newSkills = [...skills];
const newSkill: SkillProject = {
skill: skill,
skill: skillToAdd,
description: "",
amount: 1,
slots: 1,
};
newSkills.push(newSkill);
setSkills(newSkills);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export { default as NameInput } from "./Name";
export { default as NumberOfStudentsInput } from "./NumberOfStudents";
export { default as CoachInput } from "./Coach";
export { default as SkillInput } from "./Skill";
export { default as PartnerInput } from "./Partner";
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
export {
NameInput,
NumberOfStudentsInput,
CoachInput,
SkillInput,
PartnerInput,
} from "./InputFields";
export { NameInput, CoachInput, SkillInput, PartnerInput } from "./InputFields";
export { default as AddedPartners } from "./AddedPartners";
export { default as AddedCoaches } from "./AddedCoaches";
export { default as AddedSkills } from "./AddedSkills";
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { useNavigate, useParams } from "react-router-dom";
import { Project } from "../../../data/interfaces";
import { useAuth } from "../../../contexts";
import { Role } from "../../../data/enums";
import { toast } from "react-toastify";

/**
*
Expand All @@ -43,7 +44,6 @@ export default function ProjectCard({
const [show, setShow] = useState(false);
const handleClose = () => setShow(false);
const handleShow = () => setShow(true);

const navigate = useNavigate();
const params = useParams();
const editionId = params.editionId!;
Expand All @@ -53,9 +53,10 @@ export default function ProjectCard({
const success = await deleteProject(editionId, project.projectId);
setShow(false);
if (!success) {
alert("Failed to delete the project");
toast.error("Could not delete project", { toastId: "deleteProject" });
} else {
removeProject(project);
toast.success("Deleted project", { toastId: "deletedProject" });
}
}

Expand Down Expand Up @@ -94,7 +95,9 @@ export default function ProjectCard({
))}
</Clients>
<NumberOfStudents>
{project.numberOfStudents}
{
// project.numberOfStudents
}
<BsPersonFill />
</NumberOfStudents>
</ClientContainer>
Expand Down
61 changes: 42 additions & 19 deletions frontend/src/data/interfaces/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
* This file contains all interfaces used in projects pages.
*/

import { Skill } from "./skills";
import { Student } from "./students";

/**
* Data about a partner.
*/
Expand All @@ -14,35 +17,47 @@ export interface Partner {
* Data about a coach.
*/
export interface Coach {
/** The user's ID */
userId: number;
/** The name of the coach */
name: string;
}

/** The user's ID */
userId: number;
export interface ProjectRoleSuggestion {
projectRoleSuggestionId: number;
argumentation: string;
drafter: Coach;
student: Student;
}

export interface ProjectRole {
projectRoleId: number;
projectId: number;
description: string;
skill: Skill;
slots: number;
suggestions: ProjectRoleSuggestion[];
}

/**
* Data about a project.
* Such as a list of the partners and the coaches
*/
export interface Project {
/** The project's ID */
projectId: number;

/** The name of the project */
name: string;

/** How many students are needed for this project */
numberOfStudents: number;

/** The partners of this project */
partners: Partner[];
/** An url with more info */
infoUrl: string;
Tiebe-Vercoutter marked this conversation as resolved.
Show resolved Hide resolved

/** The coaches of this project */
coaches: Coach[];

/** The name of the edition this project belongs to */
editionName: string;

/** The project's ID */
projectId: number;
/** The partners of this project */
partners: Partner[];
}

/**
Expand All @@ -58,13 +73,13 @@ export interface Projects {
*/
export interface SkillProject {
/** The name of the skill */
skill: string;
skill: Skill;

/** More info about this skill in a specific project */
description: string;

/** Number of positions of this skill in a project */
amount: number;
slots: number;
}

/**
Expand All @@ -74,11 +89,8 @@ export interface CreateProject {
/** The name of the new project */
name: string;

/** Number of students the project needs */
number_of_students: number;

/** The required skills for the project */
skills: string[];
/** An url with more info */
info_url: string;

/** The partners that belong to this project */
partners: string[];
Expand All @@ -87,6 +99,17 @@ export interface CreateProject {
coaches: number[];
}

export interface CreateProjectRole {
/** The id of the skill */
skill_id: number;

/** More info about this skill in a specific project */
description: string;

/** Number of positions of this skill in a project */
slots: number;
}

/**
* Data about a place in a project
*/
Expand Down
Loading