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

Upgrade to React 19 and Next 15 #1356

Open
wants to merge 89 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
2b95696
Upgrade to React 19 and use PPR
steven-tey Oct 10, 2024
9074ee8
Upgrade a bunch more packages
TWilson023 Oct 11, 2024
fa79a6f
Merge branch 'main' into ppr-19
steven-tey Oct 21, 2024
6fdd73d
Update pnpm-lock.yaml
steven-tey Oct 21, 2024
05db108
Merge branch 'main' into ppr-19
devkiran Nov 20, 2024
e3cd16c
Merge branch 'main' into ppr-19
devkiran Nov 20, 2024
08979ef
Merge branch 'main' into ppr-19
devkiran Nov 27, 2024
73a9068
Upgrade to React 19 RC
devkiran Nov 27, 2024
8296250
upgrade Next 15
devkiran Nov 27, 2024
089bfa1
async cookie store
devkiran Nov 27, 2024
e82d8d6
async headers
devkiran Nov 27, 2024
b5d1533
temp fix
devkiran Nov 27, 2024
e3e993a
fixes
devkiran Nov 27, 2024
1c378c6
upgrade react
devkiran Nov 27, 2024
35a90d5
wip
devkiran Nov 27, 2024
caa8272
update pages
devkiran Nov 28, 2024
9552fb5
Merge branch 'main' into ppr-19
devkiran Nov 28, 2024
0479ac1
use await params or searchParams
devkiran Nov 28, 2024
f65e4ab
Update page-client.tsx
devkiran Nov 28, 2024
9e2fb24
run @next/codemod
devkiran Nov 28, 2024
8fe9e65
useActionState
devkiran Nov 28, 2024
538fdcd
ignore ts error
devkiran Nov 28, 2024
32433eb
run prettier
devkiran Nov 28, 2024
b822da4
Merge branch 'main' into ppr-19
devkiran Nov 28, 2024
80e4b13
Merge branch 'main' into ppr-19
devkiran Nov 29, 2024
85b1311
fix types
devkiran Nov 29, 2024
bb2ef34
fix build
devkiran Nov 29, 2024
a516c2d
run prettier
devkiran Nov 29, 2024
848b3a2
Update workspace.ts
devkiran Nov 29, 2024
395473e
Update admin.ts
devkiran Nov 29, 2024
f60c189
Update partner.ts
devkiran Nov 29, 2024
600dacc
Update session.ts
devkiran Nov 29, 2024
ab8d575
Update workspace.ts
devkiran Nov 29, 2024
e55036e
Merge branch 'main' into ppr-19
devkiran Nov 29, 2024
f0c74e6
Merge branch 'main' into ppr-19
devkiran Nov 29, 2024
d13ec58
Update pnpm-lock.yaml
devkiran Nov 29, 2024
85fc4bf
Merge branch 'main' into ppr-19
devkiran Dec 2, 2024
c16d0fd
upgrade typescript
devkiran Dec 2, 2024
f38cfe7
Update page.tsx
devkiran Dec 2, 2024
782c0d2
Update route.ts
devkiran Dec 2, 2024
de66697
Update page.tsx
devkiran Dec 2, 2024
a43e69c
Update page.tsx
devkiran Dec 2, 2024
55ad2c5
Update page.tsx
devkiran Dec 2, 2024
350e47d
some more fixes
devkiran Dec 2, 2024
d22af80
another fix
devkiran Dec 2, 2024
762015b
Update page.tsx
devkiran Dec 2, 2024
ff78e50
some more fixes
devkiran Dec 2, 2024
df4810e
a few more cleanup
devkiran Dec 2, 2024
141b7d5
Merge branch 'main' into ppr-19
steven-tey Dec 2, 2024
5916e61
Merge branch 'main' into ppr-19
devkiran Dec 3, 2024
df0b2d3
Merge branch 'main' into ppr-19
devkiran Dec 4, 2024
b5b25e9
fix page loading issue
devkiran Dec 4, 2024
0b160ab
fix payout page
devkiran Dec 4, 2024
65db188
revert
devkiran Dec 4, 2024
77ec840
revert temp fixes
devkiran Dec 5, 2024
78c5735
Merge branch 'main' into ppr-19
devkiran Dec 5, 2024
2897d0d
upgrade react-email
devkiran Dec 5, 2024
beff0fe
Merge branch 'main' into ppr-19
devkiran Dec 5, 2024
9238c66
Merge branch 'main' into ppr-19
devkiran Dec 5, 2024
a5b63db
remove unused
devkiran Dec 5, 2024
ee161d6
Update page.tsx
devkiran Dec 5, 2024
968d96c
remove a few export const dynamic
steven-tey Dec 5, 2024
1a27fd7
Merge branch 'main' into ppr-19
steven-tey Dec 5, 2024
db8d245
Merge branch 'main' into ppr-19
steven-tey Dec 5, 2024
c55003a
offload email sending to a Qstash
devkiran Dec 5, 2024
b5b7b55
missed some spots
devkiran Dec 5, 2024
c1709e2
Update sidebar-nav.tsx
devkiran Dec 5, 2024
fda873d
fix inert
devkiran Dec 5, 2024
7cddd6f
remove radix slot
steven-tey Dec 5, 2024
e899d06
use ppr + canary
steven-tey Dec 5, 2024
fb2bff8
move to root layout
steven-tey Dec 5, 2024
5dc3302
Merge branch 'main' into ppr-19
steven-tey Dec 5, 2024
86cba2f
wrap ReferButtonRSC in suspense
steven-tey Dec 5, 2024
4e7b4f6
remove ts-ignore
steven-tey Dec 5, 2024
6e81cb5
Revert "remove ts-ignore"
steven-tey Dec 5, 2024
305f1aa
Update program-settings.tsx
steven-tey Dec 5, 2024
86112a1
remove ts-ignore again
steven-tey Dec 5, 2024
a3d29a1
Delete page-client.tsx
steven-tey Dec 5, 2024
15b7b6c
add back ts-ignore
steven-tey Dec 5, 2024
377e26a
add back ts-ignore
steven-tey Dec 5, 2024
216427e
Merge branch 'main' into ppr-19
steven-tey Dec 10, 2024
d46043b
use ReferButtonRSC
steven-tey Dec 10, 2024
cf0f368
bump next to canary
steven-tey Dec 10, 2024
e39522a
Update refer-button.tsx
steven-tey Dec 10, 2024
b20e3d5
Delete route.ts
steven-tey Dec 10, 2024
f6d6ab5
use(params)
steven-tey Dec 10, 2024
c1e0bb7
use(params) → await params
steven-tey Dec 10, 2024
68e01bd
Merge branch 'main' into ppr-19
devkiran Dec 10, 2024
e02766b
Update page.tsx
devkiran Dec 10, 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
8 changes: 5 additions & 3 deletions apps/web/app/[domain]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ export const revalidate = 0;
export async function generateMetadata({
params,
}: {
params: { domain: string };
params: Promise<{ domain: string }>;
}) {
const title = `${params.domain.toUpperCase()} - A ${
const { domain } = await params;

const title = `${domain.toUpperCase()} - A ${
process.env.NEXT_PUBLIC_APP_NAME
} Custom Domain`;
const description = `${params.domain.toUpperCase()} is a custom domain on ${
const description = `${domain.toUpperCase()} is a custom domain on ${
process.env.NEXT_PUBLIC_APP_NAME
} - an open-source link management tool for modern marketing teams to create, share, and track short links.`;

Expand Down
8 changes: 5 additions & 3 deletions apps/web/app/[domain]/stats/[key]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ export const runtime = "edge";
export default async function OldStatsPage({
params,
}: {
params: { domain: string; key: string };
params: Promise<{ domain: string; key: string }>;
}) {
const { domain, key } = await params;

const link = await prismaEdge.link.findUnique({
where: {
domain_key: {
domain: params.domain,
key: params.key,
domain,
key,
},
},
select: {
Expand Down
81 changes: 81 additions & 0 deletions apps/web/app/api/cron/email/new-sale-created.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { limiter } from "@/lib/cron/limiter";
import { prisma } from "@/lib/prisma";
import z from "@/lib/zod";
import { sendEmail } from "emails";
import NewSaleCreated from "emails/new-sale-created";

const schema = z.object({
saleId: z.string(),
});

// Notify the partner about the new sale came via their referral link
export const newSaleCreated = async (payload: any) => {
const { saleId } = schema.parse(payload);

const { program, partner, ...sale } = await prisma.sale.findUniqueOrThrow({
where: {
id: saleId,
},
select: {
amount: true,
earnings: true,
program: {
select: {
id: true,
name: true,
logo: true,
},
},
partner: {
select: {
id: true,
programs: {
select: {
link: {
select: {
shortLink: true,
},
},
},
},
},
},
},
});

const referralLink = partner.programs[0].link?.shortLink!;

const partnerUsers = await prisma.partnerUser.findMany({
where: {
partnerId: partner.id,
},
include: {
user: {
select: {
email: true,
},
},
},
});

return await Promise.all(
partnerUsers.map(({ user }) =>
limiter.schedule(() =>
sendEmail({
subject: "You just made a sale via Dub Partners!",
from: "Dub Partners <[email protected]>",
email: user.email!,
react: NewSaleCreated({
email: user.email!,
program,
partner: {
id: partner.id,
referralLink,
},
sale,
}),
}),
),
),
);
};
38 changes: 38 additions & 0 deletions apps/web/app/api/cron/email/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { handleAndReturnErrorResponse } from "@/lib/api/errors";
import { verifyQstashSignature } from "@/lib/cron/verify-qstash";
import z from "@/lib/zod";
import { log } from "@dub/utils";
import { NextResponse } from "next/server";
import { newSaleCreated } from "./new-sale-created";

const schema = z.object({
event: z.string(),
payload: z.record(z.any()),
});

export async function POST(req: Request) {
try {
const body = await req.json();

await verifyQstashSignature(req, body);

const { event, payload } = schema.parse(body);

switch (event) {
case "new-sale-created":
await newSaleCreated(payload);
break;
}

return NextResponse.json({
response: "success",
});
} catch (error) {
await log({
message: `Error transferring domain: ${error.message}`,
type: "cron",
});

return handleAndReturnErrorResponse(error);
}
}
5 changes: 1 addition & 4 deletions apps/web/app/api/scim/v2.0/[...directory]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import type {
import { getSearchParams } from "@dub/utils";
import { NextResponse } from "next/server";

const handler = async (
req: Request,
{ params }: { params: Record<string, string> },
) => {
const handler = async (req: Request, { params }) => {
const authHeader = req.headers.get("Authorization");
const apiSecret = authHeader ? authHeader.split(" ")[1] : null;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { notifyPartnerSale } from "@/lib/api/partners/notify-partner-sale";
import { createSaleData } from "@/lib/api/sales/sale";
import { prisma } from "@/lib/prisma";
import { getLeadEvent, recordSale } from "@/lib/tinybird";
Expand All @@ -8,6 +7,7 @@ import { transformSaleEventData } from "@/lib/webhook/transform";
import { nanoid } from "@dub/utils";
import { Customer } from "@prisma/client";
import { waitUntil } from "@vercel/functions";
import { queueEmail } from "emails/publish-qstash";
import type Stripe from "stripe";

// Handle event "checkout.session.completed"
Expand Down Expand Up @@ -162,15 +162,10 @@ export async function checkoutSessionCompleted(event: Stripe.Event) {
});

waitUntil(
notifyPartnerSale({
partner: {
id: partner.id,
referralLink: link.shortLink,
},
program,
sale: {
amount: saleRecord.amount,
earnings: saleRecord.earnings,
queueEmail({
event: "new-sale-created",
payload: {
saleId: saleRecord.id,
},
}),
);
Expand Down
15 changes: 5 additions & 10 deletions apps/web/app/api/stripe/connect/webhook/invoice-paid.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { notifyPartnerSale } from "@/lib/api/partners/notify-partner-sale";
import { createSaleData } from "@/lib/api/sales/sale";
import { prisma } from "@/lib/prisma";
import { getLeadEvent, recordSale } from "@/lib/tinybird";
Expand All @@ -7,6 +6,7 @@ import { sendWorkspaceWebhook } from "@/lib/webhook/publish";
import { transformSaleEventData } from "@/lib/webhook/transform";
import { nanoid } from "@dub/utils";
import { waitUntil } from "@vercel/functions";
import { queueEmail } from "emails/publish-qstash";
import type Stripe from "stripe";

// Handle event "invoice.paid"
Expand Down Expand Up @@ -144,15 +144,10 @@ export async function invoicePaid(event: Stripe.Event) {
});

waitUntil(
notifyPartnerSale({
partner: {
id: partner.id,
referralLink: link.shortLink,
},
program,
sale: {
amount: saleRecord.amount,
earnings: saleRecord.earnings,
queueEmail({
event: "new-sale-created",
payload: {
saleId: saleRecord.id,
},
}),
);
Expand Down
16 changes: 6 additions & 10 deletions apps/web/app/api/track/sale/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { DubApiError } from "@/lib/api/errors";
import { notifyPartnerSale } from "@/lib/api/partners/notify-partner-sale";
import { createSaleData } from "@/lib/api/sales/sale";
import { parseRequestBody } from "@/lib/api/utils";
import { withWorkspaceEdge } from "@/lib/auth/workspace-edge";
Expand All @@ -14,6 +13,7 @@ import {
} from "@/lib/zod/schemas/sales";
import { nanoid } from "@dub/utils";
import { waitUntil } from "@vercel/functions";
import { queueEmail } from "emails/publish-qstash";
import { NextResponse } from "next/server";

export const runtime = "edge";
Expand Down Expand Up @@ -154,15 +154,11 @@ export const POST = withWorkspaceEdge(
prismaEdge.sale.create({
data: saleRecord,
}),
notifyPartnerSale({
partner: {
id: partner.id,
referralLink: link.shortLink,
},
program,
sale: {
amount: saleRecord.amount,
earnings: saleRecord.earnings,

queueEmail({
event: "new-sale-created",
payload: {
saleId: saleRecord.id,
},
}),
]);
Expand Down
17 changes: 0 additions & 17 deletions apps/web/app/api/user/embed-tokens/route.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { InputPassword } from "@dub/ui";

export const runtime = "nodejs";

interface Props {
params: {
token: string;
};
}
export default async function ResetPasswordPage({
params,
}: {
params: Promise<{ token: string }>;
}) {
const { token } = await params;

export default async function ResetPasswordPage({ params: { token } }: Props) {
const validToken = await isValidToken(token);

if (!validToken) {
Expand Down
12 changes: 6 additions & 6 deletions apps/web/app/app.dub.co/(auth)/invites/[code]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import { LoadingSpinner } from "@dub/ui";
import { LinkBroken, Users6 } from "@dub/ui/src/icons";
import { APP_NAME } from "@dub/utils";
import { redirect } from "next/navigation";
import { Suspense } from "react";
import { Suspense, use } from "react";

export const runtime = "nodejs";

export default function InitesPage({
export default function InvitesPage({
params,
}: {
params: {
code: string;
};
params: Promise<{ code: string }>;
}) {
const { code } = use(params);

return (
<div className="flex flex-col items-center justify-center gap-6 text-center">
<Suspense
Expand All @@ -27,7 +27,7 @@ export default function InitesPage({
/>
}
>
<VerifyInvite code={params.code} />
<VerifyInvite code={code} />
</Suspense>
</div>
);
Expand Down
7 changes: 4 additions & 3 deletions apps/web/app/app.dub.co/(auth)/oauth/authorize/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ export const metadata = constructMetadata({
export default async function Authorize({
searchParams,
}: {
searchParams?: z.infer<typeof authorizeRequestSchema>;
searchParams?: Promise<z.infer<typeof authorizeRequestSchema>>;
}) {
const session = await getSession();

if (!session) {
redirect("/login");
}

const { error, integration, requestParams } =
await vaidateAuthorizeRequest(searchParams);
const { error, integration, requestParams } = await vaidateAuthorizeRequest(
await searchParams,
);

if (error || !integration) {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { PageContent } from "@/ui/layout/page-content";
import { MaxWidthWrapper } from "@dub/ui";
import { use } from "react";
import { InvitePartnerButton } from "../invite-partner-button";
import { ProgramPartnersInvitesPageClient } from "./page-client";

export default function ProgramPartners({
params: { slug, programId },
params,
}: {
params: { slug: string; programId: string };
params: Promise<{ slug: string; programId: string }>;
}) {
const { slug, programId } = use(params);

return (
<PageContent
title="Invited partners"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ function usePartnerFilterOptions(search: string) {
(p) => p.id === searchParamsObj.partnerId,
))
? null
: ([
: // @ts-ignore
([
...(partners ?? []),
// Add selected partner to list if not already in partners
...(selectedPartners
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ const SaleTableBusinessInner = memo(
minSize: 43,
size: 43,
maxSize: 43,
// @ts-ignore
cell: ({ row }) => <SaleRowMenu row={row} />,
},
],
Expand Down
Loading
Loading