-
Notifications
You must be signed in to change notification settings - Fork 5
Refactor(client): home 화면 리페인트 최적화 #492
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import { useCallback } from 'react'; | ||
| import { useSuspenseQuery } from '@tanstack/react-query'; | ||
| import { useNavigate } from 'react-router-dom'; | ||
|
|
||
|
|
@@ -15,37 +16,27 @@ import { StatusType } from '@shared/types/type.ts'; | |
|
|
||
| import * as styles from './recommended-info-section.css.ts'; | ||
|
|
||
| interface recommendedInfoSectionProps { | ||
| interface StaticContentProps { | ||
| userName?: string; | ||
| productName?: string; | ||
| company?: string; | ||
| keywordChips?: string[]; | ||
| } | ||
|
|
||
| /** 보험 추천받은 유저가 볼 화면 */ | ||
| export const RecommendedInfoSection = ({ | ||
| const StaticContent = ({ | ||
| userName, | ||
| }: recommendedInfoSectionProps) => { | ||
| const navigate = useNavigate(); | ||
| const handleNavigateReport = () => { | ||
| navigate(routePath.REPORT); | ||
| }; | ||
|
|
||
| const { data: reportSummary } = useSuspenseQuery( | ||
| HOME_QUERY_OPTIONS.REPORT_SUMMARY(), | ||
| ); | ||
| const targetToIconMap = new Map( | ||
| homeCardConfig.map(({ target, icon }) => [target, icon]), | ||
| ); | ||
|
|
||
| if (!reportSummary) { | ||
| return; | ||
| } | ||
|
|
||
| productName, | ||
| company, | ||
| keywordChips, | ||
| }: StaticContentProps) => { | ||
| return ( | ||
| <section className={styles.infoSection}> | ||
| <> | ||
| <img | ||
| src={'./3Dicon_background.webp'} | ||
| width={223} | ||
| height={185} | ||
| className={styles.backgroundLogo} | ||
| alt="" | ||
| /> | ||
| <div className={styles.titleSection}> | ||
| <InsuranceSubtitle | ||
|
|
@@ -58,11 +49,11 @@ export const RecommendedInfoSection = ({ | |
| <InsuranceTitle | ||
| fontColor={'white'} | ||
| fontStyle={'eb_28'} | ||
| name={reportSummary.productName} | ||
| company={reportSummary.company} | ||
| name={productName} | ||
| company={company} | ||
| /> | ||
| <div className={styles.chipList}> | ||
| {reportSummary.keywordChips?.map((chip, index) => ( | ||
| {keywordChips?.map((chip, index) => ( | ||
| <Chip | ||
| key={index} | ||
| variant="round" | ||
|
|
@@ -74,7 +65,58 @@ export const RecommendedInfoSection = ({ | |
| ))} | ||
| </div> | ||
| </div> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| interface BottomButtonProps { | ||
| onClick: () => void; | ||
| } | ||
|
|
||
| const BottomButton = ({ onClick }: BottomButtonProps) => { | ||
| return ( | ||
| <div className={styles.bottomButton}> | ||
| <TextButton color={'white'} size="sm" onClick={onClick}> | ||
| <p>구체적인 내용 확인하기</p> | ||
| <Icon name={'caret_right_md'} color="white" /> | ||
| </TextButton> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| interface recommendedInfoSectionProps { | ||
| userName?: string; | ||
| } | ||
|
|
||
| /** 보험 추천받은 유저가 볼 화면 */ | ||
| export const RecommendedInfoSection = ({ | ||
| userName, | ||
| }: recommendedInfoSectionProps) => { | ||
| const navigate = useNavigate(); | ||
| const handleNavigateReport = useCallback(() => { | ||
| navigate(routePath.REPORT); | ||
| }, [navigate]); | ||
|
||
|
|
||
| const { data: reportSummary } = useSuspenseQuery( | ||
| HOME_QUERY_OPTIONS.REPORT_SUMMARY(), | ||
| ); | ||
|
|
||
| const targetToIconMap = new Map( | ||
| homeCardConfig.map(({ target, icon }) => [target, icon]), | ||
| ); | ||
|
|
||
| if (!reportSummary) { | ||
| return; | ||
| } | ||
|
|
||
| return ( | ||
| <section className={styles.infoSection}> | ||
| <StaticContent | ||
| userName={userName} | ||
| productName={reportSummary.productName} | ||
| company={reportSummary.company} | ||
| keywordChips={reportSummary.keywordChips} | ||
| /> | ||
| <Carousel slidesPerView={4.5} autoPlay className={styles.homeCardList}> | ||
| {reportSummary.statuses?.map((card, index) => ( | ||
| <Carousel.Item key={index}> | ||
|
|
@@ -92,13 +134,7 @@ export const RecommendedInfoSection = ({ | |
| </Carousel.Item> | ||
| ))} | ||
| </Carousel> | ||
|
|
||
| <div className={styles.bottomButton}> | ||
| <TextButton color={'white'} size="sm" onClick={handleNavigateReport}> | ||
| <p>구체적인 내용 확인하기</p> | ||
| <Icon name={'caret_right_md'} color="white" /> | ||
| </TextButton> | ||
| </div> | ||
| <BottomButton onClick={handleNavigateReport} /> | ||
| </section> | ||
| ); | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
따로 이 컴포넌트들을 파일로 분리 안하신 이유가 있나요?!
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.
파일 분리를 고민하다가, 재사용 목적이 아니고 분산시킬 필요성이 우리 눈에 깔끔한 거라면 불필요하다고 생각했어요.
StaticContent, BottomButton 이 이 파일에서만 쓰이는 로컬 UI 이기 때문에 같은 파일에 두어서 지역성을 유지하는 게 낫다고 생각했는데, 요 부분은 코드리뷰에서 논의해보고 싶었어요. 혜린님은 분리하는 게 좋다고 생각하시나요!