Commit ed69d9bb authored by Merekeyev Dias's avatar Merekeyev Dias

removed table reset: found bug

parent 2b5d48c0
......@@ -21,7 +21,7 @@ const HomePage: React.FC = () => {
};
const handlePaginationChange = (page: number) => {
tableRef.current?.nativeElement.scrollIntoView({ behavior: 'smooth' });
// tableRef.current?.nativeElement.scrollIntoView({ behavior: 'smooth' });
dispatch(setCurrentPage(page));
};
......@@ -48,6 +48,7 @@ const HomePage: React.FC = () => {
dataSource={paginatedData(orgs)}
columns={columns} pagination={false}
rowKey="id"
className='home_table'
ref={tableRef}
/>
} else if (isError) {
......@@ -64,8 +65,12 @@ const HomePage: React.FC = () => {
return (
<div className="container">
<section className='section'>
<div className="add">
<Button className='add_title' onClick={handleAddClick}>
<div>
<Button
className='add_title'
type='primary'
onClick={handleAddClick}
>
Добавить
</Button>
</div>
......
.container{
/* min-width: 1440px; */
margin: 0 auto;
}
.section {
margin: 0 auto;
margin-top: 10px;
margin-left: 20px;
margin-right: 20px;
margin-top: 10px 20px;
display: flex;
flex-direction: column;
height: calc(100vh - 60px);
}
.add {
margin-bottom: 10px;
display: flex;
align-items: center;
gap: 4px;
margin-left: 10px;
}
.add_button,
.view-btn {
cursor: pointer;
transition: transform 0.3s ease;
}
.add_button:hover,
.add_button:focus,
.view-btn:focus,
.view-btn:hover {
transform: scale(1.1);
}
.add_title {
font-size: 12px;
line-height: 18px;
......@@ -46,52 +17,8 @@
flex: 1;
overflow-y: auto;
padding-bottom: 20px;
}
.data-table {
min-width: 100%;
border-collapse: collapse;
color: #222222;
font-family: Open Sans;
font-size: 12px;
font-weight: 400;
line-height: 18px;
}
.data-table th,
.data-table td {
border: 1px solid #ddd;
padding: 5px;
}
.data-table th {
text-align: left;
}
.data-table tr:nth-child(even) {
background-color: #f9f9f9;
}
.data-table tr:hover {
background-color: #ddd;
}
.data-table th {
padding-top: 12px;
padding-bottom: 12px;
background-color: #E4EEFC;
}
.view-btn,
.delete-btn {
background: none;
border: none;
cursor: pointer;
}
.view-btn:hover,
.delete-btn:hover {
opacity: 0.7;
margin-top: 20px;
margin-left: -10px;
}
.pagination-container {
......
......@@ -7,8 +7,8 @@ import { useDispatch, useSelector } from 'react-redux';
import { columns, DataType } from './Columns';
import { useGetRequestsQuery } from '../../features/api/requestApiSlice';
import { setCurrentPage, setTotalReqNumber } from '../../features/pagination/reqPagination';
import './RequestPage.css';
import { TableRef } from 'antd/es/table';
import './RequestPage.css';
const dateFormat = 'YYYY/MM/DD';
......@@ -20,12 +20,12 @@ const RequestPage: React.FC = () => {
const REQ_NUMBER_PER_PAGE = useSelector((state: any) => state.reqPagination.REQ_NUMBER_PER_PAGE);
const [startDate, setStartDate] = useState<Date>();
const [endDate, setEndDate] = useState<Date>();
const [endDate, setEndDate] = useState();
const [method, setMethod] = useState('');
const [filteredData, setFilteredData] = useState<Request[]>([]);
const handlePaginationChange = (page: number) => {
tableRef.current?.nativeElement.scrollIntoView({ behavior: 'smooth' });
// tableRef.current?.nativeElement.scrollIntoView({ behavior: 'smooth' });
dispatch(setCurrentPage(page));
};
......@@ -39,6 +39,7 @@ const RequestPage: React.FC = () => {
if (!startDate || !endDate) return;
const filtered = reqs.list.filter((req) => {
const sendDate = dayjs(req.sendDate, dateFormat);
});
......@@ -47,6 +48,18 @@ const RequestPage: React.FC = () => {
dispatch(setTotalReqNumber(filtered.length));
};
const setDefaultDate = () => {
let min = Infinity;
reqs.list.map((req) => {
const dateValue = new Date(req.sendDate).valueOf();
if (min >= dateValue) {
min = dateValue;
}
})
let minDateType = new Date(min);
setStartDate(minDateType);
}
const onSelectStartDate = (dateString: any) => {
setStartDate(dateString);
}
......@@ -86,6 +99,10 @@ const RequestPage: React.FC = () => {
}
}, [isSuccess, reqs, dispatch]);
useEffect(() => {
setDefaultDate();
}, [setStartDate])
return (
<div className="container">
<div className="filter">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment