From 3a00a88a7d0e4a62560594f2695b8ab8e7c83ed3 Mon Sep 17 00:00:00 2001 From: ManuLpz4 Date: Wed, 2 Oct 2024 17:18:08 -0300 Subject: [PATCH] a --- src/components/plaude.tsx | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/components/plaude.tsx b/src/components/plaude.tsx index 91d3b9e..b0b8049 100644 --- a/src/components/plaude.tsx +++ b/src/components/plaude.tsx @@ -24,11 +24,17 @@ const usePlaude = () => { }; type PlaudeMessengerProps = React.PropsWithChildren<{ + appId: string; open: boolean; token?: string; }>; -function PlaudeMessenger({ open, token, children }: PlaudeMessengerProps) { +function PlaudeMessenger({ + appId, + open, + token, + children, +}: PlaudeMessengerProps) { const { closeMessenger } = usePlaude(); return ( @@ -55,12 +61,7 @@ function PlaudeMessenger({ open, token, children }: PlaudeMessengerProps) { @@ -68,7 +69,15 @@ function PlaudeMessenger({ open, token, children }: PlaudeMessengerProps) { ); } -const PlaudeProvider = ({ children }: React.PropsWithChildren) => { +type PlaudeProviderProps = React.PropsWithChildren<{ + appId?: string; +}>; + +const PlaudeProvider = ({ appId, children }: PlaudeProviderProps) => { + if (!(process.env.PLAUDE_APP_ID ?? appId)) { + throw new Error('It seems like you forgot to set the App ID.'); + } + const [isMessengerOpen, setIsMessengerOpen] = useState(false); const [token, setToken] = useState(); @@ -82,7 +91,11 @@ const PlaudeProvider = ({ children }: React.PropsWithChildren) => { return ( - + {children}