Skip to content

Commit

Permalink
Move provider to package
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenbleasel committed Jan 6, 2025
1 parent 26c4b2f commit 731fd00
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 27 deletions.
2 changes: 1 addition & 1 deletion apps/app/app/(authenticated)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { env } from '@/env';
import { auth, currentUser } from '@repo/auth/server';
import { SidebarProvider } from '@repo/design-system/components/ui/sidebar';
import { NotificationsProvider } from '@repo/design-system/providers/notifications';
import { showBetaFeature } from '@repo/feature-flags';
import { NotificationsProvider } from '@repo/notifications/components/provider';
import { secure } from '@repo/security';
import type { ReactNode } from 'react';
import { PostHogIdentifier } from './components/posthog-identifier';
Expand Down
1 change: 1 addition & 0 deletions apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@repo/design-system": "workspace:*",
"@repo/feature-flags": "workspace:*",
"@repo/next-config": "workspace:*",
"@repo/notifications": "workspace:*",
"@repo/observability": "workspace:*",
"@repo/security": "workspace:*",
"@repo/seo": "workspace:*",
Expand Down
26 changes: 0 additions & 26 deletions packages/design-system/providers/notifications.tsx

This file was deleted.

30 changes: 30 additions & 0 deletions packages/notifications/components/provider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use client';

import { KnockFeedProvider, KnockProvider } from '@knocklabs/react';
import type { ReactNode } from 'react';
import { keys } from '../keys';

const knockApiKey = keys().KNOCK_SECRET_API_KEY;
const knockFeedChannelId = keys().KNOCK_FEED_CHANNEL_ID;

type NotificationsProviderProps = {
children: ReactNode;
userId: string;
};

export const NotificationsProvider = ({
children,
userId,
}: NotificationsProviderProps) => {
if (!knockApiKey || !knockFeedChannelId) {
return children;
}

return (
<KnockProvider apiKey={knockApiKey} userId={userId}>
<KnockFeedProvider feedId={knockFeedChannelId}>
{children}
</KnockFeedProvider>
</KnockProvider>
);
};
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 731fd00

Please sign in to comment.