Misc fixes

This commit is contained in:
Tanner Collin 2022-05-07 06:28:33 +00:00
parent 9f91cca187
commit 497883fcce
5 changed files with 89 additions and 69 deletions

View File

@ -6,7 +6,6 @@ import moment from 'moment-timezone';
import { apiUrl, isAdmin, isInstructor, getInstructor, BasicTable, requester, useIsMobile } from './utils.js'; import { apiUrl, isAdmin, isInstructor, getInstructor, BasicTable, requester, useIsMobile } from './utils.js';
import { NotFound, PleaseLogin } from './Misc.js'; import { NotFound, PleaseLogin } from './Misc.js';
import { InstructorClassDetail, InstructorClassAttendance } from './InstructorClasses.js'; import { InstructorClassDetail, InstructorClassAttendance } from './InstructorClasses.js';
import { courseCache } from './Courses.js';
import { PayPalPayNow } from './PayPal.js'; import { PayPalPayNow } from './PayPal.js';
import { tags } from './Courses.js'; import { tags } from './Courses.js';
@ -131,7 +130,7 @@ function NewClassTableCourse(props) {
<div className='byline'> <div className='byline'>
<div className='tags'> <div className='tags'>
{!!course.tags && course.tags.split(',').map(name => {!!course.tags && course.tags.split(',').map(name =>
<Label color={tags[name]} tag size='small'> <Label key={name} color={tags[name]} tag size='small'>
{name} {name}
</Label> </Label>
)} )}
@ -230,11 +229,25 @@ function NewClassTable(props) {
<> <>
<div className='newclasstable'> <div className='newclasstable'>
{sortedClasses.map(x => {sortedClasses.map(x =>
<NewClassTableCourse course={x.course} classes={x.classes} token={token} user={user} refreshUser={refreshUser} /> <NewClassTableCourse
key={x.course.id}
course={x.course}
classes={x.classes}
token={token}
user={user}
refreshUser={refreshUser}
/>
)} )}
{courses.filter(x => !seenCourseIds.includes(x.id)).map(x => {courses.filter(x => !seenCourseIds.includes(x.id)).map(x =>
<NewClassTableCourse course={x} classes={false} token={token} user={user} refreshUser={refreshUser} /> <NewClassTableCourse
key={x.id}
course={x}
classes={false}
token={token}
user={user}
refreshUser={refreshUser}
/>
)} )}
</div> </div>
</> </>
@ -284,7 +297,7 @@ export function ClassFeed(props) {
export function Classes(props) { export function Classes(props) {
const [classes, setClasses] = useState(classesCache); const [classes, setClasses] = useState(classesCache);
const [courses, setCourses] = useState(courseCache); const [courses, setCourses] = useState(false);
const [sortByCourse, setSortByCourse] = useState(sortCache); const [sortByCourse, setSortByCourse] = useState(sortCache);
const [tagFilter, setTagFilter] = useState(tagFilterCache); const [tagFilter, setTagFilter] = useState(tagFilterCache);
const { token, user, refreshUser } = props; const { token, user, refreshUser } = props;
@ -293,7 +306,6 @@ export function Classes(props) {
requester('/courses/', 'GET', token) requester('/courses/', 'GET', token)
.then(res => { .then(res => {
setCourses(res.results); setCourses(res.results);
courseCache = res.results;
}) })
.catch(err => { .catch(err => {
console.log(err); console.log(err);
@ -351,8 +363,8 @@ export function Classes(props) {
</Button> </Button>
</p> </p>
<p> <p>Filter by tag:</p>
Filter by tag:
<div className='coursetags'> <div className='coursetags'>
<div <div
className='labelbox' className='labelbox'
@ -372,6 +384,7 @@ export function Classes(props) {
{Object.entries(tags).map(([name, color]) => {Object.entries(tags).map(([name, color]) =>
<div <div
key={name}
className='labelbox' className='labelbox'
style={{borderColor: tagFilter === name ? 'black' : 'transparent'}} style={{borderColor: tagFilter === name ? 'black' : 'transparent'}}
> >
@ -389,7 +402,6 @@ export function Classes(props) {
</div> </div>
)} )}
</div> </div>
</p>
{classes.length && courses.length ? {classes.length && courses.length ?
sortByCourse ? sortByCourse ?

View File

@ -24,7 +24,7 @@ export const tags = {
Misc: 'grey', Misc: 'grey',
}; };
export let courseCache = false; let courseCache = false;
let tagFilterCache = false; let tagFilterCache = false;
export function Courses(props) { export function Courses(props) {
@ -53,8 +53,8 @@ export function Courses(props) {
<InstructorCourseList courses={courses} setCourses={setCourses} {...props} /> <InstructorCourseList courses={courses} setCourses={setCourses} {...props} />
</Segment>} </Segment>}
<p> <p>Filter by tag:</p>
Filter by tag:
<div className='coursetags'> <div className='coursetags'>
<div <div
className='labelbox' className='labelbox'
@ -74,6 +74,7 @@ export function Courses(props) {
{Object.entries(tags).map(([name, color]) => {Object.entries(tags).map(([name, color]) =>
<div <div
key={name}
className='labelbox' className='labelbox'
style={{borderColor: tagFilter === name ? 'black' : 'transparent'}} style={{borderColor: tagFilter === name ? 'black' : 'transparent'}}
> >
@ -91,7 +92,6 @@ export function Courses(props) {
</div> </div>
)} )}
</div> </div>
</p>
{courses ? {courses ?
<Table basic='very'> <Table basic='very'>
@ -117,7 +117,7 @@ export function Courses(props) {
</Table.Cell> </Table.Cell>
<Table.Cell> <Table.Cell>
{!!x.tags && x.tags.split(',').map(name => {!!x.tags && x.tags.split(',').map(name =>
<Label color={tags[name]} tag> <Label key={name} color={tags[name]} tag>
{name} {name}
</Label> </Label>
)} )}

View File

@ -108,7 +108,11 @@ function MemberInfo(props) {
: :
<Table.Row><Table.Cell>None, please sign up for an <Link to={'/courses/249/'}>Orientation</Link></Table.Cell></Table.Row> <Table.Row><Table.Cell>None, please sign up for an <Link to={'/courses/249/'}>Orientation</Link></Table.Cell></Table.Row>
} }
{user.training.length > 3 && <Link to='/training'>[more]</Link>} {user.training.length > 3 &&
<Table.Row><Table.Cell>
<Link to='/training'>[more]</Link>
</Table.Cell></Table.Row>
}
</Table.Body> </Table.Body>
</BasicTable> </BasicTable>
@ -128,7 +132,11 @@ function MemberInfo(props) {
: :
<Table.Row><Table.Cell>None</Table.Cell></Table.Row> <Table.Row><Table.Cell>None</Table.Cell></Table.Row>
} }
{user.transactions.length > 3 && <Link to='/transactions'>[more]</Link>} {user.transactions.length > 3 &&
<Table.Row><Table.Cell>
<Link to='/transactions'>[more]</Link>
</Table.Cell></Table.Row>
}
</Table.Body> </Table.Body>
</BasicTable> </BasicTable>

View File

@ -194,10 +194,10 @@ export function Members(props) {
<p> <p>
Sort by{' '} Sort by{' '}
{Object.entries(memberSorts).map((x, i) => {Object.entries(memberSorts).map((x, i) =>
<> <React.Fragment key={x[0]}>
<a href='javascript:void(0)' onClick={() => doSort(x[0])}>{x[1]}</a> <a href='javascript:void(0)' onClick={() => doSort(x[0])}>{x[1]}</a>
{i < Object.keys(memberSorts).length - 1 && ', '} {i < Object.keys(memberSorts).length - 1 && ', '}
</> </React.Fragment>
)}. )}.
</p> </p>

View File

@ -130,7 +130,7 @@ body {
} }
.coursetags .ui.tag.label { .coursetags .ui.tag.label {
margin-top: 1rem; margin-bottom: 1rem;
} }
.newclasstable { .newclasstable {