Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#104] 이전 정산 내역 쿼리 사용 #109

Merged
merged 33 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
669ae00
feat: 정산예정부분 쿼리 사용
jiohjung98 Jan 25, 2024
ccc016c
feat: 예상정산내역 쿼리 사용 및 에러&로딩페이지 구현
jiohjung98 Jan 25, 2024
a0e61f1
rename: SettlementsExpectedUpdate로 컴포넌트명 변경
jiohjung98 Jan 25, 2024
ca49f3c
feat: 이전정산내역 쿼리 사용 및 에러&로딩페이지 구현
jiohjung98 Jan 25, 2024
1fb5617
remove: 안쓰는 스타일변수 제거
jiohjung98 Jan 25, 2024
5481d09
feat: 정산내역 현재 날짜 기준으로 필터링
jiohjung98 Jan 25, 2024
7b3869f
feat: 캘린더 조회 기간 잘못된 경우 알랄트(임시)
jiohjung98 Jan 25, 2024
c015ab8
modify: 정산내역 날짜 오류 수정
jiohjung98 Jan 25, 2024
cca68c2
feat: 숙소 변경 시, 페이지 1 처리
jiohjung98 Jan 25, 2024
9276c84
fix: 데이트피커 조회 시작 달 하나 밀리는 문제 해결
jiohjung98 Jan 25, 2024
7911e25
Merge branch 'dev' of https://github.com/CoolPeace-yanolza/frontend i…
jiohjung98 Jan 25, 2024
11887de
modify: 컨벤션 규칙 적용
jiohjung98 Jan 25, 2024
edecd27
remove: Settlemented StartDate 테스트 콘솔 제거
jiohjung98 Jan 25, 2024
0e53fa7
design: 정산안내팝업컴포넌트 위치 수정
jiohjung98 Jan 25, 2024
3eb6aac
design: 이전 정산 내역 테이블 레이아웃 재디자인
jiohjung98 Jan 26, 2024
1868f92
design: 정산페이지 팝업 레이아웃 재디자인
jiohjung98 Jan 26, 2024
c1729a8
design: 데이트피커 사이에 '-' 추가
jiohjung98 Jan 26, 2024
445a2ad
design: 데이트피커 조회 기간 잘못 설정 시, 에러 모달 적용
jiohjung98 Jan 26, 2024
8daa619
design: DatePicker 안에 캘린더 아이콘 삽입
jiohjung98 Jan 26, 2024
ce91b28
feat: 기획 수정에 따른 기본 조회기간 기능 수정
jiohjung98 Jan 26, 2024
611e4ba
design: 기획 수정에 따른 이전정산내역 UX 수정
jiohjung98 Jan 26, 2024
27ac176
design: 정산페이지 오른쪽 컴포넌트 border값 적용
jiohjung98 Jan 26, 2024
703091a
design: 버튼에 폰트패밀리 적용
jiohjung98 Jan 26, 2024
e67d5d2
remove: 데이터프레임 top값 삭제
jiohjung98 Jan 26, 2024
9134387
feat: 기본 조회 기간 설정
jiohjung98 Jan 26, 2024
82baff7
design: datePicker 캘린더 아이콘 변경
jiohjung98 Jan 26, 2024
28229f0
design: 인포메이션 아이콘 위치 수정
jiohjung98 Jan 26, 2024
0860a24
modify: 드롭다운 순서 변경
jiohjung98 Jan 26, 2024
4277a37
remove: 사용하지 않는 주석 코드 제거
jiohjung98 Jan 26, 2024
155ddbb
design: 이전 정산 내역 에러 및 로딩페이지 디자인
jiohjung98 Jan 26, 2024
a6de673
design: 이전 정산 부분 테블릿 버전에서 border 값 제거
jiohjung98 Jan 26, 2024
b309bbe
Merge branch 'dev' of https://github.com/CoolPeace-yanolza/frontend i…
jiohjung98 Jan 26, 2024
233f19c
design: DatePicker, 조회하기 버튼 사이 간격 조정
jiohjung98 Jan 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,28 @@ const Settlemented = () => {
}
};

