2020-02-16 04:57:55 +00:00
|
|
|
import React, { useState, useEffect } from 'react';
|
2022-07-13 03:14:23 +00:00
|
|
|
import { Link, useParams } from 'react-router-dom';
|
2020-02-16 04:57:55 +00:00
|
|
|
import './light.css';
|
2022-10-07 20:32:25 +00:00
|
|
|
import { Button, Checkbox, Dimmer, Form, Message, Header, Icon, Image, Segment, Table } from 'semantic-ui-react';
|
2020-08-13 22:24:04 +00:00
|
|
|
import moment from 'moment-timezone';
|
2020-02-16 04:57:55 +00:00
|
|
|
import { statusColor, BasicTable, staticUrl, requester } from './utils.js';
|
2020-08-08 22:49:03 +00:00
|
|
|
import { TrainingList } from './Training.js';
|
2020-02-16 04:57:55 +00:00
|
|
|
|
|
|
|
function AdminCardDetail(props) {
|
|
|
|
const { token, result, card } = props;
|
|
|
|
const [input, setInput] = useState({ ...card });
|
|
|
|
const [error, setError] = useState(false);
|
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
const [success, setSuccess] = useState(false);
|
|
|
|
const id = card.id;
|
|
|
|
|
|
|
|
const handleValues = (e, v) => setInput({ ...input, [v.name]: v.value });
|
|
|
|
const handleChange = (e) => handleValues(e, e.currentTarget);
|
|
|
|
|
|
|
|
const handleSubmit = (e) => {
|
|
|
|
if (loading) return;
|
|
|
|
setLoading(true);
|
|
|
|
setSuccess(false);
|
|
|
|
const data = { ...input, member_id: result.member.id };
|
|
|
|
requester('/cards/'+id+'/', 'PUT', token, data)
|
|
|
|
.then(res => {
|
|
|
|
setLoading(false);
|
|
|
|
setSuccess(true);
|
|
|
|
setError(false);
|
|
|
|
setInput(res);
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
setLoading(false);
|
|
|
|
console.log(err);
|
|
|
|
setError(err.data);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const makeProps = (name) => ({
|
|
|
|
name: name,
|
|
|
|
onChange: handleChange,
|
|
|
|
value: input[name] || '',
|
|
|
|
error: error[name],
|
|
|
|
});
|
|
|
|
|
|
|
|
const statusOptions = [
|
|
|
|
{ key: '0', text: 'Card Active', value: 'card_active' },
|
2023-06-05 01:44:40 +00:00
|
|
|
{ key: '1', text: 'Card Inactive', value: 'card_inactive' },
|
2020-02-16 04:57:55 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
return (
|
2023-06-05 01:44:40 +00:00
|
|
|
<Segment raised color={input.active_status === 'card_active' ? 'green' : 'red'}>
|
|
|
|
<Form onSubmit={handleSubmit}>
|
|
|
|
<Form.Group widths='equal'>
|
|
|
|
<Form.Input
|
|
|
|
fluid
|
|
|
|
{...makeProps('card_number')}
|
|
|
|
/>
|
|
|
|
<Form.Select
|
|
|
|
fluid
|
|
|
|
options={statusOptions}
|
|
|
|
{...makeProps('active_status')}
|
|
|
|
onChange={handleValues}
|
|
|
|
/>
|
2020-02-16 04:57:55 +00:00
|
|
|
|
2023-06-05 01:44:40 +00:00
|
|
|
<Form.Button
|
|
|
|
loading={loading}
|
|
|
|
error={error.non_field_errors}
|
|
|
|
>
|
|
|
|
{success ? 'Saved.' : 'Save'}
|
|
|
|
</Form.Button>
|
|
|
|
</Form.Group>
|
2020-02-16 04:57:55 +00:00
|
|
|
|
2023-06-05 01:44:40 +00:00
|
|
|
Notes: {input.notes || 'None'}<br />
|
|
|
|
Last Seen:{' '}
|
|
|
|
{input.last_seen ?
|
|
|
|
input.last_seen > '2021-11-14T02:01:35.415685Z' ?
|
|
|
|
moment.utc(input.last_seen).tz('America/Edmonton').format('lll')
|
2021-11-14 03:49:18 +00:00
|
|
|
:
|
2023-06-05 01:44:40 +00:00
|
|
|
moment.utc(input.last_seen).tz('America/Edmonton').format('ll')
|
|
|
|
:
|
|
|
|
'Unknown'
|
|
|
|
}
|
|
|
|
</Form>
|
|
|
|
</Segment>
|
2020-02-16 04:57:55 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-02-06 23:46:58 +00:00
|
|
|
let prevAutoscan = '';
|
|
|
|
|
2020-02-16 04:57:55 +00:00
|
|
|
export function AdminMemberCards(props) {
|
|
|
|
const { token, result, refreshResult } = props;
|
|
|
|
const cards = result.cards;
|
2022-12-30 23:52:11 +00:00
|
|
|
const startDimmed = Boolean((result.member.paused_date || !result.member.is_allowed_entry || !result.member.vetted_date) && cards.length);
|
2020-02-16 04:57:55 +00:00
|
|
|
const [dimmed, setDimmed] = useState(startDimmed);
|
|
|
|
const [input, setInput] = useState({ active_status: 'card_active' });
|
|
|
|
const [error, setError] = useState(false);
|
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
const [success, setSuccess] = useState(false);
|
2020-11-15 04:36:41 +00:00
|
|
|
const [cardPhoto, setCardPhoto] = useState(false);
|
2020-02-16 04:57:55 +00:00
|
|
|
const { id } = useParams();
|
|
|
|
|
|
|
|
useEffect(() => {
|
2022-12-30 23:52:11 +00:00
|
|
|
const startDimmed = Boolean((result.member.paused_date || !result.member.is_allowed_entry || !result.member.vetted_date) && cards.length);
|
2020-02-16 04:57:55 +00:00
|
|
|
setDimmed(startDimmed);
|
|
|
|
}, [result.member]);
|
|
|
|
|
|
|
|
const handleValues = (e, v) => setInput({ ...input, [v.name]: v.value });
|
|
|
|
const handleChange = (e) => handleValues(e, e.currentTarget);
|
|
|
|
const handleCheck = (e, v) => setInput({ ...input, [v.name]: v.checked });
|
|
|
|
|
|
|
|
const handleSubmit = (e) => {
|
|
|
|
if (loading) return;
|
|
|
|
setLoading(true);
|
|
|
|
setSuccess(false);
|
|
|
|
const data = { ...input, member_id: result.member.id };
|
|
|
|
requester('/cards/', 'POST', token, data)
|
|
|
|
.then(res => {
|
|
|
|
setLoading(false);
|
|
|
|
setSuccess(true);
|
|
|
|
setError(false);
|
|
|
|
refreshResult();
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
setLoading(false);
|
|
|
|
console.log(err);
|
|
|
|
setError(err.data);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2022-02-06 23:46:58 +00:00
|
|
|
const getAutoscan = () => {
|
|
|
|
return requester('/stats/', 'GET', token)
|
|
|
|
.then(res => {
|
|
|
|
return res?.autoscan;
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
console.log(err);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const checkAutoscan = () => {
|
|
|
|
getAutoscan().then(newScan => {
|
2022-07-13 03:14:23 +00:00
|
|
|
if (newScan !== prevAutoscan) {
|
2022-02-06 23:46:58 +00:00
|
|
|
prevAutoscan = newScan;
|
|
|
|
setInput({ ...input, card_number: newScan });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (cardPhoto) {
|
|
|
|
getAutoscan().then(scan => {
|
|
|
|
prevAutoscan = scan;
|
|
|
|
});
|
|
|
|
const interval = setInterval(checkAutoscan, 1000);
|
|
|
|
return () => clearInterval(interval);
|
|
|
|
}
|
|
|
|
}, [cardPhoto]);
|
|
|
|
|
2020-11-15 04:36:41 +00:00
|
|
|
const getCardPhoto = (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
requester('/members/' + id + '/card_photo/', 'GET', token)
|
|
|
|
.then(res => res.blob())
|
|
|
|
.then(res => {
|
|
|
|
setCardPhoto(URL.createObjectURL(res));
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
console.log(err);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-02-16 04:57:55 +00:00
|
|
|
const makeProps = (name) => ({
|
|
|
|
name: name,
|
|
|
|
onChange: handleChange,
|
|
|
|
value: input[name] || '',
|
|
|
|
error: error[name],
|
|
|
|
});
|
|
|
|
|
|
|
|
const statusOptions = [
|
|
|
|
{ key: '0', text: 'Card Active', value: 'card_active' },
|
|
|
|
{ key: '1', text: 'Card Blocked', value: 'card_blocked' },
|
|
|
|
{ key: '2', text: 'Card Inactive', value: 'card_inactive' },
|
|
|
|
{ key: '3', text: 'Card Member Blocked', value: 'card_member_blocked' },
|
|
|
|
];
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Header size='medium'>Edit Member Cards</Header>
|
2020-07-13 20:26:30 +00:00
|
|
|
|
2022-10-07 20:32:25 +00:00
|
|
|
<Header size='small'>Add a Card</Header>
|
|
|
|
|
2022-02-06 23:46:58 +00:00
|
|
|
{result.member.photo_large ?
|
|
|
|
<p>
|
2022-10-07 20:32:25 +00:00
|
|
|
<Button onClick={(e) => getCardPhoto(e)}>New Card</Button>
|
2022-02-06 23:46:58 +00:00
|
|
|
</p>
|
|
|
|
:
|
2022-10-07 20:32:25 +00:00
|
|
|
<Message warning>
|
|
|
|
<Message.Header>Member photo missing!</Message.Header>
|
|
|
|
<p>Have the member upload a photo, then refresh this page.</p>
|
|
|
|
</Message>
|
2022-02-06 23:46:58 +00:00
|
|
|
}
|
2020-02-16 04:57:55 +00:00
|
|
|
|
2022-02-06 23:46:58 +00:00
|
|
|
{cardPhoto &&
|
|
|
|
<Form onSubmit={handleSubmit}>
|
2020-07-18 22:38:07 +00:00
|
|
|
<p>
|
2020-11-15 04:36:41 +00:00
|
|
|
<Image rounded size='medium' src={cardPhoto} />
|
2020-07-18 22:38:07 +00:00
|
|
|
</p>
|
|
|
|
|
2022-10-07 20:32:25 +00:00
|
|
|
<Header size='small'>How to Add a Card</Header>
|
2020-07-18 22:38:07 +00:00
|
|
|
<ol>
|
|
|
|
<li>Right click on image > Save image as...</li>
|
|
|
|
<li>Right click on file > Print</li>
|
|
|
|
<li>Select Datacard Printer, Print</li>
|
|
|
|
<li>Plug card scanner in</li>
|
|
|
|
<li>Open "RfidReader" on desktop</li>
|
2020-08-18 17:20:57 +00:00
|
|
|
<li>Scan card, add the number</li>
|
|
|
|
<li><b>Have them test their card</b></li>
|
2020-07-18 22:38:07 +00:00
|
|
|
</ol>
|
|
|
|
|
2022-02-06 23:46:58 +00:00
|
|
|
<Form.Group widths='equal'>
|
|
|
|
<Form.Input
|
|
|
|
label='Card Number (Listening...)'
|
|
|
|
fluid
|
|
|
|
{...makeProps('card_number')}
|
|
|
|
/>
|
|
|
|
<Form.Select
|
|
|
|
label='Card Status'
|
|
|
|
options={statusOptions}
|
|
|
|
fluid
|
|
|
|
{...makeProps('active_status')}
|
|
|
|
onChange={handleValues}
|
|
|
|
/>
|
|
|
|
<Form.Input
|
|
|
|
label='Optional Note'
|
|
|
|
fluid
|
|
|
|
{...makeProps('notes')}
|
|
|
|
/>
|
|
|
|
</Form.Group>
|
2020-02-16 04:57:55 +00:00
|
|
|
|
2022-02-06 23:46:58 +00:00
|
|
|
<Form.Checkbox
|
|
|
|
label='Confirmed that the member has been given a tour and knows the alarm code'
|
|
|
|
required
|
|
|
|
{...makeProps('given_tour')}
|
|
|
|
onChange={handleCheck}
|
|
|
|
checked={input.given_tour}
|
|
|
|
/>
|
2020-10-08 22:51:37 +00:00
|
|
|
|
2022-02-06 23:46:58 +00:00
|
|
|
<Form.Button disabled={!input.given_tour} loading={loading} error={error.non_field_errors}>
|
|
|
|
Submit
|
|
|
|
</Form.Button>
|
|
|
|
{success && <div>Success!</div>}
|
|
|
|
</Form>
|
|
|
|
}
|
2020-02-16 04:57:55 +00:00
|
|
|
|
|
|
|
<Header size='small'>Current Cards</Header>
|
|
|
|
|
|
|
|
<Dimmer.Dimmable dimmed={dimmed}>
|
|
|
|
{cards.length ?
|
|
|
|
cards.map(x =>
|
|
|
|
<AdminCardDetail key={x.id} card={x} {...props} />
|
|
|
|
)
|
|
|
|
:
|
|
|
|
<p>None</p>
|
|
|
|
}
|
|
|
|
|
|
|
|
<Dimmer active={dimmed}>
|
|
|
|
<p>
|
2022-12-30 23:52:11 +00:00
|
|
|
Member paused, unvetted or not allowed entry. {cards.length} card{cards.length === 1 ? '' : 's'} ignored anyway.
|
2020-02-16 04:57:55 +00:00
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<Button size='tiny' onClick={() => setDimmed(false)}>Close</Button>
|
|
|
|
</p>
|
|
|
|
</Dimmer>
|
|
|
|
</Dimmer.Dimmable>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export function AdminMemberPause(props) {
|
|
|
|
const { token, result, refreshResult } = props;
|
|
|
|
const [error, setError] = useState(false);
|
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
const [success, setSuccess] = useState(false);
|
2022-03-19 01:19:09 +00:00
|
|
|
const [told1, setTold1] = useState(false);
|
|
|
|
const [told2, setTold2] = useState(false);
|
2020-02-16 04:57:55 +00:00
|
|
|
const { id } = useParams();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
setLoading(false);
|
|
|
|
}, [result.member]);
|
|
|
|
|
|
|
|
const handlePause = (e) => {
|
2022-03-15 01:31:26 +00:00
|
|
|
if (loading) return;
|
|
|
|
setLoading(true);
|
|
|
|
setSuccess(false);
|
|
|
|
requester('/members/' + id + '/pause/', 'POST', token, {})
|
|
|
|
.then(res => {
|
|
|
|
setSuccess(true);
|
|
|
|
setError(false);
|
|
|
|
refreshResult();
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
setLoading(false);
|
|
|
|
console.log(err);
|
|
|
|
setError(true);
|
|
|
|
});
|
2022-03-19 01:19:09 +00:00
|
|
|
setTold1(false);
|
|
|
|
setTold2(false);
|
2020-02-16 04:57:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const handleUnpause = (e) => {
|
|
|
|
if (loading) return;
|
|
|
|
setLoading(true);
|
|
|
|
setSuccess(false);
|
|
|
|
requester('/members/' + id + '/unpause/', 'POST', token, {})
|
|
|
|
.then(res => {
|
|
|
|
setSuccess(true);
|
|
|
|
setError(false);
|
|
|
|
refreshResult();
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
setLoading(false);
|
|
|
|
console.log(err);
|
|
|
|
setError(true);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Header size='medium'>Pause / Unpause Membership</Header>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
{result.member.paused_date ?
|
2022-12-30 23:52:11 +00:00
|
|
|
result.member.vetted_date && moment().diff(moment(result.member.paused_date), 'days') > 370 ?
|
|
|
|
<>
|
|
|
|
<p>
|
|
|
|
{result.member.preferred_name} has been away for more than a year and will need to be re-vetted according to our
|
|
|
|
<a href='https://wiki.protospace.ca/Approved_policies/Membership' target='_blank' rel='noopener noreferrer'> policy</a>.
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<Form.Checkbox
|
2023-01-19 18:31:56 +00:00
|
|
|
name='told1'
|
2022-12-30 23:52:11 +00:00
|
|
|
value={told1}
|
|
|
|
label='Told member to get re-vetted'
|
|
|
|
required
|
|
|
|
onChange={(e, v) => setTold1(v.checked)}
|
|
|
|
/>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<Form.Checkbox
|
2023-01-19 18:31:56 +00:00
|
|
|
name='told2'
|
2022-12-30 23:52:11 +00:00
|
|
|
value={told2}
|
|
|
|
label='Collected payment for member dues'
|
|
|
|
required
|
|
|
|
onChange={(e, v) => setTold2(v.checked)}
|
|
|
|
/>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<Button onClick={handleUnpause} loading={loading} disabled={!told1 || !told2}>
|
|
|
|
Unpause
|
|
|
|
</Button>
|
|
|
|
</>
|
|
|
|
:
|
2023-01-19 18:31:56 +00:00
|
|
|
result.member.status == 'Expired Member' ?
|
|
|
|
<>
|
|
|
|
<p>
|
|
|
|
{result.member.preferred_name} has expired due to lapse of payment.
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<Form.Checkbox
|
|
|
|
name='told1'
|
|
|
|
value={told1}
|
|
|
|
label='Member has paid any back-dues owed'
|
|
|
|
required
|
|
|
|
onChange={(e, v) => setTold1(v.checked)}
|
|
|
|
/>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<Form.Checkbox
|
|
|
|
name='told2'
|
|
|
|
value={told2}
|
|
|
|
label='Recorded payment transaction on portal'
|
|
|
|
required
|
|
|
|
onChange={(e, v) => setTold2(v.checked)}
|
|
|
|
/>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<Button onClick={handleUnpause} loading={loading} disabled={!told1 || !told2}>
|
|
|
|
Unpause
|
|
|
|
</Button>
|
|
|
|
</>
|
|
|
|
:
|
|
|
|
<Button onClick={handleUnpause} loading={loading}>
|
|
|
|
Unpause
|
|
|
|
</Button>
|
2020-02-16 04:57:55 +00:00
|
|
|
:
|
2022-03-15 01:31:26 +00:00
|
|
|
<>
|
2022-12-30 23:52:11 +00:00
|
|
|
<p>Pause members who are inactive, former, or on vacation.</p>
|
|
|
|
|
2022-03-15 01:31:26 +00:00
|
|
|
<p>
|
|
|
|
<Form.Checkbox
|
2023-01-19 18:31:56 +00:00
|
|
|
name='told1'
|
2022-03-19 01:19:09 +00:00
|
|
|
value={told1}
|
2022-03-15 01:31:26 +00:00
|
|
|
label='Told member to stop any PayPal subscriptions'
|
|
|
|
required
|
2022-03-19 01:19:09 +00:00
|
|
|
onChange={(e, v) => setTold1(v.checked)}
|
|
|
|
/>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<Form.Checkbox
|
2023-01-19 18:31:56 +00:00
|
|
|
name='told2'
|
2022-03-19 01:19:09 +00:00
|
|
|
value={told2}
|
|
|
|
label='Told member to clear any shelves'
|
|
|
|
required
|
|
|
|
onChange={(e, v) => setTold2(v.checked)}
|
2022-03-15 01:31:26 +00:00
|
|
|
/>
|
|
|
|
</p>
|
|
|
|
|
2022-03-19 01:19:09 +00:00
|
|
|
<Button onClick={handlePause} loading={loading} disabled={!told1 || !told2}>
|
2022-03-15 01:31:26 +00:00
|
|
|
Pause
|
|
|
|
</Button>
|
|
|
|
</>
|
2020-02-16 04:57:55 +00:00
|
|
|
}
|
|
|
|
</p>
|
|
|
|
|
|
|
|
{success && <div>Success!</div>}
|
|
|
|
{error && <p>Error, something went wrong.</p>}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export function AdminMemberForm(props) {
|
|
|
|
const { token, result, refreshResult } = props;
|
|
|
|
const [input, setInput] = useState(result.member);
|
|
|
|
const [error, setError] = useState(false);
|
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
const [success, setSuccess] = useState(false);
|
|
|
|
const { id } = useParams();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
setInput(result.member);
|
|
|
|
}, [result.member]);
|
|
|
|
|
|
|
|
const handleValues = (e, v) => setInput({ ...input, [v.name]: v.value });
|
|
|
|
const handleChange = (e) => handleValues(e, e.currentTarget);
|
|
|
|
const handleCheck = (e, v) => setInput({ ...input, [v.name]: v.checked });
|
|
|
|
|
|
|
|
const handleSubmit = (e) => {
|
|
|
|
if (loading) return;
|
|
|
|
setLoading(true);
|
|
|
|
setSuccess(false);
|
|
|
|
const data = { ...input, email: input.email.toLowerCase() };
|
|
|
|
requester('/members/' + id + '/', 'PATCH', token, data)
|
|
|
|
.then(res => {
|
|
|
|
setLoading(false);
|
|
|
|
setSuccess(true);
|
|
|
|
setError(false);
|
|
|
|
refreshResult();
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
setLoading(false);
|
|
|
|
console.log(err);
|
|
|
|
setError(err.data);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const makeProps = (name) => ({
|
|
|
|
name: name,
|
|
|
|
onChange: handleChange,
|
|
|
|
value: input[name] || '',
|
|
|
|
error: error[name],
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Form onSubmit={handleSubmit}>
|
|
|
|
<Header size='medium'>Edit Member Details</Header>
|
|
|
|
|
|
|
|
<Form.Group widths='equal'>
|
|
|
|
<Form.Input
|
|
|
|
label='First Name'
|
|
|
|
fluid
|
|
|
|
{...makeProps('first_name')}
|
|
|
|
/>
|
|
|
|
<Form.Input
|
|
|
|
label='Last Name'
|
|
|
|
fluid
|
|
|
|
{...makeProps('last_name')}
|
|
|
|
/>
|
|
|
|
</Form.Group>
|
|
|
|
|
2020-02-28 07:38:38 +00:00
|
|
|
<Form.Input
|
|
|
|
label='Preferred Name'
|
|
|
|
{...makeProps('preferred_name')}
|
|
|
|
/>
|
|
|
|
|
2020-02-16 04:57:55 +00:00
|
|
|
<Form.Input
|
|
|
|
label='Email'
|
|
|
|
{...makeProps('email')}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Form.Input
|
|
|
|
label='Current Start Date'
|
|
|
|
{...makeProps('current_start_date')}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Form.Input
|
|
|
|
label='Vetted Date'
|
|
|
|
{...makeProps('vetted_date')}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Form.Input
|
|
|
|
label='Membership Fee'
|
|
|
|
{...makeProps('monthly_fees')}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Form.Field>
|
|
|
|
<label>Is the member an instructor?</label>
|
|
|
|
<Checkbox
|
|
|
|
label='Yes'
|
|
|
|
name='is_instructor'
|
|
|
|
onChange={handleCheck}
|
|
|
|
checked={input.is_instructor}
|
|
|
|
/>
|
|
|
|
</Form.Field>
|
|
|
|
|
2021-09-16 22:27:36 +00:00
|
|
|
<Form.Field>
|
|
|
|
<label>Is the member allowed entry?</label>
|
|
|
|
<Checkbox
|
|
|
|
label='Yes'
|
|
|
|
name='is_allowed_entry'
|
|
|
|
onChange={handleCheck}
|
|
|
|
checked={input.is_allowed_entry}
|
|
|
|
/>
|
|
|
|
</Form.Field>
|
|
|
|
|
2020-05-01 03:54:23 +00:00
|
|
|
<Form.TextArea
|
|
|
|
label={'Private Notes (shared with ' + input.preferred_name + ')'}
|
|
|
|
{...makeProps('private_notes')}
|
|
|
|
/>
|
|
|
|
|
2020-02-16 04:57:55 +00:00
|
|
|
<Form.Button loading={loading} error={error.non_field_errors}>
|
|
|
|
Submit
|
|
|
|
</Form.Button>
|
|
|
|
{success && <div>Success!</div>}
|
|
|
|
</Form>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export function AdminMemberInfo(props) {
|
|
|
|
const member = props.result.member;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Header size='medium'>Admin Details</Header>
|
|
|
|
|
|
|
|
<BasicTable>
|
|
|
|
<Table.Body>
|
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Status:</Table.Cell>
|
|
|
|
<Table.Cell>
|
|
|
|
<Icon name='circle' color={statusColor[member.status]} />
|
|
|
|
{member.status || 'Unknown'}
|
|
|
|
</Table.Cell>
|
|
|
|
</Table.Row>
|
|
|
|
|
2022-08-22 21:33:38 +00:00
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Protocoin:</Table.Cell>
|
|
|
|
<Table.Cell>₱ {member.protocoin.toFixed(2)}</Table.Cell>
|
|
|
|
</Table.Row>
|
|
|
|
|
2022-01-15 23:14:18 +00:00
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Application Date:</Table.Cell>
|
|
|
|
<Table.Cell>{member.application_date}</Table.Cell>
|
|
|
|
</Table.Row>
|
|
|
|
|
2020-02-16 04:57:55 +00:00
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Expire Date:</Table.Cell>
|
|
|
|
<Table.Cell>{member.expire_date}</Table.Cell>
|
|
|
|
</Table.Row>
|
2022-01-15 23:14:18 +00:00
|
|
|
|
2020-02-16 04:57:55 +00:00
|
|
|
{member.paused_date && <Table.Row>
|
|
|
|
<Table.Cell>Paused Date:</Table.Cell>
|
|
|
|
<Table.Cell>{member.paused_date}</Table.Cell>
|
|
|
|
</Table.Row>}
|
|
|
|
|
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Phone:</Table.Cell>
|
|
|
|
<Table.Cell>{member.phone}</Table.Cell>
|
|
|
|
</Table.Row>
|
|
|
|
|
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Emergency Contact Name:</Table.Cell>
|
|
|
|
<Table.Cell>{member.emergency_contact_name || 'None'}</Table.Cell>
|
|
|
|
</Table.Row>
|
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Emergency Contact Phone:</Table.Cell>
|
|
|
|
<Table.Cell>{member.emergency_contact_phone || 'None'}</Table.Cell>
|
|
|
|
</Table.Row>
|
2020-10-02 23:58:45 +00:00
|
|
|
|
2021-10-02 04:44:33 +00:00
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Discourse Username:</Table.Cell>
|
2022-01-15 23:18:30 +00:00
|
|
|
<Table.Cell>
|
|
|
|
{member.discourse_username ?
|
|
|
|
<a href={'https://forum.protospace.ca/u/' + member.discourse_username + '/summary'} target='_blank'>
|
|
|
|
{member.discourse_username}
|
|
|
|
</a>
|
|
|
|
:
|
|
|
|
'None'
|
|
|
|
}
|
|
|
|
</Table.Cell>
|
2021-10-02 04:44:33 +00:00
|
|
|
</Table.Row>
|
|
|
|
|
2020-05-01 03:54:23 +00:00
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Public Bio:</Table.Cell>
|
|
|
|
</Table.Row>
|
2020-02-16 04:57:55 +00:00
|
|
|
</Table.Body>
|
|
|
|
</BasicTable>
|
|
|
|
|
2020-05-01 03:54:23 +00:00
|
|
|
<p className='bio-paragraph'>
|
|
|
|
{member.public_bio || 'None yet.'}
|
|
|
|
</p>
|
|
|
|
|
2020-02-16 04:57:55 +00:00
|
|
|
{member.member_forms && <p>
|
|
|
|
<a href={staticUrl + '/' + member.member_forms} target='_blank'>
|
|
|
|
View application forms
|
|
|
|
</a>
|
|
|
|
</p>}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2020-08-08 22:49:03 +00:00
|
|
|
|
|
|
|
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>
|
|
|
|
);
|
|
|
|
};
|
2020-08-13 22:24:04 +00:00
|
|
|
|
|
|
|
export function AdminCert(props) {
|
2022-04-11 21:54:35 +00:00
|
|
|
const { token, result, name, field, refreshResult, loading, setLoading } = props;
|
2020-08-13 22:24:04 +00:00
|
|
|
const member = result.member;
|
|
|
|
|
|
|
|
const handleCert = (e) => {
|
|
|
|
e.preventDefault();
|
2020-09-15 19:42:09 +00:00
|
|
|
if (loading) return;
|
2020-08-13 22:24:04 +00:00
|
|
|
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();
|
2020-09-15 19:42:09 +00:00
|
|
|
if (loading) return;
|
2020-08-13 22:24:04 +00:00
|
|
|
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] ?
|
|
|
|
<Button
|
|
|
|
onClick={handleUncert}
|
|
|
|
loading={loading}
|
|
|
|
>
|
2023-07-19 17:14:23 +00:00
|
|
|
Disable
|
2020-08-13 22:24:04 +00:00
|
|
|
</Button>
|
|
|
|
:
|
|
|
|
<Button
|
|
|
|
color='green'
|
|
|
|
onClick={handleCert}
|
|
|
|
loading={loading}
|
|
|
|
>
|
2023-07-19 17:14:23 +00:00
|
|
|
Enable {name}
|
2020-08-13 22:24:04 +00:00
|
|
|
</Button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function AdminMemberCertifications(props) {
|
|
|
|
const member = props.result.member;
|
2022-04-11 21:54:35 +00:00
|
|
|
const [loading, setLoading] = useState(false);
|
2020-08-13 22:24:04 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
2023-07-19 17:14:23 +00:00
|
|
|
<Header size='medium'>Machine Access</Header>
|
2020-08-13 22:24:04 +00:00
|
|
|
|
2023-07-19 17:14:23 +00:00
|
|
|
<p>These control access to the lockouts.</p>
|
2020-08-13 22:24:04 +00:00
|
|
|
|
|
|
|
<Table basic='very'>
|
|
|
|
<Table.Header>
|
|
|
|
<Table.Row>
|
|
|
|
<Table.HeaderCell>Name</Table.HeaderCell>
|
2023-07-19 17:14:23 +00:00
|
|
|
<Table.HeaderCell>Enabled</Table.HeaderCell>
|
2020-08-13 22:24:04 +00:00
|
|
|
<Table.HeaderCell>Course</Table.HeaderCell>
|
|
|
|
<Table.HeaderCell></Table.HeaderCell>
|
|
|
|
</Table.Row>
|
|
|
|
</Table.Header>
|
|
|
|
|
|
|
|
<Table.Body>
|
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Common</Table.Cell>
|
|
|
|
<Table.Cell>{member.vetted_date || member.orientation_date ? 'Yes' : 'No'}</Table.Cell>
|
|
|
|
<Table.Cell><Link to='/courses/249'>New Members: Orientation and Basic Safety</Link></Table.Cell>
|
2022-04-11 21:54:35 +00:00
|
|
|
<Table.Cell><AdminCert name='Common' field='orientation_date' {...props} loading={loading} setLoading={setLoading} /></Table.Cell>
|
2020-08-13 22:24:04 +00:00
|
|
|
</Table.Row>
|
|
|
|
<Table.Row>
|
2023-07-19 17:14:23 +00:00
|
|
|
<Table.Cell>SawStop</Table.Cell>
|
2020-08-13 22:24:04 +00:00
|
|
|
<Table.Cell>{member.wood_cert_date ? 'Yes, ' + member.wood_cert_date : 'No'}</Table.Cell>
|
2023-07-19 17:14:23 +00:00
|
|
|
<Table.Cell>SawStop course (WIP)</Table.Cell>
|
|
|
|
<Table.Cell><AdminCert name='SawStop' field='wood_cert_date' {...props} loading={loading} setLoading={setLoading} /></Table.Cell>
|
2020-08-13 22:24:04 +00:00
|
|
|
</Table.Row>
|
|
|
|
<Table.Row>
|
2023-07-19 17:14:23 +00:00
|
|
|
<Table.Cell>Drum Sander</Table.Cell>
|
2020-08-13 22:24:04 +00:00
|
|
|
<Table.Cell>{member.wood2_cert_date ? 'Yes, ' + member.wood2_cert_date : 'No'}</Table.Cell>
|
|
|
|
<Table.Cell><Link to='/courses/401'>Woodworking Tools 2: Jointer, Thickness Planer, Drum Sander</Link></Table.Cell>
|
2023-07-19 17:14:23 +00:00
|
|
|
<Table.Cell><AdminCert name='Drum Sander' field='wood2_cert_date' {...props} loading={loading} setLoading={setLoading} /></Table.Cell>
|
2020-08-13 22:24:04 +00:00
|
|
|
</Table.Row>
|
2023-07-19 17:14:23 +00:00
|
|
|
{false && <Table.Row>
|
2020-08-13 22:24:04 +00:00
|
|
|
<Table.Cell>Lathe</Table.Cell>
|
|
|
|
<Table.Cell>{member.lathe_cert_date ? 'Yes, ' + member.lathe_cert_date : 'No'}</Table.Cell>
|
|
|
|
<Table.Cell><Link to='/courses/281'>Metal: Metal Cutting & Manual Lathe</Link></Table.Cell>
|
2022-04-11 21:54:35 +00:00
|
|
|
<Table.Cell><AdminCert name='Lathe' field='lathe_cert_date' {...props} loading={loading} setLoading={setLoading} /></Table.Cell>
|
2023-07-19 17:14:23 +00:00
|
|
|
</Table.Row>}
|
|
|
|
{false && <Table.Row>
|
2020-08-13 22:24:04 +00:00
|
|
|
<Table.Cell>Mill</Table.Cell>
|
|
|
|
<Table.Cell>{member.mill_cert_date ? 'Yes, ' + member.mill_cert_date : 'No'}</Table.Cell>
|
|
|
|
<Table.Cell><Link to='/courses/283'>Metal: Manual Mill & Advanced Lathe</Link></Table.Cell>
|
2022-04-11 21:54:35 +00:00
|
|
|
<Table.Cell><AdminCert name='Mill' field='mill_cert_date' {...props} loading={loading} setLoading={setLoading} /></Table.Cell>
|
2023-07-19 17:14:23 +00:00
|
|
|
</Table.Row>}
|
2020-08-13 22:24:04 +00:00
|
|
|
<Table.Row>
|
2021-09-08 05:24:05 +00:00
|
|
|
<Table.Cell>Tormach CNC</Table.Cell>
|
|
|
|
<Table.Cell>{member.tormach_cnc_cert_date ? 'Yes, ' + member.tormach_cnc_cert_date : 'No'}</Table.Cell>
|
2020-08-13 22:24:04 +00:00
|
|
|
<Table.Cell><Link to='/courses/259'>Tormach: CAM and Tormach Intro</Link></Table.Cell>
|
2022-04-11 21:54:35 +00:00
|
|
|
<Table.Cell><AdminCert name='Tormach CNC' field='tormach_cnc_cert_date' {...props} loading={loading} setLoading={setLoading} /></Table.Cell>
|
2021-09-08 05:24:05 +00:00
|
|
|
</Table.Row>
|
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Precix CNC</Table.Cell>
|
|
|
|
<Table.Cell>{member.precix_cnc_cert_date ? 'Yes, ' + member.precix_cnc_cert_date : 'No'}</Table.Cell>
|
|
|
|
<Table.Cell><Link to='/courses/428'>Basic CNC Wood Router</Link></Table.Cell>
|
2022-04-11 21:54:35 +00:00
|
|
|
<Table.Cell><AdminCert name='Precix CNC' field='precix_cnc_cert_date' {...props} loading={loading} setLoading={setLoading} /></Table.Cell>
|
2020-08-13 22:24:04 +00:00
|
|
|
</Table.Row>
|
2020-09-15 19:21:32 +00:00
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Rabbit Laser</Table.Cell>
|
|
|
|
<Table.Cell>{member.rabbit_cert_date ? 'Yes, ' + member.rabbit_cert_date : 'No'}</Table.Cell>
|
|
|
|
<Table.Cell><Link to='/courses/247'>Laser: Cutting and Engraving</Link></Table.Cell>
|
2022-04-11 21:54:35 +00:00
|
|
|
<Table.Cell><AdminCert name='Rabbit' field='rabbit_cert_date' {...props} loading={loading} setLoading={setLoading} /></Table.Cell>
|
2020-09-15 19:21:32 +00:00
|
|
|
</Table.Row>
|
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Trotec Laser</Table.Cell>
|
|
|
|
<Table.Cell>{member.trotec_cert_date ? 'Yes, ' + member.trotec_cert_date : 'No'}</Table.Cell>
|
|
|
|
<Table.Cell><Link to='/courses/321'>Laser: Trotec Course</Link></Table.Cell>
|
2022-04-11 21:54:35 +00:00
|
|
|
<Table.Cell><AdminCert name='Trotec' field='trotec_cert_date' {...props} loading={loading} setLoading={setLoading} /></Table.Cell>
|
2020-09-15 19:21:32 +00:00
|
|
|
</Table.Row>
|
2020-08-13 22:24:04 +00:00
|
|
|
</Table.Body>
|
|
|
|
</Table>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|