fix(openapi-ts): first pass for replacing with openapi-ts

This commit is contained in:
Loïc Gremaud 2026-05-23 18:53:33 +02:00
parent 62a81e57ad
commit f1afb2096f
Signed by: Legrems
GPG Key ID: D4620E6DF3E0121D
6 changed files with 40 additions and 37 deletions

View File

@ -1,9 +1,8 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { apiService } from "./services/apiService";
import type { Game } from "./types";
import { gamesApiListGames } from "./api";
const games = ref<Game[]>([]);
const games = ref<any[]>([]);
const loading = ref(true);
const imageErrors = ref<Set<number>>(new Set());
@ -21,7 +20,7 @@ const navigate = (path: string) => {
};
onMounted(async () => {
const response = await apiService.getGames();
const response = await gamesApiListGames();
if (response.data) {
games.value = response.data;
}

View File

@ -1,11 +1,10 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { apiService } from "./services/apiService";
import type { Market } from "./types";
import { polylanSubmitterApiGetUserInfo, marketApiListMarkets } from "./api";
import MarketCard from "./components/MarketCard.vue";
import UserBets from "./components/UserBets.vue";
const markets = ref<Market[]>([]);
const markets = ref<any[]>([]);
const loading = ref(true);
const userInfo = ref<any>(null);
@ -19,13 +18,13 @@ const reloadPage = () => {
onMounted(async () => {
// Fetch user info
const userResponse = await apiService.getUserInfo();
const userResponse = await polylanSubmitterApiGetUserInfo();
if (userResponse.data) {
userInfo.value = userResponse.data;
}
// Fetch markets
const response = await apiService.getMarkets();
const response = await marketApiListMarkets();
if (response.data) {
markets.value = response.data;
}

View File

@ -7,7 +7,8 @@ import Results from "@/components/Results.vue";
import Winners from "@/components/Winners.vue";
import PuzzleResults from "@/components/PuzzleResults.vue";
import TopUsersLeaderboard from "@/components/TopUsersLeaderboard.vue";
import { apiService, errorHelpers } from "@/services/apiService";
import { polylanSubmitterApiGetUserInfo, submissionsApiGetCollection } from "@/api";
import { errorHelpers } from "@/services/apiService";
import { usePuzzlesStore } from "@/stores/puzzles";
import { useSubmissionsStore } from "@/stores/submissions";
import type { PuzzleResponse, UserInfo, SteamCollection } from "@/types";
@ -66,9 +67,9 @@ async function initialize() {
// Load user info
console.log("Loading user info...");
const userResponse = await apiService.getUserInfo();
const userResponse = await polylanSubmitterApiGetUserInfo();
if (userResponse.data) {
userInfo.value = userResponse.data;
userInfo.value = userResponse.data as UserInfo;
console.log("User info loaded:", userResponse.data);
} else if (userResponse.error) {
console.warn("User info error:", userResponse.error);
@ -76,9 +77,9 @@ async function initialize() {
// Load collection data
console.log("Loading collection...");
const collectionResponse = await apiService.getCollection();
const collectionResponse = await submissionsApiGetCollection();
if (collectionResponse.data) {
collection.value = collectionResponse.data;
collection.value = collectionResponse.data as SteamCollection;
console.log("Collection loaded:", collectionResponse.data);
} else if (collectionResponse.error) {
console.warn("Collection error:", collectionResponse.error);

View File

@ -1,7 +1,7 @@
<script setup lang="ts">
import { ref, computed, onMounted } from "vue";
import { apiService } from "../services/apiService";
import type { Market, UserBet } from "../types";
import { polylanSubmitterApiGetUserInfo, marketApiCreateBet, marketApiListUserBets } from "../api";
import type { Market } from "../types";
const props = defineProps<{
market: Market;
@ -16,8 +16,8 @@ const betAmount = ref<number>(0);
const loading = ref(false);
const error = ref<string>("");
const userInfo = ref<any>(null);
const userBets = ref<UserBet[]>([]);
const existingBet = ref<UserBet | null>(null);
const userBets = ref<any[]>([]);
const existingBet = ref<any | null>(null);
const timeRemaining = computed(() => {
const endDate = new Date(props.market.end_date).getTime();
@ -59,17 +59,22 @@ const placeBet = async () => {
error.value = "";
try {
const response = await apiService.placeBet(props.market.uuid, {
option_uuid: selectedOption.value,
amount: betAmount.value,
const response = await marketApiCreateBet({
path: {
market_uuid: props.market.uuid
},
body: {
option_uuid: selectedOption.value,
amount: betAmount.value,
},
});
if (response.status === 200 || response.status === 201) {
if (!response.error) {
// Reload user bets to reflect the new bet
await loadUserBets();
betAmount.value = 0;
} else {
error.value = response.error || "Failed to place bet";
error.value = String(response.error) || "Failed to place bet";
}
} catch (e) {
error.value = "Error placing bet";
@ -79,18 +84,18 @@ const placeBet = async () => {
};
const initializeUserInfo = async () => {
const response = await apiService.getUserInfo();
const response = await polylanSubmitterApiGetUserInfo();
if (response.data) {
userInfo.value = response.data;
}
};
const loadUserBets = async () => {
const response = await apiService.getUserBets();
const response = await marketApiListUserBets();
if (response.data) {
userBets.value = response.data;
// Find if user has a bet on this market
existingBet.value = response.data.find(bet => bet.market.uuid === props.market.uuid) || null;
existingBet.value = response.data.find(bet => bet.market?.uuid === props.market.uuid) || null;
if (existingBet.value) {
selectedOption.value = existingBet.value.option.uuid;
betAmount.value = existingBet.value.amount;

View File

@ -1,13 +1,12 @@
<script setup lang="ts">
import { ref, onMounted, computed } from "vue";
import { apiService } from "../services/apiService";
import type { UserBet } from "../types";
import { marketApiListUserBets } from "../api";
defineEmits<{
refresh: [];
}>();
const userBets = ref<UserBet[]>([]);
const userBets = ref<any[]>([]);
const loading = ref(true);
const totalBetAmount = computed(() => {
@ -37,7 +36,7 @@ const totalWinnings = computed(() => {
});
onMounted(async () => {
const response = await apiService.getUserBets();
const response = await marketApiListUserBets();
if (response.data) {
userBets.value = response.data;
}

View File

@ -1,11 +1,11 @@
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import type { SteamCollectionItem } from '@/types'
import { apiService } from '@/services/apiService'
import { submissionsApiListPuzzles } from '@/api'
export const usePuzzlesStore = defineStore('puzzles', () => {
// State
const puzzles = ref<SteamCollectionItem[]>([])
const puzzles = ref<any[]>([])
const isLoading = ref(false)
const error = ref<string>('')
@ -38,9 +38,9 @@ export const usePuzzlesStore = defineStore('puzzles', () => {
isLoading.value = true
error.value = ''
const response = await apiService.getPuzzles()
const response = await submissionsApiListPuzzles()
if (response.error) {
error.value = response.error
error.value = String(response.error)
console.error('Failed to load puzzles:', response.error)
return
}