diff --git a/webclient/src/AdminMembers.js b/webclient/src/AdminMembers.js index ce23d10..b8a9d08 100644 --- a/webclient/src/AdminMembers.js +++ b/webclient/src/AdminMembers.js @@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'; import { BrowserRouter as Router, Switch, Route, Link, useParams, useHistory } from 'react-router-dom'; 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 moment from 'moment-timezone'; import { statusColor, BasicTable, staticUrl, requester } from './utils.js'; import { TrainingList } from './Training.js'; import { NotFound } from './Misc.js'; @@ -532,3 +532,121 @@ export function AdminMemberTraining(props) { ); }; + +export function AdminCert(props) { + const { token, result, name, field, refreshResult } = props; + const member = result.member; + const [loading, setLoading] = useState(false); + + const handleCert = (e) => { + e.preventDefault(); + setLoading(true); + let data = Object(); + data[field] = moment.utc().tz('America/Edmonton').format('YYYY-MM-DD'); + requester('/members/' + member.id + '/', 'PATCH', token, data) + .then(res => { + refreshResult(); + }) + .catch(err => { + console.log(err); + }); + }; + + const handleUncert = (e) => { + e.preventDefault(); + setLoading(true); + let data = Object(); + data[field] = null; + requester('/members/' + member.id + '/', 'PATCH', token, data) + .then(res => { + refreshResult(); + }) + .catch(err => { + console.log(err); + }); + }; + + useEffect(() => { + setLoading(false); + }, [member[field]]); + + return ( + member[field] ? + + : + + ); +} + +export function AdminMemberCertifications(props) { + const member = props.result.member; + + return ( +
These certifications control access to the lockouts.
+ +