Skip to content

Commit

Permalink
Fix types and migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
julianweng committed Jan 28, 2024
1 parent 841bba9 commit ccd52d5
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
13 changes: 13 additions & 0 deletions backend/clubs/migrations/0095_merge_20240128_1321.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Generated by Django 3.2.18 on 2024-01-28 18:21

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("clubs", "0092_auto_20221118_1424"),
("clubs", "0094_applicationcycle_release_date"),
]

operations = []
18 changes: 13 additions & 5 deletions frontend/components/ClubEditPage/TicketsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,18 @@ const TicketItem = ({
)
}

type Ticket = {
name: string
count: string | null
}

const TicketsModal = (props: { event: ClubEvent }): ReactElement => {
const { event } = props
const { large_image_url, image_url, club_name, name, id } = event

const [submitting, setSubmitting] = useState(false)

const [tickets, setTickets] = useState([
const [tickets, setTickets] = useState<Ticket[]>([
{ name: 'Regular Ticket', count: null },
])

Expand Down Expand Up @@ -143,9 +148,11 @@ const TicketsModal = (props: { event: ClubEvent }): ReactElement => {

const submit = () => {
if (typeof name === 'string' && tickets.length > 0) {
const quantities = tickets.map((ticket) => {
return { type: ticket.name, count: parseInt(ticket.count) }
})
const quantities = tickets
.filter((ticket) => ticket.count != null)
.map((ticket) => {
return { type: ticket.name, count: parseInt(ticket.count || '') }
})
doApiRequest(`/events/${id}/tickets/?format=json`, {
method: 'PUT',
body: {
Expand All @@ -160,7 +167,8 @@ const TicketsModal = (props: { event: ClubEvent }): ReactElement => {
const disableSubmit = tickets.some(
(ticket) =>
typeof ticket.name !== 'string' ||
!Number.isInteger(parseInt(ticket.count)),
typeof ticket.count === null ||
!Number.isInteger(parseInt(ticket.count || '0')),
)

return (
Expand Down
Empty file.
4 changes: 3 additions & 1 deletion frontend/components/Settings/TicketTransferModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ const notify = (
toast[type](msg)
}

const TicketTransferModal = (props: { event: ClubEvent }): ReactElement => {
const TicketTransferModal = (props: {
event: ClubEvent | null
}): ReactElement => {
const [searchInput, setSearchInput] = useState<SearchInput>({})

const search = () => {
Expand Down
13 changes: 13 additions & 0 deletions frontend/pages/tickets/checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ const testCart: EventTicket[] = [
id: 12345,
name: 'Awesome Event Name',
club_name: 'UPenn Natalist Society',
badges: [],
image_url: null,
club: null,
description: 'This is a description of the event',
start_time: '2020-04-20T12:00:00Z',
end_time: '2020-04-20T14:00:00Z',
is_ics_event: false,
large_image_url: null,
ticketed: 'true',
location: 'Houston Hall',
pinned: false,
type: ClubEventType.OTHER,
url: 'https://pennclubs.com',
},
id: '497f6eca-6276-4993-bfeb-53cbbbba6f08',
type: ClubEventType.OTHER,
Expand Down

0 comments on commit ccd52d5

Please sign in to comment.