Add member's training to admin member page

This commit is contained in:
Tanner Collin 2020-08-08 22:49:03 +00:00
parent bf6abb8737
commit 9b8102a542
3 changed files with 55 additions and 25 deletions

View File

@ -4,6 +4,7 @@ import './light.css';
import { Button, Container, Checkbox, Dimmer, Divider, Dropdown, Form, Grid, Header, Icon, Image, Menu, Message, Segment, Table } from 'semantic-ui-react';
import moment from 'moment';
import { statusColor, BasicTable, staticUrl, requester } from './utils.js';
import { TrainingList } from './Training.js';
import { NotFound } from './Misc.js';
function AdminCardDetail(props) {
@ -527,3 +528,20 @@ export function AdminMemberInfo(props) {
</div>
);
};
export function AdminMemberTraining(props) {
const training = props.result.training;
return (
<div>
<Header size='medium'>Member Training</Header>
{training.length ?
<TrainingList training={training} />
:
<p>None</p>
}
</div>
);
};

View File

@ -4,7 +4,7 @@ import './light.css';
import { Button, Container, Divider, Dropdown, Form, Grid, Header, Icon, Image, Input, Item, Menu, Message, Segment, Table } from 'semantic-ui-react';
import { statusColor, isAdmin, BasicTable, staticUrl, requester } from './utils.js';
import { NotFound, PleaseLogin } from './Misc.js';
import { AdminMemberInfo, AdminMemberPause, AdminMemberForm, AdminMemberCards } from './AdminMembers.js';
import { AdminMemberInfo, AdminMemberPause, AdminMemberForm, AdminMemberCards, AdminMemberTraining } from './AdminMembers.js';
import { AdminMemberTransactions } from './AdminTransactions.js';
export function MembersDropdown(props) {
@ -204,6 +204,10 @@ export function MemberDetail(props) {
<AdminMemberCards result={result} refreshResult={refreshResult} {...props} />
</Segment>}
{isAdmin(user) && <Segment padded>
<AdminMemberTraining result={result} refreshResult={refreshResult} {...props} />
</Segment>}
{isAdmin(user) && <Segment padded>
<AdminMemberTransactions result={result} refreshResult={refreshResult} {...props} />
</Segment>}

View File

@ -6,6 +6,37 @@ import moment from 'moment';
import { requester } from './utils.js';
import { NotFound, PleaseLogin } from './Misc.js';
export function TrainingList(props) {
const { training } = props;
return (
<Table basic='very'>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Course / Event Name</Table.HeaderCell>
<Table.HeaderCell>Class Date</Table.HeaderCell>
<Table.HeaderCell>Status</Table.HeaderCell>
<Table.HeaderCell>Instructor</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
{training.slice().sort((a, b) => a.session.datetime < b.session.datetime ? 1 : -1).map(x =>
<Table.Row key={x.id}>
<Table.Cell>{x.session.course_name}</Table.Cell>
<Table.Cell>
<Link to={'/classes/'+x.session.id}>{moment(x.session.datetime).format('MMMM Do YYYY')}</Link>
</Table.Cell>
<Table.Cell>{x.attendance_status}</Table.Cell>
<Table.Cell>{x.session.instructor_name}</Table.Cell>
</Table.Row>
)}
</Table.Body>
</Table>
);
};
export function Training(props) {
const { user } = props;
@ -14,29 +45,7 @@ export function Training(props) {
<Header size='large'>Training</Header>
{user.training.length ?
<Table basic='very'>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Course / Event Name</Table.HeaderCell>
<Table.HeaderCell>Class Date</Table.HeaderCell>
<Table.HeaderCell>Status</Table.HeaderCell>
<Table.HeaderCell>Instructor</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
{user.training.slice().sort((a, b) => a.session.datetime < b.session.datetime ? 1 : -1).map(x =>
<Table.Row key={x.id}>
<Table.Cell>{x.session.course_name}</Table.Cell>
<Table.Cell>
<Link to={'/classes/'+x.session.id}>{moment(x.session.datetime).format('MMMM Do YYYY')}</Link>
</Table.Cell>
<Table.Cell>{x.attendance_status}</Table.Cell>
<Table.Cell>{x.session.instructor_name}</Table.Cell>
</Table.Row>
)}
</Table.Body>
</Table>
<TrainingList training={user.training} />
:
<p>No training yet! Sign up for a course to take a class.</p>
}
@ -44,4 +53,3 @@ export function Training(props) {
</Container>
);
};