-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
573b5d5
commit d74f3e7
Showing
12 changed files
with
83 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { SessionTask } from '@clerk/types'; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const sessionTaskRoutePaths: Record<SessionTask['key'], string> = { | ||
org: 'select-organization', | ||
}; |
46 changes: 0 additions & 46 deletions
46
packages/clerk-js/src/ui/components/PendingTask/PendingTask.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { useSessionContext } from '@clerk/shared/react/index'; | ||
import type { SessionTask } from '@clerk/types'; | ||
import type { ComponentType } from 'react'; | ||
|
||
import { OrganizationListContext } from '../../contexts'; | ||
import { OrganizationList } from '../OrganizationList'; | ||
|
||
const TaskRegistry: Record<SessionTask['key'], ComponentType> = { | ||
org: () => ( | ||
<OrganizationListContext.Provider value={{ componentName: 'OrganizationList', hidePersonal: true }}> | ||
<OrganizationList /> | ||
</OrganizationListContext.Provider> | ||
), | ||
}; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export function Task(): React.ReactNode { | ||
const session = useSessionContext(); | ||
|
||
if (!session?.hasTask) { | ||
return null; | ||
} | ||
|
||
const [task] = session.tasks ?? []; | ||
const Task = TaskRegistry[task.key]; | ||
|
||
return <Task />; | ||
} |
1 change: 1 addition & 0 deletions
1
packages/clerk-js/src/ui/components/Task/__tests__/PendingTask.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// todo |
1 change: 1 addition & 0 deletions
1
packages/clerk-js/src/ui/components/Task/__tests__/usePendingTaskRoute.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// todo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useSessionContext } from '@clerk/shared/react/index'; | ||
import type { Route } from '@clerk/shared/router'; | ||
import type { ComponentProps } from 'react'; | ||
|
||
import { sessionTaskRoutePaths } from '../../common/tasks'; | ||
import { Task } from './Task'; | ||
|
||
/** | ||
* Maps a session task key to routing props and content | ||
* @internal | ||
*/ | ||
export function useTaskRoute(): ComponentProps<typeof Route> | null { | ||
const session = useSessionContext(); | ||
|
||
if (!session?.hasTask) { | ||
return null; | ||
} | ||
|
||
const [task] = session.tasks ?? []; | ||
|
||
return { | ||
children: <Task />, | ||
path: sessionTaskRoutePaths[task.key], | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters