From 6dae6ba53cff327faf07f616c8c3f487a5ef537e Mon Sep 17 00:00:00 2001 From: Nuwan Chathuranga Date: Tue, 28 Sep 2021 19:38:47 +0530 Subject: [PATCH] write README for setting up app in dev --- jam-ui/.env.development | 2 -- jam-ui/.env.development.example | 4 +++ jam-ui/.env.production | 2 ++ jam-ui/README.md | 35 +++++++++++++++++--- jam-ui/package.json | 2 +- jam-ui/src/components/auth/JKLoginRequest.js | 4 +-- web/config/environments/development.rb | 2 +- 7 files changed, 41 insertions(+), 10 deletions(-) delete mode 100644 jam-ui/.env.development create mode 100644 jam-ui/.env.development.example diff --git a/jam-ui/.env.development b/jam-ui/.env.development deleted file mode 100644 index cc7c8f542..000000000 --- a/jam-ui/.env.development +++ /dev/null @@ -1,2 +0,0 @@ -REACT_APP_LEGACY_BASE_URL=http://www.jamkazam.local:4000 -REACT_APP_API_BASE_URL=http://www.jamkazam.local:4000/api \ No newline at end of file diff --git a/jam-ui/.env.development.example b/jam-ui/.env.development.example new file mode 100644 index 000000000..f72ec5e39 --- /dev/null +++ b/jam-ui/.env.development.example @@ -0,0 +1,4 @@ +HOST=beta.jamkazam.local +PORT=4000 +REACT_APP_LEGACY_BASE_URL=http://www.jamkazam.local:3000 +REACT_APP_API_BASE_URL=http://www.jamkazam.local:3000/api \ No newline at end of file diff --git a/jam-ui/.env.production b/jam-ui/.env.production index 64ac8589a..ba470e2f9 100644 --- a/jam-ui/.env.production +++ b/jam-ui/.env.production @@ -1,2 +1,4 @@ +HOST=beta.jamkazam.com +PORT=4000 REACT_APP_LEGACY_BASE_URL=https://www.jamkazam.com REACT_APP_API_BASE_URL=https://www.jamkazam.com/api \ No newline at end of file diff --git a/jam-ui/README.md b/jam-ui/README.md index cdbe4dd39..9ab81eefa 100644 --- a/jam-ui/README.md +++ b/jam-ui/README.md @@ -1,4 +1,31 @@ -## Falcon, a theme by ThemeWagon team. ---- -Get the figma design file here: -[https://www.figma.com/file/wX672ke9PvFbwGNiCxefAd/Falcon-Design](https://www.figma.com/file/wX672ke9PvFbwGNiCxefAd/Falcon-Design) \ No newline at end of file +# JamKazam new react frontend UI/UX + +## Running react app + +In production this React app is supposed to run on beta.jamkazam.com subdomain which is same origin domain to the production Rails app (www.jamkazam.com). This way we utilize same session based user authentication of Rails web app for authenticating users. (It looks for remember_token session cookie in headers and if it is not availale redirect the user to Rails web app sign in page) + +The DOMAIN and PORT running this app is defined in env.production file. This file also has env variables for connecting with Rails app. (When setting up in development you can copy the content of env.development.example in to env.development.local and change them according to your host setup) + +HOST=beta.jamkazam.local +PORT=4000 +REACT_APP_LEGACY_BASE_URL=http://www.jamkazam.local:3000 +REACT_APP_API_BASE_URL=http://www.jamkazam.local:3000/api + +## Subdomains setup (development) + +You need 2 host records created for React and and Rails app. For example + +127.0.0.1 www.jamkazam.local #for Rails app +127.0.0.1 beta.jamkazam.local #for React app + +## Installing npm dependencies +cd jam-ui +npm install + +## Running the app + +cd jam-ui +npm run start + +This will open it in a borwser window at http://beta.jamkazam.local:3000. Of course for it to work you also need Rails (web) app and websocket app (websocket-gateway) running. + diff --git a/jam-ui/package.json b/jam-ui/package.json index 92d75d58c..aeaf8bde4 100644 --- a/jam-ui/package.json +++ b/jam-ui/package.json @@ -75,7 +75,7 @@ "uuid": "^3.4.0" }, "scripts": { - "start": "HOST=beta.jamkazam.local react-scripts start", + "start": "react-scripts start", "build": "react-scripts build", "eject": "react-scripts eject", "scss": "gulp", diff --git a/jam-ui/src/components/auth/JKLoginRequest.js b/jam-ui/src/components/auth/JKLoginRequest.js index 285b35fa4..9435f28f2 100644 --- a/jam-ui/src/components/auth/JKLoginRequest.js +++ b/jam-ui/src/components/auth/JKLoginRequest.js @@ -8,13 +8,13 @@ function JKLoginRequest() {
- +

Signin to begin

Please login to your jamkazam account before accessing this interface.

- + Signin
diff --git a/web/config/environments/development.rb b/web/config/environments/development.rb index 3a024394b..0a787bc04 100644 --- a/web/config/environments/development.rb +++ b/web/config/environments/development.rb @@ -117,7 +117,7 @@ SampleApp::Application.configure do config.latency_data_host = "http://localhost:4001/local" config.latency_data_host_auth_code = "c2VydmVyOnBhc3N3b3Jk" - config.spa_origin = "http://beta.jamkazam.local:3000" + config.spa_origin = "http://beta.jamkazam.local:4000" config.session_cookie_domain = ".jamkazam.local" end