diff --git a/src/entities/common/model/types.ts b/src/entities/common/model/types.ts index ca33b98..3c90962 100644 --- a/src/entities/common/model/types.ts +++ b/src/entities/common/model/types.ts @@ -1,9 +1,3 @@ -import { - BillingPaymentMethod, - BillingProcessResult, - BillingRequestStatus -} from '@/entities/transaction/model/types'; - export enum SuccessResult { SUCCESS = 'SUCCESS', FAIL = 'FAIL' @@ -14,6 +8,12 @@ export enum FilterDateOptions { Month = 'Month', Input = 'Input' }; +export enum FilterMonthOptions { + Month1 = 'Month1', + Month2 = 'Month2', + Month3 = 'Month3', + Input = 'Input' +}; export enum CalendarType { Start = 'Start', End = 'End', diff --git a/src/entities/vat-return/model/contant.ts b/src/entities/vat-return/model/contant.ts new file mode 100644 index 0000000..62104b3 --- /dev/null +++ b/src/entities/vat-return/model/contant.ts @@ -0,0 +1,14 @@ +import { VatReturnReceiptType, VatReturnTargetType } from './types'; + +export const VatReturnReceiptTypeBtnGroup = [ + {name: '전체', value: VatReturnReceiptType.ALL }, + {name: '영수', value: VatReturnReceiptType.RECEIPT }, + {name: '청구', value: VatReturnReceiptType.BILL } +]; + +export const VatReturnTargetTypeBtnGroup = [ + {name: '전체', value: VatReturnTargetType.ALL }, + {name: '일반', value: VatReturnTargetType.GENERAL }, + {name: '차액정산', value: VatReturnTargetType.DIFFERENCE_COLLECTION }, + {name: '환급정산', value: VatReturnTargetType.REFUND_SETTLEMENT } +]; \ No newline at end of file diff --git a/src/entities/vat-return/ui/filter/list-filter.tsx b/src/entities/vat-return/ui/filter/list-filter.tsx new file mode 100644 index 0000000..56d07b3 --- /dev/null +++ b/src/entities/vat-return/ui/filter/list-filter.tsx @@ -0,0 +1,128 @@ +import { motion } from 'framer-motion'; +import { IMAGE_ROOT } from '@/shared/constants/common'; +import { VatReturnReceiptType, VatReturnTargetType } from '../../model/types'; +import { FilterMotionDuration, FilterMotionStyle, FilterMotionVariants } from '@/entities/common/model/constant'; +import { FilterSelect } from '@/shared/ui/filter/select'; +import { useState } from 'react'; +import { FilterButtonGroups } from '@/shared/ui/filter/button-groups'; +import { VatReturnReceiptTypeBtnGroup, VatReturnTargetTypeBtnGroup } from '../../model/contant'; +import { FilterCalendarMonth } from '@/shared/ui/filter/calendar-month'; + +export interface ListFilterProps { + filterOn: boolean; + setFilterOn: (filterOn: boolean) => void; + mid: string; + startDate: string; + endDate: string; + receiptType: VatReturnReceiptType; + targetType: VatReturnTargetType; + setMid: (mid: string) => void; + setStartDate: (date: string) => void; + setEndDate: (date: string) => void; + setReceiptType: (receiptType: VatReturnReceiptType) => void; + setTargetType: (targetType: VatReturnTargetType) => void; +}; + +export const ListFilter = ({ + filterOn, + setFilterOn, + mid, + startDate, + endDate, + receiptType, + targetType, + setMid, + setStartDate, + setEndDate, + setReceiptType, + setTargetType +}: ListFilterProps) => { + + const [filterMid, setFilterMid] = useState(mid); + const [filterStartDate, setFilterStartDate] = useState(startDate); + const [filterEndDate, setFilterEndDate] = useState(endDate); + const [filterReceiptType, setFIlterReceiptType] = useState(receiptType); + const [filterTargetType, setFilterTargetType] = useState(targetType); + + const onClickToClose = () => { + setFilterOn(false); + }; + + const onClickToSetFilter = () => { + setMid(filterMid); + setStartDate(filterStartDate); + setEndDate(filterEndDate); + setReceiptType(filterReceiptType); + setTargetType(filterTargetType); + onClickToClose(); + }; + + let MidOptions = [ + {name: 'nictest001m', value: 'nictest001m'} + ]; + + return ( + <> + +
+
+
필터
+
+ +
+
+ +
+ + + + +
+
+ +
+
+
+ + ); +}; \ No newline at end of file diff --git a/src/entities/vat-return/ui/list-filter.tsx b/src/entities/vat-return/ui/list-filter.tsx deleted file mode 100644 index f75dd6e..0000000 --- a/src/entities/vat-return/ui/list-filter.tsx +++ /dev/null @@ -1,166 +0,0 @@ -import { motion } from 'framer-motion'; -import { IMAGE_ROOT } from '@/shared/constants/common'; -import { VatReturnReceiptType, VatReturnTargetType } from '../model/types'; -import { FilterMotionDuration, FilterMotionStyle, FilterMotionVariants } from '@/entities/common/model/constant'; - -export interface ListFilterProps { - filterOn: boolean; - setFilterOn: (filterOn: boolean) => void; - mid: string; - startDate: string; - endDate: string; - receiptType: VatReturnReceiptType; - targetType: VatReturnTargetType; - setMid: (mid: string) => void; - setStartDate: (date: string) => void; - setEndDate: (date: string) => void; - setReceiptType: (receiptType: VatReturnReceiptType) => void; - setTargetType: (targetType: VatReturnTargetType) => void; -}; - -export const ListFilter = ({ - filterOn, - setFilterOn, - mid, - startDate, - endDate, - receiptType, - targetType, - setMid, - setStartDate, - setEndDate, - setReceiptType, - setTargetType -}: ListFilterProps) => { - const variants = { - hidden: { x: '100%' }, - visible: { x: '0%' }, - }; - - const onClickToClose = () => { - setFilterOn(false); - }; - return ( - <> - -
-
-
필터
-
- -
-
- -
-
-
가맹점
-
- -
-
- -
-
발행월
-
-
- 당월 - 2개월 - 3개월 - 직접입력 -
-
-
- - -
- ~ -
- - -
-
-
-
- -
-
영수 구분
-
-
- 전체 - 영수 - 청구 - -
-
-
- -
-
발행 대상
-
-
- 전체 - 일반 - 차액정산 - 환급정산 -
-
-
- -
-
- -
-
-
- - ); -}; \ No newline at end of file diff --git a/src/entities/vat-return/ui/list-item.tsx b/src/entities/vat-return/ui/list-item.tsx index f2ac798..b36b2c6 100644 --- a/src/entities/vat-return/ui/list-item.tsx +++ b/src/entities/vat-return/ui/list-item.tsx @@ -51,3 +51,4 @@ export const ListItem = ({ ); }; + \ No newline at end of file diff --git a/src/entities/vat-return/ui/list-wrap.tsx b/src/entities/vat-return/ui/list-wrap.tsx index 331a7c7..d3c0e08 100644 --- a/src/entities/vat-return/ui/list-wrap.tsx +++ b/src/entities/vat-return/ui/list-wrap.tsx @@ -2,7 +2,7 @@ import moment from 'moment'; import { useEffect, useState } from 'react'; import { IMAGE_ROOT } from '@/shared/constants/common'; -import { ListFilter } from './list-filter'; +import { ListFilter } from './filter/list-filter'; import { SortOptionsBox } from '@/entities/common/ui/sort-options-box'; import { SortByKeys } from '@/entities/common/model/types'; import { DEFAULT_PAGE_PARAM } from '@/entities/common/model/constant'; @@ -21,18 +21,25 @@ export const ListWrap = () => { const [listItems, setListItems] = useState>>({}); const [pageParam, setPageParam] = useState(DEFAULT_PAGE_PARAM); const [mid, setMid] = useState('nictest00m'); - const [startDate, setStartDate] = useState(moment().subtract(1, 'month').format('YYYY-MM-DD')); - const [endDate, setEndDate] = useState(moment().format('YYYY-MM-DD')); + const [startDate, setStartDate] = useState(moment().subtract(1, 'month').format('YYYY.MM')); + const [endDate, setEndDate] = useState(moment().format('YYYY.MM')); const [receiptType, setReceiptType] = useState(VatReturnReceiptType.ALL); const [targetType, setTargetType] = useState(VatReturnTargetType.ALL); const { mutateAsync: vatReturnList } = useVatReturnListMutation(); const callList = () => { + let strStartDate = moment(startDate).format('YYYYMM'); + let newStartDate = moment(strStartDate+'01').format('YYYY-MM-DD'); + + let strEndtDate = moment(endDate).format('YYYYMM'); + let lastDate = moment(endDate).endOf('month').date(); + let newEndDate = moment(strEndtDate+lastDate).format('YYYY-MM-DD'); + let params: VatReturnListParams = { mid: mid, - startDate: startDate, - endDate: endDate, + startDate: newStartDate, + endDate: newEndDate, receiptType: receiptType, targetType: targetType, }; @@ -51,7 +58,7 @@ export const ListWrap = () => { useEffect(() => { callList(); - }, []); + }, [mid, startDate, endDate, receiptType, targetType]); const getListDateGroup = () => { let rs = []; diff --git a/src/shared/ui/calendar/nice-calendar-month.tsx b/src/shared/ui/calendar/nice-calendar-month.tsx new file mode 100644 index 0000000..c00d0d2 --- /dev/null +++ b/src/shared/ui/calendar/nice-calendar-month.tsx @@ -0,0 +1,126 @@ +import moment, { locale } from 'moment'; +import styled from "styled-components"; +import { useState } from 'react'; +import Calendar from 'react-calendar'; +import 'react-calendar/dist/Calendar.css'; +import { useEffect } from 'react'; +import { CalendarType } from '@/entities/common/model/types'; + +interface NiceCalendarProps { + calendarOpen: boolean; + setCalendarOpen: (calendarOpen: boolean) => void; + startMonth?: string; + endMonth?: string; + singleMonth?: string; + calendarType: CalendarType; + setNewMonth: (month: string) => void; +}; + +const NiceCalendarMonth = ({ + calendarOpen, + setCalendarOpen, + startMonth, + endMonth, + singleMonth, + calendarType, + setNewMonth +}: NiceCalendarProps) => { + const [valueMonth, setValueMonth] = useState(); + const [minMonth, setMinMonth] = useState(); + const [maxMonth, setMaxMonth] = useState(); + const onchangeToMonth = (selectedMonth: any) => { + setNewMonth(moment(selectedMonth).format('YYYY.MM')); + setCalendarOpen(false); + }; + + const onClickToClose = () => { + // setCalendarOpen(false); + }; + const setMinMaxValueDate = () => { + if(calendarType === CalendarType.Start){ + setMinMonth(undefined); + if(!!endMonth){ + setMaxMonth(new Date(endMonth)); + } + setValueMonth(startMonth); + } + else if(calendarType === CalendarType.End){ + if(!!startMonth){ + setMinMonth(new Date(startMonth)); + } + setMaxMonth(new Date()); + setValueMonth(endMonth); + } + else if(calendarType === CalendarType.Single){ + setValueMonth(singleMonth); + } + }; + + const formatMonthYear = (locale: string | undefined, date: Date) => { + return date.toLocaleDateString('en', { + month: 'long', + year: 'numeric' + }); + }; + const formatYear = (locale: string | undefined, date: Date) => { + return date.toLocaleDateString('en', { + year: 'numeric' + }); + }; + const formmatMonth = (locale: string | undefined, date: Date) => { + return date.toLocaleDateString('en', { + month: 'short' + }); + }; + const formatDay = (locale: string | undefined, date: Date) => { + return date.toLocaleString('en', { + day: 'numeric' + }); + }; + const formatShortWeekday = (locale: string | undefined, date: Date) => { + return date.toLocaleString('en', { + weekday: 'short' + }); + }; + + useEffect(() => { + setMinMaxValueDate(); + + }, [calendarOpen]) + + return ( + <> + { (calendarOpen) && + <> +
+ onClickToClose() }> + + + + } + + ); +}; +const CalendarWrapper = styled.div` + z-index: 1100; + position: absolute; + width: 100%; + height: 100%; + top: 0; + left: 0; +`; + +export default NiceCalendarMonth; \ No newline at end of file diff --git a/src/shared/ui/calendar/nice-calendar.tsx b/src/shared/ui/calendar/nice-calendar.tsx index f5a79c6..2cbef70 100644 --- a/src/shared/ui/calendar/nice-calendar.tsx +++ b/src/shared/ui/calendar/nice-calendar.tsx @@ -29,7 +29,7 @@ const NiceCalendar = ({ const [minDate, setMinDate] = useState(); const [maxDate, setMaxDate] = useState(); const onchangeToDate = (selectedDate: any) => { - setNewDate(moment(selectedDate).format('YYYY-MM-DD')); + setNewDate(moment(selectedDate).format('YYYY.MM.DD')); setCalendarOpen(false); }; diff --git a/src/shared/ui/filter/button-groups.tsx b/src/shared/ui/filter/button-groups.tsx index 02674db..4a5bc0d 100644 --- a/src/shared/ui/filter/button-groups.tsx +++ b/src/shared/ui/filter/button-groups.tsx @@ -11,7 +11,6 @@ export const FilterButtonGroups = ({ let rs = []; if(!!btnGroups && btnGroups.length > 0){ - console.log(' btnGroups.length : ', btnGroups.length) let emptySpanCnt = 4 - (btnGroups.length % 4); let innerList = []; @@ -25,7 +24,10 @@ export const FilterButtonGroups = ({ ); if((i % 4) === 3 ){ rs.push( -
{ innerList }
+
{ innerList }
); innerList = []; } @@ -41,7 +43,10 @@ export const FilterButtonGroups = ({ ); } rs.push( -
{ innerList }
+
{ innerList }
); } } diff --git a/src/shared/ui/filter/calendar-month.tsx b/src/shared/ui/filter/calendar-month.tsx new file mode 100644 index 0000000..4df8cb0 --- /dev/null +++ b/src/shared/ui/filter/calendar-month.tsx @@ -0,0 +1,160 @@ +import moment from 'moment'; +import { ChangeEvent, useState } from 'react'; +import { CalendarType, FilterMonthOptions } from '@/entities/common/model/types'; +import { IMAGE_ROOT } from '@/shared/constants/common'; +import NiceCalendarMonth from '../calendar/nice-calendar-month'; +import { useEffect } from 'react'; + +interface FilterCalendarMonthProps { + title?: string; + startMonth: string; + endMonth: string; + setStartMonth: (startMonth: string) => void; + setEndMonth: (endMonth: string) => void; +}; + +export const FilterCalendarMonth = ({ + title, + startMonth, + endMonth, + setStartMonth, + setEndMonth +}: FilterCalendarMonthProps) => { + const [filterTitle, setFilterTitle] = useState(title || '조회기간'); + const [monthReadOnly, setMonthReadyOnly] = useState(false); + const [filterMonthOptionsBtn, setFilterMonthOptionsBtn] = useState(FilterMonthOptions.Input); + const [calendarOpen, setCalendarOpen] = useState(false); + const [calendarType, setCalendarType] = useState(CalendarType.Start); + + const setFilterMonth = (monthOptions: FilterMonthOptions) => { + if(monthOptions === FilterMonthOptions.Month1){ + setStartMonth(moment().format('YYYY.MM')); + setEndMonth(moment().format('YYYY.MM')); + setMonthReadyOnly(true); + setFilterMonthOptionsBtn(FilterMonthOptions.Month1); + } + else if(monthOptions === FilterMonthOptions.Month2){ + setStartMonth(moment().subtract(1, 'month').format('YYYY.MM')); + setEndMonth(moment().format('YYYY.MM')); + setMonthReadyOnly(true); + setFilterMonthOptionsBtn(FilterMonthOptions.Month2); + } + else if(monthOptions === FilterMonthOptions.Month3){ + setStartMonth(moment().subtract(2, 'month').format('YYYY.MM')); + setEndMonth(moment().format('YYYY.MM')); + setMonthReadyOnly(true); + setFilterMonthOptionsBtn(FilterMonthOptions.Month3); + } + else if(monthOptions === FilterMonthOptions.Input){ + setMonthReadyOnly(false); + setFilterMonthOptionsBtn(FilterMonthOptions.Input); + } + + }; + + const onClickToOpenCalendar = (calendarType: CalendarType) => { + if(!monthReadOnly){ + setCalendarOpen(true); + setCalendarType(calendarType); + } + else{ + setCalendarOpen(false); + + } + }; + + const setNewMonth = (month: string) => { + console.log(month) + if(calendarType === CalendarType.Start){ + setStartMonth(month); + } + else if(calendarType === CalendarType.End){ + setEndMonth(month); + } + setCalendarOpen(false); + } + + useEffect(() => { + + }, []); + return ( + <> +
+
{ filterTitle }
+
+
+ setFilterMonth(FilterMonthOptions.Month1) } + >당월 + setFilterMonth(FilterMonthOptions.Month2) } + >2개월 + setFilterMonth(FilterMonthOptions.Month3) } + >3개월 + setFilterMonth(FilterMonthOptions.Input) } + >직접입력 +
+
+
+ ) => {} } + readOnly={ monthReadOnly } + /> + +
+ ~ +
+ ) => {} } + readOnly={ monthReadOnly } + /> + +
+
+
+
+ + + ); +}; \ No newline at end of file