1- import type { DeviceDoc } from '../../../hooks/api /types' ;
1+ import type { DeviceDoc , StandardQueryParams } from '../../../utils /types' ;
22import type { DSelectItem } from '@react-devui/ui/components/select' ;
33
44import { isUndefined } from 'lodash' ;
@@ -30,6 +30,8 @@ import { useAPI, useQueryParams } from '../../../hooks';
3030import { AppDeviceModal } from './DeviceModal' ;
3131import styles from './StandardTable.module.scss' ;
3232
33+ type Device = DeviceDoc ;
34+
3335interface DeviceQueryParams {
3436 keyword : string ;
3537 sort : 'id' | '-id' | null ;
@@ -68,7 +70,7 @@ export default function StandardTable(): JSX.Element | null {
6870
6971 const [ deviceTable , setDeviceTable ] = useImmer ( {
7072 loading : true ,
71- list : [ ] as DeviceDoc [ ] ,
73+ list : [ ] as Device [ ] ,
7274 totalSize : 0 ,
7375 selected : new Set < number > ( ) ,
7476 } ) ;
@@ -79,12 +81,12 @@ export default function StandardTable(): JSX.Element | null {
7981
8082 const [ paramsOfDeleteModal , setParamsOfDeleteModal ] = useImmer < {
8183 visible : boolean ;
82- device : DeviceDoc ;
84+ device : Device ;
8385 } > ( ) ;
8486
8587 const [ paramsOfDeviceModal , setParamsOfDeviceModal ] = useImmer < {
8688 visible : boolean ;
87- device : DeviceDoc | undefined ;
89+ device : Device | undefined ;
8890 } > ( ) ;
8991 const [ deviceForm , updateDeviceForm ] = useForm (
9092 ( ) =>
@@ -93,7 +95,7 @@ export default function StandardTable(): JSX.Element | null {
9395 model : new FormControl < string | null > ( null , Validators . required ) ,
9496 } )
9597 ) ;
96- const openDeviceModal = ( device ?: DeviceDoc ) => {
98+ const openDeviceModal = ( device ?: Device ) => {
9799 setParamsOfDeviceModal ( { visible : true , device } ) ;
98100 deviceForm . reset ( device ? { name : device . name , model : device . model } : undefined ) ;
99101 updateDeviceForm ( ) ;
@@ -117,7 +119,7 @@ export default function StandardTable(): JSX.Element | null {
117119 useEffect ( ( ) => {
118120 setDeviceQuerySaved ( deviceQuery ) ;
119121
120- const apiQuery : any = {
122+ const apiQuery : StandardQueryParams = {
121123 page : deviceQuery . page ,
122124 page_size : deviceQuery . pageSize ,
123125 } ;
@@ -128,7 +130,7 @@ export default function StandardTable(): JSX.Element | null {
128130 setDeviceTable ( ( draft ) => {
129131 draft . loading = true ;
130132 } ) ;
131- deviceApi . list < DeviceDoc > ( apiQuery ) . subscribe ( {
133+ deviceApi . list < Device > ( apiQuery ) . subscribe ( {
132134 next : ( res ) => {
133135 setDeviceQuery ( ( draft ) => {
134136 draft . page = res . metadata . page ;
0 commit comments