Skip to content

Commit 09c97da

Browse files
authored
Enabling Staging-API Access on Website Dashboard (#681)
1 parent 8c27571 commit 09c97da

File tree

16 files changed

+30
-10
lines changed

16 files changed

+30
-10
lines changed

__tests__/task-requests/task-request.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ const puppeteer = require('puppeteer');
33
const { fetchedTaskRequests } = require('../../mock-data/taskRequests');
44

55
const SITE_URL = 'http://localhost:8000';
6-
// helper/loadEnv.js file causes API_BASE_URL to be stagin-api on local env url in taskRequest/index.html
7-
const API_BASE_URL = 'https://staging-api.realdevsquad.com';
6+
const API_BASE_URL = 'https://api.realdevsquad.com';
87

98
describe('Task Requests', () => {
109
let browser;

__tests__/tasks/profile-picture.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const puppeteer = require('puppeteer');
2-
const API_BASE_URL = 'https://staging-api.realdevsquad.com';
32
const { allUsersData } = require('../../mock-data/users');
3+
const API_BASE_URL = 'https://api.realdevsquad.com';
44

55
describe('Task Page - Assignee Profile Pic', () => {
66
let browser;

__tests__/users/App.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const puppeteer = require('puppeteer');
2-
const { API_BASE_URL } = require('../../constants');
32
const { filteredUsersData } = require('../../mock-data/users');
3+
const API_BASE_URL = 'https://staging-api.realdevsquad.com';
44

55
describe('App Component', () => {
66
let browser;

applications/utils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
const BASE_URL = window.API_BASE_URL;
1+
const BASE_URL =
2+
window.location.hostname === 'localhost'
3+
? 'https://staging-api.realdevsquad.com'
4+
: window.API_BASE_URL;
25
const toast = document.getElementById('toast');
36

47
function createElement({ type, attributes = {}, innerText }) {

constants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const API_BASE_URL = 'https://api.realdevsquad.com';
1+
const API_BASE_URL = window.API_BASE_URL || 'https://api.realdevsquad.com';
2+
('https://staging-sync.staging-realdevsquad-com.workers.dev');
23
const REPO_SYNC_API_URL =
34
'https://staging-sync.staging-realdevsquad-com.workers.dev';
45
const USER_MANAGEMENT_LINK = 'user-management-link';

extension-requests/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ <h2>Status</h2>
4343
<div class="extension-requests"></div>
4444
<div class="virtual"></div>
4545
</div>
46+
<script src="/helpers/loadENV.js"></script>
4647
<script src="/constants.js"></script>
4748
<script src="/extension-requests/constants.js"></script>
4849
<script src="/utils.js"></script>

groups/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<title>Discord Groups | Real Dev Squad</title>
99
<link rel="stylesheet" href="/global.css" />
1010
<link rel="stylesheet" href="/groups/style.css" />
11+
<script src="/helpers/loadENV.js"></script>
1112
<script src="/constants.js"></script>
1213
<script type="module" src="/groups/script.js" defer></script>
1314
</head>

helpers/loadENV.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
window.location.hostname !== 'dashboard.realdevsquad.com'
2-
? (window.API_BASE_URL = 'https://staging-api.realdevsquad.com')
3-
: (window.API_BASE_URL = 'https://api.realdevsquad.com');
1+
window.API_BASE_URL = 'https://api.realdevsquad.com';
2+
3+
if (
4+
window.location.hostname !== 'dashboard.realdevsquad.com' &&
5+
window.location.hostname !== 'localhost'
6+
) {
7+
window.API_BASE_URL = 'https://staging-api.realdevsquad.com';
8+
}

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<link rel="stylesheet" href="/global.css" />
99
<link rel="stylesheet" href="/style.css" />
1010
<title>Dashboard | Real Dev Squad</title>
11+
<script src="/helpers/loadENV.js"></script>
1112
<script src="/constants.js" defer></script>
1213
<script src="/utils.js" defer></script>
1314
<script type="module" src="/script.js" defer></script>

online-members/online-members.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<link rel="stylesheet" href="/global.css" />
1010
<link rel="stylesheet" href="/style.css" async />
1111
<link rel="stylesheet" href="/online-members/online-members.css" />
12+
<script src="/helpers/loadENV.js"></script>
1213
<script src="/constants.js"></script>
1314
<script src="/online-members/constants.js" defer></script>
1415
<script src="/online-members/sse-events.js" defer></script>

0 commit comments

Comments
 (0)