Skip to content

Commit

Permalink
feat(web): new dashboard naming
Browse files Browse the repository at this point in the history
  • Loading branch information
ChmaraX committed Nov 7, 2024
1 parent 0d6c11a commit 850491d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@ import { css } from '@novu/novui/css';
import { Text, Title, Button, IconButton } from '@novu/novui';
import { IconOutlineClose } from '@novu/novui/icons';
import { useUser } from '@clerk/clerk-react';
import { FeatureFlagsKeysEnum, V3DashboardOptInStatusEnum } from '@novu/shared';
import { FeatureFlagsKeysEnum, NewDashboardOptInStatusEnum } from '@novu/shared';
import { IS_SELF_HOSTED } from '../../../../config';
import { useFeatureFlag } from '../../../../hooks';

export function V3DashboardOptInWidget() {
export function NewDashboardOptInWidget() {
const { user } = useUser();
const isV3DashboardEnabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_V3_DASHBOARD_ENABLED);
const isNewDashboardEnabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_NEW_DASHBOARD_ENABLED);

const isDismissed = user?.unsafeMetadata?.v3DashboardOptInStatus === V3DashboardOptInStatusEnum.DISMISSED;
const isDismissed = user?.unsafeMetadata?.newDashboardOptInStatus === NewDashboardOptInStatusEnum.DISMISSED;

if (IS_SELF_HOSTED || isDismissed || !isV3DashboardEnabled) {
if (IS_SELF_HOSTED || isDismissed || !isNewDashboardEnabled) {
return null;
}

const updateUserOptInStatus = (status: V3DashboardOptInStatusEnum) => {
const updateUserOptInStatus = (status: NewDashboardOptInStatusEnum) => {
if (!user) return;

user.update({
unsafeMetadata: {
...user.unsafeMetadata,
v3DashboardOptInStatus: status,
newDashboardOptInStatus: status,
},
});
};

function handleOptIn() {
const v3DashboardUrl = process.env.V3_DASHBOARD_URL;
if (!v3DashboardUrl || !user) return;
const newDashboardUrl = process.env.NEW_DASHBOARD_URL;
if (!newDashboardUrl || !user) return;

updateUserOptInStatus(V3DashboardOptInStatusEnum.OPTED_IN);
window.location.href = v3DashboardUrl;
updateUserOptInStatus(NewDashboardOptInStatusEnum.OPTED_IN);
window.location.href = newDashboardUrl;
}

function handleDismiss() {
updateUserOptInStatus(V3DashboardOptInStatusEnum.DISMISSED);
updateUserOptInStatus(NewDashboardOptInStatusEnum.DISMISSED);
}

return (
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/nav/RootNavMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { SidebarFooter } from '../layout/components/LocalStudioSidebar/SidebarFo
import { useNavigateToLocalStudio } from '../../studio/hooks/useNavigateToLocalStudio';
import { OpenLocalStudioModal } from '../../studio/components/OpenLocalStudioModal';
import { OutlineButton } from '../../studio/components/OutlineButton';
import { V3DashboardOptInWidget } from '../layout/components/v2/V3DashboardOptInWidget';
import { NewDashboardOptInWidget } from '../layout/components/v2/NewDashboardOptInWidget';

const getEnvPageRoute = (route: ROUTES, env: BaseEnvironmentEnum) => parseUrl(route, { env });

Expand Down Expand Up @@ -162,7 +162,7 @@ export const RootNavMenu: React.FC = () => {
{isV2Enabled ? (
<>
<SidebarFooter>
<V3DashboardOptInWidget />
<NewDashboardOptInWidget />
<FreeTrialSidebarWidget />
<OutlineButton fullWidth onClick={navigateToLocalStudio} Icon={IconLaptop}>
Open Local Studio
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/types/clerk/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export type UserPublicMetadata = {
* Unsafe metadata can be updated from the frontend directly
*/
export type UserUnsafeMetadata = {
v3DashboardOptInStatus?: V3DashboardOptInStatusEnum;
newDashboardOptInStatus?: NewDashboardOptInStatusEnum;
};

export enum V3DashboardOptInStatusEnum {
export enum NewDashboardOptInStatusEnum {
OPTED_IN = 'opted_in', // user switched to the new dashboard
DISMISSED = 'dismissed', // user dismissed the opt-in widget
OPTED_OUT = 'opted_out', // user switched back to the old dashboard
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/types/feature-flags/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export enum FeatureFlagsKeysEnum {
IS_INTEGRATION_INVALIDATION_DISABLED = 'IS_INTEGRATION_INVALIDATION_DISABLED',
IS_EMAIL_INLINE_CSS_DISABLED = 'IS_EMAIL_INLINE_CSS_DISABLED',
IS_CONTROLS_AUTOCOMPLETE_ENABLED = 'IS_CONTROLS_AUTOCOMPLETE_ENABLED',
IS_V3_DASHBOARD_ENABLED = 'IS_V3_DASHBOARD_ENABLED',
IS_NEW_DASHBOARD_ENABLED = 'IS_NEW_DASHBOARD_ENABLED',
}

0 comments on commit 850491d

Please sign in to comment.