-
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.
Browse files
Browse the repository at this point in the history
Feature: 순위 페이지 리스트 뷰 기능 추가
- Loading branch information
Showing
6 changed files
with
225 additions
and
74 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,82 @@ | ||
import { Box, styled, Grid, ImageList } from "@mui/material"; | ||
import HoverBox from "./HoverBox"; | ||
import Item from "./Item"; | ||
import { motion } from "framer-motion"; | ||
import { useRecoilValue } from "recoil"; | ||
import { useSetRecoilState } from "recoil"; | ||
import { authorityState, isShowFullImageState } from "../../store/atom"; | ||
import { AnimatePresence } from "framer-motion"; | ||
|
||
const StyledItemSize = styled(Box)({ | ||
position: "relative", | ||
width: "300px", | ||
height: "300px", | ||
}); | ||
|
||
export default function RankGridView({ | ||
setFullImageUrl, | ||
setItemsHover, | ||
teams, | ||
itemsHover, | ||
}) { | ||
const setIsShowFullImage = useSetRecoilState(isShowFullImageState); | ||
const myAuthority = useRecoilValue(authorityState); | ||
|
||
const handleFullImageOpen = async (imageUrl) => { | ||
if (myAuthority !== "ADMIN") return; | ||
if (!imageUrl) { | ||
setFullImageUrl("/img/mainImg2.png"); | ||
} else setFullImageUrl(imageUrl); | ||
setIsShowFullImage(true); | ||
}; | ||
|
||
const handleMouseOver = (index) => { | ||
setItemsHover((prev) => [ | ||
...prev?.slice(0, index), | ||
true, | ||
...prev?.slice(index + 1), | ||
]); | ||
}; | ||
const handleMouseOut = (index) => { | ||
setItemsHover((prev) => [ | ||
...prev?.slice(0, index), | ||
false, | ||
...prev?.slice(index + 1), | ||
]); | ||
}; | ||
|
||
return ( | ||
<ImageList | ||
cols={4} | ||
gap={15} | ||
component={motion.div} | ||
initial={{ opacity: 0, y: 20 }} | ||
animate={{ opacity: 1, y: 0 }} | ||
> | ||
{teams.map((item, index) => ( | ||
<Grid | ||
item | ||
key={index} | ||
onClick={() => handleFullImageOpen(item?.thumbnail)} | ||
> | ||
<StyledItemSize | ||
onMouseOver={() => handleMouseOver(index)} | ||
onMouseOut={() => handleMouseOut(index)} | ||
> | ||
<AnimatePresence> | ||
{itemsHover[index] && ( | ||
<HoverBox | ||
members={item.members} | ||
reports={item.reports} | ||
totalMinutes={item.totalMinutes} | ||
/> | ||
)} | ||
</AnimatePresence> | ||
|
||
<Item index={index} item={item} itemsHover={itemsHover} /> | ||
</StyledItemSize> | ||
</Grid> | ||
))} | ||
</ImageList> | ||
); | ||
} |
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,58 @@ | ||
import { DataGrid } from "@mui/x-data-grid"; | ||
const columns = [ | ||
{ field: "id", headerName: "순위", width: 100 }, | ||
{ field: "groupNm", headerName: "그룹", width: 100 }, | ||
{ | ||
field: "reportNm", | ||
headerName: "제출한 레포트 수", | ||
type: "number", | ||
width: 300, | ||
}, | ||
{ | ||
field: "totalMins", | ||
headerName: "총 시간(분)", | ||
type: "number", | ||
width: 150, | ||
}, | ||
{ | ||
field: "members", | ||
headerName: "팀원", | ||
type: "text", | ||
width: 600, | ||
}, | ||
]; | ||
|
||
export default function RankListView({ teams }) { | ||
const addMedalEmogi = (id) => { | ||
switch (id) { | ||
case 1: | ||
return "🥇"; | ||
case 2: | ||
return "🥈"; | ||
case 3: | ||
return "🥉"; | ||
default: | ||
return id; | ||
} | ||
}; | ||
|
||
const convertTeams2List = (teams) => { | ||
return teams?.map((team, idx) => { | ||
return { | ||
id: addMedalEmogi(idx + 1), | ||
groupNm: team.id, | ||
reportNm: team.reports, | ||
totalMins: team.totalMinutes, | ||
members: team.members.join(", "), | ||
}; | ||
}); | ||
}; | ||
|
||
return ( | ||
<DataGrid | ||
rows={convertTeams2List(teams)} | ||
columns={columns} | ||
density="compact" | ||
/> | ||
); | ||
} |
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,29 @@ | ||
import { Stack, ToggleButton, ToggleButtonGroup } from "@mui/material"; | ||
|
||
import ViewListIcon from "@mui/icons-material/ViewList"; | ||
import ViewModuleIcon from "@mui/icons-material/ViewModule"; | ||
|
||
export default function ViewToggleButton({ view, setView }) { | ||
const handleViewChange = (event, nextView) => { | ||
setView(nextView); | ||
}; | ||
return ( | ||
<Stack direction="row" justifyContent="end" width="100%"> | ||
<ToggleButtonGroup | ||
size="small" | ||
orientation="horizontal" | ||
value={view} | ||
exclusive | ||
onChange={handleViewChange} | ||
color="primary" | ||
> | ||
<ToggleButton value="list" aria-label="list"> | ||
<ViewListIcon /> | ||
</ToggleButton> | ||
<ToggleButton value="grid" aria-label="grid"> | ||
<ViewModuleIcon /> | ||
</ToggleButton> | ||
</ToggleButtonGroup> | ||
</Stack> | ||
); | ||
} |
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