-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[#50] API GET 예시 (axios, 리액트 쿼리, 로딩, 에러)
- Loading branch information
Showing
25 changed files
with
405 additions
and
195 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export { default as instance } from './lib/instance'; | ||
export { default as getExample } from './lib/getExample'; | ||
export { default as postLogin } from './lib/postLogin'; | ||
export { default as postRefreshToken } from './lib/postRefreshToken'; | ||
export { default as getTotalReport } from './lib/getTotalReport'; | ||
export { default as getYearReport } from './lib/getYearReport'; | ||
export { default as getCouponList } from './lib/getCouponList'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { instance } from '..'; | ||
import { TotalReportResult } from '@/types/report'; | ||
|
||
const getTotalReport = async ( | ||
accommodation_id: number | ||
): Promise<TotalReportResult> => { | ||
const response = await instance.get( | ||
`/v1/dashboards/${accommodation_id}/reports/total` | ||
); | ||
|
||
return response.data; | ||
}; | ||
|
||
export default getTotalReport; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { instance } from '..'; | ||
import { YearReportResult } from '@/types/report'; | ||
|
||
const getYearReport = async ( | ||
accommodation_id: number | ||
// recoil로 쿼리 정보 가져오기 | ||
): Promise<YearReportResult> => { | ||
const response = await instance.get( | ||
`/v1/dashboards/${accommodation_id}/reports/year?year=${2023}` | ||
); | ||
|
||
return response.data; | ||
}; | ||
|
||
export default getYearReport; |
11 changes: 11 additions & 0 deletions
11
src/components/Report/LeftSection/Graph/SelectYear/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
const SelectYear = () => { | ||
return <Container>select</Container>; | ||
}; | ||
|
||
export default SelectYear; | ||
|
||
const Container = styled.div` | ||
// HACK: 이슈 #67에서 작업중 | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { FallbackProps } from 'react-error-boundary'; | ||
import styled from '@emotion/styled'; | ||
|
||
const ErrorFallback = ({ error, resetErrorBoundary }: FallbackProps) => { | ||
console.log(error); | ||
|
||
return ( | ||
<Container> | ||
<span>누적 리포트 차트 에러 발생</span> | ||
<button onClick={resetErrorBoundary}>다시 시도</button> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default ErrorFallback; | ||
|
||
const Container = styled.div` | ||
min-width: 1016px; | ||
height: 880px; | ||
border-radius: 20px; | ||
padding: 20px 30px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 10px; | ||
background-color: white; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import styled from '@emotion/styled'; | ||
import Skeleton from 'react-loading-skeleton'; | ||
import 'react-loading-skeleton/dist/skeleton.css'; | ||
|
||
import { DashboardHeader } from '@components/common'; | ||
|
||
const Loading = () => { | ||
return ( | ||
<Container> | ||
<DashboardHeader /> | ||
<Graph> | ||
<HeaderContainer /> | ||
<ChartContainer> | ||
<Chart /> | ||
</ChartContainer> | ||
</Graph> | ||
<Report> | ||
<Content /> | ||
<Content /> | ||
<Content /> | ||
</Report> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default Loading; | ||
|
||
const Container = styled.div` | ||
min-width: 1016px; | ||
height: auto; | ||
border-radius: 20px; | ||
padding: 20px 30px; | ||
display: flex; | ||
flex-direction: column; | ||
flex: 2; | ||
background-color: white; | ||
`; | ||
|
||
const BaseSkeleton = styled(Skeleton)` | ||
width: 100%; | ||
border-radius: 16px; | ||
background-color: #f2f4f5; | ||
`; | ||
|
||
const Graph = styled.div` | ||
width: 100%; | ||
border-radius: 16px; | ||
display: flex; | ||
flex-direction: column; | ||
`; | ||
|
||
const HeaderContainer = styled(BaseSkeleton)` | ||
margin: 12px 0; | ||
padding: 18px 0; | ||
`; | ||
|
||
const ChartContainer = styled.div` | ||
min-height: 500px; | ||
padding: 30px; | ||
background-color: #f2f4f5; | ||
`; | ||
|
||
const Chart = styled(BaseSkeleton)` | ||
height: 100%; | ||
background-color: white; | ||
`; | ||
|
||
const Report = styled.div` | ||
width: 100%; | ||
height: 100%; | ||
margin-top: 30px; | ||
border-radius: 16px; | ||
padding: 25px 30px; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
background-color: #fafafb; | ||
`; | ||
|
||
const Content = styled(BaseSkeleton)` | ||
width: 270px; | ||
height: 130px; | ||
border-radius: 18.5px; | ||
`; |
Oops, something went wrong.