'use client'

import React, {useState, useRef, useEffect} from 'react'
import MessageBox from './messageBox'
import SideBar from '../components/sidebar'
import ReceiverMessage from '../components/receiverMessage'
import io from 'socket.io-client';
import http from '../components/http'

//import {auth, signOut} from '../../auth'


//export async function getServerSideProps(context) {
  //  const session = await getSession(context);
    //if (!session) {
    //  return {
   // redirect: { destination: '/login', permanent: false }   };  }
   // return { props: { session } }; }

export default  function ChatBox({searchParams, id, seller}) {
    const [firm, setFirm] = useState("")
   // const seller = seller
    console.log(seller)

   

      
  useEffect(() => {
   if(seller){
    async function fetchData(){
    const res = await http.get(`/market/${seller}`)
      setFirm(res.data)}
      fetchData()
   } 
  }, []);

  console.log(firm)
  return (

   
<div className="flex h-screen antialiased text-gray-800">
    <div className="flex flex-row h-full w-full overflow-x-hidden">
      <SideBar seller={seller} description={firm.description}/>

      <MessageBox id={id} seller={firm.id}/>
    </div>
  </div>


  )
}