const getCurrentEndDate = () => {
const today = new Date();
if (today.getDate() <= 10) {
return new Date(today.getFullYear(), today.getMonth() - 2, 31).toISOString().split('T')[0];
} else if (today.getDate() > 10 && today.getDate() <= 31) {
return new Date(today.getFullYear(), today.getMonth() - 1, 31).toISOString().split('T')[0];
} else {
return today.toISOString().split('T')[0];
}
};

let adjustedStartDate: string | null = null;
if (startDate !== null) {
const startDateObj = new Date(startDate);
startDateObj.setDate(startDateObj.getDate() + 1);
adjustedStartDate = startDateObj.toISOString().split('T')[0];
}

const { data: settlements } = useGetSettlements(
accommodation.id,
startDate ? startDate.toISOString().split('T')[0] : '2000-01-01',
endDate ? endDate.toISOString().split('T')[0] : new Date().toISOString().split('T')[0],
adjustedStartDate ? adjustedStartDate : '2000-01-01',
endDate ? endDate.toISOString().split('T')[0] : getCurrentEndDate(),
orderBy,
currentPage - 1,
itemsPerPage
Expand All @@ -70,7 +88,6 @@ const Settlemented = () => {
...data,
NO: (currentPage - 1) * itemsPerPage + index + 1,
}));

