Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…nto feature/#62
  • Loading branch information
dabin-Hailey committed Jan 23, 2024
2 parents 75cb062 + 33d6c7a commit bab6b4f
Show file tree
Hide file tree
Showing 56 changed files with 1,167 additions and 209 deletions.
26 changes: 26 additions & 0 deletions src/App.error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { FallbackProps } from 'react-error-boundary';
import styled from '@emotion/styled';

const ErrorFallback = ({ resetErrorBoundary }: FallbackProps) => {
return (
<Container>
<span>App 전체 에러 발생</span>
<button onClick={resetErrorBoundary}>다시 시도</button>
</Container>
);
};

export default ErrorFallback;

const Container = styled.div`
width: 100vw;
min-width: 100vw;
height: 100vh;
max-height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 10px;
`;
112 changes: 112 additions & 0 deletions src/App.loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
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>
<Sidebar />
<Section>
<Header />
<OutletLayout />
</Section>
</Container>
);
};

export default Loading;

const BaseSkeleton = styled(Skeleton)`
width: 100%;
border-radius: 16px;
background-color: #f2f4f5;
`;

const Container = styled.div`
position: relative;
width: 100vw;
min-width: 100vw;
height: 100vh;
max-height: 100vh;
display: flex;
background-color: white;
overflow: hidden;
`;

const Sidebar = styled(BaseSkeleton)`
position: fixed;
width: 100px;
min-height: 100%;
overflow: hidden;
${theme.response.tablet} {
display: none;
}
`;

const Section = styled.div`
--sidebar-width: 100px;
width: 100%;
min-width: calc(100vh - var(--sidebar-width));
height: 100vh;
margin-left: var(--sidebar-width);
padding: 0 22px;
display: flex;
flex-direction: column;
${theme.response.tablet} {
min-width: 0;
margin-left: 0;
padding: 0 15px;
}
`;

const Header = styled(BaseSkeleton)`
position: sticky;
top: 0;
left: 0;
width: 100%;
height: 85px;
border-radius: 20px;
display: flex;
justify-content: space-between;
align-items: center;
${theme.response.tablet} {
height: 65px;
border-radius: 10px;
}
`;

const OutletLayout = styled(BaseSkeleton)`
width: 100%;
height: 85vh;
max-height: 85vh;
margin-top: 16px;
border-radius: 20px;
${theme.response.tablet} {
margin-top: 15px;
margin-top: 0;
border-radius: 10px;
}
`;
8 changes: 4 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { Suspense } from 'react';
import { MainRouter } from './routes';
import GlobalStyles from '@styles/GlobalStyles';
import theme from '@styles/theme';
import { ErrorApp } from '@components/ErrorFallback';
import { LoadingApp } from '@components/Loading';
import ErrorFallback from './App.error';
import Loading from './App.loading';

const queryClient = new QueryClient();

