Skip to content

Commit

Permalink
Merge branch 'feat/dashbaordApiCalls' of github.com:bcgov/nr-silva in…
Browse files Browse the repository at this point in the history
…to feat/dashbaordApiCalls
  • Loading branch information
jazzgrewal committed May 23, 2024
2 parents 570de9e + dcce449 commit 1147b72
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion frontend/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}
handle /env.js {
header Content-Type "text/javascript"
respond `window.config = {"VITE_USER_POOLS_WEB_CLIENT_ID":"{$VITE_USER_POOLS_WEB_CLIENT_ID}","VITE_ZONE":"{$VITE_ZONE}","VITE_BACKEND_URL":"{$VITE_BACKEND_URL}"};`
respond `window.config = {"VITE_USER_POOLS_WEB_CLIENT_ID":"{$VITE_USER_POOLS_WEB_CLIENT_ID}","VITE_ZONE":"{$VITE_ZONE}","VITE_BACKEND_URL":"{$VITE_BACKEND_URL}","BACKEND_URL":"{$BACKEND_URL}"};`
}

handle_path /* {
Expand Down
2 changes: 2 additions & 0 deletions frontend/openshift.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ objects:
imagePullPolicy: Always
name: ${NAME}
env:
- name: BACKEND_URL
value: "https://${NAME}-${ZONE}-backend.${DOMAIN}"
- name: LOG_LEVEL
value: "${LOG_LEVEL}"
- name: VITE_BACKEND_URL
Expand Down
12 changes: 7 additions & 5 deletions frontend/src/services/OpeningService.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import axios from 'axios';
import { getAuthIdToken } from './AuthService';

const backendUrl = process.env.BACKEND_URL;

export async function fetchRecentOpenings() {
let authToken = getAuthIdToken();
try {
const response = await axios.get('https://nr-silva-test-backend.apps.silver.devops.gov.bc.ca/api/openings/recent-openings?page=0&perPage=100', {
const response = await axios.get(backendUrl.concat("/api/openings/recent-openings?page=0&perPage=100"), {
headers: {
Authorization: `Bearer ${authToken}`
}
Expand Down Expand Up @@ -44,7 +46,7 @@ export async function fetchOpeningsPerYear(orgUnitCode, statusCode, entryDateSta
let authToken = await getAuthIdToken();
try {
// Construct URL with optional parameters
let url = 'https://nr-silva-test-backend.apps.silver.devops.gov.bc.ca/api/dashboard-metrics/submission-trends';
let url = backendUrl.concat("/api/dashboard-metrics/submission-trends");
if (orgUnitCode || statusCode || entryDateStart || entryDateEnd) {
url += '?';
if (orgUnitCode) url += `orgUnitCode=${orgUnitCode}&`;
Expand Down Expand Up @@ -84,7 +86,7 @@ export async function fetchOpeningsPerYear(orgUnitCode, statusCode, entryDateSta

export async function fetchFreeGrowingMilestones(orgUnitCode, clientNumber, entryDateStart, entryDateEnd) {
let authToken = await getAuthIdToken();
let url = 'https://nr-silva-test-backend.apps.silver.devops.gov.bc.ca/api/dashboard-metrics/free-growing-milestones';
let url = backendUrl.concat("/api/dashboard-metrics/free-growing-milestones");

// Construct URL with optional parameters
if (orgUnitCode || clientNumber || entryDateStart || entryDateEnd) {
Expand Down Expand Up @@ -130,7 +132,7 @@ export async function fetchRecentActions() {
let authToken = await getAuthIdToken();
try {
// Comment out the actual API call for now
// const response = await axios.get('https://nr-silva-test-backend.apps.silver.devops.gov.bc.ca/api/dashboard-metrics/my-recent-actions/requests', {
// const response = await axios.get(backendUrl.concat("/api/dashboard-metrics/my-recent-actions/requests"));
// headers: {
// Authorization: `Bearer ${authToken}`
// }
Expand Down Expand Up @@ -169,4 +171,4 @@ export async function fetchRecentActions() {
console.error('Error fetching recent actions:', error);
throw error;
}
}
}

0 comments on commit 1147b72

Please sign in to comment.