Skip to content

Commit fe1c8b7

Browse files
committed
Move buildTaskRedirectUrl into ui/utils to avoid import issues
1 parent 05105f8 commit fe1c8b7

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

packages/clerk-js/src/core/sessionTasks.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { logger } from '@clerk/shared/logger';
22
import type { ClerkOptions, SessionTask, SetActiveParams } from '@clerk/types';
33

4-
import { buildRedirectUrl } from '@/ui/common';
54
import { buildURL } from '@/utils';
65

76
/**
@@ -11,26 +10,10 @@ export const INTERNAL_SESSION_TASK_ROUTE_BY_KEY: Record<SessionTask['key'], stri
1110
'choose-organization': 'choose-organization',
1211
} as const;
1312

14-
const getTaskEndpoint = (task: SessionTask) => `/tasks/${INTERNAL_SESSION_TASK_ROUTE_BY_KEY[task.key]}`;
15-
1613
/**
1714
* @internal
1815
*/
19-
export function buildTaskRedirectUrl(
20-
task: SessionTask,
21-
opts: Omit<Parameters<typeof buildRedirectUrl>[0], 'endpoint'>,
22-
) {
23-
const { path, routing, baseUrl, authQueryString } = opts;
24-
const endpoint = getTaskEndpoint(task);
25-
26-
return buildRedirectUrl({
27-
baseUrl,
28-
path,
29-
routing,
30-
endpoint,
31-
authQueryString,
32-
});
33-
}
16+
export const getTaskEndpoint = (task: SessionTask) => `/tasks/${INTERNAL_SESSION_TASK_ROUTE_BY_KEY[task.key]}`;
3417

3518
/**
3619
* @internal

packages/clerk-js/src/ui/contexts/components/SignIn.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { isAbsoluteUrl } from '@clerk/shared/url';
33
import type { SessionResource } from '@clerk/types';
44
import { createContext, useContext, useMemo } from 'react';
55

6-
import { buildTaskRedirectUrl, INTERNAL_SESSION_TASK_ROUTE_BY_KEY } from '@/core/sessionTasks';
6+
import { INTERNAL_SESSION_TASK_ROUTE_BY_KEY } from '@/core/sessionTasks';
7+
import { buildTaskRedirectUrl } from '@/ui/utils/buildTaskRedirectUrl';
78

89
import { SIGN_IN_INITIAL_VALUE_KEYS } from '../../../core/constants';
910
import { buildURL } from '../../../utils';

packages/clerk-js/src/ui/contexts/components/SignUp.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { isAbsoluteUrl } from '@clerk/shared/url';
33
import type { SessionResource } from '@clerk/types';
44
import { createContext, useContext, useMemo } from 'react';
55

6-
import { buildTaskRedirectUrl, INTERNAL_SESSION_TASK_ROUTE_BY_KEY } from '@/core/sessionTasks';
6+
import { INTERNAL_SESSION_TASK_ROUTE_BY_KEY } from '@/core/sessionTasks';
7+
import { buildTaskRedirectUrl } from '@/ui/utils/buildTaskRedirectUrl';
78

89
import { SIGN_UP_INITIAL_VALUE_KEYS } from '../../../core/constants';
910
import { buildURL } from '../../../utils';
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type { SessionTask } from '@clerk/types';
2+
3+
import { getTaskEndpoint } from '@/core/sessionTasks';
4+
import { buildRedirectUrl } from '@/ui/common';
5+
6+
/**
7+
* @internal
8+
*/
9+
export function buildTaskRedirectUrl(
10+
task: SessionTask,
11+
opts: Omit<Parameters<typeof buildRedirectUrl>[0], 'endpoint'>,
12+
) {
13+
const { path, routing, baseUrl, authQueryString } = opts;
14+
const endpoint = getTaskEndpoint(task);
15+
16+
return buildRedirectUrl({
17+
baseUrl,
18+
path,
19+
routing,
20+
endpoint,
21+
authQueryString,
22+
});
23+
}

0 commit comments

Comments
 (0)