Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invite partner #1712

Merged
merged 79 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
b4f5e9c
add ProgramInvite
devkiran Nov 13, 2024
366e73d
invite partner sheet
devkiran Nov 13, 2024
c3769ba
send email
devkiran Nov 13, 2024
bcc74cc
update email
devkiran Nov 13, 2024
86435fd
If the partner has invites, we need to enroll them in the program and…
devkiran Nov 13, 2024
0668578
small fix
devkiran Nov 13, 2024
4e46aa3
add link selector (wip)
devkiran Nov 13, 2024
44713f7
Add the partner's email to the partnersPortal beta in edge config
devkiran Nov 13, 2024
f3eaba1
add firstName, lastName and phoneNumber field
devkiran Nov 13, 2024
a63095a
Merge branch 'main' into partner-invite
steven-tey Nov 13, 2024
1a3db99
update sheet + email
steven-tey Nov 13, 2024
8059ebf
buttonVariant
steven-tey Nov 13, 2024
df64165
fix page rerendering
steven-tey Nov 13, 2024
7b2aa6c
Fix combobox focus
TWilson023 Nov 14, 2024
865382c
Merge branch 'main' into partner-invite
steven-tey Nov 14, 2024
2b5ca5e
Merge branch 'partner-invite' of https://github.com/dubinc/dub into p…
steven-tey Nov 14, 2024
794e6fa
Update sheet defaults
TWilson023 Nov 14, 2024
c731bea
update scripts
steven-tey Nov 14, 2024
9bbe845
Merge branch 'partner-invite' of https://github.com/dubinc/dub into p…
steven-tey Nov 14, 2024
fd93e04
update userIsInBeta + partner status
steven-tey Nov 14, 2024
09995ef
fix EnrolledPartnerSchema
steven-tey Nov 14, 2024
6fe278f
Merge branch 'main' into partner-invite
steven-tey Nov 14, 2024
e6aebb6
Merge branch 'main' into partner-invite
steven-tey Nov 14, 2024
b58df72
Merge branch 'main' into partner-invite
steven-tey Nov 14, 2024
ce8997b
Merge branch 'main' into partner-invite
steven-tey Nov 14, 2024
4819ff0
Merge branch 'main' into partner-invite
steven-tey Nov 14, 2024
8e84ebc
Merge branch 'main' into partner-invite
steven-tey Nov 14, 2024
e116da0
Merge branch 'main' into partner-invite
steven-tey Nov 14, 2024
ec4f13e
fix onboard partner
devkiran Nov 14, 2024
19103bc
Merge branch 'partner-invite' of https://github.com/dubinc/dub into p…
devkiran Nov 14, 2024
20ee042
Create the Dots user with the program's DOTS_APP_ID
devkiran Nov 14, 2024
6929505
a small fix
devkiran Nov 14, 2024
06870d8
check if the user is already enrolled in the program
devkiran Nov 14, 2024
ef34bab
Merge branch 'main' into partner-invite
steven-tey Nov 14, 2024
b16b54a
Merge branch 'main' into partner-invite
steven-tey Nov 14, 2024
f5dd814
Merge branch 'main' into partner-invite
steven-tey Nov 14, 2024
5278613
Merge branch 'main' into partner-invite
steven-tey Nov 15, 2024
a8f95e6
Merge branch 'main' into partner-invite
steven-tey Nov 15, 2024
a40bf59
add schema from program-lander
steven-tey Nov 15, 2024
5c339d9
update createDotsTransferAction to use ProgramEnrollment.dotsUserId
steven-tey Nov 15, 2024
fbeed9e
Update onboard-partner.ts
steven-tey Nov 15, 2024
7071b1d
Merge branch 'main' into partner-invite
steven-tey Nov 15, 2024
e113b71
show program invites on partner programs page + let them accept the i…
steven-tey Nov 15, 2024
ec5c736
move ProgramCard and ProgramInviteCard into their own components
steven-tey Nov 15, 2024
33dad48
format prisma schemas
devkiran Nov 15, 2024
e4aa06c
add country code to mobile field + useAction
steven-tey Nov 15, 2024
d3978c1
add default domain and destination url for program
devkiran Nov 15, 2024
59cca74
Merge branch 'partner-invite' of https://github.com/dubinc/dub into p…
devkiran Nov 15, 2024
e75605a
Fix the `useAction(onboardPartnerAction)` implementation
devkiran Nov 15, 2024
91d9489
fix displaying error message
devkiran Nov 15, 2024
918212a
Allow Program owners to be able to create a new link when inviting a …
devkiran Nov 15, 2024
716b59b
fix the ui
devkiran Nov 15, 2024
0785bc5
Backfill sales for the partner's link
devkiran Nov 15, 2024
1b32da3
Backfill programId for the partner's link on TB
devkiran Nov 15, 2024
44c80b6
defaultDomain → domain, destinationUrl → url
steven-tey Nov 15, 2024
79e12b2
fix incorrect file name
steven-tey Nov 15, 2024
5195f0b
Merge branch 'main' into partner-invite
steven-tey Nov 15, 2024
146d1b9
small fixes
steven-tey Nov 15, 2024
b44a205
small edit
steven-tey Nov 15, 2024
bbc1290
Fix mobile number input
TWilson023 Nov 15, 2024
76f9f45
update ProgramCard and ProgramInviteCard
steven-tey Nov 15, 2024
6e342cc
Merge branch 'partner-invite' of https://github.com/dubinc/dub into p…
steven-tey Nov 15, 2024
683fe01
add hasIndicator
steven-tey Nov 15, 2024
e9370e3
account for different program enrollment statuses
steven-tey Nov 15, 2024
550c248
Update partner invite UI
TWilson023 Nov 15, 2024
44f4a36
small improvements
steven-tey Nov 15, 2024
2a63789
Merge branch 'partner-invite' of https://github.com/dubinc/dub into p…
steven-tey Nov 15, 2024
b637959
fix acceptProgramInviteAction + backfillLinkData
steven-tey Nov 15, 2024
059ec27
make dotsAppId optional
steven-tey Nov 15, 2024
1c52b6c
Update invite-partner-sheet.tsx
steven-tey Nov 15, 2024
8ca50e4
update default app name
steven-tey Nov 15, 2024
37755cb
fix PartnerProgramDropdown
steven-tey Nov 15, 2024
6989cc2
Update program-invite-card.tsx
steven-tey Nov 15, 2024
546e62e
Merge branch 'main' into partner-invite
steven-tey Nov 16, 2024
383bcf1
Update accept-program-invite.ts
steven-tey Nov 16, 2024
e7f0d9b
Merge branch 'partner-invite' of https://github.com/dubinc/dub into p…
steven-tey Nov 16, 2024
4bb4f09
fix useDomains
steven-tey Nov 16, 2024
547707e
only show table filters if no limit
steven-tey Nov 16, 2024
d58d39a
revert useDomains
steven-tey Nov 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/web/app/api/links/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const GET = withWorkspace(
includeWebhooks,
includeDashboard,
linkIds,
excludePartnerLinks,
} = getLinksQuerySchemaExtended.parse(searchParams);

