feat(market): enable/disable like any other games
This commit is contained in:
@@ -3,7 +3,7 @@ import { ref, onMounted, computed } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useTitle } from "@vueuse/core";
|
||||
import { gamesApiListEventGames, polylanSubmitterApiGetConfig } from "./api";
|
||||
import { gamesApiListEventGames } from "./api";
|
||||
import type { GamesApiListEventGamesResponse } from "./api/types.gen";
|
||||
|
||||
interface Props {
|
||||
@@ -19,7 +19,6 @@ useTitle(computed(() => t("home.title")));
|
||||
const games = ref<GamesApiListEventGamesResponse | undefined>();
|
||||
const loading = ref(true);
|
||||
const imageErrors = ref<Set<number>>(new Set());
|
||||
const marketEnabled = ref(false);
|
||||
|
||||
const getHeaderImage = (game: GamesApiListEventGamesResponse[number]) => {
|
||||
if (game.image) {
|
||||
@@ -35,26 +34,18 @@ const onImageError = (gameId: number) => {
|
||||
imageErrors.value.add(gameId);
|
||||
};
|
||||
|
||||
const goToMarket = () => {
|
||||
router.push(`/${props.eventPath}/market`);
|
||||
};
|
||||
|
||||
const goToGame = (game: GamesApiListEventGamesResponse[number]) => {
|
||||
const path = game.custom_path ? `/${game.path}` : `/submissions/${game.path}`;
|
||||
router.push(`/${props.eventPath}${path}`);
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
const [gamesResponse, configResponse] = await Promise.all([
|
||||
gamesApiListEventGames({ path: { event_path: props.eventPath } }),
|
||||
polylanSubmitterApiGetConfig(),
|
||||
]);
|
||||
const gamesResponse = await gamesApiListEventGames({
|
||||
path: { event_path: props.eventPath },
|
||||
});
|
||||
if (gamesResponse.data) {
|
||||
games.value = gamesResponse.data;
|
||||
}
|
||||
if (configResponse.data) {
|
||||
marketEnabled.value = configResponse.data.market_enabled;
|
||||
}
|
||||
loading.value = false;
|
||||
});
|
||||
</script>
|
||||
@@ -77,25 +68,6 @@ onMounted(async () => {
|
||||
|
||||
<!-- Cards Grid -->
|
||||
<div v-else class="grid grid-cols-1 md:grid-cols-2 gap-8">
|
||||
<!-- Market Card -->
|
||||
<div v-if="marketEnabled" @click="goToMarket"
|
||||
class="card card-xl bg-base-200 shadow-xl hover:shadow-2xl transition-all cursor-pointer transform hover:-translate-y-2 hover:scale-[1.05] hover:bg-base-100 overflow-hidden">
|
||||
<figure class="relative h-60 bg-gradient-to-br from-purple-600 to-blue-600 flex items-center justify-center">
|
||||
<i class="mdi mdi-chart-box text-6xl text-white opacity-80"></i>
|
||||
<div class="absolute inset-0 bg-black/30 group-hover:bg-black/20 transition-colors"></div>
|
||||
</figure>
|
||||
<div class="card-body">
|
||||
<h2 class="card-title text-2xl">{{ t("home.marketCard.title") }}</h2>
|
||||
<p class="text-base-content/70">{{ t("home.marketCard.description") }}</p>
|
||||
<div class="card-actions justify-end mt-4">
|
||||
<button class="btn btn-primary">
|
||||
<i class="mdi mdi-arrow-right mr-2"></i>
|
||||
{{ t("home.marketCard.cta") }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Game Cards -->
|
||||
<div v-for="game in games" :key="game.id"
|
||||
@click="goToGame(game)"
|
||||
@@ -111,6 +83,7 @@ onMounted(async () => {
|
||||
</figure>
|
||||
<div class="card-body">
|
||||
<h2 class="card-title text-2xl">{{ game.name }}</h2>
|
||||
<p v-if="game.description" class="text-base-content/70">{{ game.description }}</p>
|
||||
<div class="card-actions justify-end mt-4">
|
||||
<button class="btn btn-primary">
|
||||
<i class="mdi mdi-arrow-right mr-2"></i>
|
||||
|
||||
Reference in New Issue
Block a user