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

Commit

Permalink
add info url to project
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiebe-Vercoutter committed May 19, 2022
1 parent 5f337b4 commit eee0ef7
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 9 deletions.
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";
6 changes: 6 additions & 0 deletions frontend/src/data/interfaces/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export interface Project {
/** The name of the project */
name: string;

/** An url with more info */
infoUrl: string;

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

Expand Down Expand Up @@ -86,6 +89,9 @@ export interface CreateProject {
/** The name of the new project */
name: string;

/** An url with more info */
infoUrl: string;

/** The partners that belong to this project */
partners: string[];

Expand Down
4 changes: 3 additions & 1 deletion frontend/src/utils/api/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,19 @@ export async function getProject(edition: string, projectId: number): Promise<Pr
export async function createProject(
edition: string,
name: string,
infoUrl: string,
partners: string[],
coaches: number[]
): Promise<Project | null> {
const payload: CreateProject = {
name: name,
infoUrl: infoUrl,
partners: partners,
coaches: coaches,
};

try {
const response = await axiosInstance.post("editions/" + edition + "/projects/", payload);
const response = await axiosInstance.post("editions/" + edition + "/projects", payload);
const project = response.data as Project;

return project;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,30 @@ import { User } from "../../../utils/api/users/users";
import { toast } from "react-toastify";
import { createProjectRole } from "../../../utils/api/projectRoles";
import { CreateButton } from "../../../components/Common/Buttons";
import InfoUrl from "../../../components/ProjectsComponents/CreateProjectComponents/InputFields/InfoUrl";
/**
* React component of the create project page.
* @returns The create project page.
*/

export default function CreateProjectPage() {
const [name, setName] = useState(""); // States for coaches
const [name, setName] = useState(""); // State for project name

const [infoUrl, setInfoUrl] = useState(""); // State for info link

const [coach, setCoach] = useState("");
const [coaches, setCoaches] = useState<User[]>([]); // States for skills
const [coaches, setCoaches] = useState<User[]>([]); // States for coaches

const [skill, setSkill] = useState("");
const [projectSkills, setProjectSkills] = useState<SkillProject[]>([]); // States for partners
const [projectSkills, setProjectSkills] = useState<SkillProject[]>([]); // States for skills

const [partner, setPartner] = useState("");
const [partners, setPartners] = useState<string[]>([]);
const [partners, setPartners] = useState<string[]>([]); // States for partners

const navigate = useNavigate();
const params = useParams();
const editionId = params.editionId!;

return (
<CenterContainer>
<CreateProjectContainer>
Expand All @@ -52,7 +57,10 @@ export default function CreateProjectPage() {
<Label>Name</Label>
<NameInput name={name} setName={setName} />

<Label>Coaches</Label>
<Label>Info Link</Label>
<InfoUrl infoUrl={infoUrl} setInfoUrl={setInfoUrl} />

<Label>Add Coaches</Label>
<CoachInput
coach={coach}
setCoach={setCoach}
Expand All @@ -61,7 +69,7 @@ export default function CreateProjectPage() {
/>
<AddedCoaches coaches={coaches} setCoaches={setCoaches} />

<Label>Skills</Label>
<Label>Add Skills</Label>
<SkillInput
skill={skill}
setSkill={setSkill}
Expand All @@ -70,7 +78,7 @@ export default function CreateProjectPage() {
/>
<AddedSkills skills={projectSkills} setSkills={setProjectSkills} />

<Label>Partners</Label>
<Label>Add Partners</Label>
<PartnerInput
partner={partner}
setPartner={setPartner}
Expand Down Expand Up @@ -112,7 +120,7 @@ export default function CreateProjectPage() {
coaches.forEach(coachToAdd => {
coachIds.push(coachToAdd.userId);
});
const response = await createProject(editionId, name, partners, coachIds);
const response = await createProject(editionId, name, infoUrl, partners, coachIds);

if (response) {
await toast.promise(addProjectRoles(response.projectId), {
Expand Down

0 comments on commit eee0ef7

Please sign in to comment.