fix(openapi-ts): replace api call with generated api client
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user