This commit is contained in:
cracklesparkle
2024-07-10 14:37:00 +09:00
parent a65a431b09
commit f9de1124c3
36 changed files with 312 additions and 176 deletions

View File

@ -1,14 +1,14 @@
import { Autocomplete, Box, Button, CircularProgress, Paper, TextField, Typography } from "@mui/material"
import { useBoilers, useCities, useRegions, useServers } from "../hooks/swrHooks"
import { Autocomplete, Box, CircularProgress, Paper, TextField, Typography } from "@mui/material"
import { useBoilers, useRegions, useServers } from "../hooks/swrHooks"
import { Fragment, useEffect, useState } from "react"
import { IRegion } from "../interfaces/fuel"
import { IBoiler, IRegion } from "../interfaces/fuel"
import { DataGrid, GridColDef } from "@mui/x-data-grid"
export default function ApiTest() {
const [open, setOpen] = useState(false)
const [options, setOptions] = useState<any>([])
const [search, setSearch] = useState<any>(null)
const [debouncedSearch, setDebouncedSearch] = useState("")
const [options, setOptions] = useState<IRegion[]>([])
const [search, setSearch] = useState<string | null>(null)
const [debouncedSearch, setDebouncedSearch] = useState<string | null>("")
const [selectedOption, setSelectedOption] = useState<IRegion | null>(null)
const { regions, isLoading } = useRegions(10, 1, debouncedSearch)
@ -28,15 +28,34 @@ export default function ApiTest() {
}
}, [regions])
const handleInputChange = (event: any, value: any) => {
const handleInputChange = (value: string) => {
setSearch(value)
}
const handleOptionChange = (event: any, value: any) => {
const handleOptionChange = (value: IRegion | null) => {
setSelectedOption(value)
}
//const { boilers } = useBoilers(10, 1)
const [boilersPage, setBoilersPage] = useState(1)
const [boilerSearch, setBoilerSearch] = useState("")
const [debouncedBoilerSearch, setDebouncedBoilerSearch] = useState("")
const { boilers } = useBoilers(10, boilersPage, debouncedBoilerSearch)
useEffect(() => {
const handler = setTimeout(() => {
setDebouncedBoilerSearch(boilerSearch)
}, 500)
return () => {
clearTimeout(handler)
}
}, [boilerSearch])
useEffect(() => {
setBoilersPage(1)
setBoilerSearch("")
}, [])
//const { cities } = useCities(10, 1)
const { servers, isLoading: serversLoading } = useServers(selectedOption?.id, 0, 10)
@ -45,12 +64,20 @@ export default function ApiTest() {
{ field: 'name', headerName: 'Название', type: "string" },
]
const boilersColumns: GridColDef[] = [
{ field: 'id', headerName: 'ID', type: "number" },
{ field: 'boiler_name', headerName: 'Название', type: "string" },
{ field: 'boiler_code', headerName: 'Код', type: "string" },
{ field: 'id_city', headerName: 'Город', type: "string" },
{ field: 'activity', headerName: 'Активен', type: "boolean" },
]
return (
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '16px', height: '100%' }}>
<Paper elevation={1}>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '16px', height: '100%', p: '16px'}}>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '16px', height: '100%', p: '16px' }}>
<Typography variant='h6' fontWeight='600'>
Get servers
Servers
</Typography>
<Autocomplete
@ -61,11 +88,11 @@ export default function ApiTest() {
onClose={() => {
setOpen(false)
}}
onInputChange={handleInputChange}
onChange={handleOptionChange}
onInputChange={(_, value) => handleInputChange(value)}
onChange={(_, value) => handleOptionChange(value)}
filterOptions={(x) => x}
isOptionEqualToValue={(option: any, value: any) => option.name === value.name}
getOptionLabel={(option: any) => option.name ? option.name : ""}
isOptionEqualToValue={(option: IRegion, value: IRegion) => option.name === value.name}
getOptionLabel={(option: IRegion) => option.name ? option.name : ""}
options={options}
loading={isLoading}
value={selectedOption}
@ -98,6 +125,24 @@ export default function ApiTest() {
}
</Box>
</Paper>
<Paper elevation={1}>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '16px', height: '100%', p: '16px' }}>
<Typography variant='h6' fontWeight='600'>
Boilers
</Typography>
{boilers &&
<DataGrid
rows={boilers.map((boiler: IBoiler) => {
return { ...boiler, id: boiler.id_object }
})}
columns={boilersColumns}
/>
}
</Box>
</Paper>
</Box>
)
}

