-
Notifications
You must be signed in to change notification settings - Fork 1
feat: 기업정보 탭 api 연결 #89
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
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,34 @@ | ||
| import { | ||
| Consensus, | ||
| FinancialRatio, | ||
| RelativeNews, | ||
| } from "@/types/company-details"; | ||
|
|
||
| import makeApiRequest from "../make-api-request"; | ||
|
|
||
| // 기업 상세정보의 재무제표 조회 | ||
| export async function getFinancialStatements( | ||
| stockName: string, | ||
| ): Promise<FinancialRatio[]> { | ||
| return makeApiRequest( | ||
| "GET", | ||
| `/search/financialRatio?stockName=${stockName}`, | ||
| {}, | ||
| ); | ||
| } | ||
|
|
||
| // 기업 관련 뉴스 조회 | ||
| export async function getRelativeNews( | ||
| stockName: string, | ||
| ): Promise<RelativeNews[]> { | ||
| return makeApiRequest("GET", `/search/news?stockName=${stockName}`, {}); | ||
| } | ||
|
|
||
| // 기업 컨센서스 | ||
| export async function getConsensus(stockName: string): Promise<Consensus> { | ||
| return makeApiRequest( | ||
| "GET", | ||
| `/search/investmentRecommendation?stockName=${stockName}`, | ||
| {}, | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
100 changes: 75 additions & 25 deletions
100
src/app/search/[id]/_components/detail-info/company-overview/consensus.tsx
This file contains hidden or 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,29 +1,79 @@ | ||
| export default function Consensus() { | ||
| import React from "react"; | ||
|
|
||
| import categories from "@/constants/company-details"; | ||
| import { Consensus as ConsensusType } from "@/types/company-details"; | ||
| import { | ||
| calculateDifferencePercentage, | ||
| getRelativePosition, | ||
| } from "@/utils/calculate-consensus"; | ||
| import cn from "@/utils/cn"; | ||
|
|
||
| interface ConsensusProps { | ||
| investmentRecommendationData: ConsensusType | undefined; | ||
| } | ||
|
|
||
| export default function Consensus({ | ||
| investmentRecommendationData, | ||
| }: ConsensusProps) { | ||
| if (!investmentRecommendationData) { | ||
| return ( | ||
| <div className="flex items-center justify-center text-gray-500"> | ||
| 데이터를 로드하는 중입니다... | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| const difference = calculateDifferencePercentage( | ||
| investmentRecommendationData, | ||
| ); | ||
| const cappedDifference = Math.max(Math.min(difference, 100), -100); | ||
|
|
||
| return ( | ||
| <div className="w-full"> | ||
| <div className="mb-10 text-16-500">컨센서스</div> | ||
| <div className="flex w-full justify-between gap-8 text-center text-14-500 text-gray-100"> | ||
| <div className="flex-1"> | ||
| <div className="mb-6 h-9 w-full bg-green-900" /> | ||
| <span>적극 매도</span> | ||
| </div> | ||
| <div className="flex-1"> | ||
| <div className="mb-6 h-9 w-full bg-green-900" /> | ||
| <span>매도</span> | ||
| </div> | ||
| <div className="flex-1"> | ||
| <div className="mb-6 h-9 w-full bg-green-900" /> | ||
| <span>중립</span> | ||
| </div> | ||
| <div className="flex-1"> | ||
| <div className="mb-6 h-9 w-full bg-green-900" /> | ||
| <span>매수</span> | ||
| </div> | ||
| <div className="flex-1"> | ||
| <div className="mb-6 h-9 w-full bg-green-900" /> | ||
| <span>적극 매수</span> | ||
| </div> | ||
| <> | ||
| <div className="mb-8 mt-13 text-16-500 text-black">컨센서스</div> | ||
| <div className="relative flex w-full justify-between gap-8 text-center text-14-500 text-gray-100"> | ||
| {categories.map((category, index) => { | ||
| const isActive = | ||
| cappedDifference > category.range[0] && | ||
| cappedDifference <= category.range[1]; | ||
|
|
||
| const relativePosition = getRelativePosition( | ||
| category.range, | ||
| cappedDifference, | ||
| ); | ||
|
|
||
| return ( | ||
| // eslint-disable-next-line react/no-array-index-key | ||
| <div key={index} className="relative flex-1"> | ||
| {isActive && ( | ||
| <div | ||
| className="absolute bottom-36 w-max -translate-x-1/2" | ||
| style={{ | ||
| left: `${relativePosition}%`, | ||
| }} | ||
| > | ||
| <div className="flex flex-col items-center"> | ||
| <div className="rounded bg-lime-300 px-7 py-3 text-14-500 text-black"> | ||
| {difference.toFixed(2)}% | ||
| </div> | ||
| <div | ||
| className="size-0 border-x-8 border-t-8 border-x-transparent border-t-lime-300" | ||
| style={{ marginTop: "-1px" }} | ||
| /> | ||
| </div> | ||
| </div> | ||
| )} | ||
| <div | ||
| className={cn( | ||
| "mb-6 h-9 w-full transition-colors", | ||
| isActive ? "bg-lime-300" : "bg-green-900", | ||
| )} | ||
| /> | ||
| <span>{category.label}</span> | ||
| </div> | ||
| ); | ||
| })} | ||
| </div> | ||
| </div> | ||
| </> | ||
| ); | ||
| } |
This file contains hidden or 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
36 changes: 30 additions & 6 deletions
36
src/app/search/[id]/_components/detail-info/company-overview/index.tsx
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사소한거 좋아요