@@ -10,9 +10,13 @@ import ProductForm from "../../segment2-new_product/ProductForm";
1010import currencyTransformator from "../../../../utils/CurrencyFormatter.ts" ;
1111
1212type DataIndex = keyof Product ;
13+ const delay = ( ms : number ) => new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
14+
1315const InventoryTable : React . FC = ( ) => {
1416 const [ isModalVisible , setIsModalVisible ] = useState ( false ) ;
1517 const [ editingProduct , setEditingProduct ] = useState < Product | null > ( null ) ;
18+ const [ selectedRowKeys , setSelectedRowKeys ] = useState < React . Key [ ] > ( [ ] ) ;
19+
1620
1721 const handleClose = ( ) => {
1822 setIsModalVisible ( false ) ;
@@ -197,7 +201,7 @@ const InventoryTable: React.FC = () => {
197201 { text : 'No stock' , value : '2' }
198202 ] ,
199203 filterMultiple : false ,
200- filteredValue : stockQuantity ? [ '1' , '2' ] . includes ( String ( stockQuantity ) ) ? [ String ( stockQuantity ) ] : null : null ,
204+ filteredValue : stockQuantity ? [ '1' , '2' ] . includes ( String ( stockQuantity ) ) ? [ String ( stockQuantity ) ] : null : null ,
201205 onFilter : ( _value , _record ) => {
202206 return true ;
203207 } ,
@@ -226,8 +230,12 @@ const InventoryTable: React.FC = () => {
226230 ] ;
227231
228232 const rowSelection = {
229- onChange : async ( _ : any , selectedRowsData : Product [ ] ) => {
230- await changeAvailabilityOfSelected ( selectedRowsData ) ;
233+ selectedRowKeys,
234+ onChange : async ( keys : React . Key [ ] , rows : Product [ ] ) => {
235+ setSelectedRowKeys ( keys ) ;
236+ await changeAvailabilityOfSelected ( rows ) ;
237+ await delay ( 400 ) . then ( ( ) => setSelectedRowKeys ( [ ] ) ) ;
238+
231239 } ,
232240 } ;
233241
0 commit comments