From c7874d6d111646ba6af60d6863cc47a87c13489c Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Wed, 11 Dec 2024 20:30:26 -0800 Subject: [PATCH] fix: Fix being unable to do player actions --- .../src/client/services/DefaultService.ts | 6 +++--- availabili.tf/src/stores/teams.ts | 8 ++++---- availabili.tf/src/stores/teams/integrations.ts | 4 ++-- availabili.tf/src/stores/teams/invites.ts | 6 +++--- backend-flask/team.py | 15 +++++++++------ 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/availabili.tf/src/client/services/DefaultService.ts b/availabili.tf/src/client/services/DefaultService.ts index bf3b07f..c290348 100644 --- a/availabili.tf/src/client/services/DefaultService.ts +++ b/availabili.tf/src/client/services/DefaultService.ts @@ -596,7 +596,7 @@ export class DefaultService { */ public editMemberRoles( teamId: number, - targetPlayerId: number, + targetPlayerId: string, requestBody?: EditMemberRolesJson, ): CancelablePromise { return this.httpRequest.request({ @@ -735,7 +735,7 @@ export class DefaultService { */ public createOrUpdatePlayer( teamId: number, - playerId: number, + playerId: string, requestBody?: AddPlayerJson, ): CancelablePromise { return this.httpRequest.request({ @@ -763,7 +763,7 @@ export class DefaultService { */ public removePlayerFromTeam( teamId: number, - targetPlayerId: number, + targetPlayerId: string, ): CancelablePromise { return this.httpRequest.request({ method: 'DELETE', diff --git a/availabili.tf/src/stores/teams.ts b/availabili.tf/src/stores/teams.ts index ab7eca7..fe2cea2 100644 --- a/availabili.tf/src/stores/teams.ts +++ b/availabili.tf/src/stores/teams.ts @@ -35,7 +35,7 @@ export const useTeamsStore = defineStore("teams", () => { async function fetchTeam(id: number) { const response = await clientStore.call( fetchTeam.name, - () => client.default.getTeam(id.toString()) + () => client.default.getTeam(id) ); teams[response.team.id] = response.team; return response; @@ -44,7 +44,7 @@ export const useTeamsStore = defineStore("teams", () => { async function fetchTeamMembers(id: number) { const response = await clientStore.call( fetchTeamMembers.name, - () => client.default.getTeamMembers(id.toString()) + () => client.default.getTeamMembers(id) ); teamMembers[id] = response.map((member): ViewTeamMembersResponse => { member.roles = member.roles.sort((a, b) => (a.isMain === b.isMain ? 0 : a.isMain ? -1 : 1)); @@ -68,11 +68,11 @@ export const useTeamsStore = defineStore("teams", () => { } async function updateRoles(teamId: number, playerId: string, roles: RoleSchema[]) { - return await client.default.editMemberRoles(teamId.toString(), playerId, { roles }); + return await client.default.editMemberRoles(teamId, playerId, { roles }); } async function leaveTeam(teamId: number) { - return client.default.removePlayerFromTeam(teamId.toString(), authStore.steamId); + return client.default.removePlayerFromTeam(teamId, authStore.steamId); } return { diff --git a/availabili.tf/src/stores/teams/integrations.ts b/availabili.tf/src/stores/teams/integrations.ts index d1f2c77..384672a 100644 --- a/availabili.tf/src/stores/teams/integrations.ts +++ b/availabili.tf/src/stores/teams/integrations.ts @@ -18,7 +18,7 @@ export const useIntegrationsStore = defineStore("integrations", () => { async function getIntegrations(teamId: number) { hasLoaded.value = false; - const response = await client.default.getIntegrations(teamId.toString()); + const response = await client.default.getIntegrations(teamId); setIntegrations(response); return response; } @@ -34,7 +34,7 @@ export const useIntegrationsStore = defineStore("integrations", () => { discordIntegration: discordIntegration.value ?? null, logsTfIntegration: logsTfIntegration.value ?? null, }; - const response = await client.default.updateIntegrations(teamId.toString(), body); + const response = await client.default.updateIntegrations(teamId, body); setIntegrations(response); return response; } diff --git a/availabili.tf/src/stores/teams/invites.ts b/availabili.tf/src/stores/teams/invites.ts index 49b5b64..667c2af 100644 --- a/availabili.tf/src/stores/teams/invites.ts +++ b/availabili.tf/src/stores/teams/invites.ts @@ -12,7 +12,7 @@ export const useInvitesStore = defineStore("invites", () => { async function getInvites(teamId: number) { return clientStore.call( getInvites.name, - () => client.default.getInvites(teamId.toString()), + () => client.default.getInvites(teamId), (response) => { teamInvites[teamId] = response; return response; @@ -21,7 +21,7 @@ export const useInvitesStore = defineStore("invites", () => { } async function createInvite(teamId: number) { - const response = await client.default.createInvite(teamId.toString()); + const response = await client.default.createInvite(teamId); teamInvites[teamId].push(response); return response; } @@ -37,7 +37,7 @@ export const useInvitesStore = defineStore("invites", () => { } async function revokeInvite(teamId: number, key: string) { - const response = await client.default.revokeInvite(teamId.toString(), key); + const response = await client.default.revokeInvite(teamId, key); teamInvites[teamId] = teamInvites[teamId].filter((invite) => invite.key != key); return response; } diff --git a/backend-flask/team.py b/backend-flask/team.py index b0a34ff..b539abc 100644 --- a/backend-flask/team.py +++ b/backend-flask/team.py @@ -135,7 +135,7 @@ def delete_team(player: Player, team_id: int): db.session.commit() return make_response(200) -@api_team.delete("/id//player//") +@api_team.delete("/id//player//") @spec.validate( resp=Response( HTTP_200=None, @@ -145,7 +145,8 @@ def delete_team(player: Player, team_id: int): operation_id="remove_player_from_team" ) @requires_authentication -def remove_player_from_team(player: Player, team_id: int, target_player_id: int, **kwargs): +def remove_player_from_team(player: Player, team_id: int, target_player_id: str, **kwargs): + target_player_id: int = int(target_player_id) player_team = db.session.query( PlayerTeam ).where( @@ -202,7 +203,7 @@ class AddPlayerJson(BaseModel): team_role: PlayerTeam.TeamRole = PlayerTeam.TeamRole.Player is_team_leader: bool = False -@api_team.put("/id//player//") +@api_team.put("/id//player//") @spec.validate( resp=Response( HTTP_200=None, @@ -211,7 +212,8 @@ class AddPlayerJson(BaseModel): ), operation_id="create_or_update_player" ) -def add_player(player: Player, team_id: int, player_id: int, json: AddPlayerJson): +def add_player(player: Player, team_id: int, player_id: str, json: AddPlayerJson): + player_id: int = int(player_id) player_team = db.session.query( PlayerTeam ).where( @@ -387,7 +389,7 @@ def view_team_members(player: Player, team_id: int, **kwargs): class EditMemberRolesJson(BaseModel): roles: list[RoleSchema] -@api_team.patch("/id//edit-player/") +@api_team.patch("/id//edit-player/") @spec.validate( resp=Response( HTTP_204=None, @@ -401,9 +403,10 @@ def edit_member_roles( json: EditMemberRolesJson, player: Player, team_id: int, - target_player_id: int, + target_player_id: str, **kwargs, ): + target_player_id: int = int(target_player_id) target_player = db.session.query( PlayerTeam ).where(