'use client'

import DateRangePicker from '@/components/RangeDatePicker'
import { ReportItem, ReportItemFooter, ReportItemHeader, ReportItemSubheader } from '@/components/report/ReportItem'
import { Button, Card, CardContent, Paper } from '@mui/material'
import { useState } from 'react'

const ReportProfitLossContent = () => {
  const [startDate, setStartDate] = useState<Date | null>(new Date())
  const [endDate, setEndDate] = useState<Date | null>(new Date())

  return (
    <Card>
      <div className='p-6 border-be'>
        <div className='flex items-center justify-end gap-2'>
          <Button
            color='secondary'
            variant='tonal'
            startIcon={<i className='tabler-upload' />}
            className='max-sm:is-full'
          >
            Ekspor
          </Button>
          <DateRangePicker
            startDate={startDate}
            endDate={endDate}
            onStartDateChange={setStartDate}
            onEndDateChange={setEndDate}
          />
        </div>
      </div>
      <CardContent>
        <ReportItemHeader title='Pendapatan' date='10/09/2025' />
        <ReportItemSubheader title='Penjualan' />
        <ReportItem accountCode='4-40000' accountName='Pendapatan' amount={116791108} onClick={() => {}} />
        <ReportItemSubheader title='Penghasilan lain' />
        <ReportItem
          accountCode='7-70001'
          accountName='Pendapatan Bunga - Deposito'
          amount={-86486}
          onClick={() => {}}
        />
        <ReportItem accountCode='7-70099' accountName='Pendapatan Lain - lain' amount={54054} onClick={() => {}} />
        <ReportItem
          accountCode='7-70100'
          accountName='Pendapatan lainnya (Service Charge)'
          amount={-15315}
          onClick={() => {}}
        />
        <ReportItemFooter title='Total Pendapatan' amount={116743360} />
        <ReportItemSubheader title='' />

        <ReportItemHeader title='Beban Pokok Penjualan' date='10/09/2025' />
        <ReportItem accountCode='5-50000' accountName='Beban Pokok Pendapatan' amount={35018079} onClick={() => {}} />
        <ReportItem accountCode='5-50300' accountName='Pengiriman & Pengangkutan' amount={-15315} onClick={() => {}} />
        <ReportItemFooter title='Total Beban Pokok Penjualan' amount={35002764} />
        <ReportItemSubheader title='' />

        <ReportItemHeader title='Laba Kotor' amount={81740597} />
        <ReportItemSubheader title='' />

        <ReportItemHeader title='Biaya Operasional' date='10/09/2025' />
        <ReportItemSubheader title='Biaya Operasional' />
        <ReportItem accountCode='6-60218' accountName='Air' amount={15315} onClick={() => {}} />
        <ReportItem
          accountCode='6-60301'
          accountName='Alat Tulis Kantor & Printing'
          amount={-19820}
          onClick={() => {}}
        />
        <ReportItem accountCode='6-60302' accountName='Bea Materai' amount={-40541} onClick={() => {}} />
        <ReportItem
          accountCode='6-60003'
          accountName='Bensin, Tol dan Parkir - Penjualan'
          amount={6264865}
          onClick={() => {}}
        />
        <ReportItem accountCode='6-60401' accountName='Biaya Sewa - Kendaraan' amount={62162} onClick={() => {}} />
        <ReportItem accountCode='6-60403' accountName='Biaya Sewa - Lain - lain' amount={63964} onClick={() => {}} />
        <ReportItem accountCode='6-60402' accountName='Biaya Sewa - Operasional' amount={-2703} onClick={() => {}} />
        <ReportItem accountCode='6-60101' accountName='Gaji' amount={6306} onClick={() => {}} />
        <ReportItem accountCode='6-60001' accountName='Iklan & Promosi' amount={7851892} onClick={() => {}} />
        <ReportItem accountCode='6-60002' accountName='Komisi & Fee' amount={6277748} onClick={() => {}} />
        <ReportItem accountCode='6-60005' accountName='Komunikasi - Penjualan' amount={12058018} onClick={() => {}} />
        <ReportItem accountCode='6-60206' accountName='Komunikasi - Umum' amount={85586} onClick={() => {}} />
        <ReportItem accountCode='6-60500' accountName='Penyusutan - Bangunan' amount={73874} onClick={() => {}} />
        <ReportItem accountCode='6-60502' accountName='Penyusutan - Kendaraan' amount={-78378} onClick={() => {}} />
        <ReportItem
          accountCode='6-60004'
          accountName='Perjalanan Dinas - Penjualan'
          amount={6745045}
          onClick={() => {}}
        />
        <ReportItem accountCode='6-60204' accountName='Perjalanan Dinas - Umum' amount={-48649} onClick={() => {}} />
        <ReportItem accountCode='6-60304' accountName='Supplies dan Material' amount={58559} onClick={() => {}} />
        <ReportItem accountCode='6-60106' accountName='THR & Bonus' amount={-59459} onClick={() => {}} />

        <ReportItemSubheader title='Biaya Lain-Lain' />
        <ReportItem
          accountCode='8-80002'
          accountName='(Laba)/Rugi Pelepasan Aset Tetap'
          amount={2703}
          onClick={() => {}}
        />
        <ReportItem accountCode='8-80999' accountName='Beban Lain - lain' amount={81982} onClick={() => {}} />
        <ReportItem accountCode='8-80100' accountName='Penyesuaian Persediaan' amount={-1477900} onClick={() => {}} />
        <ReportItem accountCode='8-80001' accountName='Provisi' amount={-12613} onClick={() => {}} />
        <ReportItemFooter title='Total Biaya Operasional' amount={37907956} />
        <ReportItemSubheader title='' />

        <ReportItemHeader title='Laba Bersih' amount={43832641} />
      </CardContent>
    </Card>
  )
}

export default ReportProfitLossContent
