From a0747b07a747458d2a7e504442d227924eca926f Mon Sep 17 00:00:00 2001 From: Carl Poole Date: Wed, 28 Jun 2023 14:29:13 -0500 Subject: [PATCH] enhanced readme and made SUPABASE_URL const (#16) --- README.md | 35 +++++++++++++++++++ .../io/ionic/superapp/data/DataManager.kt | 7 ++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e463566..2ee2ca5 100644 --- a/README.md +++ b/README.md @@ -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. @@ -10,3 +26,22 @@ The usernames and passwords are as follows. | jeremiah@supernova.com | il0vedogs | contractor | tanya@supernova.com | il0vedogs | manger | trevor@supernova.com | 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. \ No newline at end of file diff --git a/android/app/src/main/java/io/ionic/superapp/data/DataManager.kt b/android/app/src/main/java/io/ionic/superapp/data/DataManager.kt index b092b07..254aa20 100644 --- a/android/app/src/main/java/io/ionic/superapp/data/DataManager.kt +++ b/android/app/src/main/java/io/ionic/superapp/data/DataManager.kt @@ -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 @@ -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) @@ -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) }