From 6e2477f430456334f07769ba88269fc3d61051bf Mon Sep 17 00:00:00 2001 From: julius Date: Sat, 25 Jan 2025 17:15:34 +0100 Subject: [PATCH] feat: implement `MVP` --- main.py | 2 +- src/App.tsx | 11 +++- src/Chemistry.tsx | 152 +++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 148 insertions(+), 17 deletions(-) diff --git a/main.py b/main.py index 6980bde..3ad1405 100644 --- a/main.py +++ b/main.py @@ -47,4 +47,4 @@ def submit_chemistry(chemistry: Chemistry): app.mount("/", StaticFiles(directory="dist", html=True), name="site") # if __name__ == "__main__": -# uvicorn.run("main:app", workers=1, port=8096) +# uvicorn.run("main:app", workers=1, port=8000, host="0.0.0.0") diff --git a/src/App.tsx b/src/App.tsx index e6987d6..a056599 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,10 +1,19 @@ import "./App.css"; -import Chemistry from "./Chemistry"; +import { Chemistry, MVP } from "./Chemistry"; function App() { return ( <> + logo +

cutt

+ cool ultimate team tool + +
+

+ something not working? message me. +

+
); } diff --git a/src/Chemistry.tsx b/src/Chemistry.tsx index 01074d7..8562a2e 100644 --- a/src/Chemistry.tsx +++ b/src/Chemistry.tsx @@ -1,5 +1,5 @@ import { useState } from "react"; -import { ReactSortable, ReactSortableProps } from "react-sortablejs"; +import { ReactSortable, ReactSortableProps, Sortable } from "react-sortablejs"; import api from "./api"; interface Player { @@ -42,7 +42,7 @@ function PlayerList(props: PlayerListProps) { ); } -export default function Chemistry() { +export function Chemistry() { const players = loadPlayers(); const [user, setUser] = useState([]); const [playersLeft, setPlayersLeft] = useState([]); @@ -70,13 +70,26 @@ export default function Chemistry() { return ( <> - logo -

cutt

- cool ultimate team tool
-

your name?

- {user.length < 1 && ( - drag your name here: + your name? + {user.length < 1 ? ( + <> +
drag your name here + + ) : ( + <> + { + let newMiddle = user.concat(playersMiddle); + setPlayersMiddle(newMiddle); + setUser([]); + }} + > + {" "} + ⟳ + +
+ )} 😬 {playersLeft.length < 1 && ( - drag people here that you'd rather not play with + drag people here that you'd rather not play with from worst to ... + ok )} 😍 {playersRight.length < 1 && ( - drag people here that you love playing with + drag people here that you love playing with from best to ... ok )} {dialog} -
-

- something not working? message me. -

-
+ + ); +} + +export function MVP() { + const players = loadPlayers(); + const [user, setUser] = useState([]); + const [availablePlayers, setAvailablePlayers] = useState(players); + const [rankedPlayers, setRankedPlayers] = useState([]); + + const [dialog, setDialog] = useState("dialog"); + + async function handleSubmit() { + const dialog = document.querySelector("dialog"); + dialog?.showModal(); + if (user.length < 1) { + setDialog("who are you?"); + } else { + setDialog("sending..."); + let _user = user.map(({ name }) => name)[0]; + let mvps = rankedPlayers.map(({ name }) => name); + const data = { user: _user, rankedPlayers: mvps }; + const response = await api("mvp", data); + response.ok ? setDialog("success!") : setDialog("try sending again"); + } + } + + return ( + <> +
+ your name? + {user.length < 1 ? ( + <> +
drag your name here + + ) : ( + <> + { + setUser([]); + }} + > + {" "} + ⟳ + +
+ + )} + +
+
+
+

🥏🏃

+ {availablePlayers.length < 1 && ( + all sorted 👍 + )} + +
+
+

🏆

+ {rankedPlayers.length < 1 && ( + + carefully place the{" "} + + Most Valued Player + {" "} + (according to your humble opinion) in this box + + )} + +
+
+ + + { + event.currentTarget.close(); + }} + > + {dialog} + ); }