forked from codesquad-members-2021/issue-tracker
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: 체크박스 클릭시 선택이슈 열기 닫기, pipe함수 사용하여 필터링 테스트 #115
- Loading branch information
1 parent
64ff358
commit 280fcad
Showing
10 changed files
with
174 additions
and
80 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
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 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
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React, { useEffect } from 'react' | ||
import ListHeader from '@components/issueList/ListHeader'; | ||
import ListItem from '@components/issueList/ListItem'; | ||
import { IssueListItemType } from '@components/common/types/APIType'; | ||
import { issueCheckedItemAtom } from '@components/common/atoms/checkBoxAtom'; | ||
import { filterRadioButtonListAtom } from '@components/common/atoms/filterAtom'; | ||
import API from '@/utils/API'; | ||
import { useRecoilState } from '@/utils/myRecoil/useRecoilState'; | ||
import useFetch, { AsyncState } from '@/utils/hook/useFetch'; | ||
import { pipe, _ } from '@/utils/functionalUtils'; | ||
|
||
type IssueListType = { | ||
handleClickShowFilterModal: (title: string) => () => void; | ||
} | ||
|
||
const IssueList = ({ handleClickShowFilterModal }: IssueListType) => { | ||
const [issueItems] = useFetch(API.get.issues); | ||
const { data, loading, error }: AsyncState<any, any> = issueItems; | ||
const [checkedFilteredState, setCheckedFilteredState] = useRecoilState(filterRadioButtonListAtom); | ||
|
||
if (data) { | ||
console.log( | ||
pipe( | ||
_.filter(getFilteredIssueItems('assignees', checkedFilteredState.manager.info.id)), | ||
_.filter(getFilteredIssueItems('labels', checkedFilteredState.label.info.id)), | ||
_.filter(getFilteredIssueItems('milestone', checkedFilteredState.milestone.info.id)), | ||
_.filter(getFilteredIssueItems('author', checkedFilteredState.writer.info.id)) | ||
)(data)) | ||
} | ||
|
||
return ( | ||
<> | ||
{ | ||
data && <> | ||
<ListHeader issueItems={data} {...{ handleClickShowFilterModal }} /> | ||
{data.map((issueItem: IssueListItemType) => { | ||
return <ListItem key={issueItem.id} {...{ issueItem }} /> | ||
})} | ||
</> | ||
} | ||
{loading && <>loading...</>} | ||
{error && <>error...</>} | ||
</> | ||
) | ||
} | ||
|
||
|
||
const getFilteredIssueItems = (filterName: string, targetId: any) => (data: any) => { | ||
if (!targetId) return data; | ||
const property = data[filterName]; | ||
if (!Array.isArray(property)) { | ||
return property.id === targetId; | ||
} else { | ||
return property.find(({ id }: { id: number }) => id === targetId); | ||
} | ||
} | ||
export default IssueList; |
49 changes: 49 additions & 0 deletions
49
fe/client/src/components/issueList/IssueStateChangeFilter.tsx
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,49 @@ | ||
import React from 'react' | ||
import FilterTab from '@components/common/FilterTab'; | ||
import styled from 'styled-components'; | ||
import ArrowBottomIcon from '@/Icons/ArrowBottom.svg'; | ||
|
||
type IssueStateChangeFilterType = { | ||
title: string; | ||
handleClickShowFilterModal: (title: string) => () => void | ||
} | ||
const filterItems = [ | ||
{ name: '선택한 이슈 열기' }, | ||
{ name: '선택한 이슈 닫기' } | ||
]; | ||
|
||
const IssueStateChangeFilter = ({ title, handleClickShowFilterModal }: IssueStateChangeFilterType) => { | ||
return ( | ||
<FilterWrapper> | ||
<div onClick={handleClickShowFilterModal(title)}> | ||
<FilterTitleSpan>상태 수정</FilterTitleSpan> | ||
<ArrowImageTag src={ArrowBottomIcon} alt="" /> | ||
</div> | ||
<FilterTab | ||
inputType='radio' | ||
header={title} | ||
filterList={filterItems} /> | ||
</FilterWrapper> | ||
) | ||
} | ||
const FilterWrapper = styled.div` | ||
display: flex; | ||
position: relative; | ||
&:hover{ | ||
cursor:pointer; | ||
} | ||
`; | ||
|
||
const ArrowImageTag = styled.img` | ||
width: 16px; | ||
height: 16px; | ||
transform: translateY(3px); | ||
`; | ||
|
||
const FilterTitleSpan = styled.span` | ||
max-width: 70px; | ||
padding-right: 10px; | ||
line-height: 24px; | ||
`; | ||
|
||
export default IssueStateChangeFilter; |
Oops, something went wrong.