-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #740 from panoratech/intercom-widget
feat: Intercom Widget
- Loading branch information
Showing
16 changed files
with
72 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
################################################ | ||
# 1/ move to the repo root directory | ||
# 2/ build the image : docker build -t front_package_installer -f ./packages/api/Dockerfile.pnpm-installer . | ||
# 3/ run with: docker run -v $(pwd):/app/ -e PACKAGE_NAME=PACKAGE_NAME package_installer | ||
# example: docker run -v $(pwd):/app/ -e PACKAGE_NAME=@stripe/stripe-js front_package_installer | ||
################################################ | ||
|
||
FROM node:20-alpine3.21 AS base | ||
# ======================================================================= | ||
FROM base AS builder | ||
RUN apk add --no-cache libc6-compat netcat-openbsd curl openssl | ||
RUN apk update | ||
|
||
# Set pnpm | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
|
||
WORKDIR /app | ||
RUN pnpm add -g [email protected] | ||
|
||
# Start Script | ||
|
||
# Set environment variable | ||
ENV PACKAGE="$PACKAGE" | ||
|
||
WORKDIR /app/apps/webapp | ||
|
||
CMD pnpm add "${PACKAGE_NAME}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,55 @@ | ||
'use client' | ||
import "../globals.css"; | ||
import { RootLayout } from "@/components/RootLayout"; | ||
import useProfileStore from "@/state/profileStore"; | ||
import { useRouter } from "next/navigation"; | ||
import { useEffect, useState } from "react"; | ||
import Cookies from 'js-cookie'; | ||
import useUser from "@/hooks/get/useUser"; | ||
import Intercom from '@intercom/messenger-js-sdk'; | ||
|
||
export default function Layout({ | ||
children, | ||
}: Readonly<{ | ||
children: React.ReactNode; | ||
}>) { | ||
|
||
const [userInitialized,setUserInitialized] = useState(false) | ||
const [userInitialized, setUserInitialized] = useState(false) | ||
const router = useRouter() | ||
const { mutate } = useUser() | ||
const { profile } = useProfileStore() | ||
|
||
// Handle authentication | ||
useEffect(() => { | ||
if(!Cookies.get('access_token')) { | ||
router.replace("/b2c/login") | ||
}else { | ||
} else { | ||
mutate( | ||
Cookies.get('access_token'), | ||
{ | ||
onError: () => router.replace("/b2c/login"), | ||
onSuccess: () => setUserInitialized(true) | ||
onError: () => router.replace("/b2c/login"), | ||
onSuccess: () => setUserInitialized(true) | ||
} | ||
) | ||
} | ||
},[]) | ||
|
||
}, []) | ||
|
||
// Initialize Intercom separately when profile is available | ||
useEffect(() => { | ||
if (profile && userInitialized) { | ||
Intercom({ | ||
app_id: 'kjwzw97u', | ||
user_id: profile.id_user, | ||
name: `${profile.first_name} ${profile.last_name}`, | ||
email: profile.email, | ||
}); | ||
} | ||
}, [profile, userInitialized]) | ||
|
||
return ( | ||
<> {userInitialized ? ( | ||
<> | ||
<RootLayout> | ||
{children} | ||
</RootLayout> | ||
</> | ||
) : ( | ||
<> | ||
|
||
</> | ||
)} | ||
|
||
</> | ||
userInitialized ? ( | ||
<RootLayout> | ||
{children} | ||
</RootLayout> | ||
) : null | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
interface Window { | ||
Intercom?: any; | ||
intercomSettings?: any; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.