partner categories fixes

This commit is contained in:
Николай Полтщук 2024-08-09 21:09:02 +03:00
parent a156557d57
commit 214d309ffb

View File

@ -17,8 +17,8 @@ import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadc
import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader"; import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader";
import rightArrow from "assets/icons/arrows/arrowRight.svg"; import rightArrow from "assets/icons/arrows/arrowRight.svg";
import folder from "assets/icons/folder.svg";
import report from "assets/icons/report.svg"; import report from "assets/icons/report.svg";
import folder from "assets/icons/folder.svg"
import "./partnerСategories.scss"; import "./partnerСategories.scss";
@ -65,8 +65,7 @@ export const PartnerCategories = () => {
<Link className="table__info" to={`/profile/summary/${item.user_id}`}> <Link className="table__info" to={`/profile/summary/${item.user_id}`}>
<p>{item?.employee.fio}</p> <p>{item?.employee.fio}</p>
<span> <span>
{item?.employee.level_title} /{" "} {item?.employee.level_title} / {item?.employee.position.name}
{item?.employee.position.name}
</span> </span>
</Link> </Link>
) )
@ -77,7 +76,12 @@ export const PartnerCategories = () => {
<div className="table__project"> <div className="table__project">
{item?.employee.projects.length ? ( {item?.employee.projects.length ? (
item.employee.projects.map((project) => { item.employee.projects.map((project) => {
return <div className="table__project__item" key={project.id}><img src={folder} alt="folder" /> <p>{project.project.name}</p></div> return (
<div className="table__project__item" key={project.id}>
<img src={folder} alt="folder" />{" "}
<p>{project.project.name}</p>
</div>
);
}) })
) : ( ) : (
<span>Нет проектов</span> <span>Нет проектов</span>
@ -131,9 +135,9 @@ export const PartnerCategories = () => {
useEffect(() => { useEffect(() => {
setLoader(true); setLoader(true);
apiRequest("/project/my-employee").then((el) => { apiRequest("/project/my-employee").then((el) => {
setNodes(el.managerEmployees) setNodes(el.managerEmployees);
setInitialNodes(el.managerEmployees) setInitialNodes(el.managerEmployees);
setLoader(false) setLoader(false);
}); });
}, []); }, []);
@ -201,8 +205,7 @@ export const PartnerCategories = () => {
setActiveTab(tab.name); setActiveTab(tab.name);
setNodes( setNodes(
initialNodes.filter( initialNodes.filter(
(item) => (item) => item.employee.position.id === tab.value
item.employee.position.id === tab.value
) )
); );
}} }}
@ -225,56 +228,61 @@ export const PartnerCategories = () => {
sort={sort} sort={sort}
pagination={pagination} pagination={pagination}
/> />
{Boolean(nodes.length) && pagination.state.getPages(data.nodes).length > 1 && {Boolean(nodes.length) &&
<div className="table__pagination"> pagination.state.getPages(data.nodes).length > 1 && (
<button <div className="table__pagination">
className={
pagination.state.page === 0 ? "switch disable" : "switch"
}
type="button"
disabled={pagination.state.page === 0}
onClick={() =>
pagination.fns.onSetPage(pagination.state.page - 1)
}
>
{"<"}
</button>
<span className="table__pages">
{pagination.state.getPages(data.nodes).map((_, index) => (
<button <button
key={index}
type="button"
className={ className={
pagination.state.page === index pagination.state.page === 0
? "page page--active " ? "switch disable"
: "page" : "switch"
}
type="button"
disabled={pagination.state.page === 0}
onClick={() =>
pagination.fns.onSetPage(pagination.state.page - 1)
} }
onClick={() => pagination.fns.onSetPage(index)}
> >
{index + 1} {"<"}
</button> </button>
))} <span className="table__pages">
</span> {pagination.state
<button .getPages(data.nodes)
className={ .map((_, index) => (
pagination.state.page + 1 === <button
pagination.state.getPages(data.nodes).length key={index}
? "switch disable" type="button"
: "switch" className={
} pagination.state.page === index
type="button" ? "page page--active "
disabled={ : "page"
pagination.state.page + 1 === }
pagination.state.getPages(data.nodes).length onClick={() => pagination.fns.onSetPage(index)}
} >
onClick={() => {index + 1}
pagination.fns.onSetPage(pagination.state.page + 1) </button>
} ))}
> </span>
{">"} <button
</button> className={
</div> pagination.state.page + 1 ===
} pagination.state.getPages(data.nodes).length
? "switch disable"
: "switch"
}
type="button"
disabled={
pagination.state.page + 1 ===
pagination.state.getPages(data.nodes).length
}
onClick={() =>
pagination.fns.onSetPage(pagination.state.page + 1)
}
>
{">"}
</button>
</div>
)}
</> </>
) : ( ) : (
<div className="partner-categories__empty"> <div className="partner-categories__empty">