-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
229 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,104 @@ | ||
import { useEffect } from 'react'; | ||
import { useEffect, useLayoutEffect, useState } from 'react'; | ||
import { useLocation, useParams } from 'react-router-dom'; | ||
import styles from 'src/pages/Teams/Teams.module.scss'; | ||
import { renderArrows, renderCards, renderEmptyCells } from 'src/services/helpers'; | ||
import { membersProps } from 'src/services/types'; | ||
import { | ||
fetchGetTeams, | ||
fetchGetTeamsId, | ||
selectTeams, | ||
} from 'src/store/features/slice/teamsSlice'; | ||
import { useAppDispatch, useAppSelector } from 'src/store/hooks'; | ||
import TeamsItem from 'src/ui/TeamsItem/TeamsItem'; | ||
|
||
export default function Teams() { | ||
const { id } = useParams() | ||
|
||
const dispatch = useAppDispatch(); | ||
const { teams } = useAppSelector(selectTeams); | ||
const { teams, team } = useAppSelector(selectTeams); | ||
|
||
const [arrows, setArrows] = useState<JSX.Element[]>([]); | ||
const [busyCells, setBusyCells] = useState<string[]>([]); | ||
const [teamsCards, setTeamsCards] = useState<membersProps[]>([]); | ||
console.log('teamsCards: ', teamsCards); | ||
|
||
|
||
|
||
// const teamsRout = location.pathname.includes(`/teams/`) | ||
|
||
// const collectCellIds = (card: membersProps, collected: string[]) => { | ||
// if (card.cellId) { | ||
// collected.push(card.cellId); | ||
// } | ||
// if (card.subordinates) { | ||
// card.subordinates.forEach((subordinate) => | ||
// collectCellIds(subordinate, collected) | ||
// ); | ||
// } | ||
// }; | ||
|
||
// useEffect(() => { | ||
// const collectCards = (card: membersProps, collected: membersProps[]) => { | ||
// collected.push(card); | ||
// if (card.subordinates) { | ||
// card.subordinates.forEach((subordinate) => | ||
// collectCards(subordinate, collected) | ||
// ); | ||
// } | ||
// }; | ||
// const newAllCards: membersProps[] = []; | ||
// const newBusyCells: string[] = []; | ||
|
||
// cards.forEach((card) => { | ||
// collectCards(card, newAllCards); | ||
// collectCellIds(card, newBusyCells); | ||
// }); | ||
|
||
// setAllCards(newAllCards); | ||
// setBusyCells(newBusyCells); | ||
// }, [cards]); | ||
|
||
// useLayoutEffect(() => { | ||
// if (team.employees?.subordinates.length > 0) { | ||
// renderArrows(team.employees?.subordinates, setArrows); | ||
// } | ||
// }, [team.employees?.subordinates]); | ||
|
||
|
||
useEffect(() => { | ||
dispatch(fetchGetTeams()); | ||
}, []); | ||
|
||
|
||
useEffect(() => { | ||
if (id) { | ||
const parsedId = parseInt(id, 10) | ||
dispatch(fetchGetTeamsId(parsedId)) | ||
} | ||
}, [dispatch, id]) | ||
|
||
useEffect(() => { | ||
setTeamsCards(team && team.employees?.subordinates) | ||
}, [team]) | ||
|
||
return ( | ||
<section className={styles.teams}> | ||
{teams.map((item) => ( | ||
<TeamsItem | ||
key={item.id} | ||
name={item.name} | ||
projects={item.projects} | ||
/> | ||
))} | ||
{id ? ( | ||
<div> | ||
{/* {team.employees?.subordinates.map(renderCards)} | ||
{renderEmptyCells(busyCells)} | ||
{arrows} */} | ||
</div> | ||
) : ( | ||
teams.map((item) => ( | ||
<TeamsItem | ||
id={item.id} | ||
key={item.id} | ||
name={item.name} | ||
projects={item.projects} | ||
/> | ||
)) | ||
)} | ||
</section> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,24 @@ | ||
|
||
export const cellWidth = 312; | ||
export const cellHeight = 149; | ||
export const numCols = 3; | ||
export const numRows = 10; | ||
export const itemsPerPage = 12; | ||
export const itemsPerPage = 12; | ||
|
||
// export const inintialMember: membersProps = { | ||
// id: '', | ||
// index: 0, | ||
// title: '', | ||
// full_name: '', | ||
// department: '', | ||
// position: '', | ||
// cellId: '', | ||
// parentId: '', | ||
// photo: '', | ||
// subordinates: [], | ||
// } | ||
|
||
export const inintialTeam = { | ||
name: '', | ||
id: '', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.