Skip to content

Commit

Permalink
enhanced readme and made SUPABASE_URL const (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlpoole authored Jun 28, 2023
1 parent e54c561 commit a0747b0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

To get started have Docker installed and then run `npx supabase start` from the root of the project.

Go into each web app directory starting with `supabaseApi` and `npm install` them. Run `npm run build` for the CRM, Human Resources, Perks, and Time Tracking apps:

```bash
cd web/
cd supabaseApi && npm install && cd ..
```

```bash
cd crm && npm install && npm build && cd ..
cd human-resources && npm install && npm build && cd ..
cd perks && npm install && npm build && cd ..
cd time-tracking && npm install && npm build && cd ..
```

Once built, the mini apps will be pulled into the Android and iOS projects automatically when the native superapps are built.

# Auth info

The usernames and passwords are as follows.
Expand All @@ -10,3 +26,22 @@ The usernames and passwords are as follows.
| [email protected] | il0vedogs | contractor
| [email protected] | il0vedogs | manger
| [email protected] | il0vedogs | sales

# Android Supabase Configuration

The Android superapp is configured to look for the Supabase instance at the default host IP address from the perspective of an emulator: `http://10.0.2.2:54321`. If you are testing this demo on a physical device you will need to change this URL to point to the host running the Supabase instance. The URL is located in the DataManager class: https://github.com/ionic-team/portals-super-app-demo/blob/e54c5617dfbe6525489426083a497f21efae4756/android/app/src/main/java/io/ionic/superapp/data/DataManager.kt#L22

# Temporary Android Workaround

The web apps are currently hardcoded to `localhost` to look for the Supabase instance but when running the Android app it needs to point to the host machine IP (default `10.0.2.2` when testing on an Android emulator). Update this hardcoded URL in the following files:

```
/web/perks/src/supabase-api/index.ts
/web/supabaseApi/supabaseApi.ts
```

Once changed, make sure to rebuild the web apps. This will be adjusted to work differently in a future update.

# Running Database Migrations

If the database has changed since your last cloning of the project, pull down updates and then run `npx supabase db reset`. Note that this will remove any data previously added to the DB.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.ionic.superapp.data

import android.content.Context
import android.util.Log
import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.createSupabaseClient
import io.github.jan.supabase.exceptions.BadRequestRestException
Expand All @@ -21,13 +19,14 @@ import org.json.JSONObject
import java.lang.Exception

class DataManager {
val SUPABASE_URL = "http://10.0.2.2:54321"

companion object {
val instance = DataManager()
}

private val client: SupabaseClient = createSupabaseClient(
supabaseUrl = "http://10.0.2.2:54321",
supabaseUrl = SUPABASE_URL,
supabaseKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0"
) {
install(GoTrue)
Expand Down Expand Up @@ -85,7 +84,7 @@ class DataManager {
fun getSessionObject(): JSONObject {
val supabaseObject = JSONObject()
session?.let {
supabaseObject.put("url","http://10.0.2.2:54321")
supabaseObject.put("url",SUPABASE_URL)
supabaseObject.put("refreshToken", it.refreshToken)
supabaseObject.put("accessToken", it.accessToken)
}
Expand Down

0 comments on commit a0747b0

Please sign in to comment.