table-pagination #27
@ -1,5 +1,7 @@
|
|||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
|
|
||||||
|
import { Fallback } from "./Fallback";
|
||||||
|
|
||||||
class ErrorBoundary extends Component {
|
class ErrorBoundary extends Component {
|
||||||
state = {
|
state = {
|
||||||
error: null
|
error: null
|
||||||
@ -13,7 +15,7 @@ class ErrorBoundary extends Component {
|
|||||||
const { error } = this.state;
|
const { error } = this.state;
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return <div>Что-то пошло не так =( {error}</div>;
|
return <Fallback />;
|
||||||
}
|
}
|
||||||
return this.props.children;
|
return this.props.children;
|
||||||
}
|
}
|
19
src/hoc/Fallback.jsx
Normal file
19
src/hoc/Fallback.jsx
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
import rightArrow from "assets/icons/arrows/arrowRight.svg";
|
||||||
|
import logo from "assets/images/logo/ITguild.svg";
|
||||||
|
|
||||||
|
import "./fallback.scss";
|
||||||
|
|
||||||
|
export const Fallback = () => {
|
||||||
|
return (
|
||||||
|
<div className="fallback">
|
||||||
|
<img src={logo} alt="logo" className="logo" />
|
||||||
|
<h1>Произошла непредвиденная ошибка</h1>
|
||||||
|
<a href="/profile">
|
||||||
|
Вернуться назад
|
||||||
|
<img src={rightArrow} alt="arrow" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
19
src/hoc/fallback.scss
Normal file
19
src/hoc/fallback.scss
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
.fallback {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
padding: 100px;
|
||||||
|
gap: 15px;
|
||||||
|
|
||||||
|
img {
|
||||||
|
max-width: 250px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
display: flex;
|
||||||
|
column-gap: 10px;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 16px;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
}
|
@ -3,11 +3,14 @@ import ReactDOM from "react-dom/client";
|
|||||||
import { Provider } from "react-redux";
|
import { Provider } from "react-redux";
|
||||||
|
|
||||||
import App from "./App";
|
import App from "./App";
|
||||||
|
import ErrorBoundary from "./hoc/ErrorBoundary";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import { store } from "./store/store";
|
import { store } from "./store/store";
|
||||||
|
|
||||||
ReactDOM.createRoot(document.getElementById("root")).render(
|
ReactDOM.createRoot(document.getElementById("root")).render(
|
||||||
|
<ErrorBoundary>
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<App />
|
<App />
|
||||||
</Provider>
|
</Provider>
|
||||||
|
</ErrorBoundary>
|
||||||
);
|
);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { getTheme } from "@table-library/react-table-library/baseline";
|
import { getTheme } from "@table-library/react-table-library/baseline";
|
||||||
import { CompactTable } from "@table-library/react-table-library/compact";
|
import { CompactTable } from "@table-library/react-table-library/compact";
|
||||||
|
import { usePagination } from "@table-library/react-table-library/pagination";
|
||||||
import { useSort } from "@table-library/react-table-library/sort";
|
import { useSort } from "@table-library/react-table-library/sort";
|
||||||
import { useTheme } from "@table-library/react-table-library/theme";
|
import { useTheme } from "@table-library/react-table-library/theme";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
@ -101,6 +102,13 @@ export const PartnerCategories = () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const pagination = usePagination(data, {
|
||||||
|
state: {
|
||||||
|
page: 0,
|
||||||
|
size: 5
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoader(true);
|
setLoader(true);
|
||||||
apiRequest("/project/my-employee").then((el) => {
|
apiRequest("/project/my-employee").then((el) => {
|
||||||
@ -259,7 +267,30 @@ export const PartnerCategories = () => {
|
|||||||
data={data}
|
data={data}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
sort={sort}
|
sort={sort}
|
||||||
|
pagination={pagination}
|
||||||
/>
|
/>
|
||||||
|
<div className="table__pagination">
|
||||||
|
<span>
|
||||||
|
Total Pages: {pagination.state.getTotalPages(data.nodes)}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span className="table__pages">
|
||||||
|
Page:{" "}
|
||||||
|
{pagination.state.getPages(data.nodes).map((_, index) => (
|
||||||
|
<button
|
||||||
|
key={index}
|
||||||
|
type="button"
|
||||||
|
style={{
|
||||||
|
fontWeight:
|
||||||
|
pagination.state.page === index ? "bold" : "normal"
|
||||||
|
}}
|
||||||
|
onClick={() => pagination.fns.onSetPage(index)}
|
||||||
|
>
|
||||||
|
{index + 1}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<div className="partner-categories__empty">
|
<div className="partner-categories__empty">
|
||||||
|
@ -176,5 +176,19 @@
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__pagination {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
font-size: 16px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__pages {
|
||||||
|
display: flex;
|
||||||
|
column-gap: 5px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user