Skip to content

Commit

Permalink
Merge pull request #34 from DDD-Community/feat/analysis_v2
Browse files Browse the repository at this point in the history
Feat/analysis v2
  • Loading branch information
HeeyeonJeong authored Sep 22, 2023
2 parents 82443cc + 7bbfd0a commit fb59ef7
Show file tree
Hide file tree
Showing 41 changed files with 1,858 additions and 252 deletions.
4 changes: 0 additions & 4 deletions .env.example

This file was deleted.

6 changes: 5 additions & 1 deletion app/(router)/analysis/amount/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use client';

import AmountAnalysisWrapper from '@/_components/analysis/amount/AmountAnalysisWrapper';

const AmountAnalysis = () => {
return <p>금액별</p>;
return <AmountAnalysisWrapper />;
};

export default AmountAnalysis;
9 changes: 9 additions & 0 deletions app/(router)/analysis/period/filter/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use client';

import PeriodicDateFilterWrapper from '@/_components/analysis/period/filter/PeriodicDateFilterWrapper';

const PeriodAnalysis = () => {
return <PeriodicDateFilterWrapper />;
};

export default PeriodAnalysis;
9 changes: 0 additions & 9 deletions app/(router)/analysis/period/pick/page.tsx

This file was deleted.

6 changes: 5 additions & 1 deletion app/(router)/analysis/rounds/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use client';

import RoundsAnalysisWrapper from '@/_components/analysis/rounds/RoundsAnalysisWrapper';

const RoundsAnalysis = () => {
return <p>회차별</p>;
return <RoundsAnalysisWrapper />;
};

export default RoundsAnalysis;
102 changes: 80 additions & 22 deletions app/_components/analysis/AnalysisMainWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,79 @@
'use client';

import palette from '@/_styles/palette';
import React from 'react';
import React, { useEffect, useState } from 'react';
import styled from 'styled-components';
import ResultAmountBannerList from './ResultAmountBannerList';
import AnalyticsDashboardMenu from './AnalyticsDashboardMenu';
import Image from 'next/image';
import PolygonIcon from '@assets/svg/polygon.svg';
import ArrowDropDownIcon from '@assets/svg/arrowDropDown.svg';
import AuthProvider from '../providers/AuthProvider';
import useLatestNumber from '@/_hooks/useLatestNumber';
import { parse } from 'date-fns';
import BottomSheet from '../common/BottomSheet';
import RoundSelector from './RoundSelector';
import { LatestNumberResponseType } from '@/_types/analysis';

