forked from purpleio/purple-admin-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproduct-search.tsx
More file actions
83 lines (78 loc) · 2.96 KB
/
product-search.tsx
File metadata and controls
83 lines (78 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { IProductFormValue } from "@/client/sample/product";
import DateRangeField from "@/components/shared/form/control/date-range-field";
import DefaultSearchForm from "@/components/shared/form/ui/default-search-form";
import FieldInline from "@/components/shared/form/ui/field-inline";
import FormSearch from "@/components/shared/form/ui/form-search";
import { Button, Checkbox, Form, Input, Select } from "antd";
import { useForm } from "antd/lib/form/Form";
import { Search } from "lucide-react";
import { useRouter } from "next/router";
import React, { useCallback } from "react";
const statusOptions = [
{ label: "전체", value: "ALL" },
{ label: "판매중", value: "SALE" },
{ label: "품절", value: "SOLDOUT" },
{ label: "판매중단", value: "NOTSALE" },
];
const ProductSearch = () => {
const [form] = useForm();
const router = useRouter();
const handleFinish = useCallback(
(formValue: IProductFormValue) => {
router.push({
pathname: router.pathname,
query: { ...router.query, ...formValue },
});
},
[router]
);
return (
<DefaultSearchForm form={form} onFinish={handleFinish}>
<FormSearch>
<FieldInline>
<Form.Item label="기간" name="searchDateType" initialValue="created">
<Select dropdownMatchSelectWidth={false}>
<Select.Option value="created">등록일자</Select.Option>
<Select.Option value="updated">수정일자</Select.Option>
</Select>
</Form.Item>
<Form.Item name="searchDatePeriod">
<DateRangeField />
</Form.Item>
</FieldInline>
<div>
<Form.Item name="status" label="판매상태">
<Checkbox.Group options={statusOptions} />
</Form.Item>
</div>
<div>
<FieldInline>
<Form.Item label="검색조건" name="searchType" initialValue="productName">
<Select dropdownMatchSelectWidth={false}>
<Select.Option value="productName">상품명</Select.Option>
<Select.Option value="brandName">브랜드명</Select.Option>
</Select>
</Form.Item>
<Form.Item name="searchText" className="grow">
<Input placeholder="검색어를 입력해주세요" />
</Form.Item>
</FieldInline>
</div>
<div>
<Form.Item name="productCode" label="상품번호">
<Input.TextArea placeholder="복수입력시 쉼표(,) 또는 엔터(Enter)로 구분해주세요" />
</Form.Item>
</div>
</FormSearch>
<div className="flex justify-center gap-2">
<Button htmlType="submit" className="btn-with-icon" icon={<Search />}>
검색
</Button>
<Button htmlType="submit" className="btn-with-icon" onClick={() => form.resetFields()}>
초기화
</Button>
</div>
</DefaultSearchForm>
);
};
export default React.memo(ProductSearch);