Skip to content

Commit

Permalink
provider errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nizzyabi committed Dec 20, 2024
1 parent 064e8d9 commit 9fbf3f1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
5 changes: 2 additions & 3 deletions apps/web/app/api/plain-hash/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { apiRouteMiddleware } from "@calcom/lib/server/apiRouteMiddleware";
const responseSchema = z.object({
hash: z.string(),
email: z.string().email(),
fullName: z.string().optional(),
shortName: z.string(),
fullName: z.string().optional(),
});

async function handler(request: Request) {
Expand All @@ -33,7 +33,6 @@ async function handler(request: Request) {
return new Response("Unauthorized - No session email found", { status: 401 });
}

// Environment variable check
const secret = process.env.PLAIN_CHAT_HMAC_SECRET_KEY;
if (!secret) {
return new Response("Missing Plain Chat secret", { status: 500 });
Expand All @@ -50,8 +49,8 @@ async function handler(request: Request) {
const response = responseSchema.parse({
hash,
email: session.user.email,
fullName: session.user.name,
shortName,
fullName: session.user.name,
});

console.log("Sending response:", response);
Expand Down
2 changes: 1 addition & 1 deletion apps/web/lib/app-providers-app-dir.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ const AppProviders = (props: PageWrapperProps) => {
const RemainingProviders = (
<EventCollectionProvider options={{ apiPath: "/api/collect-events" }}>
<SessionProvider>
<PlainChat />
<CustomI18nextProvider i18n={props.i18n}>
<TooltipProvider>
{/* color-scheme makes background:transparent not work which is required by embed. We need to ensure next-theme adds color-scheme to `body` instead of `html`(https://github.com/pacocoursey/next-themes/blob/main/src/index.tsx#L74). Once that's done we can enable color-scheme support */}
Expand Down Expand Up @@ -304,7 +305,6 @@ const AppProviders = (props: PageWrapperProps) => {

return (
<>
<PlainChat />
<DynamicHelpscoutProvider>
<DynamicIntercomProvider>
<DynamicPostHogProvider>{Hydrated}</DynamicPostHogProvider>
Expand Down
5 changes: 1 addition & 4 deletions apps/web/lib/plain/plainChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { usePathname, useSearchParams } from "next/navigation";
import Script from "next/script";
import { useEffect, useState } from "react";

// Add interface for Plain Chat configuration
interface PlainChatConfig {
appId: string;
customerDetails: {
Expand Down Expand Up @@ -96,9 +95,9 @@ const PlainChat = () => {
appId: "liveChatApp_01JFJJK1RF3XA2ZDAEHERJ0VZZ",
customerDetails: {
email,
fullName: "John",
shortName,
emailHash: hash,
fullName,
},
links: [
{
Expand Down Expand Up @@ -195,9 +194,7 @@ const PlainChat = () => {
`;

useEffect(() => {
// Check if we're on /event-types with ?plain parameter after config is loaded
if (pathname === "/event-types" && searchParams?.has("openPlain") && config) {
// Small delay to ensure Plain is fully initialized
setTimeout(() => {
openPlain();
}, 100);
Expand Down

0 comments on commit 9fbf3f1

Please sign in to comment.