Showing
5 changed files
with
37 additions
and
8 deletions
| ... | @@ -126,7 +126,11 @@ const Header = () => { | ... | @@ -126,7 +126,11 @@ const Header = () => { |
| 126 | float="left" | 126 | float="left" |
| 127 | fontsize="20px" | 127 | fontsize="20px" |
| 128 | height="50px" | 128 | height="50px" |
| 129 | - options={[{ id: 1, name: '전체' }]} | 129 | + options={[ |
| 130 | + { id: 0, name: '전체' }, | ||
| 131 | + { id: 1, name: '작성자' }, | ||
| 132 | + { id: 2, name: '내용' }, | ||
| 133 | + ]} | ||
| 130 | /> | 134 | /> |
| 131 | </DropDownWrap> | 135 | </DropDownWrap> |
| 132 | </DropDownContainer> | 136 | </DropDownContainer> | ... | ... |
| 1 | import React, { useState, useEffect } from 'react'; | 1 | import React, { useState, useEffect } from 'react'; |
| 2 | import { TiArrowSortedDown } from 'react-icons/ti'; | 2 | import { TiArrowSortedDown } from 'react-icons/ti'; |
| 3 | import { Menu, MenuItem } from '@mantine/core'; | 3 | import { Menu, MenuItem } from '@mantine/core'; |
| 4 | +import { useDispatch } from 'react-redux'; | ||
| 4 | import styled from 'styled-components'; | 5 | import styled from 'styled-components'; |
| 5 | import { dropdownHeaderColorMap } from '../../lib/styles/palette'; | 6 | import { dropdownHeaderColorMap } from '../../lib/styles/palette'; |
| 7 | +import { setSearchOption } from '../../features/searchOption'; | ||
| 6 | 8 | ||
| 7 | const DropDownBlock = styled.div` | 9 | const DropDownBlock = styled.div` |
| 8 | margin: 0 auto; | 10 | margin: 0 auto; |
| ... | @@ -41,6 +43,7 @@ const DropDown = ({ | ... | @@ -41,6 +43,7 @@ const DropDown = ({ |
| 41 | size, | 43 | size, |
| 42 | }) => { | 44 | }) => { |
| 43 | const [menuTitle, setTitle] = useState(''); | 45 | const [menuTitle, setTitle] = useState(''); |
| 46 | + const dispatch = useDispatch(); | ||
| 44 | useEffect(() => { | 47 | useEffect(() => { |
| 45 | setTitle(title); | 48 | setTitle(title); |
| 46 | }, []); | 49 | }, []); |
| ... | @@ -62,14 +65,15 @@ const DropDown = ({ | ... | @@ -62,14 +65,15 @@ const DropDown = ({ |
| 62 | </DropDownWrap> | 65 | </DropDownWrap> |
| 63 | } | 66 | } |
| 64 | > | 67 | > |
| 65 | - {options.map(friend => ( | 68 | + {options.map(option => ( |
| 66 | <MenuItem | 69 | <MenuItem |
| 67 | - value={friend.id} | 70 | + value={option.id} |
| 68 | onClick={() => { | 71 | onClick={() => { |
| 69 | - setTitle(friend.name); | 72 | + dispatch(setSearchOption(option.id)); |
| 73 | + setTitle(option.name); | ||
| 70 | }} | 74 | }} |
| 71 | > | 75 | > |
| 72 | - {friend.name} | 76 | + {option.name} |
| 73 | </MenuItem> | 77 | </MenuItem> |
| 74 | ))} | 78 | ))} |
| 75 | </DropDownHeader> | 79 | </DropDownHeader> | ... | ... |
frontend/src/features/searchOption.js
0 → 100644
| 1 | +import { createSlice } from '@reduxjs/toolkit'; | ||
| 2 | + | ||
| 3 | +const OPTION = ['ALL', 'WRITER', 'CONTENT']; | ||
| 4 | + | ||
| 5 | +const searchOptionSlice = createSlice({ | ||
| 6 | + name: 'searchOption', | ||
| 7 | + initialState: { | ||
| 8 | + option: OPTION[0], | ||
| 9 | + }, | ||
| 10 | + reducers: { | ||
| 11 | + setSearchOption: (state, action) => { | ||
| 12 | + state.option = OPTION[action.payload]; | ||
| 13 | + }, | ||
| 14 | + }, | ||
| 15 | +}); | ||
| 16 | + | ||
| 17 | +export const { setSearchOption } = searchOptionSlice.actions; | ||
| 18 | + | ||
| 19 | +export default searchOptionSlice.reducer; |
| ... | @@ -51,9 +51,9 @@ const HomePage = () => { | ... | @@ -51,9 +51,9 @@ const HomePage = () => { |
| 51 | fontsize="20px" | 51 | fontsize="20px" |
| 52 | height="50px" | 52 | height="50px" |
| 53 | options={[ | 53 | options={[ |
| 54 | - { id: 1, name: '전체' }, | 54 | + { id: 0, name: '전체' }, |
| 55 | - { id: 2, name: '개인' }, | 55 | + { id: 1, name: '작성자' }, |
| 56 | - { id: 3, name: '부서' }, | 56 | + { id: 2, name: '내용' }, |
| 57 | ]} | 57 | ]} |
| 58 | /> | 58 | /> |
| 59 | <Input color="blue" paddingsize="10px" width="100%" display /> | 59 | <Input color="blue" paddingsize="10px" width="100%" display /> | ... | ... |
| 1 | import { combineReducers } from 'redux'; | 1 | import { combineReducers } from 'redux'; |
| 2 | import parsedDocumentsReducer from '../features/parsedDocumentsSlice'; | 2 | import parsedDocumentsReducer from '../features/parsedDocumentsSlice'; |
| 3 | +import searchOptionReducer from '../features/searchOption'; | ||
| 3 | 4 | ||
| 4 | export default combineReducers({ | 5 | export default combineReducers({ |
| 5 | parsedDocuments: parsedDocumentsReducer, | 6 | parsedDocuments: parsedDocumentsReducer, |
| 7 | + searchOption: searchOptionReducer, | ||
| 6 | }); | 8 | }); | ... | ... |
-
Please register or login to post a comment