필터 추가
This commit is contained in:
@@ -1,7 +1,13 @@
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
import { useEffect } from 'react';
|
||||||
import { ChangeEvent, useState } from 'react';
|
import { ChangeEvent, useState } from 'react';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import { IMAGE_ROOT } from '@/shared/constants/common';
|
import { IMAGE_ROOT } from '@/shared/constants/common';
|
||||||
|
import { FilterSelect } from '@/shared/ui/filter/select';
|
||||||
|
import { FilterSelectInput } from '@/shared/ui/filter/select-input';
|
||||||
|
import { FilterCalendar } from '@/shared/ui/filter/filter-calendar';
|
||||||
|
import { FilterButtonGroups } from '@/shared/ui/filter/button-groups';
|
||||||
|
import { FilterRangeAmount } from '@/shared/ui/filter/range-amount';
|
||||||
import {
|
import {
|
||||||
BillingFilterProps,
|
BillingFilterProps,
|
||||||
BillingPaymentMethod,
|
BillingPaymentMethod,
|
||||||
@@ -9,11 +15,6 @@ import {
|
|||||||
BillingRequestStatus,
|
BillingRequestStatus,
|
||||||
BillingSearchType
|
BillingSearchType
|
||||||
} from '../../model/types';
|
} from '../../model/types';
|
||||||
import { FilterDateOptions } from '@/entities/common/model/types';
|
|
||||||
import { FilterCalendar } from '@/shared/ui/filter/filter-calendar';
|
|
||||||
import { FilterButtonGroups } from '@/shared/ui/filter/button-groups';
|
|
||||||
import { FilterRangeAmount } from '@/shared/ui/filter/range-amount';
|
|
||||||
import { useEffect } from 'react';
|
|
||||||
|
|
||||||
export const BillingFilter = ({
|
export const BillingFilter = ({
|
||||||
filterOn,
|
filterOn,
|
||||||
@@ -50,10 +51,6 @@ export const BillingFilter = ({
|
|||||||
const [filterPaymentMethod, setFilterPaymentMethod] = useState<BillingPaymentMethod>(paymentMethod);
|
const [filterPaymentMethod, setFilterPaymentMethod] = useState<BillingPaymentMethod>(paymentMethod);
|
||||||
const [filterMinAmount, setFilterMinAmount] = useState<number | string>(minAmount || '');
|
const [filterMinAmount, setFilterMinAmount] = useState<number | string>(minAmount || '');
|
||||||
const [filterMaxAmount, setFilterMaxAmount] = useState<number | string>(maxAmount || '');
|
const [filterMaxAmount, setFilterMaxAmount] = useState<number | string>(maxAmount || '');
|
||||||
const [dateReadOnly, setDateReadyOnly] = useState<boolean>(true);
|
|
||||||
const [filterDateOptionsBtn, setFilterDateOptionsBtn] = useState<FilterDateOptions>(FilterDateOptions.Input);
|
|
||||||
|
|
||||||
const [calendarOpen, setCalendarOpen] = useState<boolean>(false);
|
|
||||||
|
|
||||||
const variants = {
|
const variants = {
|
||||||
hidden: { x: '100%' },
|
hidden: { x: '100%' },
|
||||||
@@ -79,6 +76,13 @@ export const BillingFilter = ({
|
|||||||
setPaymentMethod(filterPaymentMethod);
|
setPaymentMethod(filterPaymentMethod);
|
||||||
onClickToClose();
|
onClickToClose();
|
||||||
};
|
};
|
||||||
|
let MidOptions = [
|
||||||
|
{name: 'nictest001m', value: 'nictest001m'}
|
||||||
|
];
|
||||||
|
let SearchTypeOptions = [
|
||||||
|
{name: '주문번호', value: BillingSearchType.ORDER_NUMBER },
|
||||||
|
{name: 'TID', value: BillingSearchType.TID }
|
||||||
|
];
|
||||||
|
|
||||||
let requestStatusBtnGroup = [
|
let requestStatusBtnGroup = [
|
||||||
{name: '전체', value: BillingRequestStatus.ALL},
|
{name: '전체', value: BillingRequestStatus.ALL},
|
||||||
@@ -134,36 +138,22 @@ export const BillingFilter = ({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="option-list pt-16">
|
<div className="option-list pt-16">
|
||||||
<div className="opt-field">
|
<FilterSelect
|
||||||
<div className="opt-label">가맹점</div>
|
title='가맹점'
|
||||||
<div className="opt-controls">
|
selectValue={ mid }
|
||||||
<select className="flex-1">
|
selectSetter={ setMid }
|
||||||
<option>nictest001m</option>
|
selectOptions={ MidOptions }
|
||||||
</select>
|
></FilterSelect>
|
||||||
</div>
|
<FilterSelectInput
|
||||||
</div>
|
title='주문번호/ID'
|
||||||
|
selectValue={ searchType }
|
||||||
<div className="opt-field">
|
selectSetter={ setSearchType }
|
||||||
<div className="opt-label">주문번호/ID</div>
|
selectOptions={ SearchTypeOptions }
|
||||||
<div className="opt-controls">
|
inputValue={ searchKeyword }
|
||||||
<select
|
inputSetter={ setSearchKeyword }
|
||||||
className="w-110"
|
></FilterSelectInput>
|
||||||
value={ filterSearchType }
|
|
||||||
onChange={ (e: any) => setFilterSearchType(e.target.value)}
|
|
||||||
>
|
|
||||||
<option value={ BillingSearchType.ORDER_NUMBER }>주문번호</option>
|
|
||||||
<option value={ BillingSearchType.TID }>ID</option>
|
|
||||||
</select>
|
|
||||||
<input
|
|
||||||
className="flex-1"
|
|
||||||
type="text"
|
|
||||||
placeholder=""
|
|
||||||
value={ filterSearchKeyword }
|
|
||||||
onChange={ (e: ChangeEvent<HTMLInputElement>) => setFilterSearchKeyword(e.target.value)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<FilterCalendar
|
<FilterCalendar
|
||||||
|
title='조회기간'
|
||||||
startDate={ filterStartDate }
|
startDate={ filterStartDate }
|
||||||
endDate={ filterEndDate }
|
endDate={ filterEndDate }
|
||||||
setStartDate={ setFilterStartDate }
|
setStartDate={ setFilterStartDate }
|
||||||
|
|||||||
56
src/shared/ui/filter/select-input.tsx
Normal file
56
src/shared/ui/filter/select-input.tsx
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
import { ChangeEvent } from 'react';
|
||||||
|
|
||||||
|
export interface FilterSelectInputProps {
|
||||||
|
title: string;
|
||||||
|
selectValue: string;
|
||||||
|
selectSetter: (value: any) => void;
|
||||||
|
selectOptions: Array<Record<string, string>>;
|
||||||
|
inputValue: string;
|
||||||
|
inputSetter: (value: any) => void;
|
||||||
|
};
|
||||||
|
export const FilterSelectInput = ({
|
||||||
|
title,
|
||||||
|
selectValue,
|
||||||
|
selectSetter,
|
||||||
|
selectOptions,
|
||||||
|
inputValue,
|
||||||
|
inputSetter
|
||||||
|
}: FilterSelectInputProps) => {
|
||||||
|
|
||||||
|
const getSelectOptions = () => {
|
||||||
|
let rs = [];
|
||||||
|
for(let i=0;i<selectOptions.length;i++){
|
||||||
|
rs.push(
|
||||||
|
<option
|
||||||
|
key={ `key-filter-select-input-${i}` }
|
||||||
|
value={ selectOptions[i]?.value }
|
||||||
|
>{ selectOptions[i]?.name }</option>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return rs;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="opt-field">
|
||||||
|
<div className="opt-label">{ title }</div>
|
||||||
|
<div className="opt-controls">
|
||||||
|
<select
|
||||||
|
className="w-110"
|
||||||
|
value={ selectValue }
|
||||||
|
onChange={ (e: any) => selectSetter(e.target.value)}
|
||||||
|
>
|
||||||
|
{ getSelectOptions() }
|
||||||
|
</select>
|
||||||
|
<input
|
||||||
|
className="flex-1"
|
||||||
|
type="text"
|
||||||
|
placeholder=""
|
||||||
|
value={ inputValue }
|
||||||
|
onChange={ (e: ChangeEvent<HTMLInputElement>) => inputSetter(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
43
src/shared/ui/filter/select.tsx
Normal file
43
src/shared/ui/filter/select.tsx
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
export interface FilterSelectProps {
|
||||||
|
title: string;
|
||||||
|
selectValue: string;
|
||||||
|
selectSetter: (value: any) => void;
|
||||||
|
selectOptions: Array<Record<string, string>>;
|
||||||
|
};
|
||||||
|
export const FilterSelect = ({
|
||||||
|
title,
|
||||||
|
selectValue,
|
||||||
|
selectSetter,
|
||||||
|
selectOptions,
|
||||||
|
}: FilterSelectProps) => {
|
||||||
|
|
||||||
|
const getSelectOptions = () => {
|
||||||
|
let rs = [];
|
||||||
|
for(let i=0;i<selectOptions.length;i++){
|
||||||
|
rs.push(
|
||||||
|
<option
|
||||||
|
key={ `key-filter-select-input-${i}` }
|
||||||
|
value={ selectOptions[i]?.value }
|
||||||
|
>{ selectOptions[i]?.name }</option>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return rs;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="opt-field">
|
||||||
|
<div className="opt-label">{ title }</div>
|
||||||
|
<div className="opt-controls">
|
||||||
|
<select
|
||||||
|
className="flex-1"
|
||||||
|
value={ selectValue }
|
||||||
|
onChange={ (e: any) => selectSetter(e.target.value)}
|
||||||
|
>
|
||||||
|
{ getSelectOptions() }
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user