diff --git a/client/src/pages/UserWelcome.jsx b/client/src/pages/UserWelcome.jsx
index dd5bd2c5d..567d89122 100644
--- a/client/src/pages/UserWelcome.jsx
+++ b/client/src/pages/UserWelcome.jsx
@@ -1,6 +1,41 @@
-import React from 'react';
-import { Typography, Box, Link } from '@mui/material';
+import {
+ Box,
+ Button,
+ CircularProgress,
+ FormControl,
+ InputLabel,
+ Link,
+ MenuItem,
+ Select,
+ Typography,
+} from '@mui/material';
+import { useEffect, useState } from 'react';
import useAuth from '../hooks/useAuth';
+import { REACT_APP_CUSTOM_REQUEST_HEADER as headerToSend } from '../utils/globalSettings';
+
+const h4sx = {
+ fontSize: { xs: '1.8rem' },
+ marginTop: '2rem',
+ marginBottom: `0rem`,
+ fontFamily: 'aliseoregular',
+ fontWeight: 'bold',
+};
+
+const pstyle = {
+ fontSize: '20px',
+ fontFamily: 'Source Sans Pro',
+ fontWeight: 600,
+};
+
+const checkInButton = {
+ width: '315px',
+ height: '42px',
+ borderRadius: '6px',
+ fontSize: '20px',
+ lineHeight: 'normal',
+};
+
+const getEventLabel = (event) => event.project?.name + ' - ' + event.name;
export default function UserWelcome() {
const { auth } = useAuth();
@@ -9,14 +44,86 @@ export default function UserWelcome() {
const firstName = user?.name.firstName;
- console.log('AUTH', auth);
+ const [events, setEvents] = useState(null);
+ const [selectedEventId, setSelectedEventId] = useState('');
+ const [isCheckedIn, setIsCheckedIn] = useState(false);
+ const [checkInError, setCheckInError] = useState(null);
+
+ const handleEventChange = (e) => {
+ setSelectedEventId(e.target.value);
+ };
+
+ const handleCheckIn = async (e) => {
+ e.preventDefault();
+ setCheckInError(null);
+
+ try {
+ const eventId = selectedEventId || null;
+ const userId = user?._id || null;
+
+ if (!eventId) {
+ throw new Error('Event ID is not selected.');
+ }
+
+ if (!userId) {
+ throw new Error('Logged-in user is not found.');
+ }
+
+ const checkInRes = await fetch('/api/checkins', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'x-customrequired-header': headerToSend,
+ },
+ body: JSON.stringify({
+ userId: userId,
+ eventId: eventId,
+ }),
+ });
+
+ if (!checkInRes.ok) {
+ throw new Error(checkInRes.statusText);
+ }
+ setIsCheckedIn(true);
+ } catch (error) {
+ setCheckInError(error.message);
+ }
+ };
+
+ // Fetching only events with checkInReady = true
+ useEffect(() => {
+ async function fetchEvents() {
+ try {
+ const res = await fetch('/api/events?checkInReady=true', {
+ headers: {
+ 'x-customrequired-header': headerToSend,
+ },
+ });
+
+ const resJson = await res.json();
+ setEvents(resJson);
+ } catch (error) {
+ console.log(error);
+ setEvents([]);
+ }
+ }
+ fetchEvents();
+ }, []);
+
+ // render loading spinner until API response
+ if (!events) {
+ return (
+
+
+
+ );
+ }
+
return (
Welcome {firstName}!
-
- For assistance using VRMS, check out the{' '}
-
+ For assistance using VRMS, check out the
+
+ {events.length > 0 ? (
+
+ {isCheckedIn ? (
+
+ SUCCESS!
+ You have checked in to:
+
+ {getEventLabel(events.find((e) => e._id === selectedEventId))}
+
+
+ ) : (
+ e.preventDefault()}
+ variant="standard"
+ >
+
+
+ Select a meeting to check-in:
+
+
+
+
+
+ {!isCheckedIn && (
+
+ )}
+ {checkInError && (
+
+ {checkInError}
+
+ )}
+
+ )}
+
+ ) : (
+
+ {/* If no meetings available*/}
+
+ No meetings available
+
+
+ )}
);
}