View File

@ -1,37 +1,6 @@
import { GridColDef } from '@mui/x-data-grid'
import FolderViewer from '../components/FolderViewer'
export default function Documents() {
const organizationColumns: GridColDef[] = [
{ field: 'id', headerName: 'ID', type: "number", width: 90 },
{ field: 'id_1c', headerName: 'ID 1C', type: "string", width: 90 },
{ field: 'name', headerName: 'Наименование', type: "string", width: 90 },
{ field: 'full_name', headerName: 'Полное наименование', type: "string", width: 90 },
{ field: 'inn', headerName: 'ИНН', type: "string", width: 70 },
{ field: 'ogrn', headerName: 'ОГРН', width: 130 },
{ field: 'kpp', headerName: 'КПП', width: 130 },
{ field: 'okopf', headerName: 'ОКОПФ', width: 90 },
{ field: 'legal_address', headerName: 'Юридический адрес', width: 90 },
{ field: 'actual_address', headerName: 'Фактический адрес', width: 90 },
{ field: 'mail_address', headerName: 'Почтовый адрес', type: "string", width: 90 },
{ field: 'id_budget', headerName: 'Активен', type: "number", width: 90 },
{ field: 'fio_dir', headerName: 'Активен', type: "string", width: 90 },
{ field: 'phone', headerName: 'Телефон', type: "string", width: 90 },
{ field: 'email', headerName: 'Email', type: "string", width: 90 },
{ field: 'comment', headerName: 'Комментарий', type: "string", width: 90 },
{ field: 'id_bank', headerName: 'Банк', type: "string", width: 90 },
{ field: 'active', headerName: 'Активен', type: "boolean", width: 90 },
];
const bankColumns: GridColDef[] = [
{ field: 'id', headerName: 'ID', type: "number", width: 90 },
{ field: 'id_1c', headerName: 'ID 1C', type: "string", width: 90 },
{ field: 'name', headerName: 'Наименование', type: "string", width: 90 },
{ field: 'bik', headerName: 'БИК', type: "string", width: 90 },
{ field: 'corschet', headerName: 'Кор. счет', type: "string", width: 70 },
{ field: 'activ', headerName: 'Активен', type: "boolean", width: 130 },
];
return (
<div>
<FolderViewer />

View File

@ -1,6 +1,5 @@
import { Error } from "@mui/icons-material";
import { Box, Typography, colors } from "@mui/material";
import { red } from "@mui/material/colors";
import { Box, Typography } from "@mui/material";
export default function NotFound() {
return (

View File

@ -1,18 +1,15 @@
import { useEffect, useState } from "react"
import { Box, Button, Typography } from "@mui/material"
import { useState } from "react"
import { Box, Button } from "@mui/material"
import axiosInstance from "../http/axiosInstance"
import { DataGrid } from "@mui/x-data-grid"
export default function Reports() {
const [state, setState] = useState<any>(null)
const [exportData, setExportData] = useState<any>(null)
const [state, setState] = useState(null)
const fetch = async () => {
await axiosInstance.get(`/info/reports/0?to_export=true`, {
responseType: 'blob',
}).then(response => {
setExportData(response.data)
const url = window.URL.createObjectURL(response.data)
const link = document.createElement('a')
link.href = url
@ -71,7 +68,7 @@ export default function Reports() {
disableRowSelectionOnClick
processRowUpdate={(updatedRow, originalRow) => {
console.log(updatedRow)
console.log(updatedRow, originalRow)
return updatedRow
}}

View File

@ -49,7 +49,7 @@ export default function Roles() {
disableRowSelectionOnClick
processRowUpdate={(updatedRow, originalRow) => {
console.log(updatedRow)
console.log(updatedRow, originalRow)
return updatedRow
}}

View File

@ -23,7 +23,7 @@ export default function Settings() {
{
field: 'role_id',
headerName: 'Роль',
valueGetter: (value, row) => {
valueGetter: (value) => {
if (roles) {
const roleName = roles.find((role: IRole) => role.id === value).name
return roleName
@ -70,7 +70,7 @@ export default function Settings() {
disableRowSelectionOnClick
processRowUpdate={(updatedRow, originalRow) => {
console.log(updatedRow)
console.log(updatedRow, originalRow)
return updatedRow
}}

View File

@ -65,7 +65,7 @@ export default function Users() {
disableRowSelectionOnClick
processRowUpdate={(updatedRow, originalRow) => {
console.log(updatedRow)
console.log(updatedRow, originalRow)
return updatedRow
}}