Skip to content

Commit

Permalink
continuing to think
Browse files Browse the repository at this point in the history
  • Loading branch information
ichub committed Sep 27, 2024
1 parent ab2c179 commit a1282ca
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { requestGenericIssuanceTicketPreviews } from "@pcd/passport-interface";
import { useCallback, useEffect } from "react";
import { useParams } from "react-router-dom";
import { appConfig } from "../../../src/appConfig";
import { useDispatch, useSelf } from "../../../src/appHooks";
import { MaybeModal } from "../../modals/Modal";
import { AppContainer } from "../../shared/AppContainer";
Expand Down Expand Up @@ -37,6 +39,20 @@ export function OneClickLoginScreen(): JSX.Element | null {
// code,
// targetFolder
// });

const result = await requestGenericIssuanceTicketPreviews(
appConfig.zupassServer,
email,
code
);

console.log(result);

if (result.success) {
console.log(result.value);
} else {
console.error(result.error);
}
} catch (err) {
await dispatch({
type: "error",
Expand Down
19 changes: 18 additions & 1 deletion apps/passport-server/src/routing/routes/genericIssuanceRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import {
PodboxTicketActionRequest,
PodboxTicketActionResponseValue,
PollFeedRequest,
PollFeedResponseValue
PollFeedResponseValue,
TicketPreviewResultValue
} from "@pcd/passport-interface";
import { SerializedSemaphoreGroup } from "@pcd/semaphore-group-pcd";
import { sleep } from "@pcd/util";
Expand Down Expand Up @@ -667,4 +668,20 @@ export function initGenericIssuanceRoutes(
res.json(result satisfies GenericIssuanceSendPipelineEmailResponseValue);
}
);

app.post(
"/generic-issuance/api/ticket-previews/:email/:orderCode",
async (req, res) => {
checkGenericIssuanceServiceStarted(genericIssuanceService);
const email = checkUrlParam(req, "email");
const orderCode = checkUrlParam(req, "orderCode");

const result = await genericIssuanceService.handleGetTicketPreview(
email,
orderCode
);

res.json(result satisfies TicketPreviewResultValue);
}
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
PodboxTicketActionRequest,
PodboxTicketActionResponseValue,
PollFeedRequest,
PollFeedResponseValue
PollFeedResponseValue,
TicketPreviewResultValue
} from "@pcd/passport-interface";
import { RollbarService } from "@pcd/server-shared";
import { Request } from "express";
Expand Down Expand Up @@ -345,4 +346,21 @@ export class GenericIssuanceService {
public async getEdgeCityBalances(): Promise<EdgeCityBalance[]> {
return getEdgeCityBalances(this.context.dbPool);
}

public async handleGetTicketPreview(
email: string,

Check failure on line 351 in apps/passport-server/src/services/generic-issuance/GenericIssuanceService.ts

View workflow job for this annotation

GitHub Actions / Build-and-Test

'email' is defined but never used. Allowed unused args must match /^_/u
orderCode: string

Check failure on line 352 in apps/passport-server/src/services/generic-issuance/GenericIssuanceService.ts

View workflow job for this annotation

GitHub Actions / Build-and-Test

'orderCode' is defined but never used. Allowed unused args must match /^_/u
): Promise<TicketPreviewResultValue> {
return {
tickets: [
{
name: "Test",
email: "[email protected]",
ticketSecret: "test",
eventName: "Test Event",
productName: "Test Product"
}
]
} satisfies TicketPreviewResultValue;
}
}
10 changes: 10 additions & 0 deletions packages/lib/passport-interface/src/RequestTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1236,3 +1236,13 @@ export type OneClickEmailResponseValue = {
*/
values: Record<string, string[]>;
};

export type TicketPreviewResultValue = {
tickets: Array<{
name: string;
email: string;
ticketSecret: string;
eventName: string;
productName: string;
}>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import urlJoin from "url-join";
import { TicketPreviewResultValue } from "../RequestTypes";
import { APIResult } from "./apiResult";
import { httpPostSimple } from "./makeRequest";

/**
* Asks the server to fetch the pipeline definition corresponding to the
* given pipeline ID. Requires cookies, as this is part of generic issuance
* user authentication.
*/
export async function requestGenericIssuanceTicketPreviews(
zupassServerUrl: string,
email: string,
orderCode: string
): Promise<GenericIssuanceTicketPreviewResponse> {
return httpPostSimple(
urlJoin(
zupassServerUrl,
`/generic-issuance/api/ticket-previews`,
encodeURIComponent(email),
encodeURIComponent(orderCode)
),
async (resText) => ({
value: JSON.parse(resText) as TicketPreviewResultValue,
success: true
}),
{},
true
);
}

export type GenericIssuanceTicketPreviewResponse =
APIResult<TicketPreviewResultValue>;
1 change: 1 addition & 0 deletions packages/lib/passport-interface/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export * from "./api/requestGenericIssuanceSemaphoreGroup";
export * from "./api/requestGenericIssuanceSemaphoreGroupRoot";
export * from "./api/requestGenericIssuanceSendPipelineEmail";
export * from "./api/requestGenericIssuanceSetManualCheckInState";
export * from "./api/requestGenericIssuanceTicketPreviews";
export * from "./api/requestGenericIssuanceUpsertPipeline";
export * from "./api/requestGenericIssuanceValidSemaphoreGroup";
export * from "./api/requestIssuanceServiceEnabled";
Expand Down

0 comments on commit a1282ca

Please sign in to comment.