summaryrefslogtreecommitdiff
path: root/client/src/components/Rsvp.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/components/Rsvp.tsx')
-rw-r--r--client/src/components/Rsvp.tsx29
1 files changed, 29 insertions, 0 deletions
diff --git a/client/src/components/Rsvp.tsx b/client/src/components/Rsvp.tsx
new file mode 100644
index 0000000..dad7213
--- /dev/null
+++ b/client/src/components/Rsvp.tsx
@@ -0,0 +1,29 @@
+import React from 'react';
+import { useMemo } from 'react';
+import { useLocation, Navigate, Outlet } from 'react-router-dom';
+import { useSelector } from 'react-redux';
+import CssBaseline from '@mui/material/CssBaseline';
+import NavBar from './NavBar';
+import { selectCurrentGuest } from '../features/auth/authSlice';
+
+const authenticate = () => {
+ const guest = useSelector(selectCurrentGuest);
+ return useMemo(() => ({ guest }), [guest]);
+};
+
+function Rsvp() {
+ const auth = authenticate();
+ const location = useLocation();
+
+ return auth?.guest ? (
+ <>
+ <CssBaseline />
+ <NavBar />
+ <Outlet context={auth?.guest} />
+ </>
+ ) : (
+ <Navigate to="/guest-login" state={{ from: location }} replace />
+ );
+}
+
+export default Rsvp;