diff --git a/apps/console/app/routes/groups.enroll.$groupID.$invitationCode.tsx b/apps/console/app/routes/groups.enroll.$groupID.$invitationCode.tsx
index 57f4acd020..b35e2afd1b 100644
--- a/apps/console/app/routes/groups.enroll.$groupID.$invitationCode.tsx
+++ b/apps/console/app/routes/groups.enroll.$groupID.$invitationCode.tsx
@@ -159,7 +159,7 @@ export const action: ActionFunction = getRollupReqFunctionErrorWrapper(
identityGroupURN,
})
- return redirect(`/groups/${groupID}`)
+ return redirect(`/onboarding`)
}
)
diff --git a/apps/console/app/routes/onboarding.tsx b/apps/console/app/routes/onboarding.tsx
index e0a8194978..54b1906a83 100644
--- a/apps/console/app/routes/onboarding.tsx
+++ b/apps/console/app/routes/onboarding.tsx
@@ -24,6 +24,7 @@ import { HiOutlineBookOpen, HiOutlineLogout } from 'react-icons/hi'
import { TbUserCog } from 'react-icons/tb'
import useConnectResult from '@proofzero/design-system/src/hooks/useConnectResult'
import { Toaster } from '@proofzero/design-system/src/atoms/toast'
+import { IdentityGroupURN } from '@proofzero/urns/identity-group'
export const loader: LoaderFunction = getRollupReqFunctionErrorWrapper(
async ({ request, context }) => {
@@ -53,11 +54,20 @@ export const loader: LoaderFunction = getRollupReqFunctionErrorWrapper(
})
const connectedEmails = getEmailDropdownItems(connectedAccounts)
+ const igs = await coreClient.identity.listIdentityGroups.query()
+ const targetIG =
+ igs[0] &&
+ igs[0].members.length > 1 &&
+ igs[0].members[0].URN !== identityURN
+ ? igs[0]
+ : undefined
+
return json({
url: request.url,
profile,
connectedEmails,
PASSPORT_URL: context.env.PASSPORT_URL,
+ targetIG,
})
}
)
@@ -77,14 +87,22 @@ export const shouldRevalidate = ({
}
export default function Onboarding() {
- const { connectedEmails, PASSPORT_URL, profile, url } = useLoaderData<{
- connectedEmails: DropdownSelectListItem[]
- PASSPORT_URL: string
- profile: Profile
- url: string
- }>()
+ const { connectedEmails, PASSPORT_URL, profile, url, targetIG } =
+ useLoaderData<{
+ connectedEmails: DropdownSelectListItem[]
+ PASSPORT_URL: string
+ profile: Profile
+ url: string
+ targetIG:
+ | {
+ name: string
+ URN: IdentityGroupURN
+ }
+ | undefined
+ }>()
- const currentPage = new URL(url).searchParams.get('rollup_result') ? 1 : 0
+ const currentPage =
+ new URL(url).searchParams.get('rollup_result') || targetIG ? 1 : 0
useConnectResult()
@@ -100,7 +118,9 @@ export default function Onboarding() {
'basis-full 2xl:basis-2/5 flex items-start justify-center py-[2.5%] h-full'
}
>
-
+
{
@@ -35,7 +36,7 @@ export const action: ActionFunction = getRollupReqFunctionErrorWrapper(
...generateTraceContextHeaders(context.traceSpan),
})
- try {
+ const createApp = async (formData: FormData) => {
const clientName = formData.get('clientName') as string
const account = formData.get('account') as AccountURN
@@ -52,12 +53,60 @@ export const action: ActionFunction = getRollupReqFunctionErrorWrapper(
clientId,
})
- return json({ clientId, success: true })
- } catch (error) {
- console.error({ error })
- return new InternalServerError({
- message: 'Could not create the application',
+ return {
+ clientId,
+ success: true,
+ }
+ }
+
+ const createGroup = async (formData: FormData) => {
+ const groupName = formData.get('groupName') as undefined | string
+
+ if (!groupName?.length) {
+ throw new BadRequestError({
+ message: 'Group name is required',
+ })
+ }
+
+ const { groupID } = await coreClient.identity.createIdentityGroup.mutate({
+ name: groupName,
})
+
+ return {
+ groupID,
+ success: true,
+ }
+ }
+
+ switch (formData.get('op')) {
+ case 'createApp':
+ try {
+ const { clientId, success: createAppSuccess } = await createApp(
+ formData
+ )
+
+ return json({ clientId, success: createAppSuccess })
+ } catch (error) {
+ return new InternalServerError({
+ message: 'Could not create the application',
+ })
+ }
+ case 'createGroup':
+ try {
+ const { groupID, success: createGroupSuccess } = await createGroup(
+ formData
+ )
+
+ return json({ groupID, success: createGroupSuccess })
+ } catch (error) {
+ return new InternalServerError({
+ message: 'Could not create the group',
+ })
+ }
+ default:
+ throw new BadRequestError({
+ message: 'Invalid operation',
+ })
}
}
)
@@ -82,8 +131,9 @@ const Option = ({
return (
{
if (disabled) return
setSelectedType(type)
@@ -121,8 +171,9 @@ const SelectOrgType = ({
return (
1/4
@@ -138,17 +189,16 @@ const SelectOrgType = ({
header="I'm solo developer"
description="I'm setting up app for myself"
selected={orgType === 'solo'}
- setSelectedType={setOrgType}
+ setSelectedType={() => setOrgType('solo')}
type="solo"
/>