import type { InferGetServerSidePropsType, NextPage } from "next"; import { withPageOnboardingRequired } from "../../lib/session-helpers"; import { findCustomerPhoneCalls } from "../database/phone-call"; import useUser from "../hooks/use-user"; import Layout from "../components/layout"; type Props = InferGetServerSidePropsType; const pageTitle = "Calls"; const Calls: NextPage = ({ phoneCalls }) => { const { userProfile } = useUser(); console.log("userProfile", userProfile); if (!userProfile) { return Loading...; } return (

Calls page

    {phoneCalls.map((phoneCall) => { const recipient = phoneCall.direction === "outbound" ? phoneCall.to : phoneCall.from; return (
  • {recipient}
    {new Date(phoneCall.createdAt).toLocaleString("fr-FR")}
  • ) })}
); }; export const getServerSideProps = withPageOnboardingRequired( async ({ res }, user) => { res.setHeader( "Cache-Control", "private, s-maxage=15, stale-while-revalidate=59", ); const phoneCalls = await findCustomerPhoneCalls(user.id); return { props: { phoneCalls }, }; }, ); export default Calls;