fix(openapi-ts): replace api call with generated api client
This commit is contained in:
parent
f1afb2096f
commit
43b314bb20
@ -1,8 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
import { gamesApiListGames } from "./api";
|
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 loading = ref(true);
|
||||||
|
|
||||||
const imageErrors = ref<Set<number>>(new Set());
|
const imageErrors = ref<Set<number>>(new Set());
|
||||||
|
|||||||
@ -1,12 +1,14 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
import { polylanSubmitterApiGetUserInfo, marketApiListMarkets } from "./api";
|
import { polylanSubmitterApiGetUserInfo, marketApiListMarkets } from "./api";
|
||||||
|
import type { UserInfoOut } from "./api/types.gen";
|
||||||
|
import type { Market } from "./types";
|
||||||
import MarketCard from "./components/MarketCard.vue";
|
import MarketCard from "./components/MarketCard.vue";
|
||||||
import UserBets from "./components/UserBets.vue";
|
import UserBets from "./components/UserBets.vue";
|
||||||
|
|
||||||
const markets = ref<any[]>([]);
|
const markets = ref<Market[]>([]);
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
const userInfo = ref<any>(null);
|
const userInfo = ref<UserInfoOut | undefined>();
|
||||||
|
|
||||||
const goHome = () => {
|
const goHome = () => {
|
||||||
window.location.href = "/";
|
window.location.href = "/";
|
||||||
@ -26,7 +28,7 @@ onMounted(async () => {
|
|||||||
// Fetch markets
|
// Fetch markets
|
||||||
const response = await marketApiListMarkets();
|
const response = await marketApiListMarkets();
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
markets.value = response.data;
|
markets.value = response.data as unknown as Market[];
|
||||||
}
|
}
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
import { ref, computed, onMounted } from "vue";
|
import { ref, computed, onMounted } from "vue";
|
||||||
import { polylanSubmitterApiGetUserInfo, marketApiCreateBet, marketApiListUserBets } from "../api";
|
import { polylanSubmitterApiGetUserInfo, marketApiCreateBet, marketApiListUserBets } from "../api";
|
||||||
import type { Market } from "../types";
|
import type { Market } from "../types";
|
||||||
|
import type { UserInfoOut, UserBetSchema } from "../api/types.gen";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
market: Market;
|
market: Market;
|
||||||
@ -15,9 +16,9 @@ const selectedOption = ref<string | null>(null);
|
|||||||
const betAmount = ref<number>(0);
|
const betAmount = ref<number>(0);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const error = ref<string>("");
|
const error = ref<string>("");
|
||||||
const userInfo = ref<any>(null);
|
const userInfo = ref<UserInfoOut | undefined>();
|
||||||
const userBets = ref<any[]>([]);
|
const userBets = ref<UserBetSchema[]>([]);
|
||||||
const existingBet = ref<any | null>(null);
|
const existingBet = ref<UserBetSchema | null>(null);
|
||||||
|
|
||||||
const timeRemaining = computed(() => {
|
const timeRemaining = computed(() => {
|
||||||
const endDate = new Date(props.market.end_date).getTime();
|
const endDate = new Date(props.market.end_date).getTime();
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, computed } from "vue";
|
import { ref, onMounted, computed } from "vue";
|
||||||
import { marketApiListUserBets } from "../api";
|
import { marketApiListUserBets } from "../api";
|
||||||
|
import type { UserBetSchema } from "../api/types.gen";
|
||||||
|
|
||||||
defineEmits<{
|
defineEmits<{
|
||||||
refresh: [];
|
refresh: [];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const userBets = ref<any[]>([]);
|
const userBets = ref<UserBetSchema[]>([]);
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
|
|
||||||
const totalBetAmount = computed(() => {
|
const totalBetAmount = computed(() => {
|
||||||
@ -16,19 +17,19 @@ const totalBetAmount = computed(() => {
|
|||||||
const winningBets = computed(() => {
|
const winningBets = computed(() => {
|
||||||
return userBets.value.filter(bet => {
|
return userBets.value.filter(bet => {
|
||||||
const market = bet.market;
|
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(() => {
|
const losingBets = computed(() => {
|
||||||
return userBets.value.filter(bet => {
|
return userBets.value.filter(bet => {
|
||||||
const market = bet.market;
|
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(() => {
|
const openBets = computed(() => {
|
||||||
return userBets.value.filter(bet => bet.market.status === "open");
|
return userBets.value.filter(bet => bet.market?.status === "open");
|
||||||
});
|
});
|
||||||
|
|
||||||
const totalWinnings = computed(() => {
|
const totalWinnings = computed(() => {
|
||||||
@ -103,7 +104,7 @@ onMounted(async () => {
|
|||||||
<div class="card-body py-4">
|
<div class="card-body py-4">
|
||||||
<div class="flex justify-between items-start">
|
<div class="flex justify-between items-start">
|
||||||
<div class="flex-1">
|
<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">
|
<p class="text-sm text-base-content/70">
|
||||||
Bet on: <span class="font-medium">{{ bet.option.text }}</span>
|
Bet on: <span class="font-medium">{{ bet.option.text }}</span>
|
||||||
</p>
|
</p>
|
||||||
@ -111,7 +112,7 @@ onMounted(async () => {
|
|||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<div class="text-lg font-bold">{{ bet.amount }} pts</div>
|
<div class="text-lg font-bold">{{ bet.amount }} pts</div>
|
||||||
<div class="text-xs text-base-content/60 mt-1">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -135,7 +136,7 @@ onMounted(async () => {
|
|||||||
<div class="card-body py-4">
|
<div class="card-body py-4">
|
||||||
<div class="flex justify-between items-start">
|
<div class="flex justify-between items-start">
|
||||||
<div class="flex-1">
|
<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">
|
<p class="text-sm text-base-content/70">
|
||||||
Correct! You bet on: <span class="font-medium text-success">{{ bet.option.text }}</span>
|
Correct! You bet on: <span class="font-medium text-success">{{ bet.option.text }}</span>
|
||||||
</p>
|
</p>
|
||||||
@ -164,12 +165,12 @@ onMounted(async () => {
|
|||||||
<div class="card-body py-4">
|
<div class="card-body py-4">
|
||||||
<div class="flex justify-between items-start">
|
<div class="flex justify-between items-start">
|
||||||
<div class="flex-1">
|
<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">
|
<p class="text-sm text-base-content/70">
|
||||||
You bet on: <span class="font-medium">{{ bet.option.text }}</span>
|
You bet on: <span class="font-medium">{{ bet.option.text }}</span>
|
||||||
</p>
|
</p>
|
||||||
<p class="text-sm text-base-content/60 mt-1">
|
<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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import type { SteamCollectionItem } from '@/types'
|
|
||||||
import { submissionsApiListPuzzles } from '@/api'
|
import { submissionsApiListPuzzles } from '@/api'
|
||||||
|
import type { SteamCollectionItem } from '@/types'
|
||||||
|
|
||||||
export const usePuzzlesStore = defineStore('puzzles', () => {
|
export const usePuzzlesStore = defineStore('puzzles', () => {
|
||||||
// State
|
// State
|
||||||
const puzzles = ref<any[]>([])
|
const puzzles = ref<SteamCollectionItem[]>([])
|
||||||
const isLoading = ref(false)
|
const isLoading = ref(false)
|
||||||
const error = ref<string>('')
|
const error = ref<string>('')
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ export const usePuzzlesStore = defineStore('puzzles', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
puzzles.value = response.data
|
puzzles.value = response.data as unknown as SteamCollectionItem[]
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
error.value = 'Failed to load puzzles'
|
error.value = 'Failed to load puzzles'
|
||||||
|
|||||||
@ -30,9 +30,9 @@ export interface SteamCollectionItem {
|
|||||||
title: string
|
title: string
|
||||||
author_name: string
|
author_name: string
|
||||||
description: string
|
description: string
|
||||||
tags: string[]
|
tags?: string[]
|
||||||
order_index: number
|
order_index?: number
|
||||||
collection: number
|
steam_url: string
|
||||||
points_factor?: PointsFactor
|
points_factor?: PointsFactor
|
||||||
created_at: string
|
created_at: string
|
||||||
updated_at: string
|
updated_at: string
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user