feat: add events app + "multi-tenants" aka multi-events
This commit is contained in:
@@ -3,6 +3,7 @@ import { ref, computed, onMounted } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { marketApiCreateBet, marketApiCloseMarket, marketApiResolveMarket } from "../api";
|
||||
import { useMarketStore } from "../stores/market";
|
||||
import { useEventPath } from "../composables/useEventPath";
|
||||
import type { Market, MarketOption } from "../types";
|
||||
import type { UserBetSchema } from "../api/types.gen";
|
||||
|
||||
@@ -14,6 +15,7 @@ const emit = defineEmits<{
|
||||
refresh: [];
|
||||
}>();
|
||||
|
||||
const eventPath = useEventPath();
|
||||
const marketStore = useMarketStore();
|
||||
const { userInfo, userBets } = storeToRefs(marketStore);
|
||||
|
||||
@@ -82,7 +84,7 @@ const closeMarket = async () => {
|
||||
|
||||
try {
|
||||
await marketApiCloseMarket({
|
||||
path: { market_uuid: props.market.uuid },
|
||||
path: { event_path: eventPath, market_uuid: props.market.uuid },
|
||||
});
|
||||
emit("refresh");
|
||||
} catch (e) {
|
||||
@@ -103,7 +105,7 @@ const resolveMarket = async () => {
|
||||
|
||||
try {
|
||||
await marketApiResolveMarket({
|
||||
path: { market_uuid: props.market.uuid },
|
||||
path: { event_path: eventPath, market_uuid: props.market.uuid },
|
||||
body: { winning_option_uuid: selectedWinningOption.value },
|
||||
});
|
||||
emit("refresh");
|
||||
@@ -132,6 +134,7 @@ const placeBet = async () => {
|
||||
try {
|
||||
const response = await marketApiCreateBet({
|
||||
path: {
|
||||
event_path: eventPath,
|
||||
market_uuid: props.market.uuid
|
||||
},
|
||||
body: {
|
||||
@@ -142,7 +145,7 @@ const placeBet = async () => {
|
||||
|
||||
if (!response.error) {
|
||||
// Reload user bets to reflect the new bet
|
||||
await marketStore.loadUserBets();
|
||||
await marketStore.loadUserBets(eventPath);
|
||||
updateExistingBet();
|
||||
betAmount.value = 0;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user