This commit is contained in:
=
2026-04-03 14:16:13 +10:00
parent b096ac7aa3
commit f76757311f
3 changed files with 17 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ import { useState } from 'react'
import Table from './components/Table.jsx';
import buildings from './data.js';
import './CSS/App.css'
import Task from './Task.jsx'
function App() {
const [count, setCount] = useState(0)
@@ -9,6 +10,7 @@ function App() {
<div className="App">
<h3>Самые высокие здания и сооружения</h3>
<Table data={ buildings } amountRows="15" />
<Task/>
</div>
)
}

View File

@@ -34,8 +34,15 @@ const Filter = (props) => {
//передаем родительскому компоненту новое состояние - отфильтрованный массив
props.filtering(arr);
}
const doReset=(event)=>{
event.target.querySelectorAll("input[type=\"number\"],input[type=\"text\"]").forEach(element => {
element.value=null;
});
handleSubmit(event);
}
return (
<form onSubmit={handleSubmit} onReset={handleSubmit}>
<form onSubmit={handleSubmit} onReset={doReset}>
<p>
<label>Название:</label>
<input name="structure" type="text" />

View File

@@ -20,7 +20,12 @@ const Table = (props) => {
};
//количество страниц разбиения таблицы
const n = Math.ceil(dataTable.length / props.amountRows);
let n = Math.ceil(dataTable.length / props.amountRows);
let rowCount = props.amountRows;
if(props.disablePagination){
n=1;
rowCount=dataTable.length;
}
// массив с номерами страниц
const arr = Array.from({ length: n }, (v, i) => i + 1);
@@ -37,7 +42,7 @@ const Table = (props) => {
<table>
<TableHead head={Object.keys(props.data[0])} />
<TableBody body={dataTable} amountRows={props.amountRows} numPage={activePage} />
<TableBody body={dataTable} amountRows={rowCount} numPage={activePage} />
</table>
{n>1 &&