setCurrentData(newSettlementData);
setTotalItems(settlements.total_settlement_count);
setTotalPages(settlements.total_page_count);
Expand All @@ -93,12 +110,12 @@ const Settlemented = () => {
const response = await getSettlements(
accommodation.id,
startDate ? startDate.toISOString().split('T')[0] : '2000-01-01',
endDate ? endDate.toISOString().split('T')[0] : new Date().toISOString().split('T')[0],
endDate ? endDate.toISOString().split('T')[0] : getCurrentEndDate(),
orderBy,
0,
totalItems
);

const allData = response.settlement_responses.map((data: SettlementedItem, index: number) => ({
...data,
NO: index + 1,
Expand All @@ -108,13 +125,17 @@ const Settlemented = () => {
const workSheet = XLSX.utils.json_to_sheet(allData);

XLSX.utils.book_append_sheet(workBook, workSheet, "Sheet1");

XLSX.writeFile(workBook, "SettlementedDownload.xlsx");
} catch (error) {
console.error('Error fetching all settlements data for download:', error);
}
};


useEffect(() => {
setCurrentPage(1);
}, [accommodation]);

return (
<Container>
<SettlementedHeader>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import styled from '@emotion/styled';
import { SettlementsPopupProps } from '@/types/settlements';

const SettlementsPopup: React.FC<SettlementsPopupProps> = ({ isOpen, onClose }) => {

return (
<PopupContainer isOpen={isOpen}>
<PopupHeader>
Expand All @@ -28,22 +29,28 @@ const SettlementsPopup: React.FC<SettlementsPopupProps> = ({ isOpen, onClose })
);
};

const PopupContainer = styled.div<{ isOpen: boolean }>`
display: ${({ isOpen }) => (isOpen ? 'block' : 'none')};
position: fixed;
top: 50%;
left: 50%;
const PopupContainer = styled.div<{ isOpen: boolean; style?: React.CSSProperties }>`
position: absolute;

padding: 20px;
margin-top: 22px;
margin-left: 10px;
border-radius: 6px;

transform: translate(-50%, -50%);
width: 500px;

display: ${({ isOpen }) => (isOpen ? 'block' : 'none')};
top: 50%;
left: 100%;

transform: translateY(-50%);
background-color: white;
box-shadow: 0px 2px 64px rgba(0, 0, 0, 0.1);

z-index: 90;
`;


const PopupHeader = styled.div`
display: flex;
flex-direction: row;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const MiddleText = styled.div`
const InformationContainer = styled.div`
display: flex;
align-items: center;
position: relative;
`;

const InformationIcon = styled.img`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,24 @@ const SettlementsSetting = () => {
};

const handleButtonClick = () => {
const currentDate = new Date();
const currentMonth = currentDate.getMonth();
const currentYear = currentDate.getFullYear();

if (startDate && endDate) {
setSettlementsDate({ startDate, endDate });
if (
(startDate.getFullYear() === currentYear && startDate.getMonth() === currentMonth) ||
endDate.getFullYear() > currentYear ||
(endDate.getFullYear() === currentYear && endDate.getMonth() >= currentMonth) ||
(startDate > endDate)
) {
alert("조회할 기간을 다시 선택해주세요.");
return;
}
setSettlementsDate({ startDate, endDate });
}
};


const DatePickerCustom = createGlobalStyle`
.react-datepicker {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import { FallbackProps } from 'react-error-boundary';
import styled from '@emotion/styled';

import theme from '@styles/theme';
import errorIcon from '@assets/icons/ic-error.svg';
import reloadIcon from '@assets/icons/ic-reload.svg';

const ErrorFallback = ({ resetErrorBoundary }: FallbackProps) => {
return (
<Container>
<ErrorContainer>
<ErrorIcon
src={errorIcon}
alt="에러 발생"
/>
<ErrorWord>이전 정산 내역을 불러올 수 없습니다.</ErrorWord>
</ErrorContainer>
<ReLoadButton onClick={resetErrorBoundary}>
<ReloadIcon
src={reloadIcon}
alt="에러 발생"
/>
다시 시도 하기
</ReLoadButton>
</Container>
);
};

export default ErrorFallback;

const Container = styled.div`
width: 100%;
height: 72.67px;

margin-top: 20px;
border: 1px solid white;
border-radius: 5px;

display: flex;
flex-direction: column;
justify-content: center;
align-items: center;

background-color: white;


${theme.response.tablet} {
padding: 15px 15px;
border-radius: 5px;

background-color: #f2f4f5;
}
`;

const ErrorContainer = styled.div`
display: flex;
align-items: center;
`;

const ErrorIcon = styled.img`
width: 35px;
height: 35px;

margin-right: 3px;

${theme.response.tablet} {
width: 30px;
height: 30px;
}

@media (max-width: 592px) {
width: 25px;
height: 25px;
}
`;

const ErrorWord = styled.span`
font-size: 12px;
font-weight: 500;

@media (max-width: 592px) {
font-size: 10px;
}

@media (max-width: 526px) {
font-size: 8px;
}
`;

const ReLoadButton = styled.button`
margin-left: 3px;
border: none;

display: flex;
justify-content: center;
align-items: center;

background-color: transparent;
font-size: 10px;
text-align: center;

transition: all 0.5s;

&:hover {
color: gray;
}

${theme.response.tablet} {
margin: 0;
}

@media (max-width: 592px) {
font-size: 8px;
}

@media (max-width: 526px) {
font-size: 6px;
}
`;

const ReloadIcon = styled.img`
width: 20px;
height: 20px;

margin-right: 3px;

${theme.response.tablet} {
width: 15px;
height: 15px;
}

@media (max-width: 592px) {
width: 22px;
height: 12px;
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import styled from '@emotion/styled';
import Skeleton from 'react-loading-skeleton';
import 'react-loading-skeleton/dist/skeleton.css';

import theme from '@styles/theme';

const Loading = () => {
return (
<Container>
<ContentsWrapper>
<ContentsTop />
</ContentsWrapper>
</Container>
);
};

export default Loading;

const Container = styled.div`
width: 100%;
height: 72.67px;

margin-top: 20px;
padding-top: 15px;
border: 1px solid white;
border-radius: 5px;

display: flex;
flex-direction: column;
justify-content: center;
align-items: center;

background-color: white;

${theme.response.tablet} {
border-radius: 5px;

gap: 15px;

background-color: #f2f4f5;
}
`;

const BaseSkeleton = styled(Skeleton)`
width: 100%;

border-radius: 16px;

background-color: #f2f4f5;
`;

const ContentsWrapper = styled.div`
width: 100%;

border-radius: 16px;

display: flex;
flex-direction: column;
gap: 10px;

${theme.response.tablet} {
border-radius: 10px;

gap: 5px;
}
`;

const ContentsTop = styled(BaseSkeleton)`
padding-top: 10px;
margin-top: auto;
margin-bottom: auto;

display: flex;
flex-direction: column;
flex: 1;

${theme.response.tablet} {
width: 100%;
height: 50px;
}
`;
Loading