Skip to content

Commit

Permalink
fix(novu): handle missing env variable in Novu components (#1302)
Browse files Browse the repository at this point in the history
  • Loading branch information
ertugrulcan-ays authored Feb 20, 2025
2 parents 2428029 + 66c6d57 commit 3aa63e1
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/web/src/app/[lang]/(main)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default async function Layout({children, params}: LayoutProps) {
<Novu
appId={process.env.NOVU_APP_IDENTIFIER || ""}
appUrl={process.env.NOVU_APP_URL || ""}
subscriberId={session?.user?.novuSubscriberId || "0"}
subscriberId={session?.user?.novuSubscriberId || ""}
/>
}
prefix=""
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/providers/novu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function NovuProvider({
subscriberId: string;
appUrl: string;
}) {
if (!appId || !appUrl || !subscriberId) throw new Error("appId, appUrl and subscriberId are required");
if (!appId || !appUrl || !subscriberId) return children;
return (
<Novu applicationIdentifier={appId} backendUrl={appUrl} subscriberId={subscriberId}>
{children}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/providers/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default async function Providers({children}: ProvidersProps) {
<NovuProvider
appId={process.env.NOVU_APP_IDENTIFIER || ""}
appUrl={process.env.NOVU_APP_URL || ""}
subscriberId={session?.user?.novuSubscriberId || "0"}>
subscriberId={session?.user?.novuSubscriberId || ""}>
{children}
</NovuProvider>
</GrantedPoliciesProvider>
Expand Down
4 changes: 3 additions & 1 deletion apps/web/src/utils/navbar/notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import {} from "lucide-react";
import {useRouter} from "next/navigation";

export function Novu({appId, appUrl, subscriberId}: {appId: string; appUrl: string; subscriberId: string}) {
if (!appId || !appUrl || !subscriberId) throw new Error("appId, appUrl and subscriberId are required");
const router = useRouter();

if (!appId || !appUrl || !subscriberId) return null;

const defaultAppearance = {
elements: {
popoverContent: {
Expand Down

0 comments on commit 3aa63e1

Please sign in to comment.