This commit is contained in:
2024-07-13 21:48:03 +03:00
parent 065cfe1413
commit bbce1fb05f
3 changed files with 26 additions and 7 deletions

View File

@ -41,7 +41,7 @@ func main() {
return return
} }
if len(req.Events) > 10 { if len(req.Events) > 11 {
c.JSON(http.StatusBadRequest, gin.H{ c.JSON(http.StatusBadRequest, gin.H{
"error": "too many events", "error": "too many events",
}) })

View File

@ -19,8 +19,8 @@ type PermWithTime struct {
} }
type AssignmentWithTime struct { type AssignmentWithTime struct {
Assignment Assignment Assignment Assignment `json:"assignment"`
Time float64 Time float64 `json:"time"`
} }
type Config struct { type Config struct {

View File

@ -4,7 +4,8 @@ import SolverForm from "./SolverForm";
import axios from "axios"; import axios from "axios";
type Assignment = { type Assignment = {
[solver: string]: string[]; solver: string;
events: string[];
}; };
const backend = axios.create({ baseURL: "http://localhost:8080" }); const backend = axios.create({ baseURL: "http://localhost:8080" });
@ -66,8 +67,14 @@ const RelayForm: React.FC = () => {
.post("/relay", data) .post("/relay", data)
.then((response) => { .then((response) => {
setRelayTime(response.data.response.time); setRelayTime(response.data.response.time);
console.log("assi", response.data.response.assignment); setAssignments(
setAssignments(response.data.response.assignment); Object.entries(response.data.response.assignment).map(
([solver, events]) => ({
solver,
events: events as string[],
}),
),
);
}) })
.catch((error) => { .catch((error) => {
console.error(error); console.error(error);
@ -92,7 +99,19 @@ const RelayForm: React.FC = () => {
<Statistic title="Relay Time" value={relayTime} precision={2} /> <Statistic title="Relay Time" value={relayTime} precision={2} />
</Space> </Space>
<Space> <Space>
{Object.entries(assignments).toString()} {assignments.map((assignment, index) => (
<Card
key={index}
title={assignment.solver}
style={{ width: 300, margin: "16px" }}
>
<div>
{assignment.events.map((event, idx) => (
<Tag key={idx}>{event}</Tag>
))}
</div>
</Card>
))}
</Space> </Space>
</Space> </Space>
); );