Skip to content

Commit afcac1e

Browse files
authored
Merge pull request #2098 from Northeastern-Electric-Racing/#1794-DaoHo-ticket
#1794: Allow Guests to browse without SlackId
2 parents e27d302 + 6384e7b commit afcac1e

4 files changed

Lines changed: 7 additions & 17 deletions

File tree

src/frontend/src/app/AppAuthenticated.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ import Sidebar from '../layouts/Sidebar/Sidebar';
2525
import { Box } from '@mui/system';
2626
import { Container } from '@mui/material';
2727
import ErrorPage from '../pages/ErrorPage';
28+
import { Role, isGuest } from 'shared';
2829

2930
interface AppAuthenticatedProps {
3031
userId: number;
32+
userRole: Role;
3133
}
3234

33-
const AppAuthenticated: React.FC<AppAuthenticatedProps> = ({ userId }) => {
35+
const AppAuthenticated: React.FC<AppAuthenticatedProps> = ({ userId, userRole }) => {
3436
const { isLoading, isError, error, data: userSettingsData } = useSingleUserSettings(userId);
3537

3638
if (isLoading || !userSettingsData) return <LoadingIndicator />;
@@ -43,7 +45,7 @@ const AppAuthenticated: React.FC<AppAuthenticatedProps> = ({ userId }) => {
4345
}
4446
}
4547

46-
return userSettingsData.slackId ? (
48+
return userSettingsData.slackId || isGuest(userRole) ? (
4749
<AppContextUser>
4850
<Box display={'flex'}>
4951
<Sidebar />

src/frontend/src/app/AppPublic.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const AppPublic: React.FC = () => {
2323
theme.toggleTheme();
2424
}
2525

26-
return <AppAuthenticated userId={auth.user.userId} />;
26+
return <AppAuthenticated userId={auth.user.userId} userRole={auth.user.role} />;
2727
}
2828

2929
// if we're on development and the userId is stored in localStorage,

src/frontend/src/pages/HomePage/Home.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,18 @@
33
* See the LICENSE file in the repository root folder for details.
44
*/
55

6-
import { Typography, Alert, Link } from '@mui/material';
7-
import { routes } from '../../utils/routes';
6+
import { Typography } from '@mui/material';
87
import OverdueWorkPackageAlerts from './OverdueWorkPackageAlerts';
98
import UsefulLinks from './UsefulLinks';
109
import WorkPackagesByTimelineStatus from './WorkPackagesByTimelineStatus';
1110
import UpcomingDeadlines from './UpcomingDeadlines';
1211
import { useCurrentUser, useSingleUserSettings } from '../../hooks/users.hooks';
1312
import LoadingIndicator from '../../components/LoadingIndicator';
1413
import ErrorPage from '../ErrorPage';
15-
import { useHistory } from 'react-router-dom';
1614
import PageLayout from '../../components/PageLayout';
1715

1816
const Home = () => {
1917
const user = useCurrentUser();
20-
const history = useHistory();
2118
const { isLoading, isError, error, data: userSettingsData } = useSingleUserSettings(user.userId);
2219

2320
if (isLoading || !userSettingsData) return <LoadingIndicator />;
@@ -28,15 +25,6 @@ const Home = () => {
2825
<Typography variant="h3" marginLeft="auto" sx={{ marginTop: 2, textAlign: 'center', pt: 3, padding: 0 }}>
2926
Welcome, {user.firstName}!
3027
</Typography>
31-
{!userSettingsData?.slackId && (
32-
<Alert variant="filled" severity="warning" onClose={() => history.push(routes.SETTINGS)}>
33-
You don't have a slack id set! Without it, you won't be able to get important updates from us. You can set it{' '}
34-
<Link href={routes.SETTINGS} sx={{ color: 'blue' }}>
35-
here
36-
</Link>
37-
.
38-
</Alert>
39-
)}
4028
<OverdueWorkPackageAlerts />
4129
<UsefulLinks />
4230
<UpcomingDeadlines />

src/frontend/src/tests/app/AppAuthenticated.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const renderComponent = (path?: string, route?: string) => {
3030
const RouterWrapper = routerWrapperBuilder({ path, route });
3131
return render(
3232
<RouterWrapper>
33-
<AppAuthenticated userId={1} />
33+
<AppAuthenticated userId={1} userRole={'GUEST'} />
3434
</RouterWrapper>
3535
);
3636
};

0 commit comments

Comments
 (0)