Skip to content

Commit

Permalink
config
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoff Kendal committed Jan 31, 2024
1 parent 99e34d9 commit 13c98c4
Show file tree
Hide file tree
Showing 65 changed files with 45 additions and 3,366 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ jobs:
tg_dir: environments/dev
tg_command: 'apply'

- name: Copy build to s3
run: aws s3 sync frontend/build s3://stumblefunk-www-dev/accreditation

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.tgz
.*.sw?
.idea
.env
terragrunt.iml
vendor
.terraform
Expand Down
3 changes: 3 additions & 0 deletions frontend/public/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var config = {
apiUrl: "https://nf2c6o0vt2.execute-api.eu-west-1.amazonaws.com/dev"
}
1 change: 1 addition & 0 deletions frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<base href="/accreditation/">
<script src="config.js"></script>
<title>Stumblefunk - Accreditation</title>
</head>
<body>
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/AdminView.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState, useEffect } from 'react';
import { Link, useNavigate } from 'react-router-dom';
import config from './config';

const AdminView = ({ groupCode, onUpdateLogin }) => {
const [groups, setGroups] = useState([]);
Expand All @@ -9,7 +8,7 @@ const AdminView = ({ groupCode, onUpdateLogin }) => {
useEffect(() => {
const fetchData = async () => {
try {
const response = await fetch(`${config.apiUrl}/groups`, {
const response = await fetch(`${window.config.apiUrl}/groups`, {
headers: {
'Authorization': groupCode,
'Content-Type': 'application/json',
Expand All @@ -28,7 +27,7 @@ const AdminView = ({ groupCode, onUpdateLogin }) => {

const handleNew = async () => {
try {
const response = await fetch(`${config.apiUrl}/group`, {
const response = await fetch(`${window.config.apiUrl}/group`, {
method: 'POST',
headers: {
'Authorization': groupCode,
Expand All @@ -51,7 +50,7 @@ const AdminView = ({ groupCode, onUpdateLogin }) => {
const handleDelete = async (groupId) => {
if (window.confirm('This will remove the group and any tickets that have been created by the group! Are you sure?')) {
try {
const response = await fetch(`${config.apiUrl}/group?group_id=${groupId}`, {
const response = await fetch(`${window.config.apiUrl}/group?group_id=${groupId}`, {
method: 'DELETE',
headers: {
'Authorization': groupCode,
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/GroupEdit.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState, useEffect } from 'react';
import { useParams } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import config from './config';

const GroupEdit = (groupCode) => {
const navigate = useNavigate();
Expand All @@ -19,7 +18,7 @@ const GroupEdit = (groupCode) => {
useEffect(() => {
const fetchData = async () => {
try {
const response = await fetch(`${config.apiUrl}/group?group_id=${group_id}`, {
const response = await fetch(`${window.config.apiUrl}/group?group_id=${group_id}`, {
headers: {
'Authorization': group_id,
},
Expand All @@ -45,7 +44,7 @@ const GroupEdit = (groupCode) => {
const handleSubmit = async (e) => {
e.preventDefault();
try {
const response = await fetch(`${config.apiUrl}/group`, {
const response = await fetch(`${window.config.apiUrl}/group`, {
method: 'PATCH',
headers: {
'Authorization': groupCode.groupCode,
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/ListTickets.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useState, useEffect } from 'react';
import config from './config';

const ListTickets = ({ groupCode, ticketType }) => {
const [groups, setGroups] = useState([]);
Expand All @@ -10,7 +9,7 @@ const ListTickets = ({ groupCode, ticketType }) => {
useEffect(() => {
const fetchGroupsData = async () => {
try {
const response = await fetch(`${config.apiUrl}/groups`, {
const response = await fetch(`${window.config.apiUrl}/groups`, {
headers: {
'Authorization': groupCode,
},
Expand All @@ -34,7 +33,7 @@ const ListTickets = ({ groupCode, ticketType }) => {
const fetchDataForGroups = async () => {
for (const group of groups) {
try {
const ticketsResponse = await fetch(`${config.apiUrl}/tickets?group_id=${group.group_id}`, {
const ticketsResponse = await fetch(`${window.config.apiUrl}/tickets?group_id=${group.group_id}`, {
headers: {
'Authorization': groupCode,
},
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/Login.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useState, useEffect } from 'react';
import config from './config';
import { useNavigate } from 'react-router-dom';


Expand All @@ -17,7 +16,7 @@ const Login = ({ onLogin }) => {

const handleLoginApi = async () => {
try {
const response = await fetch(`${config.apiUrl}/login`, {
const response = await fetch(`${window.config.apiUrl}/login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/TicketAdult.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import config from './config';

const TicketAdult = ({ groupCode }) => {
const navigate = useNavigate();
Expand All @@ -16,7 +15,7 @@ const TicketAdult = ({ groupCode }) => {
event.preventDefault();

try {
const response = await fetch(`${config.apiUrl}/ticket`, {
const response = await fetch(`${window.config.apiUrl}/ticket`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/TicketChild.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState, useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import config from './config';

const TicketChild = ({ groupCode }) => {
const navigate = useNavigate();
Expand All @@ -21,7 +20,7 @@ const TicketChild = ({ groupCode }) => {
event.preventDefault();

try {
const response = await fetch(`${config.apiUrl}/ticket`, {
const response = await fetch(`${window.config.apiUrl}/ticket`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -52,7 +51,7 @@ const TicketChild = ({ groupCode }) => {

const fetchParentData = async () => {
try {
const response = await fetch(`${config.apiUrl}/tickets?group_id=${groupCode}`, {
const response = await fetch(`${window.config.apiUrl}/tickets?group_id=${groupCode}`, {
headers: {
'Authorization': groupCode,
},
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/TicketVehicle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState, useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import config from './config';

const TicketVehicle = ({ groupCode }) => {
const navigate = useNavigate();
Expand All @@ -19,7 +18,7 @@ const TicketVehicle = ({ groupCode }) => {
event.preventDefault();

try {
const response = await fetch(`${config.apiUrl}/ticket`, {
const response = await fetch(`${window.config.apiUrl}/ticket`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -50,7 +49,7 @@ const TicketVehicle = ({ groupCode }) => {

const fetchDriverData = async () => {
try {
const response = await fetch(`${config.apiUrl}/tickets?group_id=${groupCode}`, {
const response = await fetch(`${window.config.apiUrl}/tickets?group_id=${groupCode}`, {
headers: {
'Authorization': groupCode,
},
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/Totals.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React, { useState, useEffect } from 'react';
import config from './config';

const Totals = ({ groupCode }) => {
const [totalsData, setTotalsData] = useState({});

useEffect(() => {
const fetchTotalsData = async () => {
try {
const response = await fetch(`${config.apiUrl}/groups?`, {
const response = await fetch(`${window.config.apiUrl}/groups?`, {
headers: {
'Authorization': groupCode,
},
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/UserView.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState, useEffect } from 'react';
import { Link } from 'react-router-dom';
import config from './config';

const UserView = ({ groupCode }) => {
const [groupInfo, setGroupInfo] = useState({
Expand All @@ -22,7 +21,7 @@ const UserView = ({ groupCode }) => {
const fetchData = async () => {
try {
// Make API call to fetch ticket data
const ticketResponse = await fetch(`${config.apiUrl}/tickets?group_id=${groupCode}`, {
const ticketResponse = await fetch(`${window.config.apiUrl}/tickets?group_id=${groupCode}`, {
headers: {
'Authorization': groupCode,
},
Expand All @@ -31,7 +30,7 @@ const UserView = ({ groupCode }) => {
setTickets(ticketData);

// Make additional API call to fetch group info
const groupResponse = await fetch(`${config.apiUrl}/group?group_id=${groupCode}`, {
const groupResponse = await fetch(`${window.config.apiUrl}/group?group_id=${groupCode}`, {
headers: {
'Authorization': groupCode,
},
Expand All @@ -52,7 +51,7 @@ const UserView = ({ groupCode }) => {

const handleRemoveTicket = async (ticketId) => {
try {
const response = await fetch(`${config.apiUrl}/ticket?ticket_id=${ticketId}`, {
const response = await fetch(`$window.config.apiUrl}/ticket?ticket_id=${ticketId}`, {
method: 'DELETE',
headers: {
'Authorization': groupCode,
Expand Down
17 changes: 12 additions & 5 deletions frontend/src/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
const config = {
apiUrl: 'https://nf2c6o0vt2.execute-api.eu-west-1.amazonaws.com/dev',
};

export default config;
async function config() {
try {
const response = await fetch('config.json');
const config = await response.json();
return config;
} catch (error) {
console.error('Error fetching config:', error);
throw error;
}
}

export default config;
2 changes: 1 addition & 1 deletion frontend/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/js/bootstrap.bundle.min';
import 'font-awesome/css/font-awesome.min.css';

import './index.css';
import './index.css'

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
Expand Down
6 changes: 0 additions & 6 deletions old/Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions old/README.md

This file was deleted.

22 changes: 0 additions & 22 deletions old/helm/.helmignore

This file was deleted.

2 changes: 0 additions & 2 deletions old/helm/.sops.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions old/helm/Chart.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions old/helm/requirements.lock

This file was deleted.

4 changes: 0 additions & 4 deletions old/helm/requirements.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions old/helm/secrets.yaml

This file was deleted.

21 changes: 0 additions & 21 deletions old/helm/templates/NOTES.txt

This file was deleted.

Loading

0 comments on commit 13c98c4

Please sign in to comment.