-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dashboard): switch to synchronous onboarding flow (#1173)
- Loading branch information
Showing
15 changed files
with
209 additions
and
134 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
ui/apps/dashboard/src/app/(auth)/ReloadClerkAndRedirect.tsx
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,33 @@ | ||
'use client'; | ||
|
||
import { useEffect } from 'react'; | ||
import { useUser } from '@clerk/nextjs'; | ||
|
||
import LoadingIcon from '@/icons/LoadingIcon'; | ||
|
||
type ReloadClerkAndRedirectProps = { | ||
redirectURL: string; | ||
}; | ||
|
||
/** | ||
* This is used to reload Clerk on the client before redirecting to a new page. This is needed when | ||
* we update some Clerk data on the server and need to ensure that the client has the latest data | ||
* before redirecting. | ||
* | ||
* @param {string} redirectURL - The URL to redirect to after reloading Clerk | ||
*/ | ||
export default function ReloadClerkAndRedirect({ redirectURL }: ReloadClerkAndRedirectProps) { | ||
const { user } = useUser(); | ||
|
||
useEffect(() => { | ||
user?.reload().then(() => { | ||
window.location.href = redirectURL; | ||
}); | ||
}, [user, redirectURL]); | ||
|
||
return ( | ||
<div className="flex h-full w-full items-center justify-center"> | ||
<LoadingIcon /> | ||
</div> | ||
); | ||
} |
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
27 changes: 27 additions & 0 deletions
27
ui/apps/dashboard/src/app/(auth)/create-organization/set-up/error.tsx
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,27 @@ | ||
'use client'; | ||
|
||
import { useEffect } from 'react'; | ||
import { ExclamationCircleIcon } from '@heroicons/react/20/solid'; | ||
import { Button } from '@inngest/components/Button'; | ||
import * as Sentry from '@sentry/nextjs'; | ||
|
||
type OrganizationSetupErrorProps = { | ||
error: Error & { digest?: string }; | ||
reset: () => void; | ||
}; | ||
|
||
export default function OrganizationSetupError({ error }: OrganizationSetupErrorProps) { | ||
useEffect(() => { | ||
Sentry.captureException(new Error('Failed to set up organization', { cause: error })); | ||
}, [error]); | ||
|
||
return ( | ||
<div className="flex h-full w-full flex-col items-center justify-center gap-5"> | ||
<div className="inline-flex items-center gap-2 text-red-600"> | ||
<ExclamationCircleIcon className="h-4 w-4" /> | ||
<h2 className="text-sm">Failed to set up your organization</h2> | ||
</div> | ||
<Button label="Contact Support" appearance="outlined" href="/support" /> | ||
</div> | ||
); | ||
} |
9 changes: 9 additions & 0 deletions
9
ui/apps/dashboard/src/app/(auth)/create-organization/set-up/loading.tsx
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,9 @@ | ||
import LoadingIcon from '@/icons/LoadingIcon'; | ||
|
||
export default function OrganizationSetupLoading() { | ||
return ( | ||
<div className="flex h-full w-full items-center justify-center"> | ||
<LoadingIcon /> | ||
</div> | ||
); | ||
} |
18 changes: 18 additions & 0 deletions
18
ui/apps/dashboard/src/app/(auth)/create-organization/set-up/page.tsx
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,18 @@ | ||
import ReloadClerkAndRedirect from '@/app/(auth)/ReloadClerkAndRedirect'; | ||
import { graphql } from '@/gql'; | ||
import graphqlAPI from '@/queries/graphqlAPI'; | ||
|
||
const SetUpAccountDocument = graphql(` | ||
mutation SetUpAccount { | ||
setUpAccount { | ||
account { | ||
id | ||
} | ||
} | ||
} | ||
`); | ||
|
||
export default async function OrganizationSetupPage() { | ||
await graphqlAPI.request(SetUpAccountDocument); | ||
return <ReloadClerkAndRedirect redirectURL="/env/production/apps" />; | ||
} |
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
108 changes: 0 additions & 108 deletions
108
ui/apps/dashboard/src/app/(auth)/sign-up/account-setup/page.tsx
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use client'; | ||
|
||
import { useEffect } from 'react'; | ||
import { useRouter } from 'next/navigation'; | ||
import { useAuth } from '@clerk/nextjs'; | ||
import { ExclamationCircleIcon } from '@heroicons/react/20/solid'; | ||
import { Button } from '@inngest/components/Button'; | ||
import * as Sentry from '@sentry/nextjs'; | ||
|
||
type UserSetupErrorProps = { | ||
error: Error & { digest?: string }; | ||
reset: () => void; | ||
}; | ||
|
||
export default function UserSetupError({ error }: UserSetupErrorProps) { | ||
const { signOut } = useAuth(); | ||
const router = useRouter(); | ||
|
||
useEffect(() => { | ||
Sentry.captureException(new Error('Failed to set up user', { cause: error })); | ||
}, [error]); | ||
|
||
return ( | ||
<div className="flex h-full w-full flex-col items-center justify-center gap-5"> | ||
<div className="inline-flex items-center gap-2 text-red-600"> | ||
<ExclamationCircleIcon className="h-4 w-4" /> | ||
<h2 className="text-sm">Failed to set up your user</h2> | ||
</div> | ||
<Button | ||
label="Contact Support" | ||
appearance="outlined" | ||
btnAction={() => { | ||
signOut(() => router.push('/support')); | ||
}} | ||
/> | ||
</div> | ||
); | ||
} |
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,9 @@ | ||
import LoadingIcon from '@/icons/LoadingIcon'; | ||
|
||
export default function UserSetupLoading() { | ||
return ( | ||
<div className="flex h-full w-full items-center justify-center"> | ||
<LoadingIcon /> | ||
</div> | ||
); | ||
} |
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,18 @@ | ||
import ReloadClerkAndRedirect from '@/app/(auth)/ReloadClerkAndRedirect'; | ||
import { graphql } from '@/gql'; | ||
import graphqlAPI from '@/queries/graphqlAPI'; | ||
|
||
const CreateUserDocument = graphql(` | ||
mutation CreateUser { | ||
createUser { | ||
user { | ||
id | ||
} | ||
} | ||
} | ||
`); | ||
|
||
export default async function UserSetupPage() { | ||
await graphqlAPI.request(CreateUserDocument); | ||
return <ReloadClerkAndRedirect redirectURL="/organization-list" />; | ||
} |
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
Oops, something went wrong.