Skip to content

Commit 8f25a02

Browse files
authored
Merge pull request #139 from TEAM-COMFIT/feat/#136/company-detail-qa
2 parents 77cdb60 + cfd4e6d commit 8f25a02

4 files changed

Lines changed: 60 additions & 3 deletions

File tree

โ€Žsrc/features/home/ui/major-company-card/major-company-card.tsxโ€Ž

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { assignInlineVars } from "@vanilla-extract/dynamic";
22
import { useNavigate } from "react-router-dom";
33

4+
import {
5+
getCompanyDetail,
6+
getCompanySuggestions,
7+
} from "@/features/company-detail";
8+
import { queryClient } from "@/shared/api";
9+
import { companyQueryKey } from "@/shared/api/config/query-key";
410
import { IconMove } from "@/shared/assets/icons";
511
import { getScaleLabel } from "@/shared/config";
612
import { Tag } from "@/shared/ui/tag/tag";
@@ -28,15 +34,31 @@ const MajorCompanyCard = ({
2834
}: MajorCompanyCardProps) => {
2935
const navigate = useNavigate();
3036

37+
const prefetchCompany = () => {
38+
void queryClient.prefetchQuery({
39+
queryKey: companyQueryKey.detail(id),
40+
queryFn: () => getCompanyDetail(id),
41+
});
42+
void queryClient.prefetchQuery({
43+
queryKey: companyQueryKey.suggestion(id),
44+
queryFn: () => getCompanySuggestions(id),
45+
});
46+
};
47+
3148
const handleClick = () => {
49+
window.scrollTo({ top: 0, left: 0, behavior: "auto" });
50+
prefetchCompany();
3251
navigate(`/company/${id}`);
3352
};
3453

3554
return (
3655
<button
3756
type="button"
3857
onClick={handleClick}
39-
aria-label="๊ธฐ์—… ์ƒ์„ธ๋กœ ์ด๋™"
58+
onMouseEnter={prefetchCompany}
59+
onFocus={prefetchCompany}
60+
onTouchStart={prefetchCompany}
61+
aria-label="ๆ—ฎๅŠžๆขพ ?ไพ…ๅŠฏๆฟ??ๆŽชๅฝŠ"
4062
className={styles.card({ type })}
4163
style={assignInlineVars({ [styles.bgImageUrl]: `url(${imgUrl})` })}
4264
>

โ€Žsrc/pages/company-detail/company-detail-page.css.tsโ€Ž

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ export const container = style({
1515
margin: "0 auto",
1616
padding: "0 2rem 0",
1717
});
18+
19+
export const skeletonWrapper = style({
20+
width: "100%",
21+
height: "600px",
22+
backgroundColor: themeVars.color.gray100,
23+
borderRadius: "16px",
24+
});

โ€Žsrc/pages/company-detail/company-detail-page.tsxโ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ const CompanyDetailPage = () => {
6565
<div className={styles.container}>
6666
{companyData ? (
6767
<CompanyDetailSection companyData={companyData} />
68-
) : null}
68+
) : (
69+
<div className={styles.skeletonWrapper} />
70+
)}
6971
</div>
7072

7173
<CompanyRecommendationSection

โ€Žsrc/widgets/company-card/company-analyze-button.tsxโ€Ž

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { useNavigate } from "react-router-dom";
22

3+
import {
4+
getCompanyDetail,
5+
getCompanySuggestions,
6+
} from "@/features/company-detail";
7+
import { queryClient } from "@/shared/api";
8+
import { companyQueryKey } from "@/shared/api/config/query-key";
39
import { IconCompany } from "@/shared/assets/icons";
410

511
import * as styles from "./company-analyze-button.css";
@@ -11,12 +17,32 @@ interface CompanyAnalyzeButtonProps {
1117
const CompanyAnalyzeButton = ({ companyId }: CompanyAnalyzeButtonProps) => {
1218
const navigate = useNavigate();
1319

20+
const prefetchCompany = () => {
21+
void queryClient.prefetchQuery({
22+
queryKey: companyQueryKey.detail(companyId),
23+
queryFn: () => getCompanyDetail(companyId),
24+
});
25+
void queryClient.prefetchQuery({
26+
queryKey: companyQueryKey.suggestion(companyId),
27+
queryFn: () => getCompanySuggestions(companyId),
28+
});
29+
};
30+
1431
const handleClick = () => {
32+
window.scrollTo({ top: 0, left: 0, behavior: "auto" });
33+
prefetchCompany();
1534
navigate(`/company/${companyId}`);
1635
};
1736

1837
return (
19-
<button type="button" className={styles.button} onClick={handleClick}>
38+
<button
39+
type="button"
40+
className={styles.button}
41+
onClick={handleClick}
42+
onMouseEnter={prefetchCompany}
43+
onFocus={prefetchCompany}
44+
onTouchStart={prefetchCompany}
45+
>
2046
<IconCompany className={styles.icon} />
2147
<span>๊ธฐ์—… ๋ถ„์„ ๋ณด๊ธฐ</span>
2248
</button>

0 commit comments

Comments
ย (0)