-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Customers pages updates #3235
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
Open
TWilson023
wants to merge
33
commits into
main
Choose a base branch
from
customers-updates
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,396
−719
Open
Customers pages updates #3235
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
a3d66e5
WIP customer page updates
TWilson023 3a81c38
Update partner-nav.tsx
TWilson023 01a7ba5
More WIP customer page
TWilson023 70c5c14
Merge branch 'main' into customers-updates
TWilson023 612be20
WIP
TWilson023 5cbd56a
Merge branch 'main' into customers-updates
TWilson023 a0d579d
Sales table tweaks
TWilson023 b182979
Update customer-details-column.tsx
TWilson023 4199328
Referral partner info
TWilson023 9ce98d0
Responsive grid rework
TWilson023 69b3a0e
Add stats
TWilson023 88ef57a
Update timestamp-tooltip.tsx
TWilson023 5a30c9c
Update customer-details-column.tsx
TWilson023 8a0896d
WIP program customers
TWilson023 67707c1
Merge branch 'main' into customers-updates
TWilson023 58a0225
Add partner column to program customers table
TWilson023 5f7f2e5
Update customer links
TWilson023 d64358c
Update more links
TWilson023 ce129a6
Improve layout/page code duplication
TWilson023 0e44eff
Update links
TWilson023 fe2e63b
Merge branch 'main' into customers-updates
TWilson023 8e96c81
Update layout.tsx
TWilson023 9911e1b
Update app-redirect.ts
TWilson023 f007c16
Update customer-table.tsx
TWilson023 fd058df
Update customer-table.tsx
TWilson023 efb8fab
Merge branch 'customers-updates' of github.com:dubinc/dub into custom…
TWilson023 9606a45
Quick fixes
TWilson023 20fe549
Misc. fixes
TWilson023 63a4d2a
Update partner-side customer page
TWilson023 72d6ee1
Merge branch 'main' into customers-updates
TWilson023 b2b56bc
Update app-redirect.ts
TWilson023 6eaeae3
Merge branch 'customers-updates' of github.com:dubinc/dub into custom…
TWilson023 cbf5fe2
Name tweaks
TWilson023 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 1 addition & 9 deletions
10
...ners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,5 @@ | ||
| import { PageContent } from "@/ui/layout/page-content"; | ||
| import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper"; | ||
| import { ProgramCustomerPageClient } from "./page-client"; | ||
|
|
||
| export default function ProgramCustomer() { | ||
| return ( | ||
| <PageContent> | ||
| <PageWidthWrapper className="flex flex-col gap-6 pb-10"> | ||
| <ProgramCustomerPageClient /> | ||
| </PageWidthWrapper> | ||
| </PageContent> | ||
| ); | ||
| return <ProgramCustomerPageClient />; | ||
| } |
107 changes: 107 additions & 0 deletions
107
...eb/app/app.dub.co/(dashboard)/[slug]/(ee)/customers/[customerId]/earnings/page-client.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| "use client"; | ||
|
|
||
| import { CUSTOMER_PAGE_EVENTS_LIMIT } from "@/lib/constants/misc"; | ||
| import useCustomer from "@/lib/swr/use-customer"; | ||
| import useWorkspace from "@/lib/swr/use-workspace"; | ||
| import { CommissionResponse, CustomerEnriched } from "@/lib/types"; | ||
| import { CustomerPartnerEarningsTable } from "@/ui/customers/customer-partner-earnings-table"; | ||
| import { ArrowUpRight } from "@dub/ui"; | ||
| import { OG_AVATAR_URL, fetcher } from "@dub/utils"; | ||
| import Link from "next/link"; | ||
| import { redirect, useParams } from "next/navigation"; | ||
| import { memo } from "react"; | ||
| import useSWR from "swr"; | ||
|
|
||
| export function CustomerEarningsPageClient() { | ||
| const { customerId } = useParams<{ customerId: string }>(); | ||
|
|
||
| const { slug } = useWorkspace(); | ||
| const { data: customer, isLoading } = useCustomer<CustomerEnriched>({ | ||
| customerId, | ||
| query: { includeExpandedFields: true }, | ||
| }); | ||
|
|
||
| if (!customer && !isLoading) redirect(`/${slug}/customers`); | ||
|
|
||
| return !customer || (customer.partner && customer.programId) ? ( | ||
| <section className="flex flex-col gap-4"> | ||
| <h2 className="text-lg font-semibold text-neutral-900"> | ||
| Partner earnings | ||
| </h2> | ||
| <div className="border-border-subtle flex flex-col overflow-hidden rounded-lg border"> | ||
| <Link | ||
| href={`/${slug}/program/partners/${customer?.partner?.id}`} | ||
| target="_blank" | ||
| className="group flex items-center justify-between overflow-hidden bg-neutral-100 px-3 py-2.5" | ||
| > | ||
| <div className="flex min-w-0 items-center gap-3"> | ||
| {customer?.partner ? ( | ||
| <> | ||
| <img | ||
| src={ | ||
| customer?.partner?.image || | ||
| `${OG_AVATAR_URL}${customer?.partner?.name}` | ||
| } | ||
| alt={customer.partner.name} | ||
| className="size-5 rounded-full" | ||
| /> | ||
| <span className="block min-w-0 truncate text-sm font-medium text-neutral-900"> | ||
| {customer.partner.name} | ||
| </span> | ||
| </> | ||
| ) : ( | ||
| <> | ||
| <div className="size-5 animate-pulse rounded-full bg-neutral-200" /> | ||
| <div className="h-5 w-24 animate-pulse rounded bg-neutral-200" /> | ||
| </> | ||
| )} | ||
| </div> | ||
| <ArrowUpRight className="size-3 shrink-0 -translate-x-0.5 translate-y-0.5 opacity-0 transition-[transform,opacity] group-hover:translate-x-0 group-hover:translate-y-0 group-hover:opacity-100" /> | ||
| </Link> | ||
|
|
||
| <div className="border-border-subtle border-t"> | ||
| <PartnerEarningsTable customerId={customerId} /> | ||
| </div> | ||
| </div> | ||
| </section> | ||
| ) : null; | ||
| } | ||
|
|
||
| const PartnerEarningsTable = memo(({ customerId }: { customerId: string }) => { | ||
| const { id: workspaceId, slug } = useWorkspace(); | ||
|
|
||
| const { data: commissions, isLoading: isComissionsLoading } = useSWR< | ||
| CommissionResponse[] | ||
| >( | ||
| `/api/commissions?${new URLSearchParams({ | ||
| customerId, | ||
| workspaceId: workspaceId!, | ||
| pageSize: CUSTOMER_PAGE_EVENTS_LIMIT.toString(), | ||
| })}`, | ||
| fetcher, | ||
| ); | ||
|
|
||
| const { data: totalCommissions, isLoading: isTotalCommissionsLoading } = | ||
| useSWR<{ all: { count: number } }>( | ||
| // Only fetch total earnings count if the earnings data is equal to the limit | ||
| commissions?.length === CUSTOMER_PAGE_EVENTS_LIMIT && | ||
| `/api/commissions/count?${new URLSearchParams({ | ||
| customerId, | ||
| workspaceId: workspaceId!, | ||
| })}`, | ||
| fetcher, | ||
| ); | ||
|
|
||
| return ( | ||
| <CustomerPartnerEarningsTable | ||
| commissions={commissions} | ||
| totalCommissions={ | ||
| isTotalCommissionsLoading | ||
| ? undefined | ||
| : totalCommissions?.all?.count ?? commissions?.length | ||
| } | ||
| viewAllHref={`/${slug}/program/commissions?customerId=${customerId}`} | ||
| isLoading={isComissionsLoading} | ||
| /> | ||
| ); | ||
| }); | ||
5 changes: 5 additions & 0 deletions
5
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/customers/[customerId]/earnings/page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { CustomerEarningsPageClient } from "./page-client"; | ||
|
|
||
| export default function CustomerEarningsPage() { | ||
| return <CustomerEarningsPageClient />; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.