forked from VinokurovVE/tests
upstream to API changes
This commit is contained in:
@ -1,41 +1,7 @@
|
||||
import React, { useState } from 'react'
|
||||
import DocumentService from '../services/DocumentService'
|
||||
import { Box, Button, Typography } from '@mui/material'
|
||||
import { GridColDef } from '@mui/x-data-grid'
|
||||
import DataTable from '../components/DataTable'
|
||||
import FolderViewer from '../components/FolderViewer'
|
||||
|
||||
export default function Documents() {
|
||||
const [companies, setCompanies] = useState()
|
||||
const [departments, setDepartments] = useState()
|
||||
const [organizations, setOrganizations] = useState()
|
||||
const [banks, setBanks] = useState()
|
||||
|
||||
const [documents, setDocuments] = useState()
|
||||
|
||||
const fetchData = async () => {
|
||||
await DocumentService.getCompanies().then(response => {
|
||||
setCompanies(response.data)
|
||||
})
|
||||
|
||||
await DocumentService.getOrganizations().then(response => {
|
||||
setOrganizations(response.data)
|
||||
})
|
||||
|
||||
await DocumentService.getDepartments().then(response => {
|
||||
setDepartments(response.data)
|
||||
})
|
||||
|
||||
await DocumentService.getBanks().then(response => {
|
||||
setBanks(response.data)
|
||||
})
|
||||
}
|
||||
|
||||
const fetchDocuments = async () => {
|
||||
await DocumentService.getDocuments().then(response => {
|
||||
setDocuments(response.data)
|
||||
})
|
||||
}
|
||||
|
||||
const organizationColumns: GridColDef[] = [
|
||||
{ field: 'id', headerName: 'ID', type: "number", width: 90 },
|
||||
{ field: 'id_1c', headerName: 'ID 1C', type: "string", width: 90 },
|
||||
@ -68,52 +34,7 @@ export default function Documents() {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Button onClick={() => {
|
||||
fetchData()
|
||||
}}>
|
||||
Get data
|
||||
</Button>
|
||||
|
||||
<Box>
|
||||
<Typography variant='h6'>
|
||||
Companies
|
||||
</Typography>
|
||||
{JSON.stringify(companies)}
|
||||
</Box>
|
||||
|
||||
<Box>
|
||||
<Typography variant='h6'>
|
||||
Organizations
|
||||
</Typography>
|
||||
{organizations &&
|
||||
<DataTable columns={organizationColumns} rows={organizations} />
|
||||
}
|
||||
</Box>
|
||||
|
||||
<Box>
|
||||
<Typography variant='h6'>
|
||||
Departments
|
||||
</Typography>
|
||||
{JSON.stringify(departments)}
|
||||
</Box>
|
||||
|
||||
<Box>
|
||||
<Typography variant='h6'>
|
||||
Get banks
|
||||
</Typography>
|
||||
{banks &&
|
||||
<DataTable columns={bankColumns} rows={banks} />
|
||||
}
|
||||
</Box>
|
||||
|
||||
|
||||
<Button onClick={() => {
|
||||
fetchDocuments()
|
||||
}}>
|
||||
Get documents
|
||||
</Button>
|
||||
|
||||
{JSON.stringify(documents)}
|
||||
<FolderViewer />
|
||||
</div>
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user