-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Settings pages update #3191
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
Merged
Merged
Settings pages update #3191
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions
11
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/layout.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,11 @@ | ||
| import { PageContent } from "@/ui/layout/page-content"; | ||
| import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper"; | ||
| import { ReactNode } from "react"; | ||
|
|
||
| export default function BillingLayout({ children }: { children: ReactNode }) { | ||
| return ( | ||
| <PageContent title="Billing"> | ||
| <PageWidthWrapper>{children}</PageWidthWrapper> | ||
| </PageContent> | ||
| ); | ||
| } |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions
24
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/layout.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,24 @@ | ||
| import { PageContent } from "@/ui/layout/page-content"; | ||
| import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper"; | ||
| import { ReactNode } from "react"; | ||
|
|
||
| export default function IntegrationsLayout({ | ||
| children, | ||
| }: { | ||
| children: ReactNode; | ||
| }) { | ||
| return ( | ||
| <PageContent | ||
| title="Integrations" | ||
| titleInfo={{ | ||
| title: | ||
| "Use Dub with your existing favorite tools with our seamless integrations.", | ||
| href: "https://d.to/integrations", | ||
| }} | ||
| > | ||
| <PageWidthWrapper className="max-w-[800px] pb-20"> | ||
| {children} | ||
| </PageWidthWrapper> | ||
| </PageContent> | ||
| ); | ||
| } |
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/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,7 @@ | ||
| import { IntegrationsList } from "./integrations-list"; | ||
|
|
||
| export const revalidate = 300; // 5 minutes | ||
|
|
||
| export default function IntegrationsPage() { | ||
| return <IntegrationsList />; | ||
| } |
1 change: 0 additions & 1 deletion
1
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/layout.tsx
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions
21
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/notifications/layout.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,21 @@ | ||
| import { PageContent } from "@/ui/layout/page-content"; | ||
| import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper"; | ||
| import { ReactNode } from "react"; | ||
|
|
||
| export default function NotificationsLayout({ | ||
| children, | ||
| }: { | ||
| children: ReactNode; | ||
| }) { | ||
| return ( | ||
| <PageContent | ||
| title="Notifications" | ||
| titleInfo={{ | ||
| title: | ||
| "Adjust your notification preferences and choose the updates you want to receive. These settings apply only to your account.", | ||
| }} | ||
| > | ||
| <PageWidthWrapper>{children}</PageWidthWrapper> | ||
| </PageContent> | ||
| ); | ||
| } |
223 changes: 223 additions & 0 deletions
223
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/notifications/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,223 @@ | ||
| "use client"; | ||
|
|
||
| import { updateNotificationPreference } from "@/lib/actions/update-notification-preference"; | ||
| import useWorkspace from "@/lib/swr/use-workspace"; | ||
| import { notificationTypes } from "@/lib/zod/schemas/workspaces"; | ||
| import { Switch, useOptimisticUpdate } from "@dub/ui"; | ||
| import { Globe, Hyperlink, Msgs, UserPlus } from "@dub/ui/icons"; | ||
| import { isClickOnInteractiveChild } from "@dub/utils"; | ||
| import { DollarSign, Trophy } from "lucide-react"; | ||
| import { useAction } from "next-safe-action/hooks"; | ||
| import React from "react"; | ||
| import { z } from "zod"; | ||
|
|
||
| type PreferenceType = z.infer<typeof notificationTypes>; | ||
| type Preferences = Record<PreferenceType, boolean>; | ||
|
|
||
| export default function NotificationsSettingsPageClient() { | ||
| const { id: workspaceId } = useWorkspace(); | ||
| const { executeAsync } = useAction(updateNotificationPreference); | ||
|
|
||
| const workspaceNotifications = [ | ||
| { | ||
| type: "domainConfigurationUpdates", | ||
| icon: Globe, | ||
| title: "Domain configuration updates", | ||
| description: "Updates to your custom domain configuration.", | ||
| }, | ||
| { | ||
| type: "linkUsageSummary", | ||
| icon: Hyperlink, | ||
| title: "Monthly links usage summary", | ||
| description: | ||
| "Monthly summary email of your top 5 links by usage & total links created.", | ||
| }, | ||
| ]; | ||
|
|
||
| const partnerProgramNotifications = [ | ||
| { | ||
| type: "newPartnerApplication", | ||
| icon: UserPlus, | ||
| title: "New partner application", | ||
| description: | ||
| "Alert when a new partner application is made in your partner program.", | ||
| }, | ||
| { | ||
| type: "newPartnerSale", | ||
| icon: DollarSign, | ||
| title: "New partner sale", | ||
| description: "Alert when a new sale is made in your partner program.", | ||
| }, | ||
| { | ||
| type: "newBountySubmitted", | ||
| icon: Trophy, | ||
| title: "New bounty submitted", | ||
| description: | ||
| "Alert when a new bounty is submitted in your partner program.", | ||
| }, | ||
| { | ||
| type: "newMessageFromPartner", | ||
| icon: Msgs, | ||
| title: "New message from partner", | ||
| description: | ||
| "Alert when a new message is received from a partner in your partner program.", | ||
| }, | ||
| // { | ||
| // type: "fraudEventsSummary", | ||
| // icon: ShieldAlert, | ||
| // title: "Daily Fraud events summary", | ||
| // description: | ||
| // "Daily summary email of unresolved fraud events detected in your partner program.", | ||
| // }, | ||
| ]; | ||
|
|
||
| const { | ||
| data: preferences, | ||
| isLoading, | ||
| update, | ||
| } = useOptimisticUpdate<Preferences>( | ||
| `/api/workspaces/${workspaceId}/notification-preferences`, | ||
| { | ||
| loading: "Updating notification preference...", | ||
| success: "Notification preference updated.", | ||
| error: "Failed to update notification preference.", | ||
| }, | ||
| ); | ||
|
|
||
| const handleUpdate = async ({ | ||
| type, | ||
| value, | ||
| currentPreferences, | ||
| }: { | ||
| type: string; | ||
| value: boolean; | ||
| currentPreferences: Preferences; | ||
| }) => { | ||
| await executeAsync({ | ||
| workspaceId: workspaceId!, | ||
| type: type as PreferenceType, | ||
| value, | ||
| }); | ||
|
|
||
| return { | ||
| ...currentPreferences, | ||
| [type]: value, | ||
| }; | ||
| }; | ||
|
|
||
| const renderNotificationItem = ({ | ||
| type, | ||
| icon: Icon, | ||
| title, | ||
| description, | ||
| isLast, | ||
| }: { | ||
| type: string; | ||
| icon: React.ComponentType<{ className?: string }>; | ||
| title: string; | ||
| description: string; | ||
| isLast?: boolean; | ||
| }) => { | ||
| const handleRowClick = (e: React.MouseEvent<HTMLDivElement>) => { | ||
| if (isClickOnInteractiveChild(e) || !preferences || isLoading) return; | ||
|
|
||
| const newValue = !preferences[type]; | ||
| update( | ||
| () => | ||
| handleUpdate({ | ||
| type, | ||
| value: newValue, | ||
| currentPreferences: preferences, | ||
| }), | ||
| { | ||
| ...preferences, | ||
| [type]: newValue, | ||
| }, | ||
| ); | ||
| }; | ||
|
|
||
| return ( | ||
| <div key={type}> | ||
| <div | ||
| onClick={handleRowClick} | ||
| className="flex cursor-pointer items-start justify-between py-5 pr-2 sm:items-center" | ||
| > | ||
| <div className="flex min-w-0 items-start gap-4 sm:items-center"> | ||
| <div className="flex shrink-0 items-center justify-center rounded-full border border-neutral-200 bg-gradient-to-t from-neutral-100 p-2.5"> | ||
| <Icon className="size-5" /> | ||
| </div> | ||
| <div className="min-w-0 flex-1 pr-4"> | ||
| <div className="text-sm font-medium text-neutral-800"> | ||
| {title} | ||
| </div> | ||
| <div className="mt-0.5 text-xs text-neutral-500"> | ||
| {description} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <Switch | ||
| checked={preferences?.[type] ?? false} | ||
| disabled={isLoading} | ||
| fn={(checked: boolean) => { | ||
| if (!preferences) return; | ||
|
|
||
| update( | ||
| () => | ||
| handleUpdate({ | ||
| type, | ||
| value: checked, | ||
| currentPreferences: preferences, | ||
| }), | ||
| { | ||
| ...preferences, | ||
| [type]: checked, | ||
| }, | ||
| ); | ||
| }} | ||
| /> | ||
| </div> | ||
| {!isLast && <div className="border-t border-neutral-200" />} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| const renderSection = ({ | ||
| title, | ||
| notifications, | ||
| }: { | ||
| title: string; | ||
| notifications: Array<{ | ||
| type: string; | ||
| icon: React.ComponentType<{ className?: string }>; | ||
| title: string; | ||
| description: string; | ||
| }>; | ||
| }) => ( | ||
| <div className="rounded-xl border border-neutral-200 bg-white"> | ||
| <div className="border-b border-neutral-200 p-5"> | ||
| <h2 className="text-base font-semibold text-neutral-900">{title}</h2> | ||
| </div> | ||
| <div className="px-5"> | ||
| {notifications.map((notification, index) => | ||
| renderNotificationItem({ | ||
| ...notification, | ||
| isLast: index === notifications.length - 1, | ||
| }), | ||
| )} | ||
| </div> | ||
| </div> | ||
| ); | ||
|
|
||
| return ( | ||
| <div className="flex flex-col gap-6"> | ||
| {renderSection({ | ||
| title: "Short links", | ||
| notifications: workspaceNotifications, | ||
| })} | ||
| {renderSection({ | ||
| title: "Partner program", | ||
| notifications: partnerProgramNotifications, | ||
| })} | ||
| </div> | ||
| ); | ||
| } | ||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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.