error boundary and table pagination

This commit is contained in:
Mikola 2024-03-19 16:39:36 +03:00
parent 6afccb19d8
commit 2a5991da1f
5 changed files with 16 additions and 13 deletions

View File

@ -286,15 +286,15 @@ export const ProfileCalendarComponent = React.memo(
? `${getCorrectDate(startDate)} - ${getCorrectDate(endDate)}` ? `${getCorrectDate(startDate)} - ${getCorrectDate(endDate)}`
: `${getCorrectDate(endDate)} - ${getCorrectDate(startDate)}` : `${getCorrectDate(endDate)} - ${getCorrectDate(startDate)}`
: activePeriod : activePeriod
? "Выберите диапазон на календаре" ? "Выберите диапазон на календаре"
: "Выбрать диапазон"} : "Выбрать диапазон"}
</span> </span>
<span> <span>
{totalRangeHours {totalRangeHours
? `${totalRangeHours} ${hourOfNum(totalRangeHours)}` ? `${totalRangeHours} ${hourOfNum(totalRangeHours)}`
: endDate : endDate
? "0 часов" ? "0 часов"
: ""} : ""}
</span> </span>
{endDate && ( {endDate && (
<BaseButton <BaseButton

View File

@ -1,4 +1,5 @@
import React, { Component } from "react"; import React, { Component } from "react";
import { Fallback } from "./Fallback"; import { Fallback } from "./Fallback";
class ErrorBoundary extends Component { class ErrorBoundary extends Component {

View File

@ -1,17 +1,16 @@
import React from "react"; import React from "react";
import logo from "assets/images/logo/ITguild.svg";
import rightArrow from "assets/icons/arrows/arrowRight.svg"; import rightArrow from "assets/icons/arrows/arrowRight.svg";
import logo from "assets/images/logo/ITguild.svg";
import './fallback.scss' import "./fallback.scss";
export const Fallback = () => { export const Fallback = () => {
return ( return (
<div className="fallback"> <div className="fallback">
<img src={logo} alt="logo" className="logo" /> <img src={logo} alt="logo" className="logo" />
<h1>Произошла непредвиденная ошибка</h1> <h1>Произошла непредвиденная ошибка</h1>
<a href='/profile'> <a href="/profile">
Вернуться назад Вернуться назад
<img src={rightArrow} alt="arrow" /> <img src={rightArrow} alt="arrow" />
</a> </a>

View File

@ -1,9 +1,9 @@
import React from "react"; import React from "react";
import ReactDOM from "react-dom/client"; import ReactDOM from "react-dom/client";
import { Provider } from "react-redux"; import { Provider } from "react-redux";
import ErrorBoundary from "./hoc/ErrorBoundary";
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";

View File

@ -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";
@ -14,7 +15,6 @@ import { Loader } from "@components/Common/Loader/Loader";
import { Navigation } from "@components/Navigation/Navigation"; import { Navigation } from "@components/Navigation/Navigation";
import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs"; import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs";
import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader"; import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader";
import { usePagination } from "@table-library/react-table-library/pagination";
import rightArrow from "assets/icons/arrows/arrowRight.svg"; import rightArrow from "assets/icons/arrows/arrowRight.svg";
@ -105,7 +105,7 @@ export const PartnerCategories = () => {
const pagination = usePagination(data, { const pagination = usePagination(data, {
state: { state: {
page: 0, page: 0,
size: 5, size: 5
} }
}); });
@ -270,7 +270,9 @@ export const PartnerCategories = () => {
pagination={pagination} pagination={pagination}
/> />
<div className="table__pagination"> <div className="table__pagination">
<span>Total Pages: {pagination.state.getTotalPages(data.nodes)}</span> <span>
Total Pages: {pagination.state.getTotalPages(data.nodes)}
</span>
<span className="table__pages"> <span className="table__pages">
Page:{" "} Page:{" "}
@ -279,7 +281,8 @@ export const PartnerCategories = () => {
key={index} key={index}
type="button" type="button"
style={{ style={{
fontWeight: pagination.state.page === index ? "bold" : "normal", fontWeight:
pagination.state.page === index ? "bold" : "normal"
}} }}
onClick={() => pagination.fns.onSetPage(index)} onClick={() => pagination.fns.onSetPage(index)}
> >