import styled from 'styled-components';
import { TextInput, BtnWrapper, InputLabel, SelectInput } from '../../../styles/Components';
import Button from '../../common/button/Button';
import { SearchBarLayout, SearchPeriod } from '../../common/SearchBar';
import { useState } from 'react';
import { mailReceiveType, mailSendStatus, mailSendType, mailType } from '../../../assets/data';
const MailListSearchBar = ({ handleSearch, setResultData }) => {
const [searchData, setSearchData] = useState({
mailTitle: '',
content: '',
sendType: 'ALL',
sendStatus: 'ALL',
mailType: 'ALL',
receiveType: 'ALL',
sendDate: '',
endDate: '',
});
const handleSubmit = event => {
event.preventDefault();
handleSearch(
searchData.mailTitle,
searchData.content,
searchData.sendType ? searchData.sendType : 'ALL',
searchData.sendStatus ? searchData.sendStatus : 'ALL',
searchData.mailType ? searchData.mailType : 'ALL',
searchData.receiveType ? searchData.receiveType : 'ALL',
searchData.sendDate ? searchData.sendDate : '',
searchData.endDate ? searchData.endDate : new Date(),
(searchData.sendDate && searchData.endDate === '') && setSearchData({ sendDate : searchData.sendDate ,endDate : new Date()}),
);
setResultData(searchData);
};
const handleReset = () => {
setSearchData({
mailTitle: '',
content: '',
sendType: 'ALL',
sendStatus: 'ALL',
mailType: 'ALL',
receiveType: 'ALL',
sendDate: '',
endDate: '',
order: 'DESC',
});
handleSearch('', '', 'ALL', 'ALL', 'ALL', 'ALL', '', '');
setResultData('', '', 'ALL', 'ALL', 'ALL', 'ALL', '', '');
window.location.reload();
};
// console.log("searchData.endDate", searchData.endDate)
const searchList = [
<>
우편 제목
setSearchData({ ...searchData, mailTitle: e.target.value })}
/>
>,
<>
조회 일자
{
setSearchData({ ...searchData, sendDate: data });
}}
endDate={searchData.endDate}
handleEndDate={data => setSearchData({ ...searchData, endDate: data })}
maxDate={new Date()}
/>
>,
<>
우편 내용
setSearchData({ ...searchData, content: e.target.value })}
/>
>
];
const optionList = [
<>
발송 방식
setSearchData({ ...searchData, sendType: e.target.value })}>
{mailSendType.map((data, index) => (
))}
>,
<>
발송 상태
setSearchData({ ...searchData, sendStatus: e.target.value })}>
{mailSendStatus.map((data, index) => (
))}
>,
<>
우편 타입
setSearchData({ ...searchData, mailType: e.target.value })}>
{mailType.map((data, index) => (
))}
>,
<>
수신 대상
setSearchData({ ...searchData, receiveType: e.target.value })}>
{mailReceiveType.map((data, index) => (
))}
>,
];
return ;
};
export default MailListSearchBar;