All files / app/src/views/inspections-view inspections-view.tsx

4.25% Statements 2/47
100% Branches 0/0
0% Functions 0/1
4.25% Lines 2/47

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 681x                                   1x                                                                                                  
import {
  getInspectionFilters,
  getInspectionsTableColumns,
  InspectionDocumentModal,
  inspectionSchedulePageAtom,
  inspectionSchedulePageSizeAtom,
  inspectionsSortCollectionAtom,
  selectedInspectionAtom,
  useInspectionSchedule,
} from '@/entities/accounting-object'
import { DEFAULT_PAGE_SIZE_OPTIONS } from '@/shared/config'
import { useTranslate } from '@/shared/lib'
import { AdminPagination } from '@/shared/ui'
import { SelectedTableFilters } from '@/widgets/table'
import { Table, TableFilterItem } from '@tmk/ui-kit'
import { useAtom } from 'jotai'
import { FC } from 'react'
 
export const InspectionsView: FC = () => {
  const { t } = useTranslate(['common', 'accounting-object'])
  const { data, isLoading, isRefetching } = useInspectionSchedule()
  const [sort, setSort] = useAtom(inspectionsSortCollectionAtom)
  const [page, setPage] = useAtom(inspectionSchedulePageAtom)
  const [pageSize, setPageSize] = useAtom(inspectionSchedulePageSizeAtom)
  const [selectedInspection, setSelectedInspection] = useAtom(selectedInspectionAtom)
 
  return (
    <>
      <InspectionDocumentModal isModalOpen={!!selectedInspection} onClose={() => setSelectedInspection(null)} />
      <div className='flex flex-col gap-y-5'>
        <SelectedTableFilters filters={getInspectionFilters(t) as TableFilterItem[]} />
        <Table
          t={t}
          caption={false}
          rowClassName='!bg-white text-min cursor-pointer'
          tableClassname={{
            body: { cell: 'border-b border-border first:text-center h-[50px] !text-black !p-2 !align-top' },
            header: { cell: 'first:text-center !pb-0 h-[50px] !text-black !px-1.5' },
            table: 'rounded-base',
          }}
          isRefetching={isRefetching}
          isLoading={isLoading}
          data={data?.['hydra:member']}
          emptyText={t('common:Empty_data')}
        >
          {getInspectionsTableColumns({
            t,
            ordersSort: sort,
            setOrdersSort: setSort,
            setSelectedInspection,
          })}
        </Table>
        <AdminPagination
          pageSizeTitle={t('common:RowsPerPage')}
          pageSizeOptions={DEFAULT_PAGE_SIZE_OPTIONS}
          onPageSizeChange={setPageSize}
          pageSize={pageSize}
          withPageSize
          page={page}
          onPageChange={setPage}
          showTotal
          totalItems={data?.['hydra:totalItems']}
        />
      </div>
    </>
  )
}