Expand All @@ -28,9 +28,9 @@ const App = () => {
<GlobalStyles />
<ErrorBoundary
onReset={reset}
FallbackComponent={ErrorApp}
FallbackComponent={ErrorFallback}
>
<Suspense fallback={<LoadingApp />}>
<Suspense fallback={<Loading />}>
<BrowserRouter>
<MainRouter />
</BrowserRouter>
Expand Down
7 changes: 6 additions & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
export { default as instance } from './lib/instance';
export { default as postLogin } from './lib/postLogin';
export { default as postRefreshToken } from './lib/postRefreshToken';
export {
getCouponList,
couponUpdateApi,
couponDeleteApi,
couponToggleApi
} from './lib/getCouponList';
export { default as getTotalReport } from './lib/getTotalReport';
export { default as getYearReport } from './lib/getYearReport';
export { default as getCouponList } from './lib/getCouponList';
export { default as getHeaderAccommodation } from './lib/getHeaderAccommodation';
export { default as getMonthReports } from './lib/getMonthReports';
export { default as getDailyReport } from './lib/getDailyReport';
Expand Down
38 changes: 35 additions & 3 deletions src/api/lib/getCouponList.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { CouponListResponse } from '@/types/couponList';
import {
CouponDeleteCredential,
CouponListResponse,
CouponToggleCredential,
CouponUpdateCredential
} from '@/types/couponList';
import { instance } from '..';

// 쿠폰 정보 가져오는 api
const getCouponList = async (
export const getCouponList = async (
accommodationId: number,
date?: string,
status?: string,
Expand All @@ -22,4 +27,31 @@ const getCouponList = async (
return response.data;
};

export default getCouponList;
// 쿠폰 수정 api
export const couponUpdateApi = async (credential: CouponUpdateCredential) => {
const couponNumber = credential.coupon_number;
const response = await instance.put(
`/v1/coupons/${couponNumber}`,
credential
);
return response.data;
};

// 쿠폰 삭제 api
export const couponDeleteApi = async (
credential: CouponDeleteCredential
): Promise<void> => {
const couponNumber = credential.coupon_number;
const response = await instance.delete(`/v1/coupons/${couponNumber}`);
return response.data;
};

// 토클 on/off api
export const couponToggleApi = async (credential: CouponToggleCredential) => {
const couponNumber = credential.coupon_number;
const response = await instance.put(
`/v1/coupons/${couponNumber}/expose`,
credential
);
return response.data;
};
9 changes: 6 additions & 3 deletions src/api/lib/getHeaderAccommodation.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { AxiosResponse } from 'axios';

import { instance } from '..';
import { HeaderAccommodationResult } from '@/types/layout';
import {
HeaderAccommodationData,
HeaderAccommodationResult
} from '@/types/layout';

const getHeaderAccommodation = async (): Promise<HeaderAccommodationResult> => {
const getHeaderAccommodation = async (): Promise<HeaderAccommodationData> => {
const response: AxiosResponse<HeaderAccommodationResult, Error> =
await instance.get(`/v1/accommodation`);

return response.data;
return response.data.accommodation_responses;
};

export default getHeaderAccommodation;
17 changes: 8 additions & 9 deletions src/api/lib/getLocalCouponUsage.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { instance } from '..';
import { LocalCouponUsageResult } from '@/types/dashboard';

const getLocalCouponUsage = async (id: number) => {
try {
const response = await instance.get(
`v1/dashboards/${id}/coupons/local/count`
);
return response.data;
} catch (err) {
console.error(err);
}
const getLocalCouponUsage = async (
id: number
): Promise<LocalCouponUsageResult> => {
const response = await instance.get(
`v1/dashboards/${id}/coupons/local/count`
);
return response.data;
};

export default getLocalCouponUsage;
12 changes: 5 additions & 7 deletions src/api/lib/getMonthReports.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { instance } from '..';

const getMonthReports = async (id: number) => {
try {
const response = await instance.get(`v1/dashboards/${id}/reports/month`);
return response.data;
} catch (err) {
console.error(err);
}
import { MonthReportsResults } from '@/types/dashboard';

const getMonthReports = async (id: number): Promise<MonthReportsResults[]> => {
const response = await instance.get(`v1/dashboards/${id}/reports/month`);
return response.data.monthly_data_responses;
};

export default getMonthReports;
17 changes: 16 additions & 1 deletion src/components/CouponList/CouponBanner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ import styled from '@emotion/styled';
import theme from '@styles/theme';

import bannerIcon from '@assets/icons/ic-couponlist-speaker.svg';
import { useRecoilValue } from 'recoil';
import { headerAccommodationState } from '@recoil/index';
// import { useGetCouponRanking } from '@hooks/queries/useGetCouponRanking';

const CouponBanner = () => {
const headerAccommodation = useRecoilValue(headerAccommodationState);
const sigunguData = headerAccommodation.sigungu;
// const { data } = useGetCouponRanking(headerAccommodation.id);

return (
<BannerContainer>
<TabBanner>
Expand All @@ -14,7 +21,8 @@ const CouponBanner = () => {
<div>
<TabBannerTitle>이번 달 우리 지역 인기 쿠폰</TabBannerTitle>
<TabBannerContent>
OO구에서 가장 많이 사용된 쿠폰은? 재방문 고객 20% 할인쿠폰 이에요!
{sigunguData}에서 가장 많이 사용된 쿠폰은?
{/* <span>{data.first_coupon_title}쿠폰</span>이에요! */}
</TabBannerContent>
</div>
</TabBanner>
Expand Down Expand Up @@ -46,9 +54,16 @@ const TabBanner = styled.div`
const TabBannerTitle = styled.div`
font-size: 12px;
font-style: normal;
font-weight: 500;
margin-bottom: 6px;
`;
const TabBannerContent = styled.div`
font-size: 17px;
font-style: normal;
font-weight: 500;
span {
margin: 0px 5px;
border-bottom: 1px solid;
}
`;
6 changes: 5 additions & 1 deletion src/components/CouponList/CouponHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ const CouponRegisterButton = styled.div`
font-size: 17px;
color: ${theme.colors.white};
background: #ff3478;
background: linear-gradient(91deg, #ff3478 1.39%, #ff83ad 98.63%);
cursor: pointer;
&:hover {
background: #b22655;
}
`;
Loading

0 comments on commit bab6b4f

Please sign in to comment.