Skip to content

Commit

Permalink
fix/add finish2
Browse files Browse the repository at this point in the history
  • Loading branch information
k0t1k777 committed Aug 23, 2024
1 parent 9ae82ee commit 0c8df49
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 58 deletions.
6 changes: 6 additions & 0 deletions src/components/Filter/Filter.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,10 @@

.downContainer {
height: 100px;
}

.noFound {
@include mp-null;
@include use-font;
margin: 200px auto;
}
48 changes: 27 additions & 21 deletions src/components/Filter/Filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,27 +142,33 @@ export default function Filter({ droppedCards }: FilterProps) {
/>
<p className={styles.text}>Фильтры</p>
</div>
<FilterList />
<div className={styles.containerResult}>
{members &&
members.map((card, index) => (
<Card
id={String(card.id)}
key={String(card.id)}
title={card.position}
full_name={card.full_name}
department={card.department}
index={index}
isFilterOpen={isFilterOpen}
onDragStart={(e) => handleDragStart(e, droppedCards)}
draggable={
!droppedCards.some(
(droppedCard) => droppedCard.id === String(card.id)
)
}
/>
))}
</div>
<FilterList setCurrentPageFilter={setCurrentPageFilter} />
{members.length ? (
<div className={styles.containerResult}>
{members &&
members.map((card, index) => (
<Card
id={String(card.id)}
key={String(card.id)}
title={card.position}
full_name={card.full_name}
department={card.department}
index={index}
isFilterOpen={isFilterOpen}
onDragStart={(e) => handleDragStart(e, droppedCards)}
draggable={
!droppedCards.some(
(droppedCard) => droppedCard.id === String(card.id)
)
}
/>
))}
</div>
) : (
<p className={styles.noFound}>
По вашему запросу ничего не найдено, попробуйте изменить фильтры
</p>
)}
<div className={styles.downContainer}></div>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ export default function Header({ droppedCards }: HeaderProps) {
dispatch(setIsProfileOpen(false));
}

const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const { value } = event.target;
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
dispatch(setCurrentPage(1));
const { value } = event.target;
dispatch(setSearch(value));
dispatch(
await dispatch(
fetchGetMembers({
page: currentPage,
search: value,
Expand Down
1 change: 1 addition & 0 deletions src/components/SideBar/SideBar.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
.text {
@include mp-null;
@include use-font;
@include user-highlighting;
word-break: normal;
overflow: hidden;
display: flex;
Expand Down
6 changes: 6 additions & 0 deletions src/pages/Employees/Employees.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,9 @@
.arrow {
color: $button-focus;
}

.noFound {
@include mp-null;
@include use-font(24px, 28.8px, 500);
margin: 200px auto;
}
54 changes: 36 additions & 18 deletions src/pages/Employees/Employees.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ export default function Employees() {
function nextPage() {
if (currentPage < maxPages) {
dispatch(
fetchGetMembers({ page: currentPage + 1, search, position, department, city })
fetchGetMembers({
page: currentPage + 1,
search,
position,
department,
city,
})
);
dispatch(setCurrentPage(currentPage + 1));
}
Expand All @@ -40,7 +46,13 @@ export default function Employees() {
function previousPage() {
if (currentPage > 1) {
dispatch(
fetchGetMembers({ page: currentPage - 1, search, position, department, city })
fetchGetMembers({
page: currentPage - 1,
search,
position,
department,
city,
})
);
dispatch(setCurrentPage(currentPage - 1));
}
Expand Down Expand Up @@ -93,22 +105,28 @@ export default function Employees() {
</div>
</div>
</div>
<div
className={cx(styles.cardContainer, {
[styles.cardContainer_center]: shortWindow,
})}
>
{members.map((card, index) => (
<Card
id={card.id}
key={card.id}
title={card.position}
full_name={card.full_name}
department={card.department}
index={index}
/>
))}
</div>
{members.length ? (
<div
className={cx(styles.cardContainer, {
[styles.cardContainer_center]: shortWindow,
})}
>
{members.map((card, index) => (
<Card
id={card.id}
key={card.id}
title={card.position}
full_name={card.full_name}
department={card.department}
index={index}
/>
))}
</div>
) : (
<p className={styles.noFound}>
По вашему запросу ничего не найдено, попробуйте изменить фильтры
</p>
)}
{isProfileOpen && <PopupProfile />}
</section>
);
Expand Down
33 changes: 21 additions & 12 deletions src/ui/EmployeesList/EmployeesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,35 @@ export default function EmployeesList() {
dispatch(setSearch(value));
dispatch(setCurrentPage(1));
await dispatch(
fetchGetMembers({ page: 1, search: value, position, department, city: '' })
fetchGetMembers({
page: 1,
search: value,
position,
department,
city: '',
})
);
};

const handleSelectChange = (value: string, type: 'position' | 'department') => {
const handleSelectChange = (
value: string,
type: 'position' | 'department'
) => {
if (type === 'position') {
dispatch(setPosition(value));
dispatch(setPosition(value));
} else {
dispatch(setDepartment(value));
dispatch(setDepartment(value));
}
dispatch(setCurrentPage(1));
};

useEffect(() => {
return () => {
dispatch(setPosition(''));
dispatch(setDepartment(''));
dispatch(setCurrentPage(1));
};
}, [location.pathname, dispatch]);

useEffect(() => {
return () => {
dispatch(setPosition(''));
dispatch(setDepartment(''));
dispatch(setCurrentPage(1));
};
}, [location.pathname, dispatch]);

useEffect(() => {
dispatch(fetchSelects());
Expand Down
12 changes: 8 additions & 4 deletions src/ui/FilterList/FilterList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import styles from 'src/ui/FilterList/FilterList.module.scss';
import { useAppDispatch, useAppSelector } from 'src/store/hooks';
import { setCurrentPage } from 'src/store/features/slice/membersSlice';
import {
fetchSelects,
selectFilter,
Expand All @@ -11,7 +10,11 @@ import {
import { useEffect } from 'react';
import Select from 'src/ui/Select/Select';

export default function FilterList() {
interface currentPageFilterProps {
setCurrentPageFilter: (type: number) => void;
}

export default function FilterList({ setCurrentPageFilter}: currentPageFilterProps) {
const { selects, department, position, city } = useAppSelector(selectFilter);

const dispatch = useAppDispatch();
Expand All @@ -27,15 +30,16 @@ export default function FilterList() {
} else if (type === 'city') {
dispatch(setCity(value));
}
dispatch(setCurrentPage(1));
setCurrentPageFilter(1);
};

useEffect(() => {
return () => {
dispatch(setPosition(''));
dispatch(setDepartment(''));
dispatch(setCity(''));
dispatch(setCurrentPage(1));

setCurrentPageFilter(1);
};
}, [location.pathname, dispatch]);

Expand Down

0 comments on commit 0c8df49

Please sign in to comment.