이승윤

feat: 고급 검색 Input 쿼리 형식 변경

1 -import React, { useRef } from 'react'; 1 +import React, { useRef, useState } from 'react';
2 -import { Card } from '@mantine/core'; 2 +import { Card, TextInput } from '@mantine/core';
3 +import { useHistory } from 'react-router-dom';
3 import styled from 'styled-components'; 4 import styled from 'styled-components';
4 import Button from './common/Button'; 5 import Button from './common/Button';
5 -import Input from './common/Input';
6 6
7 const Background = styled.div``; 7 const Background = styled.div``;
8 8
...@@ -34,13 +34,13 @@ const CloseWrap = styled.div` ...@@ -34,13 +34,13 @@ const CloseWrap = styled.div`
34 34
35 const StandardWrap = styled.div` 35 const StandardWrap = styled.div`
36 position: absolute; 36 position: absolute;
37 - width: 50px; 37 + width: 250px;
38 top: 15px; 38 top: 15px;
39 left: 30%; 39 left: 30%;
40 `; 40 `;
41 41
42 const AdvancedWrap = styled.div` 42 const AdvancedWrap = styled.div`
43 - width: 50px; 43 + width: 250px;
44 position: absolute; 44 position: absolute;
45 top: 75px; 45 top: 75px;
46 left: 30%; 46 left: 30%;
...@@ -57,6 +57,11 @@ const TextWrap = styled.div` ...@@ -57,6 +57,11 @@ const TextWrap = styled.div`
57 `; 57 `;
58 58
59 const Modal = ({ showModal, setShowModal }) => { 59 const Modal = ({ showModal, setShowModal }) => {
60 + const [query, setQuery] = useState('');
61 + const [keywordQuery, setKeywordQuery] = useState('');
62 + const [writerQuery, setWriterQuery] = useState('');
63 + const [dateQuery, setDateQuery] = useState('');
64 + const history = useHistory();
60 const modalRef = useRef(); 65 const modalRef = useRef();
61 const closeModal = e => { 66 const closeModal = e => {
62 if (modalRef.current === e.target) { 67 if (modalRef.current === e.target) {
...@@ -75,47 +80,62 @@ const Modal = ({ showModal, setShowModal }) => { ...@@ -75,47 +80,62 @@ const Modal = ({ showModal, setShowModal }) => {
75 기본검색 80 기본검색
76 </TextWrap> 81 </TextWrap>
77 <StandardWrap> 82 <StandardWrap>
78 - <Input 83 + <TextInput
79 - float="left" 84 + inputStyle={{
80 - color="blue" 85 + marginBottom: 18,
81 - width="350px" 86 + fontSize: 15,
82 - height="40px" 87 + }}
83 - paddingsize="3px" 88 + placeholder="내용을 입력해 주세요."
84 - fontsize="15px" 89 + type="text"
90 + value={decodeURIComponent(query)}
91 + onChange={e => setQuery(e.target.value)}
92 + onKeyPress={e => {
93 + if (e.key === 'Enter') {
94 + if (query === '') {
95 + alert('검색어를 입력 해 주세요.');
96 + return;
97 + }
98 + const params = new URLSearchParams({ query });
99 + history.push(
100 + `search?${decodeURIComponent(params.toString())}`
101 + );
102 + }
103 + }}
85 /> 104 />
86 </StandardWrap> 105 </StandardWrap>
87 <TextWrap top="24%" right="10%" bottom="31%"> 106 <TextWrap top="24%" right="10%" bottom="31%">
88 고급검색 107 고급검색
89 </TextWrap> 108 </TextWrap>
90 <AdvancedWrap> 109 <AdvancedWrap>
91 - <Input 110 + <TextInput
92 - float="left" 111 + inputStyle={{
93 - color="blue" 112 + marginBottom: 18,
94 - width="350px" 113 + fontSize: 15,
95 - height="40px" 114 + }}
96 - paddingsize="3px" 115 + placeholder="단어/문장 검색"
97 - fontsize="15px" 116 + type="text"
98 - placeholder="단어/ 문장검색" 117 + value={decodeURIComponent(keywordQuery)}
118 + onChange={e => setKeywordQuery(e.target.value)}
99 /> 119 />
100 - <br /> <br /> 120 + <TextInput
101 - <Input 121 + inputStyle={{
102 - float="left" 122 + marginBottom: 18,
103 - color="blue" 123 + fontSize: 15,
104 - width="350px" 124 + }}
105 - height="40px" 125 + placeholder="작성자"
106 - paddingsize="3px" 126 + type="text"
107 - fontsize="15px" 127 + value={decodeURIComponent(writerQuery)}
108 - placeholder="최초 작성자" 128 + onChange={e => setWriterQuery(e.target.value)}
109 /> 129 />
110 - <br /> <br /> 130 + <TextInput
111 - <Input 131 + inputStyle={{
112 - float="left" 132 + marginBottom: 18,
113 - color="blue" 133 + fontSize: 15,
114 - width="350px" 134 + }}
115 - height="40px" 135 + placeholder="생성 날짜"
116 - paddingsize="3px" 136 + type="text"
117 - fontsize="15px" 137 + value={decodeURIComponent(dateQuery)}
118 - placeholder="최종 수정자" 138 + onChange={e => setDateQuery(e.target.value)}
119 /> 139 />
120 </AdvancedWrap> 140 </AdvancedWrap>
121 </ModalContent> 141 </ModalContent>
......