-
Notifications
You must be signed in to change notification settings - Fork 0
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
Angga Maulana
authored and
Angga Maulana
committed
Mar 26, 2023
1 parent
90774fb
commit 4a44030
Showing
5 changed files
with
105 additions
and
177 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import React, { useEffect, memo } from 'react' | ||
import { Tree, TreeNode } from "react-organizational-chart"; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { ProfileActions } from 'store/redux/profileReducer'; | ||
|
||
const OrgChart = () => { | ||
const dispatch = useDispatch(); | ||
const { tree } = useSelector(state => state.profileReducer) | ||
const color = { | ||
silver: "#c0c0c0", | ||
gold: "#d4af37", | ||
diamond: "#61e2ff", | ||
} | ||
|
||
const renderColor = (param) => { | ||
const paket = param?.split(' ')[1].toLowerCase() | ||
|
||
switch(paket){ | ||
case "gold":{ | ||
return color.gold; | ||
} | ||
case "silver":{ | ||
return color.silver | ||
} | ||
case "diamond":{ | ||
return color.diamond | ||
} | ||
default : | ||
return ""; | ||
} | ||
} | ||
|
||
useEffect(()=>{ | ||
dispatch(ProfileActions.doGetTreeRequest()) | ||
},[]) | ||
|
||
const RenderNode = () => { | ||
return tree?.data?.downlines?.map((item,i) => ( | ||
<> | ||
<TreeNode key={i} label={ | ||
<div className="flex items-center justify-center" onClick={() => alert("hii")}> | ||
<div className="border rounded rounded-md p-5 justify-center" style={{backgroundColor: renderColor(item?.user?.deposit?.name)}}> | ||
<img className="w-16 h-16 rounded rounded-full mx-auto" src="/img/team-1-800x800.jpg" /> | ||
<p className="font-medium text-md pt-2 text-white">{item?.user?.name?.length > 0 && item?.user?.name?.substring(0, 7)+' ...'}</p> | ||
<p className="font-italic text-sm text-white">{item?.user?.deposit?.name?.split(' ')[1]}</p> | ||
</div> | ||
</div> | ||
}> | ||
{item?.user?.downlines?.map((x,y) => ( | ||
<> | ||
<TreeNode key={y} label={ | ||
<div className="flex items-center justify-center" onClick={() => alert("hii")}> | ||
<div className="border rounded rounded-md p-5" style={{backgroundColor: renderColor(x?.user?.deposit?.name)}}> | ||
<img className="w-16 h-16 rounded rounded-full mx-auto" src="/img/team-1-800x800.jpg" /> | ||
<p className="font-medium text-md pt-2 text-white">{x?.user?.name?.length > 0 && x?.user?.name?.substring(0, 7)+' ...'}</p> | ||
<p className="font-italic text-sm text-white">{x?.user?.deposit?.name?.split(' ')[1]}</p> | ||
</div> | ||
</div> | ||
}> | ||
{x?.user?.downlines?.map((u,v) => ( | ||
<> | ||
<TreeNode label={ | ||
<div className="flex items-center justify-center" onClick={() => alert("hii")}> | ||
<div className="border rounded rounded-md p-5" style={{backgroundColor: renderColor(u?.user?.deposit?.name)}}> | ||
<img className="w-16 h-16 rounded rounded-full mx-auto" src="/img/team-1-800x800.jpg" /> | ||
<p className="font-medium text-md pt-2 text-white">{u?.user?.name?.length > 0 && u?.user?.name?.substring(0, 7)+' ...'}</p> | ||
<p className="font-italic text-sm text-white">{u?.user?.deposit?.name?.split(' ')[1]}</p> | ||
</div> | ||
</div> | ||
} /> | ||
</> | ||
))} | ||
</TreeNode> | ||
</> | ||
))} | ||
</TreeNode> | ||
</> | ||
)) | ||
} | ||
return ( | ||
<Tree | ||
lineWidth={"2px"} | ||
lineColor={"black"} | ||
lineHeight={"40px"} | ||
nodePadding={"5px"} | ||
lineBorderRadius={"10px"} | ||
label={ | ||
<div className="flex items-center justify-center" onClick={() => alert("hii")}> | ||
<div className="border rounded rounded-md p-5 jusify-center" style={{backgroundColor: renderColor(tree?.data?.deposit?.name)}}> | ||
<img className="w-16 h-16 rounded rounded-full mx-auto" src="/img/team-1-800x800.jpg" /> | ||
<p className="font-medium text-md pt-2 text-white">{tree?.data?.name}</p> | ||
<p className="font-italic text-sm text-white">{tree?.data?.deposit?.name?.split(' ')[1]}</p> | ||
</div> | ||
</div> | ||
}> | ||
<RenderNode /> | ||
</Tree> | ||
) | ||
} | ||
|
||
export default memo(OrgChart) |
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,22 +0,0 @@ | ||
html, | ||
body { | ||
padding: 0; | ||
margin: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, | ||
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; | ||
} | ||
|
||
html, | ||
body, | ||
#__next { | ||
height: 100%; | ||
} | ||
|
||
a { | ||
color: inherit; | ||
text-decoration: none; | ||
} | ||
|
||
* { | ||
box-sizing: border-box; | ||
} | ||