|
1 | 1 | import { assignInlineVars } from "@vanilla-extract/dynamic"; |
2 | 2 | import { useNavigate } from "react-router-dom"; |
3 | 3 |
|
| 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"; |
4 | 10 | import { IconMove } from "@/shared/assets/icons"; |
5 | 11 | import { getScaleLabel } from "@/shared/config"; |
6 | 12 | import { Tag } from "@/shared/ui/tag/tag"; |
@@ -28,15 +34,31 @@ const MajorCompanyCard = ({ |
28 | 34 | }: MajorCompanyCardProps) => { |
29 | 35 | const navigate = useNavigate(); |
30 | 36 |
|
| 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 | + |
31 | 48 | const handleClick = () => { |
| 49 | + window.scrollTo({ top: 0, left: 0, behavior: "auto" }); |
| 50 | + prefetchCompany(); |
32 | 51 | navigate(`/company/${id}`); |
33 | 52 | }; |
34 | 53 |
|
35 | 54 | return ( |
36 | 55 | <button |
37 | 56 | type="button" |
38 | 57 | onClick={handleClick} |
39 | | - aria-label="๊ธฐ์
์์ธ๋ก ์ด๋" |
| 58 | + onMouseEnter={prefetchCompany} |
| 59 | + onFocus={prefetchCompany} |
| 60 | + onTouchStart={prefetchCompany} |
| 61 | + aria-label="ๆฎๅๆขพ ?ไพ
ๅฏๆฟ??ๆชๅฝ" |
40 | 62 | className={styles.card({ type })} |
41 | 63 | style={assignInlineVars({ [styles.bgImageUrl]: `url(${imgUrl})` })} |
42 | 64 | > |
|
0 commit comments