if (domain) {
Expand All @@ -57,6 +58,7 @@ export const GET = withWorkspace(
includeWebhooks,
includeDashboard,
linkIds,
excludePartnerLinks,
});

return NextResponse.json(response, {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/partners/[partnerId]/dots-user/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const GET = withPartner(async ({ partner }) => {
return NextResponse.json({});
}

const dotsUser = await retrieveDotsUser({ dotsUserId, partner });
const dotsUser = await retrieveDotsUser(partner);

return NextResponse.json(dotsUser);
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DubApiError } from "@/lib/api/errors";
import { withPartner } from "@/lib/auth/partner";
import { prisma } from "@/lib/prisma";
import { ProgramEnrollmentSchema } from "@/lib/zod/schemas/partners";
import { ProgramEnrollmentSchema } from "@/lib/zod/schemas/programs";
import { NextResponse } from "next/server";

// GET /api/partners/[partnerId]/programs/[programId] – get a partner's enrollment in a program
Expand Down
19 changes: 19 additions & 0 deletions apps/web/app/api/partners/[partnerId]/programs/invites/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { withPartner } from "@/lib/auth/partner";
import { prisma } from "@/lib/prisma";
import { ProgramInviteSchema } from "@/lib/zod/schemas/programs";
import { NextResponse } from "next/server";
import { z } from "zod";

// GET /api/partners/[partnerId]/programs/invites - get all invites for a given partnerId/email
export const GET = withPartner(async ({ session }) => {
const invites = await prisma.programInvite.findMany({
where: {
email: session.user.email, // in the future we will check for invites for a given partnerId as well
},
include: {
program: true,
},
});

return NextResponse.json(z.array(ProgramInviteSchema).parse(invites));
});
22 changes: 14 additions & 8 deletions apps/web/app/api/partners/[partnerId]/programs/route.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
import { withPartner } from "@/lib/auth/partner";
import { prisma } from "@/lib/prisma";
import { ProgramSchema } from "@/lib/zod/schemas/partners";
import { ProgramEnrollmentSchema } from "@/lib/zod/schemas/programs";
import { NextResponse } from "next/server";
import { z } from "zod";

// GET /api/partners/[partnerId]/programs - get all enrolled programs for a given partnerId
export const GET = withPartner(async ({ partner }) => {
const programs = await prisma.program.findMany({
const programEnrollments = await prisma.programEnrollment.findMany({
where: {
partners: {
some: {
partnerId: partner.id,
},
},
partnerId: partner.id,
},
include: {
program: true,
},
});

return NextResponse.json(z.array(ProgramSchema).parse(programs));
return NextResponse.json(
z.array(ProgramEnrollmentSchema).parse(
programEnrollments.map((enrollment) => ({
...enrollment,
link: null, // hacky way of not having to fetch link
})),
),
);
});
2 changes: 1 addition & 1 deletion apps/web/app/api/partners/[partnerId]/withdrawals/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const GET = withPartner(async ({ partner }) => {
platform: t.external_data?.platform,
fee:
t.transactions?.find(
(t) => t.type === "fee" && t.source_name !== "Acme, Inc.",
(t) => t.type === "fee" && t.source_name !== "Default App",
)?.amount || "0",
};
});
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/programs/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { withWorkspace } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
import { ProgramSchema } from "@/lib/zod/schemas/partners";
import { ProgramSchema } from "@/lib/zod/schemas/programs";
import { NextResponse } from "next/server";
import { z } from "zod";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ export async function checkoutSessionCompleted(event: Stripe.Event) {
paymentProcessor: saleData.payment_processor,
amount: saleData.amount,
currency: saleData.currency,
programEnrollment,
partnerId: programEnrollment.partnerId,
program: programEnrollment.program,
metadata: {
...leadEvent.data[0],
stripeMetadata: charge,
Expand Down
3 changes: 2 additions & 1 deletion apps/web/app/api/stripe/connect/webhook/invoice-paid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ export async function invoicePaid(event: Stripe.Event) {
paymentProcessor: saleData.payment_processor,
amount: saleData.amount,
currency: saleData.currency,
programEnrollment,
partnerId: programEnrollment.partnerId,
program: programEnrollment.program,
metadata: {
...leadEvent.data[0],
stripeMetadata: invoice,
Expand Down
3 changes: 2 additions & 1 deletion apps/web/app/api/track/sale/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ export const POST = withWorkspaceEdge(
paymentProcessor,
amount,
currency,
programEnrollment,
partnerId: programEnrollment.partnerId,
program: programEnrollment.program,
metadata: clickData,
}),
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use client";

import { Button } from "@dub/ui";
import { Plus } from "@dub/ui/src/icons";
import { useInvitePartnerSheet } from "./invite-partner-sheet";

export function InvitePartnerButton() {
const { invitePartnerSheet, setIsOpen: setShowInvitePartnerSheet } =
useInvitePartnerSheet();

return (
<>
{invitePartnerSheet}
<Button
type="button"
variant="secondary"
onClick={() => setShowInvitePartnerSheet(true)}
text="Invite Partner"
icon={<Plus className="size-4" />}
/>
</>
);
}
Loading
Loading