diff --git a/frontend/.env b/frontend/.env
index cb285291..b6b98fb1 100644
--- a/frontend/.env
+++ b/frontend/.env
@@ -1 +1,5 @@
-VITE_OPEN_COLLECTIVE_API_KEY=your_key
\ No newline at end of file
+VITE_OPEN_COLLECTIVE_API_KEY=your_key
+
+VITE_API_URL=https://api.utopia-lab.org
+VITE_VALIDATE_INVITE_FLOW_ID=01d61db0-25aa-4bfa-bc24-c6a8f208a455
+VITE_REDEEM_INVITE_FLOW_ID=todo
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index 82dc26f8..f0de565d 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -175,6 +175,7 @@ function App() {
}>
+ } />
} />
} />
{
+ try {
+ const response = await fetch(
+ `${config.apiUrl}/flows/trigger/${config.validateInviteFlowId}/${inviteId}`,
+ {
+ method: 'GET',
+ mode: 'cors',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ },
+ )
+
+ if (!response.ok) {
+ return null
+ }
+
+ const data = (await response.json()) as InvitingProfileResponse
+
+ return data.id
+ } catch (error: unknown) {
+ // eslint-disable-next-line no-console
+ console.error('Error fetching inviting profile:', error)
+ if (error instanceof Error && error.message) {
+ throw new Error(error.message)
+ } else {
+ throw new Error('An unknown error occurred while fetching the inviting profile.')
+ }
+ }
+ }
+
+ async validateInvite(inviteId: string): Promise {
+ const invitingProfileId = await this.getInvitingProfileId(inviteId)
+
+ return invitingProfileId !== null
+ }
+
+ async redeemInvite(inviteId: string): Promise {
+ try {
+ const response = await fetch(
+ `${config.apiUrl}/flows/trigger/${config.redeemInviteFlowId}/${inviteId}`,
+ {
+ method: 'GET',
+ mode: 'cors',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ },
+ )
+
+ return response.ok
+ } catch (error: unknown) {
+ // eslint-disable-next-line no-console
+ console.error('Error fetching inviting profile:', error)
+ if (error instanceof Error && error.message) {
+ throw new Error(error.message)
+ } else {
+ throw new Error('An unknown error occurred while fetching the inviting profile.')
+ }
+ }
+ }
+}
diff --git a/frontend/src/config/index.ts b/frontend/src/config/index.ts
new file mode 100644
index 00000000..c908112c
--- /dev/null
+++ b/frontend/src/config/index.ts
@@ -0,0 +1,7 @@
+export const config = {
+ apiUrl: String(import.meta.env.VITE_API_URL ?? 'https://api.utopia-lab.org'),
+ validateInviteFlowId: String(
+ import.meta.env.VITE_VALIDATE_INVITE_FLOW_ID ?? '01d61db0-25aa-4bfa-bc24-c6a8f208a455',
+ ),
+ redeemInviteFlowId: String(import.meta.env.VITE_REDEEM_INVITE_FLOW_ID ?? 'todo'),
+}
diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json
index 9720a1eb..f7d59d5e 100644
--- a/frontend/tsconfig.json
+++ b/frontend/tsconfig.json
@@ -17,8 +17,14 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
- "noFallthroughCasesInSwitch": true
+ "noFallthroughCasesInSwitch": true,
+
+ /* Paths */
+ "baseUrl": ".",
+ "paths": {
+ "@/*": ["src/*"],
+ }
},
- "include": ["src"],
+ "include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}