diff --git a/frontend/src/GameList.tsx b/frontend/src/GameList.tsx
index 3caddcd..fc89e8a 100644
--- a/frontend/src/GameList.tsx
+++ b/frontend/src/GameList.tsx
@@ -5,6 +5,7 @@ import {
GameList as GameListProto,
Person as PersonProto,
Opinion,
+ AddOpinionRequest,
} from "../items";
import { Link } from "react-router-dom";
import { apiFetch, get_auth_status } from "./api";
@@ -457,27 +458,82 @@ export function GameList() {
{games.map((game) => {
const opinion = opinions.find((op) => op.title === game.title);
+ function handleOpinion(title: string, wouldPlay: boolean): void {
+ apiFetch(`/api/opinion`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/octet-stream",
+ },
+ body: AddOpinionRequest.encode(
+ AddOpinionRequest.create({
+ gameTitle: title,
+ wouldPlay,
+ })
+ ).finish(),
+ })
+ .then((res) => res.arrayBuffer())
+ .then((resBuffer) => {
+ const response = PersonProto.decode(
+ new Uint8Array(resBuffer)
+ );
+
+ setOpinions(response.opinion);
+ })
+ .catch((err) => {
+ console.error(err);
+ });
+ }
+
return (
-
- {game.title}
-
-
+
+
+
{game.title}
+
+
+
+
+
+
+
);
})}
diff --git a/frontend/src/PersonDetails.tsx b/frontend/src/PersonDetails.tsx
index 7e48124..b55688a 100644
--- a/frontend/src/PersonDetails.tsx
+++ b/frontend/src/PersonDetails.tsx
@@ -167,7 +167,13 @@ export const PersonDetails = () => {
Would Play
-