fix(openapi-ts): replace api call with generated api client

This commit is contained in:
Loïc Gremaud 2026-05-23 19:51:08 +02:00
parent f1afb2096f
commit 43b314bb20
Signed by: Legrems
GPG Key ID: D4620E6DF3E0121D
6 changed files with 29 additions and 24 deletions

View File

@ -1,8 +1,9 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { gamesApiListGames } from "./api";
import type { GamesApiListGamesResponse } from "./api/types.gen";
const games = ref<any[]>([]);
const games = ref<GamesApiListGamesResponse | undefined>();
const loading = ref(true);
const imageErrors = ref<Set<number>>(new Set());

View File

@ -1,12 +1,14 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { polylanSubmitterApiGetUserInfo, marketApiListMarkets } from "./api";
import type { UserInfoOut } from "./api/types.gen";
import type { Market } from "./types";
import MarketCard from "./components/MarketCard.vue";
import UserBets from "./components/UserBets.vue";
const markets = ref<any[]>([]);
const markets = ref<Market[]>([]);
const loading = ref(true);
const userInfo = ref<any>(null);
const userInfo = ref<UserInfoOut | undefined>();
const goHome = () => {
window.location.href = "/";
@ -26,7 +28,7 @@ onMounted(async () => {
// Fetch markets
const response = await marketApiListMarkets();
if (response.data) {
markets.value = response.data;
markets.value = response.data as unknown as Market[];
}
loading.value = false;
});

View File

@ -2,6 +2,7 @@
import { ref, computed, onMounted } from "vue";
import { polylanSubmitterApiGetUserInfo, marketApiCreateBet, marketApiListUserBets } from "../api";
import type { Market } from "../types";
import type { UserInfoOut, UserBetSchema } from "../api/types.gen";
const props = defineProps<{
market: Market;
@ -15,9 +16,9 @@ const selectedOption = ref<string | null>(null);
const betAmount = ref<number>(0);
const loading = ref(false);
const error = ref<string>("");
const userInfo = ref<any>(null);
const userBets = ref<any[]>([]);
const existingBet = ref<any | null>(null);
const userInfo = ref<UserInfoOut | undefined>();
const userBets = ref<UserBetSchema[]>([]);
const existingBet = ref<UserBetSchema | null>(null);
const timeRemaining = computed(() => {
const endDate = new Date(props.market.end_date).getTime();

View File

@ -1,12 +1,13 @@
<script setup lang="ts">
import { ref, onMounted, computed } from "vue";
import { marketApiListUserBets } from "../api";
import type { UserBetSchema } from "../api/types.gen";
defineEmits<{
refresh: [];
}>();
const userBets = ref<any[]>([]);
const userBets = ref<UserBetSchema[]>([]);
const loading = ref(true);
const totalBetAmount = computed(() => {
@ -16,19 +17,19 @@ const totalBetAmount = computed(() => {
const winningBets = computed(() => {
return userBets.value.filter(bet => {
const market = bet.market;
return market.status === "resolved" && market.winning_option?.uuid === bet.option.uuid;
return market?.status === "resolved" && market?.winning_option?.uuid === bet.option.uuid;
});
});
const losingBets = computed(() => {
return userBets.value.filter(bet => {
const market = bet.market;
return market.status === "resolved" && market.winning_option?.uuid !== bet.option.uuid;
return market?.status === "resolved" && market?.winning_option?.uuid !== bet.option.uuid;
});
});
const openBets = computed(() => {
return userBets.value.filter(bet => bet.market.status === "open");
return userBets.value.filter(bet => bet.market?.status === "open");
});
const totalWinnings = computed(() => {
@ -103,7 +104,7 @@ onMounted(async () => {
<div class="card-body py-4">
<div class="flex justify-between items-start">
<div class="flex-1">
<h4 class="font-semibold text-lg">{{ bet.market.title }}</h4>
<h4 class="font-semibold text-lg">{{ bet.market?.title }}</h4>
<p class="text-sm text-base-content/70">
Bet on: <span class="font-medium">{{ bet.option.text }}</span>
</p>
@ -111,7 +112,7 @@ onMounted(async () => {
<div class="text-right">
<div class="text-lg font-bold">{{ bet.amount }} pts</div>
<div class="text-xs text-base-content/60 mt-1">
Status: <span class="badge badge-info badge-sm">{{ bet.market.status }}</span>
Status: <span class="badge badge-info badge-sm">{{ bet.market?.status }}</span>
</div>
</div>
</div>
@ -135,7 +136,7 @@ onMounted(async () => {
<div class="card-body py-4">
<div class="flex justify-between items-start">
<div class="flex-1">
<h4 class="font-semibold text-lg">{{ bet.market.title }}</h4>
<h4 class="font-semibold text-lg">{{ bet.market?.title }}</h4>
<p class="text-sm text-base-content/70">
Correct! You bet on: <span class="font-medium text-success">{{ bet.option.text }}</span>
</p>
@ -164,12 +165,12 @@ onMounted(async () => {
<div class="card-body py-4">
<div class="flex justify-between items-start">
<div class="flex-1">
<h4 class="font-semibold text-lg">{{ bet.market.title }}</h4>
<h4 class="font-semibold text-lg">{{ bet.market?.title }}</h4>
<p class="text-sm text-base-content/70">
You bet on: <span class="font-medium">{{ bet.option.text }}</span>
</p>
<p class="text-sm text-base-content/60 mt-1">
Winner: <span class="font-medium">{{ bet.market.winning_option?.text }}</span>
Winner: <span class="font-medium">{{ bet.market?.winning_option?.text }}</span>
</p>
</div>
<div class="text-right">

View File

@ -1,11 +1,11 @@
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import type { SteamCollectionItem } from '@/types'
import { submissionsApiListPuzzles } from '@/api'
import type { SteamCollectionItem } from '@/types'
export const usePuzzlesStore = defineStore('puzzles', () => {
// State
const puzzles = ref<any[]>([])
const puzzles = ref<SteamCollectionItem[]>([])
const isLoading = ref(false)
const error = ref<string>('')
@ -14,7 +14,7 @@ export const usePuzzlesStore = defineStore('puzzles', () => {
const findPuzzleByName = computed(() => (name: string): SteamCollectionItem | null => {
if (!name) return null
// First try exact match (case insensitive)
const exactMatch = puzzles.value.find(
puzzle => puzzle.title.toLowerCase() === name.toLowerCase()
@ -26,7 +26,7 @@ export const usePuzzlesStore = defineStore('puzzles', () => {
puzzle => puzzle.title.toLowerCase().includes(name.toLowerCase()) ||
name.toLowerCase().includes(puzzle.title.toLowerCase())
)
return partialMatch || null
})
@ -46,7 +46,7 @@ export const usePuzzlesStore = defineStore('puzzles', () => {
}
if (response.data) {
puzzles.value = response.data
puzzles.value = response.data as unknown as SteamCollectionItem[]
}
} catch (err) {
error.value = 'Failed to load puzzles'

View File

@ -30,9 +30,9 @@ export interface SteamCollectionItem {
title: string
author_name: string
description: string
tags: string[]
order_index: number
collection: number
tags?: string[]
order_index?: number
steam_url: string
points_factor?: PointsFactor
created_at: string
updated_at: string