import React from "react";

import { redirect } from "next/navigation";
import ChatPage from './chatPage'
import {checkIsAuthenticated} from '../../lib/checkIsAuthenticated'
import { auth } from "../../auth";

const Chat =async({searchParams}) => {
   const {seller }= searchParams
  // console.log(seller)
  const isAuthenticated = await checkIsAuthenticated();
    const isloggedIn = auth.name
   // console.log(isloggedIn)
    if(isAuthenticated) {
     return( <ChatPage seller={seller}/>)
    }
    else {
      redirect('/auth/sign_in')
   
   
    }
 
}

export default Chat;
 