Skip to content

Commit 0d78ed5

Browse files
update gatsby env variable, remove destructuring
1 parent 2c03e75 commit 0d78ed5

File tree

14 files changed

+23
-41
lines changed

14 files changed

+23
-41
lines changed

gatsby-node.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@ const paginatedCollectionQuery = (paginatedName) => {
4141

4242
exports.createPages = async ({ graphql, actions }) => {
4343
const { createPage } = actions;
44-
const { GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT } = process.env;
45-
4644
try {
4745
// eslint-disable-next-line
48-
const specialBadgesApi = `${GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/special-badges`;
46+
const specialBadgesApi = `${process.env.GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/special-badges`;
4947
const getSpecialBadges = await axios({
5048
method: 'GET',
5149
url: specialBadgesApi,
@@ -75,7 +73,7 @@ exports.createPages = async ({ graphql, actions }) => {
7573

7674
try {
7775
// eslint-disable-next-line max-len
78-
const replaysApi = `${GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/replays?active=true`;
76+
const replaysApi = `${process.env.GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/replays?active=true`;
7977
const getReplays = await axios({
8078
method: 'GET',
8179
url: replaysApi,

src/components/Footer/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ import Feedback from '../Feedback/index';
88
import AuthService from '../../services/auth.service';
99
// import { AppContext } from '../../providers/AppProvider';
1010

11-
const { GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT } = process.env;
12-
1311
export const Footer = () => {
1412
const [isSubmissionSuccess, setIsSubmissionSuccess] = useState(undefined);
1513
const sendEmail = (data) => {
1614
axios({
1715
method: 'POST',
18-
url: `${GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/email/send-feedback`,
16+
url: `${process.env.GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/email/send-feedback`,
1917
headers: {
2018
'x-access-token': AuthService.getCurrentUser().accessToken,
2119
},

src/components/Header/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import { AppContext } from '../../providers/AppProvider';
1616
import { ButtonLink } from '..';
1717
import { UserMenu } from './UserMenu';
1818

19-
const { GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT } = process.env;
20-
const { GATSBY_COCKPIT_HPE_OAUTH } = process.env;
2119

2220
// const { GATSBY_CLIENT_ID } = process.env;
2321
// const { GATSBY_CLIENT_OAUTH } = process.env;
@@ -145,9 +143,9 @@ function Header() {
145143

146144
console.log(
147145
'Sign in URL+++',
148-
`${GATSBY_COCKPIT_HPE_OAUTH}?redirectUri=${redirectURI}`,
146+
`${process.env.GATSBY_COCKPIT_HPE_OAUTH}?redirectUri=${redirectURI}`,
149147
);
150-
window.location.href = `${GATSBY_COCKPIT_HPE_OAUTH}?redirectUri=${redirectURI}`;
148+
window.location.href = `${process.env.GATSBY_COCKPIT_HPE_OAUTH}?redirectUri=${redirectURI}`;
151149
};
152150
// const hanldeGitHubSignIn = () => {
153151
// window.location.href = `${GATSBY_CLIENT_OAUTH}?scope=user&client_id=${GATSBY_CLIENT_ID}&redirect_uri=${GATSBY_REDIRECT_URI}`;
@@ -163,7 +161,7 @@ function Header() {
163161
window.history.pushState({}, null, newUrl[0]);
164162
axios
165163
.post(
166-
`${GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/users/github-auth`,
164+
`${process.env.GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/users/github-auth`,
167165
{
168166
code: newUrl[1],
169167
},

src/components/hackshack/Card/ScheduleCard.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ import AuthService from '../../../services/auth.service';
2929
import { AppContext } from '../../../providers/AppProvider';
3030
import Share from '../Share';
3131

32-
const { GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT } = process.env;
33-
3432
export const UnregisterLayer = ({
3533
formData,
3634
setFormData,
@@ -65,7 +63,7 @@ export const UnregisterLayer = ({
6563
axios({
6664
method: 'GET',
6765
// eslint-disable-next-line max-len
68-
url: `${GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/customers/${customerId}`,
66+
url: `${process.env.GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/customers/${customerId}`,
6967
headers: {
7068
'x-access-token': AuthService.getCurrentUser().accessToken,
7169
},
@@ -74,7 +72,7 @@ export const UnregisterLayer = ({
7472
axios({
7573
method: 'GET',
7674
// eslint-disable-next-line max-len
77-
url: `${GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/students/${customerData.data.studentId}`,
75+
url: `${process.env.GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/students/${customerData.data.studentId}`,
7876
headers: {
7977
'x-access-token': AuthService.getCurrentUser().accessToken,
8078
},
@@ -88,7 +86,7 @@ export const UnregisterLayer = ({
8886
axios({
8987
method: 'PUT',
9088
// eslint-disable-next-line max-len
91-
url: `${GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/customer/unregister/${customerId}`,
89+
url: `${process.env.GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/customer/unregister/${customerId}`,
9290
headers: {
9391
'x-access-token': AuthService.getCurrentUser().accessToken,
9492
},
@@ -268,7 +266,7 @@ export const SignupLayer = ({
268266
const postCustomer = () => {
269267
axios({
270268
method: 'POST',
271-
url: `${GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/customer`,
269+
url: `${process.env.GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/customer`,
272270
headers: {
273271
'x-access-token': AuthService.getCurrentUser().accessToken,
274272
},
@@ -611,11 +609,11 @@ const ScheduleCard = ({
611609
switch (sessionType) {
612610
case 'Workshops-on-Demand':
613611
backgroundColor = '#263040';
614-
uri = `${GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/workshops/`;
612+
uri = `${process.env.GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/workshops/`;
615613
break;
616614
case 'Coding Challenge':
617615
backgroundColor = 'rgba(155, 99, 16, 0.8)';
618-
uri = `${GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/workshops/`;
616+
uri = `${process.env.GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/workshops/`;
619617
break;
620618
default:
621619
backgroundColor = 'background';

src/containers/EmailCapture/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
import { Link } from '../../components';
1616
import { AppContext } from '../../providers/AppProvider';
1717

18-
const { GATSBY_NEWSLETTER_API } = process.env;
1918

2019
const emailValidation = [
2120
{
@@ -58,7 +57,7 @@ export const EmailCapture = ({ children, heading, bodyCopy1, bodyCopy2 }) => {
5857
setErrorMsg('');
5958
const { email } = formData;
6059
const listId = 14530343;
61-
return fetch(GATSBY_NEWSLETTER_API, {
60+
return fetch(process.env.GATSBY_NEWSLETTER_API, {
6261
method: 'POST',
6362
headers: new Headers({
6463
'content-type': 'application/json',

src/hack-shack-attack/scenes/gameSceneMethods.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,7 @@ function gameSceneMethods(GameScene, Phaser) {
408408
};
409409

410410
GameScene.getLeaderboard = function getLeaderboard() {
411-
const { GATSBY_NETLIFY_ENDPOINT } = process.env;
412-
return fetch(`${GATSBY_NETLIFY_ENDPOINT}/getLeaderboard`, {
411+
return fetch(`${process.env.GATSBY_NETLIFY_ENDPOINT}/getLeaderboard`, {
413412
method: 'GET',
414413
})
415414
.then((res) => res.json())

src/hack-shack-attack/scenes/highScoreSceneMethods.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,7 @@ function highScoreSceneMethods(HighScoreScene, Phaser) {
307307
) {
308308
this.loading = true;
309309
const data = { initials, name, score };
310-
const { GATSBY_NETLIFY_ENDPOINT } = process.env;
311-
return fetch(`${GATSBY_NETLIFY_ENDPOINT}/postLeaderboard`, {
310+
return fetch(`${process.env.GATSBY_NETLIFY_ENDPOINT}/postLeaderboard`, {
312311
method: 'POST',
313312
body: JSON.stringify(data),
314313
})

src/hack-shack-attack/scenes/titleSceneMethods.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,7 @@ function titleSceneMethods(TitleScene, Phaser) {
232232
};
233233

234234
TitleScene.getLeaderboard = function getLeaderboard() {
235-
const { GATSBY_NETLIFY_ENDPOINT } = process.env;
236-
return fetch(`${GATSBY_NETLIFY_ENDPOINT}/getLeaderboard`, {
235+
return fetch(`${process.env.GATSBY_NETLIFY_ENDPOINT}/getLeaderboard`, {
237236
method: 'GET',
238237
})
239238
.then((res) => res.json())

src/pages/evangelist/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ function Evangelist({ data }) {
168168
const postEvangelist = () => {
169169
axios({
170170
method: 'POST',
171-
url: `${GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/evangelist`,
171+
url: `${process.env.GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/evangelist`,
172172
headers: {
173173
'x-access-token': AuthService.getCurrentUser().accessToken,
174174
},

src/pages/hackshack/challenges/template.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ const renderScheduleCard = (workshop, i) => (
3333
);
3434

3535
const Challenge = (props) => {
36-
const { GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT } = process.env;
37-
const getWorkshopsApi = `${GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/workshops?active=true`;
36+
const getWorkshopsApi = `${process.env.GATSBY_WORKSHOPCHALLENGE_API_ENDPOINT}/api/workshops?active=true`;
3837
const [workshops, setworkshops] = useState([]);
3938
const [error, setError] = useState('');
4039
const arr = [];

0 commit comments

Comments
 (0)