-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow a course to open/close their queues #128
Changes from 14 commits
4e317fc
6e64954
356e239
f32dd3d
7e87fff
4144de5
12a2008
80bccf6
9ae93a4
dbe52e7
bc3995d
c8c3cd8
dc0b5cc
888d4c4
da5dd1e
45a8672
0dc8acc
49e5453
e7f72e3
1348abd
55f27cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { Card, CardBody, CardTitle, CardSubtitle, Button } from 'reactstrap' | ||
import FontAwesomeIcon from '@fortawesome/react-fontawesome' | ||
import faMapMarker from '@fortawesome/fontawesome-free-solid/faMapMarker' | ||
import faQuestion from '@fortawesome/fontawesome-free-solid/faQuestionCircle' | ||
|
||
import ShowForCourseStaff from './ShowForCourseStaff' | ||
|
||
const ClosedQueueCard = ({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a lot of code duplication - might be better to just have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was trying this way earlier, I can do it like this, but if I did, then closed cards would have the hover animation. If thats okay, then I can switch it so they use the same component There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. earlier an issue was with the color of the card too, but now that would be an easy fix, so hover is the only issue There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should be able to fix that by just applying a different set of styles? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. v true, i was trying something overly complicated last night lol |
||
queue, | ||
courseName, | ||
onDelete, | ||
onUpdate, | ||
...rest | ||
}) => { | ||
const { name: queueName, location, questionCount } = queue | ||
|
||
const questionCountText = `${questionCount} Question${ | ||
questionCount !== 1 ? 's' : '' | ||
}` | ||
const locationText = location || 'No location specified' | ||
|
||
const handleDelete = e => { | ||
e.stopPropagation() | ||
e.preventDefault() | ||
onDelete() | ||
} | ||
|
||
const handleUpdate = e => { | ||
e.stopPropagation() | ||
e.preventDefault() | ||
onUpdate() | ||
} | ||
|
||
const title = courseName || queueName | ||
const showQueueNameInBody = !!courseName | ||
return ( | ||
<Card className="closed-queue-card bg-light" {...rest}> | ||
<CardBody> | ||
<CardTitle className="d-flex flex-wrap align-items-center"> | ||
<span className="mb-2 mr-auto pr-3">{title}</span> | ||
<div> | ||
<ShowForCourseStaff courseId={queue.courseId}> | ||
<Button color="danger" size="sm" outline onClick={handleDelete}> | ||
Delete | ||
</Button> | ||
</ShowForCourseStaff> | ||
<ShowForCourseStaff courseId={queue.courseId}> | ||
<Button | ||
color="primary" | ||
size="sm" | ||
className="mr-0 ml-1" | ||
outline | ||
onClick={handleUpdate} | ||
> | ||
Edit | ||
</Button> | ||
</ShowForCourseStaff> | ||
</div> | ||
</CardTitle> | ||
{showQueueNameInBody && ( | ||
<CardSubtitle className="mb-2">{queueName}</CardSubtitle> | ||
)} | ||
<div className="text-muted"> | ||
<FontAwesomeIcon icon={faMapMarker} fixedWidth className="mr-2" /> | ||
{locationText} | ||
<br /> | ||
<FontAwesomeIcon icon={faQuestion} fixedWidth className="mr-2" /> | ||
{questionCountText} | ||
</div> | ||
</CardBody> | ||
<style global jsx>{` | ||
.closed-queue-card { | ||
transition: all 200ms; | ||
cursor: pointer; | ||
} | ||
`}</style> | ||
</Card> | ||
) | ||
} | ||
|
||
ClosedQueueCard.defaultProps = { | ||
courseName: null, | ||
} | ||
|
||
ClosedQueueCard.propTypes = { | ||
queue: PropTypes.shape({ | ||
courseId: PropTypes.number, | ||
}).isRequired, | ||
courseName: PropTypes.string, | ||
onUpdate: PropTypes.func.isRequired, | ||
onDelete: PropTypes.func.isRequired, | ||
} | ||
|
||
export default ClosedQueueCard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to stick to proper HTTP semantics (we already violate them in some places, but) we should really just have a single
PATCH
endpoint that can handle updating name, location, open/closed status, etc; it just updates any fields that are present in the request.