'use client'
import { ClientData } from '@/types'
import { parseGst, parsePlants } from '@/utils'

import SectionWrapper from '@/components/ui/section/SectionWrapper'
import DocumentsSection from '../about/sections/DocumentsSection'
import CorporateSection from '../about/sections/CorporateSection'
import GstSection from '../about/sections/GstSection'
import AddressSection from '../about/sections/AddressSection'
import PlantLocationSection from '../about/sections/PlantLocationSection'
import BusinessSection from '../about/sections/BusinessSection'

export default function AboutCompany({ client }: { client: ClientData }) {
  const gstEntries = parseGst(client.gstNumber)
  const plantList = parsePlants(client.plantLocations)

  return (
    <div className="flex-1 overflow-auto px-3 py-3">
      <div className="space-y-6">

        <SectionWrapper title='Corporate Identity'>
          <CorporateSection client={client} />
        </SectionWrapper>


        <SectionWrapper
          title='GST Registrations'
          count={gstEntries}
          countLabel='state'
          countLabelPlural='states'
        >
          <GstSection gstEntries={gstEntries} />

        </SectionWrapper>


        <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
          <SectionWrapper title='Registered Address'>
            <AddressSection client={client} />
          </SectionWrapper>


          {plantList.length > 0 && (
            <SectionWrapper
              title='Plant Locations'
            >
              <PlantLocationSection plantList={plantList} />
            </SectionWrapper>

          )}
        </div>

        <SectionWrapper
          title='Business Profile'
        >
          <BusinessSection client={client} />
        </SectionWrapper>


        <SectionWrapper title='Constitutional Documents'>
          <DocumentsSection client={client} />
        </SectionWrapper>

      </div>
    </div>
  )
}
