Skip to content

Commit e0dd99c

Browse files
Merge pull request #301 from cmu15122/jtromero/working
Access Control Lists
2 parents cabf990 + 6ca529f commit e0dd99c

File tree

15 files changed

+915
-40
lines changed

15 files changed

+915
-40
lines changed

client/src/components/common/dialogs/DeleteDialog.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ export default function DeleteDialog(props) {
1818
</Typography>
1919
<Typography sx={{textAlign: 'center'}}>
2020
Are you sure you want to remove <strong>{itemName}</strong>?
21-
<br/>
22-
This action cannot be undone.
2321
</Typography>
2422
<Box textAlign='center' sx={{pt: 5}}>
2523
<Button onClick={handleDelete} variant="contained" color="error" sx={{alignSelf: 'center'}}>Delete</Button>

client/src/components/home/shared/AskQuestion.tsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default function AskQuestion() {
3737
const [name, setName] = useState('');
3838
const [andrewID, setAndrewID] = useState('');
3939
const [location, setLocation] = useState('');
40-
const [topic, setTopic] = useState(null);
40+
const [topicId, setTopicId] = useState('');
4141
const [question, setQuestion] = useState('');
4242

4343
const [showCooldownOverlay, setShowCooldownOverlay] = useState(false);
@@ -68,23 +68,24 @@ export default function AskQuestion() {
6868

6969
const topics = useMemo(() => {
7070
if (queueData != null) {
71-
const newRows = [];
71+
const shownTopics = new Map();
7272
queueData.topics.forEach((topic) => {
7373
if (
7474
new Date(topic.start_date) <= new Date() &&
7575
new Date(topic.end_date) > new Date()
7676
) {
77-
newRows.push(topic);
77+
shownTopics.set(topic.assignment_id, topic);
7878
}
7979
});
80-
newRows.push(createData(-1, 'Other'));
8180

82-
if (newRows.length === 1) {
83-
setTopic(newRows[0]);
81+
shownTopics.set(-1, createData(-1, 'Other'));
82+
83+
if (shownTopics.size === 1) {
84+
setTopicId(shownTopics.keys().next().value);
8485
}
8586

86-
return newRows;
87-
} else return [createData(-1, 'Other')];
87+
return shownTopics;
88+
} else return new Map([[-1, createData(-1, 'Other')]]);
8889
}, [queueData.topics]);
8990

9091
useEffect(() => {
@@ -107,7 +108,7 @@ export default function AskQuestion() {
107108
andrewID: andrewID,
108109
question: question,
109110
location: location,
110-
topic: topic,
111+
topic: topics.get(topicId),
111112
}),
112113
)
113114
.then((res) => {
@@ -144,7 +145,7 @@ export default function AskQuestion() {
144145
setName('');
145146
setAndrewID('');
146147
setLocation('');
147-
setTopic(null);
148+
setTopicId('');
148149
setQuestion('');
149150
}
150151

@@ -214,14 +215,14 @@ export default function AskQuestion() {
214215
<Select
215216
labelId="topic-select-label"
216217
id="topic-select"
217-
value={topic ?? ''}
218+
value={topicId ?? ''}
218219
label="Topic"
219-
onChange={(e) => setTopic(e.target.value)}
220+
onChange={(e) => setTopicId(e.target.value)}
220221
style={{ textAlign: 'left' }}
221222
>
222-
{topics.map((top) => (
223-
<MenuItem value={top} key={top.assignment_id}>
224-
{top.name}
223+
{Array.from(topics.values()).map((topic) => (
224+
<MenuItem value={topic.assignment_id} key={topic.assignment_id}>
225+
{topic.name}
225226
</MenuItem>
226227
))}
227228
</Select>
@@ -271,7 +272,7 @@ export default function AskQuestion() {
271272
andrewID={andrewID}
272273
question={question}
273274
location={location}
274-
topic={topic}
275+
topic={topics.get(topicId)}
275276
/>
276277
</div>
277278
);

0 commit comments

Comments
 (0)