diff --git a/apps/ticketing/src/pages/events/new.tsx b/apps/ticketing/src/pages/events/new.tsx
index ec79124..ed37e8a 100644
--- a/apps/ticketing/src/pages/events/new.tsx
+++ b/apps/ticketing/src/pages/events/new.tsx
@@ -146,6 +146,12 @@ const CreateEvent: NextPageWithLayout = () => {
const placeHolderTicket: TicketInfoFormMetadata = {
name: 'General Admission',
denomination: 'Near',
+ salesValidThrough: {
+ startDate: Date.now(), // Milliseconds from Unix Epoch
+ startTime: '00:00', // Raw 24 hour time string such as 18:00
+ endDate: new Date().setDate(Date.now() + 14), // Milliseconds from start date
+ endTime: '00:00',
+ },
};
useEffect(() => {
@@ -457,6 +463,24 @@ const CreateEvent: NextPageWithLayout = () => {
})}
/>
+
+
+
+
diff --git a/apps/ticketing/src/utils/helpers.ts b/apps/ticketing/src/utils/helpers.ts
index bc1cc2e..a58820e 100644
--- a/apps/ticketing/src/utils/helpers.ts
+++ b/apps/ticketing/src/utils/helpers.ts
@@ -21,7 +21,7 @@ export interface TicketInfoFormMetadata {
priceFiat?: string;
description?: string | undefined;
artwork?: FileList;
- salesValidThrough?: DateAndTimeInfo;
+ salesValidThrough: DateAndTimeInfo;
passValidThrough?: DateAndTimeInfo;
}
@@ -50,7 +50,7 @@ export interface TicketMetadataExtra {
priceNear?: string;
priceFiat?: string;
maxSupply?: number;
- salesValidThrough?: DateAndTimeInfo;
+ salesValidThrough: DateAndTimeInfo;
passValidThrough?: DateAndTimeInfo;
}
@@ -310,10 +310,8 @@ export const createPayload = async ({
const drop_ids: string[] = [];
const drop_configs: any = [];
const asset_datas: any = [];
- const marketTicketInfo: Record<
- string,
- { max_tickets: number; price: string; sale_start?: number; sale_end?: number }
- > = {};
+ const marketTicketInfo: Record =
+ {};
for (const ticket of formData.tickets) {
const dropId = `${Date.now().toString()}-${ticket.name.replaceAll(' ', '').toLocaleLowerCase()}`;
@@ -330,7 +328,11 @@ export const createPayload = async ({
dateCreated: Date.now().toString(),
priceNear: ticket.priceNear,
priceFiat: ticket.priceFiat,
- salesValidThrough: ticket.salesValidThrough,
+ salesValidThrough: {
+ ...ticket.salesValidThrough,
+ startDate: Date.parse(ticket.salesValidThrough.startDate.toString()),
+ endDate: Date.parse(ticket.salesValidThrough.endDate!.toString()),
+ },
passValidThrough: ticket.passValidThrough,
maxSupply: ticket.maxSupply,
limitPerUser: ticket.maxPurchases,
@@ -347,8 +349,8 @@ export const createPayload = async ({
marketTicketInfo[`${dropId}`] = {
max_tickets: ticket.maxSupply ?? 0,
price: parseNearAmount(ticket.priceNear || '0')!.toString(),
- sale_start: Date.now() || undefined,
- sale_end: Date.parse(formData.date) || undefined,
+ sale_start: Date.parse(ticket.salesValidThrough.startDate.toString()),
+ sale_end: Date.parse(ticket.salesValidThrough.endDate!.toString()),
};
const dropConfig = {
diff --git a/apps/ticketing/src/utils/purchase.ts b/apps/ticketing/src/utils/purchase.ts
index 5763065..2af6834 100644
--- a/apps/ticketing/src/utils/purchase.ts
+++ b/apps/ticketing/src/utils/purchase.ts
@@ -46,13 +46,6 @@ type PurchaseTicketOptions = {
viewAccount: Account | null;
};
-type PurchaseWorkerResponse = {
- tickets: {
- public_key: string;
- secret_key: string;
- }[];
-};
-
type PurchasedTicket = {
secretKey: string;
};
@@ -135,8 +128,13 @@ export async function purchaseTickets({
});
if (response.ok) {
- const data = (await response.json()) as PurchaseWorkerResponse;
- data.tickets.forEach((t) => purchases.push({ secretKey: t.secret_key }));
+ const data = await response.json();
+ if (!ticketIsFree) {
+ // redirect to stripe for checkout
+ window.location.href = data.stripe_url;
+ } else {
+ data.tickets.forEach((t: { secret_key: any }) => purchases.push({ secretKey: t.secret_key }));
+ }
} else {
/*
TODO: We'll need to think through how we redirect to Stripe after exiting this loop.