|
1 | | -import { FC, PropsWithChildren, useCallback } from 'react' |
2 | | -import { useLocation, useNavigate } from 'react-router-dom' |
| 1 | +import { FC, PropsWithChildren } from 'react' |
3 | 2 |
|
4 | 3 | import { Badge, BadgeProps, Icon, IconProps, Tabs, TabsTriggerProps } from '@/components' |
5 | 4 | import { useRouterContext } from '@/context' |
@@ -43,41 +42,25 @@ export const PullRequestLayout: FC<PullRequestLayoutProps> = ({ |
43 | 42 | repoId, |
44 | 43 | updateTitle |
45 | 44 | }) => { |
46 | | - const { Outlet } = useRouterContext() |
| 45 | + const { Outlet, navigate } = useRouterContext() |
47 | 46 | const { pullRequest } = usePullRequestStore() |
48 | 47 | const { t } = useTranslationStore() |
49 | | - const navigate = useNavigate() |
50 | | - const location = useLocation() |
51 | 48 |
|
52 | | - const getIsActiveTab = useCallback( |
53 | | - (tab: string) => (location.pathname.endsWith(tab) ? 'active' : 'inactive'), |
54 | | - [location.pathname] |
55 | | - ) |
56 | | - const makeHandleTabChange = useCallback((tab: string) => () => navigate(tab), [navigate]) |
57 | | - |
58 | | - const getTabProps = useCallback( |
59 | | - (tab: PullRequestTabsKeys): TabsTriggerProps => ({ |
60 | | - value: tab, |
61 | | - ...{ 'data-state': getIsActiveTab(tab) }, |
62 | | - onClick: makeHandleTabChange(tab), |
63 | | - className: 'group gap-x-1.5', |
64 | | - role: 'link' |
65 | | - }), |
66 | | - [getIsActiveTab, makeHandleTabChange] |
67 | | - ) |
| 49 | + const getTabProps = (tab: PullRequestTabsKeys): TabsTriggerProps => ({ |
| 50 | + value: tab, |
| 51 | + onClick: () => navigate(tab), |
| 52 | + className: 'group gap-x-1.5', |
| 53 | + role: 'link' |
| 54 | + }) |
68 | 55 |
|
69 | 56 | return ( |
70 | 57 | <SandboxLayout.Main fullWidth> |
71 | 58 | <SandboxLayout.Content className="mx-auto max-w-[1500px] px-6"> |
72 | 59 | {pullRequest && ( |
73 | | - <PullRequestHeader |
74 | | - className="mb-10" |
75 | | - updateTitle={updateTitle} |
76 | | - data={{ ...pullRequest, stats: { commits: pullRequest?.stats?.commits }, spaceId, repoId }} |
77 | | - /> |
| 60 | + <PullRequestHeader className="mb-10" updateTitle={updateTitle} data={{ ...pullRequest, spaceId, repoId }} /> |
78 | 61 | )} |
79 | 62 |
|
80 | | - <Tabs.Root variant="tabnav" className="mb-7"> |
| 63 | + <Tabs.Root variant="tabnav" className="mb-7" defaultValue={PullRequestTabsKeys.CONVERSATION}> |
81 | 64 | <Tabs.List className="before:left-1/2 before:w-[calc(100vw-220px)] before:-translate-x-1/2"> |
82 | 65 | <Tabs.Trigger {...getTabProps(PullRequestTabsKeys.CONVERSATION)}> |
83 | 66 | <TabTitleWithIcon icon="comments"> |
|
0 commit comments