Skip to content

Commit 1f874e0

Browse files
committed
main functionalities with imported data
1 parent aa61b58 commit 1f874e0

24 files changed

+173
-369
lines changed

client/src/AdminDashboard/AdminDashboardPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { Typography, Grid } from '@mui/material';
2+
import { Typography, Grid, AppBar } from '@mui/material';
33
import ScreenGrid from '../components/ScreenGrid';
44
// import UserTable from './QuestionTable';
55
import QuestionTable from './QuestionTable';

client/src/App.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,10 @@ function App() {
5858
path="/reset-password/:token"
5959
element={<ResetPasswordPage />}
6060
/>
61-
{/* <Route element={<AdminRoutesWrapper />}> */}
62-
{/* <Route path="/users" element={<AdminDashboardPage />} /> */}
63-
{/* </Route> */}
61+
<Route path="/home" element={<HomePage />} />
62+
<Route path="/question" element={<QuestionPage />} />
6463
</Route>
6564
{/* Routes accessed only if user is authenticated */}
66-
{/* <Route element={<AdminRoutesWrapper />}> */}
6765
<Route element={<ProtectedRoutesWrapper />}>
6866
<Route
6967
path="/admin-dashboard"
@@ -81,9 +79,7 @@ function App() {
8179
/>
8280
}
8381
/>
84-
<Route path="/home" element={<HomePage />} />
8582
<Route path="/about" element={<AboutThisProjectPage />} />
86-
<Route path="/question" element={<QuestionPage />} />
8783

8884
{/* Route which is accessed if no other route is matched */}
8985
<Route path="*" element={<NotFoundPage />} />

client/src/Authentication/LoginPage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function LoginPage() {
134134
<FormCol>
135135
<Grid item container justifyContent="center">
136136
<Typography variant="h2" textAlign="center">
137-
Log In
137+
Administrator Log In
138138
</Typography>
139139
</Grid>
140140
<Grid item width="1">
@@ -177,11 +177,11 @@ function LoginPage() {
177177
Forgot password?
178178
</Link>
179179
</Grid>
180-
<Grid item>
180+
{/* <Grid item>
181181
<Link component={RouterLink} to="/register">
182182
Sign up
183183
</Link>
184-
</Grid>
184+
</Grid> */}
185185
</FormRow>
186186
</FormCol>
187187
</FormGrid>

client/src/Home/AboutThisProjectPage.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ function AboutThisProjectPage() {
2121
direction="row"
2222
justifyContent="space-between"
2323
alignItems="flex-start"
24-
height="100%"
24+
height="100vh"
2525
fit-content="100%"
2626
>
2727
<Grid item width="100%">
2828
<NavBar />
2929
</Grid>
3030

31-
<Grid item width="100%" padding={2} justifyContent="flex-start">
31+
<Grid item width="100%" justifyContent="flex-start">
3232
<Typography variant="h3" fontWeight="bold" textAlign="center">
3333
Guide to Interpersonal Resources at Penn
3434
</Typography>
@@ -130,7 +130,15 @@ function AboutThisProjectPage() {
130130
</Box>
131131
</Grid>
132132
</Grid>
133-
<Grid item width="100%" alignItems="flex-end" padding={0} spacing={0}>
133+
<Grid
134+
item
135+
width="100%"
136+
alignItems="flex-end"
137+
padding={0}
138+
spacing={0}
139+
position="fixed"
140+
bottom={0}
141+
>
134142
<Footer />
135143
</Grid>
136144
</Grid>

client/src/Question/QuestionPage.tsx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable no-underscore-dangle */
22
import React, { useEffect, useState } from 'react';
3-
import { Box } from '@mui/material';
3+
import { Box, CircularProgress } from '@mui/material';
44
import ScreenGrid from '../components/ScreenGrid';
55
import QuestionComponent from './QuestionComponent';
66
import ResourceComponent from './ResourceComponent';
@@ -10,7 +10,6 @@ import SidebarComponent from '../components/sidebar/SidebarComponent';
1010
import BackButton from './Components/BackButton';
1111
import NextButton from './Components/NextButton';
1212
import StartOverButton from './Components/StartOverButton';
13-
import PopupWarning from '../components/PopupWarning';
1413

1514
/**
1615
* This page is the source of truth for all the state driven interactions of the question system.
@@ -21,18 +20,9 @@ import PopupWarning from '../components/PopupWarning';
2120
* It also stores an array of "allQuestions" which will be used to handle to "back" functionality
2221
*/
2322
function QuestionPage() {
24-
const initialQuestion = '637ea16cf9860ef25c72e639';
25-
const [currentQuestion, setCurrentQuestion] = useState({
26-
_id: 'Placeholder',
27-
text: '',
28-
isQuestion: true,
29-
resultantAnswers: [],
30-
} as IQuestion);
31-
32-
// const allQuestions: string[] = [initialQuestion];
23+
const [currentQuestion, setCurrentQuestion] = useState({} as IQuestion);
3324
const [questionIndex, setQuestionIndex] = useState(0);
34-
const [allQuestions, setAllQuestions] = useState<string[]>([initialQuestion]);
35-
// const [allAnswers, setAllAnswers] = useState<string[]>([]);
25+
const [allQuestions, setAllQuestions] = useState<string[]>([]);
3626

3727
// Helper functions
3828
const appendQuestion = (value: string) => {
@@ -109,10 +99,11 @@ function QuestionPage() {
10999
};
110100

111101
useEffect(() => {
112-
if (initialQuestion != null) {
113-
getNextFromID(initialQuestion);
102+
if (allQuestions.length === 0) {
103+
getNextFromID('1');
104+
appendQuestion('1');
114105
}
115-
}, [initialQuestion]);
106+
}, [allQuestions]);
116107

117108
let leftButton = <div />;
118109
if (questionIndex !== 0) {
@@ -132,6 +123,14 @@ function QuestionPage() {
132123
rightButton = <StartOverButton />;
133124
}
134125

126+
if (!currentQuestion.text) {
127+
return (
128+
<ScreenGrid>
129+
<CircularProgress />
130+
</ScreenGrid>
131+
);
132+
}
133+
135134
if (currentQuestion.isQuestion) {
136135
return (
137136
<ScreenGrid>
@@ -163,7 +162,6 @@ function QuestionPage() {
163162
{rightButton}
164163
</ScreenGrid>
165164
);
166-
// }
167165
}
168166

169167
export default QuestionPage;

client/src/Question/ResourceComponent.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ function ResourceComponent(props: ResourceComponentProps) {
3838
</Typography>
3939
</Grid>
4040
{question.resultantAnswers.map((answer) => {
41+
console.log(answer.resourceContent);
4142
return (
4243
<Grid item margin="auto" marginTop="1%">
4344
<ResourceDropdown
4445
title={answer.text}
4546
content={answer.resourceContent}
47+
link={answer.resourceLink}
4648
/>
4749
</Grid>
4850
);

client/src/Question/ResourcePage.tsx

Lines changed: 0 additions & 21 deletions
This file was deleted.

client/src/components/Footer.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { Box, Button, Stack } from '@mui/material';
33
import ArrowForward from '@mui/icons-material/ArrowForward';
44

55
export default function Footer() {
6+
const params = window.location.pathname;
7+
const isAbout = params === '/about';
68
return (
79
<div>
810
<Stack
@@ -21,14 +23,13 @@ export default function Footer() {
2123
alt="Penn Logo"
2224
src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/Shield_of_the_University_of_Pennsylvania.svg/1200px-Shield_of_the_University_of_Pennsylvania.svg.png"
2325
/>
24-
2526
<Button
2627
color="primary"
2728
size="medium"
2829
endIcon={<ArrowForward />}
29-
href="/about"
30+
href={isAbout ? '/question' : '/about'}
3031
>
31-
About This Project
32+
{isAbout ? 'Ask a Question' : 'About This Project'}
3233
</Button>
3334
</Stack>
3435
</div>

client/src/components/ResourceDropdown.tsx

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { useState } from 'react';
33
import Card from '@mui/material/Card';
44
import CardHeader from '@mui/material/CardHeader';
55
import CardContent from '@mui/material/CardContent';
6-
import Container from '@mui/material/Container';
76
import IconButton from '@mui/material/IconButton';
87
import Collapse from '@mui/material/Collapse';
98
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
@@ -12,12 +11,13 @@ import { Button, Grid, Typography } from '@mui/material';
1211

1312
interface ResourceDropdownProps {
1413
title: string;
15-
content: string;
14+
content: string | undefined;
15+
link: string | undefined;
1616
}
1717

1818
export default function ResourceDropdown(props: ResourceDropdownProps) {
1919
const [open, setOpen] = useState(false);
20-
const { title, content } = props;
20+
const { title, content, link } = props;
2121
return (
2222
<Card
2323
sx={{
@@ -45,12 +45,29 @@ export default function ResourceDropdown(props: ResourceDropdownProps) {
4545
<div style={{ backgroundColor: 'rgba(211,211,211,0.4)' }}>
4646
<Collapse in={open} timeout="auto" unmountOnExit>
4747
<CardContent>
48-
<Typography>{content}</Typography>
49-
<Grid container justifyContent="flex-end">
50-
<Button variant="text" size="medium">
51-
Learn More
52-
</Button>
53-
</Grid>
48+
<Typography>{content || ''}</Typography>
49+
{link ? (
50+
<Grid container justifyContent="flex-end">
51+
<Button
52+
variant="text"
53+
size="medium"
54+
onClick={() => {
55+
const newWindow = window.open(
56+
link,
57+
'_blank',
58+
'noopener,noreferrer',
59+
);
60+
if (newWindow) {
61+
newWindow.opener = null;
62+
}
63+
}}
64+
>
65+
Learn More
66+
</Button>
67+
</Grid>
68+
) : (
69+
<div />
70+
)}
5471
</CardContent>
5572
</Collapse>
5673
</div>

client/src/components/sidebar/SidebarContent.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export default function SidebarContent(props: SidebarProps) {
4141
<div>
4242
<Toolbar />
4343
<List>
44+
<ListItem>
45+
<h1>Definitions</h1>
46+
</ListItem>
4447
{definitions.map((definition) => (
4548
<ListItem>
4649
<SidebarContentItem

0 commit comments

Comments
 (0)