Skip to content

Commit cabc1b9

Browse files
committed
add projectId parameter to pay analytics components
1 parent 880148b commit cabc1b9

File tree

15 files changed

+179
-8
lines changed

15 files changed

+179
-8
lines changed

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

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

20-
return <PayAnalytics clientId={project.publishableKey} />;
20+
return (
21+
<PayAnalytics clientId={project.publishableKey} projectId={project.id} />
22+
);
2123
}

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

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ 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;
6469
};
6570

6671
export function PayWebhooksPage(props: PayWebhooksPageProps) {
@@ -71,7 +76,12 @@ export function PayWebhooksPage(props: PayWebhooksPageProps) {
7176
method: "GET",
7277
pathname: "/webhooks/get-all",
7378
searchParams: {
79+
/**
80+
* @deprecated - remove after migration
81+
*/
7482
clientId: props.clientId,
83+
// switching to projectId for lookup, but have to send both during migration
84+
projectId: props.projectId,
7585
},
7686
headers: {
7787
"Content-Type": "application/json",
@@ -95,7 +105,10 @@ export function PayWebhooksPage(props: PayWebhooksPageProps) {
95105
return (
96106
<div className="flex flex-col items-center gap-8 rounded-lg border border-border p-8 text-center">
97107
<h2 className="font-semibold text-xl">No webhooks configured yet.</h2>
98-
<CreateWebhookButton clientId={props.clientId}>
108+
<CreateWebhookButton
109+
clientId={props.clientId}
110+
projectId={props.projectId}
111+
>
99112
<Button variant="primary" className="gap-1">
100113
<PlusIcon className="size-4" />
101114
<span>Create Webhook</span>
@@ -109,7 +122,10 @@ export function PayWebhooksPage(props: PayWebhooksPageProps) {
109122
<div>
110123
<div className="flex items-center justify-between">
111124
<h2 className="font-semibold text-xl tracking-tight">Webhooks</h2>
112-
<CreateWebhookButton clientId={props.clientId}>
125+
<CreateWebhookButton
126+
clientId={props.clientId}
127+
projectId={props.projectId}
128+
>
113129
<Button size="sm" variant="default" className="gap-1">
114130
<PlusIcon className="size-4" />
115131
<span>Create Webhook</span>
@@ -149,6 +165,7 @@ export function PayWebhooksPage(props: PayWebhooksPageProps) {
149165
<TableCell className="text-right">
150166
<DeleteWebhookButton
151167
clientId={props.clientId}
168+
projectId={props.projectId}
152169
webhookId={webhook.id}
153170
>
154171
<Button variant="ghost" size="icon">
@@ -185,7 +202,15 @@ function CreateWebhookButton(props: PropsWithChildren<PayWebhooksPageProps>) {
185202
const res = await payServerProxy({
186203
method: "POST",
187204
pathname: "/webhooks/create",
188-
body: JSON.stringify({ ...values, clientId: props.clientId }),
205+
body: JSON.stringify({
206+
...values,
207+
/**
208+
* @deprecated - remove after migration
209+
*/
210+
clientId: props.clientId,
211+
// switching to projectId for lookup, but have to send both during migration
212+
projectId: props.projectId,
213+
}),
189214
headers: {
190215
"Content-Type": "application/json",
191216
},
@@ -311,7 +336,15 @@ function DeleteWebhookButton(
311336
headers: {
312337
"Content-Type": "application/json",
313338
},
314-
body: JSON.stringify({ id, clientId: props.clientId }),
339+
body: JSON.stringify({
340+
id,
341+
/**
342+
* @deprecated - remove after migration
343+
*/
344+
clientId: props.clientId,
345+
// switching to projectId for lookup, but have to send both during migration
346+
projectId: props.projectId,
347+
}),
315348
pathname: "/webhooks/revoke",
316349
});
317350

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

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

20-
return <PayWebhooksPage clientId={project.publishableKey} />;
20+
return (
21+
<PayWebhooksPage clientId={project.publishableKey} projectId={project.id} />
22+
);
2123
}

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,16 @@ 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+
}) {
1825
const clientId = props.clientId;
26+
const projectId = props.projectId;
1927
const [range, setRange] = useState<Range>(() =>
2028
getLastNDaysRange("last-120"),
2129
);
@@ -34,12 +42,14 @@ export function PayAnalytics(props: { clientId: string }) {
3442
<div className="flex items-center border-border border-b pb-6 xl:border-none xl:pb-0">
3543
<TotalVolumePieChart
3644
clientId={clientId}
45+
projectId={projectId}
3746
from={range.from}
3847
to={range.to}
3948
/>
4049
</div>
4150
<TotalPayVolume
4251
clientId={clientId}
52+
projectId={projectId}
4353
from={range.from}
4454
to={range.to}
4555
numberOfDays={numberOfDays}
@@ -50,6 +60,7 @@ export function PayAnalytics(props: { clientId: string }) {
5060
<CardContainer>
5161
<Payouts
5262
clientId={clientId}
63+
projectId={projectId}
5364
from={range.from}
5465
to={range.to}
5566
numberOfDays={numberOfDays}
@@ -58,6 +69,7 @@ export function PayAnalytics(props: { clientId: string }) {
5869
<CardContainer>
5970
<PaymentsSuccessRate
6071
clientId={clientId}
72+
projectId={projectId}
6173
from={range.from}
6274
to={range.to}
6375
/>
@@ -68,20 +80,27 @@ export function PayAnalytics(props: { clientId: string }) {
6880
<div className="border-border border-b pb-6 xl:border-none xl:pb-0">
6981
<PayNewCustomers
7082
clientId={clientId}
83+
projectId={projectId}
7184
from={range.from}
7285
to={range.to}
7386
numberOfDays={numberOfDays}
7487
/>
7588
</div>
7689
<PayCustomersTable
7790
clientId={clientId}
91+
projectId={projectId}
7892
from={range.from}
7993
to={range.to}
8094
/>
8195
</GridWithSeparator>
8296

8397
<CardContainer>
84-
<PaymentHistory clientId={clientId} from={range.from} to={range.to} />
98+
<PaymentHistory
99+
clientId={clientId}
100+
projectId={projectId}
101+
from={range.from}
102+
to={range.to}
103+
/>
85104
</CardContainer>
86105
</div>
87106
</div>

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,12 @@ 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;
7580
from: Date;
7681
to: Date;
7782
}) {
@@ -80,7 +85,12 @@ export function PayCustomersTable(props: {
8085
);
8186

8287
const topCustomersQuery = usePayCustomers({
88+
/**
89+
* @deprecated - remove after migration
90+
*/
8391
clientId: props.clientId,
92+
// switching to projectId for lookup, but have to send both during migration
93+
projectId: props.projectId,
8494
from: props.from,
8595
to: props.to,
8696
pageSize: 100,

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ 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;
7378
from: Date;
7479
to: Date;
7580
numberOfDays: number;
@@ -86,7 +91,12 @@ export function PayNewCustomers(props: {
8691

8792
const uiQuery = processQuery(
8893
usePayNewCustomers({
94+
/**
95+
* @deprecated - remove after migration
96+
*/
8997
clientId: props.clientId,
98+
// switching to projectId for lookup, but have to send both during migration
99+
projectId: props.projectId,
90100
from: props.from,
91101
to: props.to,
92102
intervalType,

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,24 @@ 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;
6772
from: Date;
6873
to: Date;
6974
}) {
7075
const [page, setPage] = useState(1);
7176

7277
const purchasesQuery = usePayPurchases({
78+
/**
79+
* @deprecated - remove after migration
80+
*/
7381
clientId: props.clientId,
82+
// switching to projectId for lookup, but have to send both during migration
83+
projectId: props.projectId,
7484
from: props.from,
7585
to: props.to,
7686
start: (page - 1) * pageSize,
@@ -88,7 +98,12 @@ export function PaymentHistory(props: {
8898
fileName="transaction_history"
8999
getData={async () => {
90100
const purchaseData = await getPayPurchases({
101+
/**
102+
* @deprecated - remove after migration
103+
*/
91104
clientId: props.clientId,
105+
// switching to projectId for lookup, but have to send both during migration
106+
projectId: props.projectId,
92107
count: 10000,
93108
from: props.from,
94109
start: 0,

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,25 @@ 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;
9398
from: Date;
9499
to: Date;
95100
}) {
96101
const [type, setType] = useState<PayVolumeType>("all");
97102

98103
const uiQuery = processQuery(
99104
usePayVolume({
105+
/**
106+
* @deprecated - remove after migration
107+
*/
100108
clientId: props.clientId,
109+
// switching to projectId for lookup, but have to send both during migration
110+
projectId: props.projectId,
101111
from: props.from,
102112
to: props.to,
103113
intervalType: "day",

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ 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;
6974
from: Date;
7075
to: Date;
7176
numberOfDays: number;
@@ -82,7 +87,12 @@ export function Payouts(props: {
8287

8388
const uiQuery = processQuery(
8489
usePayVolume({
90+
/**
91+
* @deprecated - remove after migration
92+
*/
8593
clientId: props.clientId,
94+
// switching to projectId for lookup, but have to send both during migration
95+
projectId: props.projectId,
8696
from: props.from,
8797
to: props.to,
8898
intervalType,

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ 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;
5863
from: Date;
5964
to: Date;
6065
numberOfDays: number;
@@ -71,7 +76,12 @@ export function TotalPayVolume(props: {
7176

7277
const volumeQuery = processQuery(
7378
usePayVolume({
79+
/**
80+
* @deprecated - remove after migration
81+
*/
7482
clientId: props.clientId,
83+
// switching to projectId for lookup, but have to send both during migration
84+
projectId: props.projectId,
7585
from: props.from,
7686
intervalType,
7787
to: props.to,

0 commit comments

Comments
 (0)