Skip to content

Commit

Permalink
some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
devkiran committed Mar 3, 2025
1 parent 4920d66 commit 0e177e3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 48 deletions.
32 changes: 1 addition & 31 deletions apps/web/app/api/tokens/embed/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,37 +98,7 @@ export const POST = withWorkspace(
programEnrollment = {
partnerId: enrolledPartner.id,
};
}

// else if (partner.programs.length === 0) {
// const partnerLink = await createPartnerLink({
// workspace,
// program,
// partner: partnerProps,
// userId: session.user.id,
// });

// const enrolledPartner = await createAndEnrollPartner({
// program,
// link: partnerLink,
// workspace,
// partner: {
// name: partnerProps.name,
// email: partnerProps.email,
// image: partnerProps.image ?? null,
// country: partnerProps.country ?? null,
// description: partnerProps.description,
// },
// tenantId: partnerProps.tenantId,
// });

// programEnrollment = {
// partnerId: enrolledPartner.id,
// };
// }

// partner exists and is enrolled in the program, we can use the existing partnerId
else {
} else {
console.log(
"partner exists and is enrolled in the program, we can use the existing partnerId",
);
Expand Down
24 changes: 13 additions & 11 deletions apps/web/app/api/user/embed-tokens/route.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import { withSession } from "@/lib/auth";
import { createEmbedTokenSchema } from "@/lib/zod/schemas/token";
import { NextResponse } from "next/server";
import { z } from "zod";

export const GET = withSession(async ({ session }) => {
// const { publicToken } = await dub.embedTokens.create({
// programId: "prog_d8pl69xXCv4AoHNT281pHQdo",
// partnerId: dubPartnerId,
// });

const partnerProps: z.infer<typeof createEmbedTokenSchema> = {
programId: "prog_d8pl69xXCv4AoHNT281pHQdo",
partner: {
name: session.user.name,
email: session.user.email,
image: session.user.image || null,
tenantId: session.user.id,
},
};

const { publicToken } = await fetch(
"http://localhost:8888/api/tokens/embed",
{
Expand All @@ -15,15 +27,7 @@ export const GET = withSession(async ({ session }) => {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.DUB_API_KEY}`,
},
body: JSON.stringify({
programId: "prog_d8pl69xXCv4AoHNT281pHQdo",
tenantId: session.user.id,
partner: {
name: session.user.name,
email: session.user.email,
image: session.user.image,
},
}),
body: JSON.stringify(partnerProps),
},
).then((res) => {
if (!res.ok) {
Expand All @@ -32,7 +36,5 @@ export const GET = withSession(async ({ session }) => {
return res.json();
});

console.log({ publicToken });

return NextResponse.json({ publicToken });
});
5 changes: 1 addition & 4 deletions apps/web/lib/actions/partners/add-partner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ export const addPartnerAction = authActionClient
workspace,
partner: {
name,
email: email ?? null,
image: null,
country: null,
description: null,
email: email ?? "",
},
});
}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/lib/api/partners/create-and-enroll-partner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { createId } from "@/lib/api/utils";
import { recordLink } from "@/lib/tinybird";
import {
PartnerProps,
CreatePartnerProps,
ProgramPartnerLinkProps,
ProgramProps,
WorkspaceProps,
Expand All @@ -28,7 +28,7 @@ export const createAndEnrollPartner = async ({
workspace: Pick<WorkspaceProps, "id" | "webhookEnabled">;
link: ProgramPartnerLinkProps;
partner: Pick<
PartnerProps,
CreatePartnerProps,
"email" | "name" | "image" | "country" | "description"
>;
tenantId?: string;
Expand Down

0 comments on commit 0e177e3

Please sign in to comment.