-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
fix(dashboard): Opt-in new orgs created from org switcher in v2 #7277
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { OrganizationSwitcher as ClerkOrganizationSwitcher } from '@clerk/clerk-react'; | ||
import type { OrganizationSwitcherTheme } from '@clerk/types'; | ||
import { ROUTES } from '../../utils/routes'; | ||
|
||
const OrganizationSwitcherAppearance: OrganizationSwitcherTheme = { | ||
elements: { | ||
|
@@ -11,19 +12,28 @@ const OrganizationSwitcherAppearance: OrganizationSwitcherTheme = { | |
organizationSwitcherPopoverActionButton__manageOrganization: { | ||
display: 'none', | ||
}, | ||
organizationSwitcherPopoverInvitationActionsBox: 'p-0 pr-2', | ||
organizationSwitcherInvitationAcceptButton: '!text-[10px] !min-w-[90px] !w-[90px] px-0', | ||
organizationPreviewMainIdentifier: 'text-foreground-950 text-base', | ||
organizationPreviewAvatarContainer: 'size-6 rounded-full', | ||
organizationPreviewAvatarBox: 'rounded-full size-6', | ||
organizationPreview: 'py-1.5 px-4 gap-2', | ||
organizationSwitcherPopoverActionButton: 'py-1.5 px-4 -ml-1.5 text-sm gap-0', | ||
organizationPreview: 'py-1.5 px-2 gap-2', | ||
organizationSwitcherPopoverActionButton: 'py-1 px-2 -ml-1.5 text-sm gap-0', | ||
organizationSwitcherPopoverCard: 'w-64', | ||
organizationSwitcherPreviewButton: 'p-0 [&>svg]:mr-2 !border-0', | ||
organizationPreviewSecondaryIdentifier: 'hidden', | ||
organizationSwitcherPopoverActions: | ||
'py-2 [&_.cl-organizationPreviewMainIdentifier]:text-sm [&>div:nth-child(2)]:!border-0', | ||
'py-0.5 [&_.cl-organizationPreviewMainIdentifier]:text-sm [&>div:nth-child(2)]:!border-0', | ||
}, | ||
}; | ||
|
||
export const OrganizationDropdown = () => { | ||
return <ClerkOrganizationSwitcher hidePersonal appearance={OrganizationSwitcherAppearance} />; | ||
return ( | ||
<ClerkOrganizationSwitcher | ||
hidePersonal | ||
skipInvitationScreen | ||
afterCreateOrganizationUrl={ROUTES.USECASE_SELECT + '?v2_opt_in=true'} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We want to redirect the user and skip the questionnaire straight to the usecase select page |
||
appearance={OrganizationSwitcherAppearance} | ||
/> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
import { PropsWithChildren, useLayoutEffect } from 'react'; | ||
import { NewDashboardOptInStatusEnum } from '@novu/shared'; | ||
import { useNewDashboardOptIn } from '@/hooks/use-new-dashboard-opt-in'; | ||
import { useSearchParams } from 'react-router-dom'; | ||
|
||
export const OptInProvider = (props: PropsWithChildren) => { | ||
const { children } = props; | ||
const { status, isLoaded, redirectToLegacyDashboard } = useNewDashboardOptIn(); | ||
const { status, isLoaded, redirectToLegacyDashboard, optIn } = useNewDashboardOptIn(); | ||
const [searchParams] = useSearchParams(); | ||
const hasV2OptIn = searchParams.has('v2_opt_in'); | ||
|
||
useLayoutEffect(() => { | ||
if (isLoaded && status !== NewDashboardOptInStatusEnum.OPTED_IN) { | ||
redirectToLegacyDashboard(); | ||
if (hasV2OptIn) { | ||
(async () => { | ||
await optIn(); | ||
})(); | ||
} else { | ||
Comment on lines
+14
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Allowing to force opt in if a query param was passed to the url |
||
redirectToLegacyDashboard(); | ||
} | ||
} | ||
|
||
// set light theme on the new domain for both legacy and new dashboard | ||
localStorage.setItem('mantine-theme', 'light'); | ||
}, [status, redirectToLegacyDashboard, isLoaded]); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [status, redirectToLegacyDashboard, isLoaded, hasV2OptIn]); | ||
|
||
return <>{children}</>; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something was cmpletly off when a new invitation is available to a user to join an org. Fixed the excess paddings