feat(market): add draft status and multiplier
This commit is contained in:
@@ -77,19 +77,31 @@ onMounted(async () => {
|
||||
<div class="space-y-8">
|
||||
<!-- My Bets Section -->
|
||||
<div v-if="userInfo?.is_authenticated">
|
||||
<h3 class="text-2xl font-bold mb-4 flex items-center gap-2">
|
||||
<i class="mdi mdi-heart text-error"></i>
|
||||
My Bets
|
||||
</h3>
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h3 class="text-2xl font-bold flex items-center gap-2">
|
||||
<i class="mdi mdi-heart text-error"></i>
|
||||
My Bets
|
||||
</h3>
|
||||
<div class="text-lg font-semibold">
|
||||
<span class="text-primary">{{ userInfo.points }}</span>
|
||||
<span class="text-base-content/60 ml-1">pts</span>
|
||||
</div>
|
||||
</div>
|
||||
<UserBets :markets="markets" @refresh="reloadPage" />
|
||||
</div>
|
||||
|
||||
<!-- All Markets Section -->
|
||||
<div>
|
||||
<h3 class="text-2xl font-bold mb-4 flex items-center gap-2">
|
||||
<i class="mdi mdi-list"></i>
|
||||
All Markets
|
||||
</h3>
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h3 class="text-2xl font-bold flex items-center gap-2">
|
||||
<i class="mdi mdi-list"></i>
|
||||
All Markets
|
||||
</h3>
|
||||
<a v-if="userInfo?.is_superuser" href="/admin/market/market/add/" class="btn btn-sm btn-primary">
|
||||
<i class="mdi mdi-plus"></i>
|
||||
Create Market
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div v-if="markets.length === 0" class="alert">
|
||||
<i class="mdi mdi-information mr-2"></i>
|
||||
@@ -97,12 +109,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<MarketCard
|
||||
v-for="market in markets"
|
||||
:key="market.uuid"
|
||||
:market="market"
|
||||
@refresh="reloadPage"
|
||||
/>
|
||||
<MarketCard v-for="market in markets" :key="market.uuid" :market="market" @refresh="reloadPage" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -194,7 +194,7 @@ export const gamesApiListGames = <ThrowOnError extends boolean = false>(options?
|
||||
/**
|
||||
* List Markets
|
||||
*
|
||||
* List all markets.
|
||||
* List all markets (excludes draft markets).
|
||||
*/
|
||||
export const marketApiListMarkets = <ThrowOnError extends boolean = false>(options?: Options<MarketApiListMarketsData, ThrowOnError>) => (options?.client ?? client).get<MarketApiListMarketsResponses, unknown, ThrowOnError>({ url: '/api/market/', ...options });
|
||||
|
||||
|
||||
@@ -30,6 +30,10 @@ export type UserInfoOut = {
|
||||
* Email
|
||||
*/
|
||||
email?: string | null;
|
||||
/**
|
||||
* Points
|
||||
*/
|
||||
points?: number;
|
||||
/**
|
||||
* Is Authenticated
|
||||
*/
|
||||
@@ -986,6 +990,10 @@ export type MarketListSchema = {
|
||||
* End Date
|
||||
*/
|
||||
end_date: string;
|
||||
/**
|
||||
* Multiplier
|
||||
*/
|
||||
multiplier?: number;
|
||||
/**
|
||||
* Created At
|
||||
*/
|
||||
|
||||
@@ -41,6 +41,8 @@ const timeRemaining = computed(() => {
|
||||
|
||||
const statusColor = computed(() => {
|
||||
switch (props.market.status) {
|
||||
case "draft":
|
||||
return "badge-secondary";
|
||||
case "open":
|
||||
return "badge-success";
|
||||
case "closed":
|
||||
@@ -68,7 +70,7 @@ const getMultiplier = (option: MarketOption) => {
|
||||
const getPotentialGain = (option: MarketOption) => {
|
||||
if (!existingBet.value || existingBet.value.option.uuid !== option.uuid) return 0;
|
||||
const multiplier = getMultiplier(option);
|
||||
return Math.round(existingBet.value.amount * multiplier);
|
||||
return Math.round(existingBet.value.amount * multiplier * props.market.multiplier);
|
||||
};
|
||||
|
||||
const closeMarket = async () => {
|
||||
@@ -194,10 +196,15 @@ onMounted(async () => {
|
||||
<p class="text-sm text-base-content/70">{{ market.description }}</p>
|
||||
</div>
|
||||
<div class="flex flex-col items-end gap-2">
|
||||
<div :class="['badge', statusColor, 'text-white']">
|
||||
{{ market.status }}
|
||||
<div class="flex gap-2 items-center">
|
||||
<div :class="['badge', statusColor, 'text-white']">
|
||||
{{ market.status }}
|
||||
</div>
|
||||
<div v-if="market.multiplier > 1" class="badge badge-accent text-white font-bold">
|
||||
{{ market.multiplier }}x
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="market.status === 'open'" class="text-sm text-base-content/60 text-right">
|
||||
<div v-if="market.status === 'open' || market.status === 'closed'" class="text-sm text-base-content/60 text-right">
|
||||
<div>{{ timeRemaining }}</div>
|
||||
<div class="text-xs">until close</div>
|
||||
</div>
|
||||
|
||||
@@ -18,7 +18,7 @@ const winningBets = computed(() => {
|
||||
return userBets.value.filter(bet => {
|
||||
const market = bet.market;
|
||||
return market?.status === "resolved" && market?.winning_option?.uuid === bet.option.uuid;
|
||||
});
|
||||
}).reverse();
|
||||
});
|
||||
|
||||
const losingBets = computed(() => {
|
||||
|
||||
@@ -180,8 +180,9 @@ export interface Market {
|
||||
uuid: string
|
||||
title: string
|
||||
description: string
|
||||
status: 'open' | 'closed' | 'resolved'
|
||||
status: 'draft' | 'open' | 'closed' | 'resolved'
|
||||
end_date: string
|
||||
multiplier: number
|
||||
created_at: string
|
||||
options: MarketOption[]
|
||||
winning_option?: MarketOption | null
|
||||
|
||||
Reference in New Issue
Block a user