-
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
- Loading branch information
Showing
38 changed files
with
380 additions
and
247 deletions.
There are no files selected for viewing
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
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
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
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,20 @@ | ||
import { z } from 'zod'; | ||
|
||
export const ErrorResponseSchema = z.object({ | ||
message: z.string(), | ||
error: z.string(), | ||
statusCode: z.number(), | ||
}); | ||
|
||
export const AxiosErrorSchema = z.object({ | ||
response: z.object({ | ||
data: ErrorResponseSchema, | ||
status: z.number(), | ||
statusText: z.string(), | ||
}), | ||
request: z.any().optional(), | ||
message: z.string(), | ||
}); | ||
|
||
export type ErrorResponse = z.infer<typeof ErrorResponseSchema>; | ||
export type AxiosError = z.infer<typeof AxiosErrorSchema>; |
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,5 @@ | ||
export * from './schema'; | ||
export * from './useGetTopViews'; | ||
export * from './useGetStocksByPrice'; | ||
export * from './useGetSearchStocks'; | ||
export * from './useGetStocksPriceSeries'; | ||
export * from './useStockQueries'; |
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
17 changes: 0 additions & 17 deletions
17
packages/frontend/src/apis/queries/stocks/useGetStockIndex.ts
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
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
22 changes: 0 additions & 22 deletions
22
packages/frontend/src/apis/queries/stocks/useGetTopViews.ts
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
packages/frontend/src/apis/queries/stocks/useStockQueries.ts
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,42 @@ | ||
import { useSuspenseQueries } from '@tanstack/react-query'; | ||
import { z } from 'zod'; | ||
import { | ||
GetStockListRequest, | ||
GetStockListResponseSchema, | ||
GetStockTopViewsResponse, | ||
StockIndexResponse, | ||
StockIndexSchema, | ||
} from './schema'; | ||
import { get } from '@/apis/utils/get'; | ||
|
||
interface StockQueriesProps { | ||
viewsLimit: GetStockListRequest['limit']; | ||
} | ||
|
||
const getStockIndex = () => | ||
get<StockIndexResponse[]>({ | ||
schema: z.array(StockIndexSchema), | ||
url: `/api/stock/index`, | ||
}); | ||
|
||
const getTopViews = ({ limit }: Partial<GetStockListRequest>) => | ||
get<Partial<GetStockTopViewsResponse>[]>({ | ||
schema: z.array(GetStockListResponseSchema.partial()), | ||
url: `/api/stock/topViews`, | ||
params: { limit }, | ||
}); | ||
|
||
export const useStockQueries = ({ viewsLimit }: StockQueriesProps) => { | ||
return useSuspenseQueries({ | ||
queries: [ | ||
{ | ||
queryKey: ['stockIndex'], | ||
queryFn: getStockIndex, | ||
}, | ||
{ | ||
queryKey: ['topViews'], | ||
queryFn: () => getTopViews({ limit: viewsLimit }), | ||
}, | ||
], | ||
}); | ||
}; |
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,30 @@ | ||
import Lottie from 'react-lottie-player'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { Button } from '../ui/button'; | ||
import error from '@/components/lottie/error-loading.json'; | ||
import { cn } from '@/utils/cn'; | ||
|
||
interface ErrorProps { | ||
className?: string; | ||
} | ||
|
||
export const Error = ({ className }: ErrorProps) => { | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<div className="bg-extra-light-gray flex justify-center"> | ||
<section className="flex flex-col items-center gap-5"> | ||
<Lottie | ||
className={cn('h-36 w-36', className)} | ||
animationData={error} | ||
play | ||
/> | ||
<p>에러가 발생했어요. 주춤주춤 팀을 찾아주세요.</p> | ||
<div className="flex gap-5"> | ||
<Button onClick={() => navigate(-1)}>뒤로가기</Button> | ||
<Button onClick={() => navigate('/')}>홈</Button> | ||
</div> | ||
</section> | ||
</div> | ||
); | ||
}; |
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
Oops, something went wrong.