Skip to content

Commit

Permalink
Fix for issue where campsite forms link (required to proceed) wouldn'…
Browse files Browse the repository at this point in the history
…t show up for vibeclipse
  • Loading branch information
brundonsmith committed Mar 1, 2024
1 parent 79e9207 commit 29aa83e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion front-end/src/components/Tickets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default observer(() => {
{Store.accountInfo.state.result.allowed_to_purchase
? <>
{FESTIVALS_WITH_SALES_OPEN.map(festival => {
const tickets = Store.purchasedTickets[festival.festival_id] ?? []
const tickets = Store.purchasedTickets[festival.festival_id]

return (
<React.Fragment key={festival.festival_id}>
Expand Down
2 changes: 1 addition & 1 deletion front-end/src/components/tickets/SelectionView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export default observer((props: Props) => {

</>}

{Store.purchasedTickets[festival.festival_id]?.length === 0 && festival.festival_name === 'Vibeclipse 2024' && // HACK
{Store.purchasedTickets[festival.festival_id].length === 0 && festival.festival_name === 'Vibeclipse 2024' && // HACK
<>
<Spacer size={32} />
<hr />
Expand Down
15 changes: 7 additions & 8 deletions front-end/src/stores/Store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import dayjs from 'dayjs'
import jwtDecode from 'jwt-decode'
import { autorun, makeAutoObservable } from 'mobx'

import { Tables } from '../../../back-end/types/db-types.ts'
import { TABLE_ROWS, Tables } from '../../../back-end/types/db-types.ts'
import { PURCHASE_TYPES_BY_TYPE, VibeJWTPayload } from '../../../back-end/types/misc'
import { objectFromEntries } from '../../../back-end/utils/misc.ts'
import { request } from '../mobx/request'
import { given, jsonParse } from '../utils'
import { vibefetch } from '../vibefetch'
Expand Down Expand Up @@ -63,7 +64,8 @@ class Store {
})

get purchasedTickets() {
const purchasedTickets: Partial<Record<Tables['festival']['festival_id'], Tables['purchase'][]>> = {}
const purchasedTickets = objectFromEntries(TABLE_ROWS.festival.map(f =>
[f.festival_id, []] as [typeof f.festival_id, Tables['purchase'][]]))

const accountInfo = this.accountInfo.state.result

Expand All @@ -73,14 +75,11 @@ class Store {

for (const ticket of tickets) {
const festival_id = PURCHASE_TYPES_BY_TYPE[ticket.purchase_type_id].festival_id
const ticketsForFestival = purchasedTickets[festival_id] = purchasedTickets[festival_id] ?? []
ticketsForFestival.push(ticket)
purchasedTickets[festival_id].push(ticket)
}

return purchasedTickets
} else {
return {}
}

return purchasedTickets
}

/// Events
Expand Down

0 comments on commit 29aa83e

Please sign in to comment.