Skip to content

Commit

Permalink
Add poster on archive page
Browse files Browse the repository at this point in the history
  • Loading branch information
KwikKill committed Nov 21, 2024
1 parent 0b5170c commit c6bea9f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/models/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface BaseEvent {
month: number;
ongoing: boolean;
logo?: string;
poster?: string;
seats: [number, number][];
}

Expand Down
20 changes: 13 additions & 7 deletions src/stores/tournament.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ export const useTournamentStore = defineStore('tournament', () => {
}, [] as Event[]));

async function fetchAllEvents() {
const res = await axios.get<Event[]>('/tournament/event');
const res = await axios.get<Event[]>('/tournament/event/');
res.data.forEach((ev) => { eventsList.value[ev.id] = ev; });
}

async function fetchEventsByYear(year: number) {
const res = await axios.get<Event[]>(`tournament/event/year/${year}`);
const res = await axios.get<Event[]>(`tournament/event/year/${year}/`);
res.data.forEach((ev) => { eventsList.value[ev.id] = ev; });
}

Expand All @@ -74,7 +74,7 @@ export const useTournamentStore = defineStore('tournament', () => {
}

async function fetchEventById(id: number) {
const res = await axios<Event>(`tournament/event/${id}`);
const res = await axios<Event>(`tournament/event/${id}/`);
eventsList.value[id] = res.data;
}

Expand Down Expand Up @@ -126,7 +126,7 @@ export const useTournamentStore = defineStore('tournament', () => {
}

async function fetchTournamentFull(id: number) {
const res = await axios.get<Tournament>(`/tournament/tournament/${id}/full`);
const res = await axios.get<Tournament>(`/tournament/tournament/${id}/full/`);
tournamentsList.value[id] = res.data;
}

Expand Down Expand Up @@ -351,7 +351,7 @@ export const useTournamentStore = defineStore('tournament', () => {
}

async function get_ticket_pdf(token: string) {
const response = await axios.get(`/tickets/generate/${token}`, {
const response = await axios.get(`/tickets/generate/${token}/`, {
responseType: 'blob',
});
const url = window.URL.createObjectURL(new Blob([response.data]));
Expand All @@ -361,6 +361,7 @@ export const useTournamentStore = defineStore('tournament', () => {
document.body.appendChild(link);
link.click();
}

function getTournamentTeams() {
tourney_teams.value = (tournament.value?.teams as Team[]).reduce((ret, team) => {
if (team.validated) {
Expand All @@ -378,14 +379,14 @@ export const useTournamentStore = defineStore('tournament', () => {
type: string;
user: string;
team: string;
}[]>('/tickets/unpaid');
}[]>('/tickets/unpaid/');
unpaidRegistration.value = response.data;
}

async function validate_registration(type: string, id: number) {
await get_csrf();

await axios.post('/tickets/pay', {
await axios.post('/tickets/pay/', {
id,
type,
}, {
Expand All @@ -404,9 +405,11 @@ export const useTournamentStore = defineStore('tournament', () => {
function get_validated_team_by_id(id: number) {
return tourney_teams.value.validated_teams.find((team) => team.id === id);
}

function get_group_by_id(groups: Group[], id: number) {
return groups.find((group) => group.id === id);
}

function is_winning_team(match: Match, team_id: number) {
if (match.bo_type === BestofType.RANKING) {
return match.score[team_id] >= Object.keys(match.score).length;
Expand All @@ -420,15 +423,18 @@ export const useTournamentStore = defineStore('tournament', () => {
}
return 2 * (bracket.depth - 1) + 3;
}

function get_winner_matchs_per_round(matchs: KnockoutMatch[], round: number) {
const winner_matchs = matchs.filter((match) => match.bracket_set === BracketSet.WINNER);
const round_matchs = groupBy(winner_matchs, 'round_number');
return round_matchs[round];
}

function get_col_class(bracket: Bracket) {
const nb_cols = get_bracket_cols_count(bracket);
return `grid-cols-[repeat(${nb_cols},17rem)]`;
}

function get_col_style(bracket: Bracket) {
const nb_cols = get_bracket_cols_count(bracket);
return { 'grid-template-columns': `repeat(${nb_cols},17rem)` };
Expand Down
22 changes: 17 additions & 5 deletions src/views/Archives.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,24 @@ await fetchAllEvents();
<h2 class="text-center text-2xl">
{{ event.name }} | {{ `${String(event.month).padStart(2, '0')}/${event.year}` }}
</h2>
<div class="mb-4 grid w-full gap-4 px-4 md:grid-cols-2 xl:grid-cols-4">
<TournamentCard
v-for="tournament in event.tournaments"
:id="tournament"
:key="tournament"
<div
class="mx-2 mb-2 flex flex-col gap-4 md:grid md:grid-cols-2 xl:grid-cols-3"
>
<img
:src="event.poster"
class="w-full object-contain"
:alt="`Poster ${event.name}`"
/>
<div class="col-span-2 mb-4 grid gap-4 px-4 md:grid-cols-2 xl:grid-cols-2 2xl:grid-cols-3">
<div
v-for="tournament in event.tournaments"
:key="tournament"
>
<TournamentCard
:id="tournament"
/>
</div>
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit c6bea9f

Please sign in to comment.