Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,10 @@
"standard-with-typescript",
"prettier"
],
"plugins": [
"react",
"prettier"
],
"plugins": ["react", "prettier"],
"rules": {
"semi": [
1,
"always"
],
"quotes": [
2,
"single"
],
"semi": [1, "always"],
"quotes": [2, "single"],
"max-len": ["error", { "code": 80 }],
"no-unused-vars": 1,
"multiline-ternary": 0,
Expand All @@ -45,14 +36,11 @@
},
"overrides": [
{
"files": [
"vite.config.ts",
".eslintrc.cjs"
],
"files": ["vite.config.ts", ".eslintrc.cjs"],
"parserOptions": {
"parser": "@typescript-eslint/parser",
"project": "./tsconfig.json"
}
}
]
}
}
47 changes: 23 additions & 24 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ name: Node.js CI

on:
push:
branches: [ "main" ]
branches: ['main']

permissions: write-all

jobs:
build:

runs-on: ubuntu-latest

strategy:
Expand All @@ -20,25 +19,25 @@ jobs:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm install

- name: Build
run: npm run build

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload dist folder
path: './dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm install

- name: Build
run: npm run build

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload dist folder
path: './dist'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"trailingComma": "none",
"singleQuote": true,
"printWidth": 80
}
}
49 changes: 26 additions & 23 deletions 404.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WCS Points</title>
<script type="text/javascript">
// handles redirects for single page apps on GitHub Pages
var segmentCount = 0;
var location = window.location;

// redirect to the index.html with a special query parameter containing the path
location.replace(
location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '') +
'/' +
'?path=' +
location.pathname.slice(1).split('/').slice(segmentCount).join('/') +
(location.search || '') +
(location.hash || '')
);
</script>
</head>
<body>
Redirecting...
</body>
</html>
<head>
<meta charset="utf-8" />
<title>WCS Points</title>
<script type="text/javascript">
// handles redirects for single page apps on GitHub Pages
var segmentCount = 0;
var location = window.location;

// redirect to the index.html with a special query parameter containing the path
location.replace(
location.protocol +
'//' +
location.hostname +
(location.port ? ':' + location.port : '') +
'/' +
'?path=' +
location.pathname.slice(1).split('/').slice(segmentCount).join('/') +
(location.search || '') +
(location.hash || '')
);
</script>
</head>
<body>
Redirecting...
</body>
</html>
12 changes: 6 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
<title>WCS Points</title>
<script type="text/javascript">
// Thandles the redirect from 404.html
(function() {
(function () {
var path = window.location.search.match(/path=([^&]*)/);
if (path) {
var originalPath = path[1];
var search = window.location.search.replace(/path=[^&]*(&|$)/, '');
search = search === '?' ? '' : search;
window.history.replaceState(null, null,
'/' + originalPath +
(search || '') +
(window.location.hash || '')

window.history.replaceState(
null,
null,
'/' + originalPath + (search || '') + (window.location.hash || '')
);
}
})();
Expand Down
4 changes: 3 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const App = (): React.ReactElement => {
window.location.href = `${newUrl}#/loading/${eventKey}`;

// Force a reload to ensure the component loads fresh
setTimeout(() => { window.location.reload(); }, 100);
setTimeout(() => {
window.location.reload();
}, 100);
}
}, []);

Expand Down
4 changes: 2 additions & 2 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import axios from 'axios';
const instance = axios.create({
baseURL: import.meta.env.VITE_BASE_URL
? import.meta.env.VITE_BASE_URL
: // : 'http://127.0.0.1:3000',
'https://points-api.illinoiswcs.org',
// : 'http://127.0.0.1:3000',
: 'https://points-api.illinoiswcs.org',
withCredentials: true
});

Expand Down
73 changes: 73 additions & 0 deletions src/pages/Events/ConfirmationModal/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React, { useState } from 'react';
import {
Modal,
ModalCloseButton,
ModalHeader,
ModalOverlay,
ModalBody,
ModalContent,
Box,
Button,
FormLabel,
ModalFooter
} from '@chakra-ui/react';
import { ConfirmationModalProps } from './types';
import { useMutation } from 'react-query';
import axiosInstance from '../../../api';
import { Event } from '../../../types/event';

const ConfirmationModal = (
props: ConfirmationModalProps
): React.ReactElement => {
const [hasDeleted, setHasDeleted] = useState(false);
const { open, event, toggleConfirmationModal } = props;

const deleteEvent = useMutation({
mutationFn: async (event: Event): Promise<void> => {
await axiosInstance.delete(`/events/${event._id}`);
}
});

const handleEventDeletion = async (): Promise<void> => {
if (!event) return;

await deleteEvent.mutateAsync(event);
if (!hasDeleted) {
setHasDeleted(true);
}

window.location.reload();
};

const clearAndToggleOnNo = (): void => {
toggleConfirmationModal();
};

return (
<Modal isOpen={open} onClose={clearAndToggleOnNo} isCentered>
<ModalOverlay />
<ModalContent p="10">
<ModalCloseButton />
<ModalHeader>
<Box>{event?.name} Event Deletion</Box>
</ModalHeader>
<ModalBody>
<FormLabel>Do you really want to delete this event?</FormLabel>
<ModalFooter>
<Button
onClick={() => {
handleEventDeletion().catch(console.error);
}}
style={{ marginRight: '10px' }}
>
Yes
</Button>
<Button onClick={clearAndToggleOnNo}>No</Button>
</ModalFooter>
</ModalBody>
</ModalContent>
</Modal>
);
};

export default ConfirmationModal;
9 changes: 9 additions & 0 deletions src/pages/Events/ConfirmationModal/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Event } from '../../../types/event';

export interface ConfirmationModalProps {
open: boolean;
event?: Event;
toggleConfirmationModal: () => void;
toggleEventModal: () => void;
reloadOnClose: () => void;
}
Loading