From e49aad75623b4301b0d30c61d37a15840574b56f Mon Sep 17 00:00:00 2001 From: SibiAkkash Date: Mon, 11 Dec 2023 17:55:33 +0530 Subject: [PATCH] edit-player-roles: Add modal to edit player roles --- frontend/src/components/ValidateRoster.js | 160 +++++++++++++++++++++- 1 file changed, 159 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/ValidateRoster.js b/frontend/src/components/ValidateRoster.js index 08770e31..c37ee577 100644 --- a/frontend/src/components/ValidateRoster.js +++ b/frontend/src/components/ValidateRoster.js @@ -8,9 +8,12 @@ import { handThumbDown, handThumbUp, noSymbol, + pencil, + plus, shieldCheck, shieldExclamation, - xCircle + xCircle, + xMark } from "solid-heroicons/solid-mini"; import { createEffect, createSignal, For, Match, Show, Switch } from "solid-js"; import { onMount } from "solid-js"; @@ -19,6 +22,152 @@ import { accreditationChoices, matchUpChoices, minAge } from "../constants"; import { useStore } from "../store"; import { fetchUrl, getAge, getLabel } from "../utils"; +const allRoles = [ + "captain", + "spirit captain", + "coach", + "assistant coach", + "admin", + "player" +]; + +const EditPlayerRoles = props => { + let dialogRef; + + const [roles, setRoles] = createSignal(props.registration?.roles); + + const otherRoles = () => allRoles.filter(role => !roles().includes(role)); + + const updatePlayerRoles = async registration => { + console.log( + `person_id: ${registration?.person?.id}, reg_id: ${ + registration?.id + }, roles: ${roles()}` + ); + // const response = await fetch("/api/player/set-roles", { + // method: "POST", + // headers: { + // "Content-Type": "application/json", + // "X-CSRFToken": getCookie("csrftoken") + // }, + // credentials: "same-origin", + // body: JSON.stringify({ + // person_id: registration.person.id, + // registration_id: registration.id, + // roles: roles() + // }) + // }); + }; + + return ( + <> + +
+
+
+ Player - + + {props.registration?.person?.first_name}{" "} + {props.registration?.person?.last_name} + +
+ +
+ +
+ +
+
Current roles
+
+ + {role => ( + <> + + {role} + + + + )} + +
+
+ +
+
Other roles
+
+ + {role => ( + <> + + {role} + + + + )} + +
+
+ + +
+
+ + + + ); +}; + const groupByTeam = registrations => { const teamsMap = registrations?.reduce( (acc, r) => ({ ...acc, [r.team.id]: r.team }), @@ -398,6 +547,15 @@ const ValidateRoster = () => { )} > + + + {registration.person.first_name}{" "} {registration.person.last_name}