feat(AccountsPage): add on table change

This commit is contained in:
Vladislav Syrochkin 2025-06-24 13:18:45 +05:00
parent 7c2c4071cc
commit aae56a8c73
4 changed files with 18 additions and 3 deletions

View File

@ -64,5 +64,5 @@ check-api:
poetry run ruff format . --check poetry run ruff format . --check
regenerate-openapi-local: regenerate-openapi-local:
rm client/src/types/openapi-types.types \ rm client/src/types/openapi-types.ts \
npx openapi-typescript http://localhost:8000/openapi -o client/src/types/openapi-types.ts npx openapi-typescript http://localhost:8000/openapi -o client/src/types/openapi-types.ts

View File

@ -19,6 +19,7 @@ export default function AccountsPage() {
amountCount: 0, amountCount: 0,
amountPages: 0, amountPages: 0,
users: [], users: [],
currentPage: 1,
}); });
useEffect(() => { useEffect(() => {
@ -103,6 +104,13 @@ export default function AccountsPage() {
}, },
]; ];
const onTableChange: TableProps<AllUser>['onChange'] = (pagination) => {
console.log(pagination);
UserService.getUsers(pagination.current as number, 10).then((data) => {
setAccounts(data);
});
};
return ( return (
<> <>
<Header <Header
@ -121,9 +129,14 @@ export default function AccountsPage() {
} }
/> />
<Table <Table
onChange={onTableChange}
columns={columns} columns={columns}
dataSource={accounts.users} dataSource={accounts.users}
pagination={{ pageSize: 10, current: 1, total: accounts.amountCount }} pagination={{
pageSize: 10,
current: accounts.currentPage,
total: accounts.amountCount,
}}
rowKey={'id'} rowKey={'id'}
/> />

View File

@ -191,6 +191,8 @@ export interface components {
amountCount: number; amountCount: number;
/** Amountpages */ /** Amountpages */
amountPages: number; amountPages: number;
/** Currentpage */
currentPage: number;
}; };
/** Auth */ /** Auth */
Auth: { Auth: {

View File

@ -1,4 +1,4 @@
import { components } from './openapi-types'; import { components } from "./openapi-types";
export type User = components['schemas']['User']; export type User = components['schemas']['User'];
export type AllUserResponse = components['schemas']['AllUserResponse']; export type AllUserResponse = components['schemas']['AllUserResponse'];