feat: Implement client-side routing for person list and details, including adding opinions.

This commit is contained in:
2025-12-02 21:45:16 +01:00
parent f30af57934
commit 30950e6c83
6 changed files with 289 additions and 29 deletions
+84 -3
View File
@@ -101,6 +101,11 @@ export interface GameRequest {
title: string;
}
export interface AddOpinionRequest {
gameTitle: string;
wouldPlay: boolean;
}
function createBasePerson(): Person {
return { name: "", opinion: [] };
}
@@ -979,6 +984,82 @@ export const GameRequest: MessageFns<GameRequest> = {
},
};
function createBaseAddOpinionRequest(): AddOpinionRequest {
return { gameTitle: "", wouldPlay: false };
}
export const AddOpinionRequest: MessageFns<AddOpinionRequest> = {
encode(message: AddOpinionRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.gameTitle !== "") {
writer.uint32(10).string(message.gameTitle);
}
if (message.wouldPlay !== false) {
writer.uint32(16).bool(message.wouldPlay);
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): AddOpinionRequest {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseAddOpinionRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.gameTitle = reader.string();
continue;
}
case 2: {
if (tag !== 16) {
break;
}
message.wouldPlay = reader.bool();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): AddOpinionRequest {
return {
gameTitle: isSet(object.gameTitle) ? globalThis.String(object.gameTitle) : "",
wouldPlay: isSet(object.wouldPlay) ? globalThis.Boolean(object.wouldPlay) : false,
};
},
toJSON(message: AddOpinionRequest): unknown {
const obj: any = {};
if (message.gameTitle !== "") {
obj.gameTitle = message.gameTitle;
}
if (message.wouldPlay !== false) {
obj.wouldPlay = message.wouldPlay;
}
return obj;
},
create<I extends Exact<DeepPartial<AddOpinionRequest>, I>>(base?: I): AddOpinionRequest {
return AddOpinionRequest.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<AddOpinionRequest>, I>>(object: I): AddOpinionRequest {
const message = createBaseAddOpinionRequest();
message.gameTitle = object.gameTitle ?? "";
message.wouldPlay = object.wouldPlay ?? false;
return message;
},
};
/** Authentication service */
export interface AuthService {
Login(request: LoginRequest): Promise<LoginResponse>;
@@ -1018,7 +1099,7 @@ export class AuthServiceClientImpl implements AuthService {
export interface MainService {
GetGame(request: GameRequest): Promise<Game>;
AddOpinion(request: GameRequest): Promise<Person>;
AddOpinion(request: AddOpinionRequest): Promise<Person>;
}
export const MainServiceServiceName = "items.MainService";
@@ -1037,8 +1118,8 @@ export class MainServiceClientImpl implements MainService {
return promise.then((data) => Game.decode(new BinaryReader(data)));
}
AddOpinion(request: GameRequest): Promise<Person> {
const data = GameRequest.encode(request).finish();
AddOpinion(request: AddOpinionRequest): Promise<Person> {
const data = AddOpinionRequest.encode(request).finish();
const promise = this.rpc.request(this.service, "AddOpinion", data);
return promise.then((data) => Person.decode(new BinaryReader(data)));
}