|
| 1 | + |
| 2 | +import React, { useEffect, useState } from 'react' |
| 3 | +import { useCalendlyEventListener, InlineWidget } from "react-calendly"; |
| 4 | +import Footer from '../components/Footer' |
| 5 | +import Navbar from '../views/Navbar' |
| 6 | +import ProductDemo from '../views/Demo' |
| 7 | +import type { Session } from 'next-auth'; |
| 8 | +import { getAndSetAnonymousIdFromLocalStorage } from '../utils/rudderstack_initialize'; |
| 9 | +import RudderContext from '../components/RudderContext'; |
| 10 | +import { getAuthUserEmail, getAuthUserId, getAuthUserName } from '../utils/auth'; |
| 11 | + |
| 12 | +const Demo = () => { |
| 13 | + const [loading, setLoading] = useState(true); |
| 14 | + const [session, setSession] = useState<Session | null>(null); |
| 15 | + const { rudderEventMethods } = React.useContext(RudderContext); |
| 16 | + |
| 17 | + useEffect(() => { |
| 18 | + fetch("/api/auth/session", { cache: "no-store" }).then(async (res) => { |
| 19 | + const sessionVal: Session | null = await res.json(); |
| 20 | + setSession(sessionVal); |
| 21 | + }).catch((err) => { |
| 22 | + console.error(`[docs] Error in getting session`, err); |
| 23 | + }).finally(() => { |
| 24 | + setLoading(false); |
| 25 | + }); |
| 26 | + }, []) |
| 27 | + |
| 28 | + React.useEffect(() => { |
| 29 | + const anonymousId = getAndSetAnonymousIdFromLocalStorage(); |
| 30 | + rudderEventMethods?.track(getAuthUserId(session), "docs page", { type: "page", eventStatusFlag: 1, name: getAuthUserName(session) }, anonymousId) |
| 31 | + }, [rudderEventMethods, session]); |
| 32 | + |
| 33 | + useCalendlyEventListener({ |
| 34 | + onProfilePageViewed: () => console.log("onProfilePageViewed"), |
| 35 | + onDateAndTimeSelected: () => console.log("onDateAndTimeSelected"), |
| 36 | + onEventTypeViewed: () => console.log("onEventTypeViewed"), |
| 37 | + onEventScheduled: (e) => console.log(e.data.payload), |
| 38 | + }); |
| 39 | + |
| 40 | + return ( |
| 41 | + <div> |
| 42 | + <Navbar transparent={false} /> |
| 43 | + <ProductDemo /> |
| 44 | + <div className='w-full text-center py-12'> |
| 45 | + <h2 className='font-bold text-[2rem]'>Book a <span className='text-[2rem] text-secondary font-bold'>Live Demo</span> with the Founder</h2> |
| 46 | + <div className='w-full md:w-2/3 m-auto'> |
| 47 | + <InlineWidget |
| 48 | + url="https://calendly.com/avikalp-gupta/30min" |
| 49 | + pageSettings={{ |
| 50 | + hideEventTypeDetails: true, |
| 51 | + }} |
| 52 | + prefill={{ |
| 53 | + email: getAuthUserEmail(session), |
| 54 | + name: getAuthUserName(session), |
| 55 | + }} |
| 56 | + /> |
| 57 | + </div> |
| 58 | + </div> |
| 59 | + <Footer /> |
| 60 | + </div> |
| 61 | + ) |
| 62 | +} |
| 63 | + |
| 64 | +export default Demo |
0 commit comments