Skip to content

Commit b7158c2

Browse files
authored
add projectId parameter to pay analytics components (#6245)
1 parent 5f26883 commit b7158c2

File tree

15 files changed

+224
-8
lines changed

15 files changed

+224
-8
lines changed

apps/dashboard/src/app/team/[team_slug]/[project_slug]/connect/pay/page.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,11 @@ export default async function Page(props: {
1717
notFound();
1818
}
1919

20-
return <PayAnalytics clientId={project.publishableKey} />;
20+
return (
21+
<PayAnalytics
22+
clientId={project.publishableKey}
23+
projectId={project.id}
24+
teamId={project.teamId}
25+
/>
26+
);
2127
}

apps/dashboard/src/app/team/[team_slug]/[project_slug]/connect/pay/webhooks/components/webhooks.client.tsx

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ type Webhook = {
6060
};
6161

6262
type PayWebhooksPageProps = {
63+
/**
64+
* @deprecated - remove after migration
65+
*/
6366
clientId: string;
67+
// switching to projectId for lookup, but have to send both during migration
68+
projectId: string;
69+
teamId: string;
6470
};
6571

6672
export function PayWebhooksPage(props: PayWebhooksPageProps) {
@@ -71,7 +77,13 @@ export function PayWebhooksPage(props: PayWebhooksPageProps) {
7177
method: "GET",
7278
pathname: "/webhooks/get-all",
7379
searchParams: {
80+
/**
81+
* @deprecated - remove after migration
82+
*/
7483
clientId: props.clientId,
84+
// switching to projectId for lookup, but have to send both during migration
85+
projectId: props.projectId,
86+
teamId: props.teamId,
7587
},
7688
headers: {
7789
"Content-Type": "application/json",
@@ -95,7 +107,11 @@ export function PayWebhooksPage(props: PayWebhooksPageProps) {
95107
return (
96108
<div className="flex flex-col items-center gap-8 rounded-lg border border-border p-8 text-center">
97109
<h2 className="font-semibold text-xl">No webhooks configured yet.</h2>
98-
<CreateWebhookButton clientId={props.clientId}>
110+
<CreateWebhookButton
111+
clientId={props.clientId}
112+
projectId={props.projectId}
113+
teamId={props.teamId}
114+
>
99115
<Button variant="primary" className="gap-1">
100116
<PlusIcon className="size-4" />
101117
<span>Create Webhook</span>
@@ -109,7 +125,11 @@ export function PayWebhooksPage(props: PayWebhooksPageProps) {
109125
<div>
110126
<div className="flex items-center justify-between">
111127
<h2 className="font-semibold text-xl tracking-tight">Webhooks</h2>
112-
<CreateWebhookButton clientId={props.clientId}>
128+
<CreateWebhookButton
129+
clientId={props.clientId}
130+
projectId={props.projectId}
131+
teamId={props.teamId}
132+
>
113133
<Button size="sm" variant="default" className="gap-1">
114134
<PlusIcon className="size-4" />
115135
<span>Create Webhook</span>
@@ -149,7 +169,9 @@ export function PayWebhooksPage(props: PayWebhooksPageProps) {
149169
<TableCell className="text-right">
150170
<DeleteWebhookButton
151171
clientId={props.clientId}
172+
projectId={props.projectId}
152173
webhookId={webhook.id}
174+
teamId={props.teamId}
153175
>
154176
<Button variant="ghost" size="icon">
155177
<TrashIcon className="size-5" strokeWidth={1} />
@@ -185,7 +207,15 @@ function CreateWebhookButton(props: PropsWithChildren<PayWebhooksPageProps>) {
185207
const res = await payServerProxy({
186208
method: "POST",
187209
pathname: "/webhooks/create",
188-
body: JSON.stringify({ ...values, clientId: props.clientId }),
210+
body: JSON.stringify({
211+
...values,
212+
/**
213+
* @deprecated - remove after migration
214+
*/
215+
clientId: props.clientId,
216+
// switching to projectId for lookup, but have to send both during migration
217+
projectId: props.projectId,
218+
}),
189219
headers: {
190220
"Content-Type": "application/json",
191221
},
@@ -311,7 +341,15 @@ function DeleteWebhookButton(
311341
headers: {
312342
"Content-Type": "application/json",
313343
},
314-
body: JSON.stringify({ id, clientId: props.clientId }),
344+
body: JSON.stringify({
345+
id,
346+
/**
347+
* @deprecated - remove after migration
348+
*/
349+
clientId: props.clientId,
350+
// switching to projectId for lookup, but have to send both during migration
351+
projectId: props.projectId,
352+
}),
315353
pathname: "/webhooks/revoke",
316354
});
317355

apps/dashboard/src/app/team/[team_slug]/[project_slug]/connect/pay/webhooks/page.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,11 @@ export default async function Page(props: {
1717
notFound();
1818
}
1919

20-
return <PayWebhooksPage clientId={project.publishableKey} />;
20+
return (
21+
<PayWebhooksPage
22+
clientId={project.publishableKey}
23+
projectId={project.id}
24+
teamId={project.teamId}
25+
/>
26+
);
2127
}

apps/dashboard/src/components/pay/PayAnalytics/PayAnalytics.tsx

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,18 @@ import { Payouts } from "./components/Payouts";
1414
import { TotalPayVolume } from "./components/TotalPayVolume";
1515
import { TotalVolumePieChart } from "./components/TotalVolumePieChart";
1616

17-
export function PayAnalytics(props: { clientId: string }) {
17+
export function PayAnalytics(props: {
18+
/**
19+
* @deprecated - remove after migration
20+
*/
21+
clientId: string;
22+
// switching to projectId for lookup, but have to send both during migration
23+
projectId: string;
24+
teamId: string;
25+
}) {
1826
const clientId = props.clientId;
27+
const projectId = props.projectId;
28+
const teamId = props.teamId;
1929
const [range, setRange] = useState<Range>(() =>
2030
getLastNDaysRange("last-120"),
2131
);
@@ -34,12 +44,16 @@ export function PayAnalytics(props: { clientId: string }) {
3444
<div className="flex items-center border-border border-b pb-6 xl:border-none xl:pb-0">
3545
<TotalVolumePieChart
3646
clientId={clientId}
47+
projectId={projectId}
48+
teamId={teamId}
3749
from={range.from}
3850
to={range.to}
3951
/>
4052
</div>
4153
<TotalPayVolume
4254
clientId={clientId}
55+
projectId={projectId}
56+
teamId={teamId}
4357
from={range.from}
4458
to={range.to}
4559
numberOfDays={numberOfDays}
@@ -50,6 +64,8 @@ export function PayAnalytics(props: { clientId: string }) {
5064
<CardContainer>
5165
<Payouts
5266
clientId={clientId}
67+
projectId={projectId}
68+
teamId={teamId}
5369
from={range.from}
5470
to={range.to}
5571
numberOfDays={numberOfDays}
@@ -58,6 +74,8 @@ export function PayAnalytics(props: { clientId: string }) {
5874
<CardContainer>
5975
<PaymentsSuccessRate
6076
clientId={clientId}
77+
projectId={projectId}
78+
teamId={teamId}
6179
from={range.from}
6280
to={range.to}
6381
/>
@@ -68,20 +86,30 @@ export function PayAnalytics(props: { clientId: string }) {
6886
<div className="border-border border-b pb-6 xl:border-none xl:pb-0">
6987
<PayNewCustomers
7088
clientId={clientId}
89+
projectId={projectId}
90+
teamId={teamId}
7191
from={range.from}
7292
to={range.to}
7393
numberOfDays={numberOfDays}
7494
/>
7595
</div>
7696
<PayCustomersTable
7797
clientId={clientId}
98+
projectId={projectId}
99+
teamId={teamId}
78100
from={range.from}
79101
to={range.to}
80102
/>
81103
</GridWithSeparator>
82104

83105
<CardContainer>
84-
<PaymentHistory clientId={clientId} from={range.from} to={range.to} />
106+
<PaymentHistory
107+
clientId={clientId}
108+
projectId={projectId}
109+
teamId={teamId}
110+
from={range.from}
111+
to={range.to}
112+
/>
85113
</CardContainer>
86114
</div>
87115
</div>

apps/dashboard/src/components/pay/PayAnalytics/components/PayCustomersTable.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,13 @@ function processQuery(
7171
}
7272

7373
export function PayCustomersTable(props: {
74+
/**
75+
* @deprecated - remove after migration
76+
*/
7477
clientId: string;
78+
// switching to projectId for lookup, but have to send both during migration
79+
projectId: string;
80+
teamId: string;
7581
from: Date;
7682
to: Date;
7783
}) {
@@ -80,7 +86,13 @@ export function PayCustomersTable(props: {
8086
);
8187

8288
const topCustomersQuery = usePayCustomers({
89+
/**
90+
* @deprecated - remove after migration
91+
*/
8392
clientId: props.clientId,
93+
// switching to projectId for lookup, but have to send both during migration
94+
projectId: props.projectId,
95+
teamId: props.teamId,
8496
from: props.from,
8597
to: props.to,
8698
pageSize: 100,

apps/dashboard/src/components/pay/PayAnalytics/components/PayNewCustomers.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ function processQuery(
6969
}
7070

7171
export function PayNewCustomers(props: {
72+
/**
73+
* @deprecated - remove after migration
74+
*/
7275
clientId: string;
76+
// switching to projectId for lookup, but have to send both during migration
77+
projectId: string;
78+
teamId: string;
7379
from: Date;
7480
to: Date;
7581
numberOfDays: number;
@@ -86,7 +92,13 @@ export function PayNewCustomers(props: {
8692

8793
const uiQuery = processQuery(
8894
usePayNewCustomers({
95+
/**
96+
* @deprecated - remove after migration
97+
*/
8998
clientId: props.clientId,
99+
// switching to projectId for lookup, but have to send both during migration
100+
projectId: props.projectId,
101+
teamId: props.teamId,
90102
from: props.from,
91103
to: props.to,
92104
intervalType,

apps/dashboard/src/components/pay/PayAnalytics/components/PaymentHistory.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,26 @@ function processQuery(
6363
}
6464

6565
export function PaymentHistory(props: {
66+
/**
67+
* @deprecated - remove after migration
68+
*/
6669
clientId: string;
70+
// switching to projectId for lookup, but have to send both during migration
71+
projectId: string;
72+
teamId: string;
6773
from: Date;
6874
to: Date;
6975
}) {
7076
const [page, setPage] = useState(1);
7177

7278
const purchasesQuery = usePayPurchases({
79+
/**
80+
* @deprecated - remove after migration
81+
*/
7382
clientId: props.clientId,
83+
// switching to projectId for lookup, but have to send both during migration
84+
projectId: props.projectId,
85+
teamId: props.teamId,
7486
from: props.from,
7587
to: props.to,
7688
start: (page - 1) * pageSize,
@@ -88,7 +100,13 @@ export function PaymentHistory(props: {
88100
fileName="transaction_history"
89101
getData={async () => {
90102
const purchaseData = await getPayPurchases({
103+
/**
104+
* @deprecated - remove after migration
105+
*/
91106
clientId: props.clientId,
107+
// switching to projectId for lookup, but have to send both during migration
108+
projectId: props.projectId,
109+
teamId: props.teamId,
92110
count: 10000,
93111
from: props.from,
94112
start: 0,

apps/dashboard/src/components/pay/PayAnalytics/components/PaymentsSuccessRate.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,27 @@ function processQuery(
8989
}
9090

9191
export function PaymentsSuccessRate(props: {
92+
/**
93+
* @deprecated - remove after migration
94+
*/
9295
clientId: string;
96+
// switching to projectId for lookup, but have to send both during migration
97+
projectId: string;
98+
teamId: string;
9399
from: Date;
94100
to: Date;
95101
}) {
96102
const [type, setType] = useState<PayVolumeType>("all");
97103

98104
const uiQuery = processQuery(
99105
usePayVolume({
106+
/**
107+
* @deprecated - remove after migration
108+
*/
100109
clientId: props.clientId,
110+
// switching to projectId for lookup, but have to send both during migration
111+
projectId: props.projectId,
112+
teamId: props.teamId,
101113
from: props.from,
102114
to: props.to,
103115
intervalType: "day",

apps/dashboard/src/components/pay/PayAnalytics/components/Payouts.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,13 @@ function processQuery(query: ReturnType<typeof usePayVolume>): ProcessedQuery {
6565
}
6666

6767
export function Payouts(props: {
68+
/**
69+
* @deprecated - remove after migration
70+
*/
6871
clientId: string;
72+
// switching to projectId for lookup, but have to send both during migration
73+
projectId: string;
74+
teamId: string;
6975
from: Date;
7076
to: Date;
7177
numberOfDays: number;
@@ -82,7 +88,13 @@ export function Payouts(props: {
8288

8389
const uiQuery = processQuery(
8490
usePayVolume({
91+
/**
92+
* @deprecated - remove after migration
93+
*/
8594
clientId: props.clientId,
95+
// switching to projectId for lookup, but have to send both during migration
96+
projectId: props.projectId,
97+
teamId: props.teamId,
8698
from: props.from,
8799
to: props.to,
88100
intervalType,

apps/dashboard/src/components/pay/PayAnalytics/components/TotalPayVolume.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ function processQuery(
5454
}
5555

5656
export function TotalPayVolume(props: {
57+
/**
58+
* @deprecated - remove after migration
59+
*/
5760
clientId: string;
61+
// switching to projectId for lookup, but have to send both during migration
62+
projectId: string;
63+
teamId: string;
5864
from: Date;
5965
to: Date;
6066
numberOfDays: number;
@@ -71,7 +77,13 @@ export function TotalPayVolume(props: {
7177

7278
const volumeQuery = processQuery(
7379
usePayVolume({
80+
/**
81+
* @deprecated - remove after migration
82+
*/
7483
clientId: props.clientId,
84+
// switching to projectId for lookup, but have to send both during migration
85+
projectId: props.projectId,
86+
teamId: props.teamId,
7587
from: props.from,
7688
intervalType,
7789
to: props.to,

0 commit comments

Comments
 (0)