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

This commit is contained in:
2026-05-23 18:53:33 +02:00
parent 62a81e57ad
commit f1afb2096f
6 changed files with 40 additions and 37 deletions
+17 -12
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;
@@ -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;
}