diff --git a/src/components/App.tsx b/src/components/App.tsx
index 9314c31..e9946a4 100644
--- a/src/components/App.tsx
+++ b/src/components/App.tsx
@@ -3,6 +3,7 @@ import { BrowserRouter, Route, Switch } from 'react-router-dom';
import NotificationsProvider from '../state/Notifications/NotificationsProvider';
import AuthenticationContext from './Authentication/AuthenticationContext';
import EasterEgg from './EasterEgg';
+import ErrorReport from './ErrorReport';
import Footer from './Footer';
import Header from './Header/Header';
import {
@@ -49,7 +50,7 @@ export default function App() {
+
(null);
+ const [status, setStatus] =
+ useState(null);
+ const submit = useCallback(() => {
+ const text = ref.current?.value ?? '';
+ if (text.length > 0) {
+ setStatus('pending');
+ sendErrorReport(text)
+ .then(() => setStatus('resolved'))
+ .catch(() => setStatus('rejected'));
+ }
+ }, []);
+ return (
+
+
Error Report
+
+ {status === 'pending' ? (
+ <>Submitting...>
+ ) : status === 'resolved' ? (
+ <>Submitted!>
+ ) : (
+ <>
+ {status === 'rejected' && <>Failed to submit.>}
+ Submit
+ >
+ )}
+
+ );
+}
diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx
index d6756ab..4170c91 100644
--- a/src/components/Footer.tsx
+++ b/src/components/Footer.tsx
@@ -6,7 +6,8 @@ export default function Footer() {
bottom: '0.5rem',
fontSize: '0.75rem',
textAlign: 'center',
- width: '100%',
+ left: 0,
+ right: 0,
}}
>
Made by Michael Fatemi
@@ -19,6 +20,7 @@ export default function Footer() {
Code:{' '}
frontend,{' '}
backend{' '}
+ Report an error{' '}
{
return await get(`/carpools/${carpoolId}/potential_invitees`);
}
+
+export async function sendErrorReport(error: string) {
+ const response = await fetch(`${domain}user_reported_error`, {
+ method: 'post',
+ body: JSON.stringify({ error }),
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ });
+
+ if (response.status !== 200) {
+ throw new Error(response.statusText);
+ }
+}