type AnalysisMainWrapperProps = {};
const AnalysisMainWrapper: React.FC = () => {
const { latestNumbers, isLoading } = useLatestNumber();
const [isOpenScrapBottomSheet, setIsOpenScrapBottomSheet] = useState(false);
const [selectNumbers, setSelectNumbers] = useState<LatestNumberResponseType>();

const AnalysisMainWrapper: React.FC<AnalysisMainWrapperProps> = () => {
// const test = [3, 5, 7, 9, 1, 13, 4]; //? res값 정제
useEffect(() => {
if (!latestNumbers) {
return console.log('no number');
}
setSelectNumbers(latestNumbers);
}, [latestNumbers]);

return (
<AnalysisMainWrapperBlock>
<AnalysisMainTitle>
7월 2주차 1078회
<br />
당첨번호를 확인하세요.
</AnalysisMainTitle>
const parsedDate = parse(`${selectNumbers?.drwt_date}`, 'yyyy-MM-dd', new Date());
const monthNumber = parsedDate.getMonth() + 1;
const weekNumber = Math.ceil(parsedDate.getDate() / 7);

if (isLoading) return <p>loading</p>; //로딩 UI 필요
//latestNumbers 없을 때 행동

<WeekWinningNumberBox>
<WeekWinningNumber>3 5 7 9 1 13 4</WeekWinningNumber>{' '}
<WeekWinningBonusNumber>34</WeekWinningBonusNumber>
<PolygonIconSVG />
</WeekWinningNumberBox>
return (
<AuthProvider>
<AnalysisMainWrapperBlock>
<AnalysisMainTitle>
<Text>
{monthNumber}{weekNumber}주차{' '}
<SelectorButton onClick={() => setIsOpenScrapBottomSheet(true)}>
{selectNumbers?.drwt_no}<ArrowDropDownIcon />
</SelectorButton>
</Text>
당첨번호를 확인하세요.
</AnalysisMainTitle>
<WeekWinningNumberBox>
{selectNumbers &&
new Array(6)
.fill('')
.map((_, i) => (
<WeekWinningNumber key={i}>{selectNumbers[`drwt_no${i + 1}`]}</WeekWinningNumber>
))}
<WeekWinningBonusNumber>{selectNumbers?.bnus_no}</WeekWinningBonusNumber>
<PolygonIconSVG />
</WeekWinningNumberBox>
<Image src="/assets/images/analysisMain.png" alt="분석페이지" width="120" height="120" />
<ResultAmountBannerList roundNumbers={selectNumbers} />

<Image src="/assets/images/analysisMain.png" alt="분석페이지" width="120" height="120" />
<ResultAmountBannerList />
<AnalyticsDashboardMenu />
</AnalysisMainWrapperBlock>
<AnalyticsDashboardMenu />
</AnalysisMainWrapperBlock>
<BottomSheet
isOpen={isOpenScrapBottomSheet}
onOpen={() => setIsOpenScrapBottomSheet(true)}
onClose={() => setIsOpenScrapBottomSheet(false)}
title="회차 선택"
>
<RoundSelector
lastestRound={latestNumbers?.drwt_no}
setIsOpenScrapBottomSheet={setIsOpenScrapBottomSheet}
setSelectNumbers={setSelectNumbers}
/>
</BottomSheet>
</AuthProvider>
);
};

Expand All @@ -42,14 +85,28 @@ const AnalysisMainWrapperBlock = styled.div`
`;

const AnalysisMainTitle = styled.p`
display: flex;
flex-direction: column;
align-items: center;
font-size: 20px;
font-weight: bold;
line-height: 26px;
text-align: center;
padding: 15px 0;
margin-bottom: 16px;
`;

const Text = styled.p`
display: flex;
gap: 5px;
`;

const SelectorButton = styled.button`
display: flex;
font-size: 20px;
font-weight: bold;
color: ${palette.orange_20};
`;

const PolygonIconSVG = styled(PolygonIcon)`
position: absolute;
bottom: -10px;
Expand All @@ -64,12 +121,13 @@ const WeekWinningNumberBox = styled.div`
border-radius: 400px;
margin-bottom: 21px;
position: relative;
display: flex;
gap: 10px;
`;

const WeekWinningNumber = styled.span`
color: ${palette.grey_20};
font-size: 20px;
letter-spacing: 6px;
font-weight: bold;
`;
const WeekWinningBonusNumber = styled.span`
Expand Down
2 changes: 1 addition & 1 deletion app/_components/analysis/AnalyticsDashboardMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const AnalyticsDashboardMenu: React.FC<AnalyticsDashboardMenuProps> = () => {
</div>
</HorizontalMenuBox>
<VerticalMenuWrapper>
<VerticalMenuBox href="/analysis/amount">
<VerticalMenuBox href="/analysis/amount?type=desc">
<AmountIcon />
<VerticalTitle>당첨금액별</VerticalTitle>
<Description>금액이 높은 순으로 조회하기</Description>
Expand Down
54 changes: 16 additions & 38 deletions app/_components/analysis/ResultAmountBannerList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,31 @@ import React from 'react';
import styled from 'styled-components';
import palette from '@/_styles/palette';
import { Swiper, SwiperSlide } from 'swiper/react';
import useLatestNumber from '@/_hooks/useLatestNumber';
import { LatestNumberResponseType } from '@/_types/analysis';

type ResultAmountBannerListProps = {};

const ResultAmountBannerList: React.FC<ResultAmountBannerListProps> = () => {
const testList = [
{
count: 1,
amount: 2539849237,
},
{
count: 1,
amount: 2539849237,
},
{
count: 1,
amount: 2539849237,
},
{
count: 1,
amount: 2539849237,
},
{
count: 1,
amount: 2539849237,
},
{
count: 1,
amount: 2539849237,
},
];
type ResultAmountBannerListProps = {
roundNumbers: LatestNumberResponseType;
};

const ResultAmountBannerList: React.FC<ResultAmountBannerListProps> = ({ roundNumbers }) => {
return (
<ResultAmountBannerListBlock
direction={'horizontal'}
slidesPerView={'auto'}
direction="horizontal"
slidesPerView="auto"
className="swiper-banner"
>
{testList.map((test, i) => (
<SwiperSlide key={i}>
{roundNumbers && (
<SwiperSlide>
<ResultAmountBannerItem>
<ItemInner>
<p>{i + 1}</p>
<p>{test.count}</p>
<p>1등</p>
<p>{roundNumbers.first_win_count}</p>
</ItemInner>
<ItemAmount>{test.amount.toLocaleString()}</ItemAmount>
<ItemAmount>{roundNumbers.first_win_amount.toLocaleString()}</ItemAmount>
</ResultAmountBannerItem>
</SwiperSlide>
))}
)}
</ResultAmountBannerListBlock>
);
};
Expand All @@ -71,9 +48,10 @@ const ResultAmountBannerListBlock = styled(Swiper)`
`;

const ResultAmountBannerItem = styled.li`
width: 108px;
display: flex;
flex-direction: column;
padding: 20px 14px;
padding: 20px 15px;
background-color: ${palette.white};
border-radius: 10px;
`;
Expand Down
56 changes: 56 additions & 0 deletions app/_components/analysis/RoundSelector.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import instance from '@/_apis/core';
import { LatestNumberResponseType } from '@/_types/analysis';
import React from 'react';
import styled from 'styled-components';

type RoundSelectorProps = {
lastestRound: number;
setIsOpenScrapBottomSheet: React.Dispatch<React.SetStateAction<boolean>>;
setSelectNumbers: React.Dispatch<React.SetStateAction<LatestNumberResponseType | undefined>>;
};

const RoundSelector: React.FC<RoundSelectorProps> = ({
lastestRound,
setIsOpenScrapBottomSheet,
setSelectNumbers,
}) => {
const selectOptions = Array.from({ length: lastestRound }, (_, index) => lastestRound - index);

const onSelect = async (drwtNo: number) => {
try {
const data = await instance.get<undefined, LatestNumberResponseType>(`/api/number`, {
params: {
drwtNo,
},
});

setSelectNumbers(data);
} catch (err) {
console.log('err', err);
}
setIsOpenScrapBottomSheet(false);
};

return (
<RoundSelectorBlock>
{selectOptions.map(round => (
<Item key={round} onClick={() => onSelect(round)}>
{round}
</Item>
))}
</RoundSelectorBlock>
);
};

const RoundSelectorBlock = styled.div`
display: flex;
flex-direction: column;
gap: 26px;
`;

const Item = styled.button`
text-align: center;
font-size: 20px;
`;

export default RoundSelector;
45 changes: 45 additions & 0 deletions app/_components/analysis/amount/AmountAnalysisWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import NavTabs from '@/_components/common/NavTabs';
import React from 'react';
import styled from 'styled-components';
import PrizeAmountList from './PrizeAmountList';
import { useSearchParams } from 'next/navigation';
import PrizeRankAnalysisWrapper from './PrizeRankAnalysisWrapper';
import { SortOption } from '@/_types/analysis';

type AmountAnalysisWrapperProps = {};

const AmountAnalysisWrapper: React.FC<AmountAnalysisWrapperProps> = () => {
const searchParams = useSearchParams();

const tabOptions = [
{
label: '당첨금액 높은 순',
queryParams: 'type',
value: 'desc',
},
{
label: '당첨금액 낮은 순',
queryParams: 'type',
value: 'asc',
},
];

return (
<AmountAnalysisWrapperBlock>
<NavTabs tabOptions={tabOptions} />
<PrizeAmountList />
<Line />
<PrizeRankAnalysisWrapper />
</AmountAnalysisWrapperBlock>
);
};

const AmountAnalysisWrapperBlock = styled.div``;

const Line = styled.div`
width: 100%;
background-color: #eff3f8;
height: 10px;
`;

export default AmountAnalysisWrapper;
Loading

0 comments on commit fb59ef7

Please sign in to comment.