From 0c7c9cd4cabfee83e4e19fe7f3d4aea829997e06 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Thu, 13 Aug 2020 22:24:04 +0000 Subject: [PATCH] Add admin UI for certifying members --- webclient/src/AdminMembers.js | 120 +++++++++++++++++++++++++++++++++- webclient/src/Members.js | 6 +- 2 files changed, 124 insertions(+), 2 deletions(-) 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 ( +
+
Member Certifications
+ +

These certifications control access to the lockouts.

+ + + + + Name + Certification + Course + + + + + + + Common + {member.vetted_date || member.orientation_date ? 'Yes' : 'No'} + New Members: Orientation and Basic Safety + + + Wood 1 + {member.wood_cert_date ? 'Yes, ' + member.wood_cert_date : 'No'} + Woodworking Tools 1: Intro to Saws + + + + Wood 2 + {member.wood2_cert_date ? 'Yes, ' + member.wood2_cert_date : 'No'} + Woodworking Tools 2: Jointer, Thickness Planer, Drum Sander + + + + Lathe + {member.lathe_cert_date ? 'Yes, ' + member.lathe_cert_date : 'No'} + Metal: Metal Cutting & Manual Lathe + + + + Mill + {member.mill_cert_date ? 'Yes, ' + member.mill_cert_date : 'No'} + Metal: Manual Mill & Advanced Lathe + + + + CNC + {member.cnc_cert_date ? 'Yes, ' + member.cnc_cert_date : 'No'} + Tormach: CAM and Tormach Intro + + + +
+ +
+ ); +}; diff --git a/webclient/src/Members.js b/webclient/src/Members.js index 2c6442c..89f308a 100644 --- a/webclient/src/Members.js +++ b/webclient/src/Members.js @@ -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, AdminMemberTraining } from './AdminMembers.js'; +import { AdminMemberInfo, AdminMemberPause, AdminMemberForm, AdminMemberCards, AdminMemberTraining, AdminMemberCertifications } from './AdminMembers.js'; import { AdminMemberTransactions } from './AdminTransactions.js'; export function MembersDropdown(props) { @@ -204,6 +204,10 @@ export function MemberDetail(props) { } + {isAdmin(user) && + + } + {isAdmin(user) && }