import React, { useState, useEffect } from 'react'; import { BrowserRouter as Router, Switch, Route, Link, useParams } from 'react-router-dom'; import './light.css'; import moment from 'moment-timezone'; import { Button, Container, Divider, Dropdown, Form, Grid, Header, Icon, Image, Menu, Message, Segment, Table } from 'semantic-ui-react'; import { BasicTable, requester, staticUrl } from './utils.js'; import { NotFound, PleaseLogin } from './Misc.js'; export function Cards(props) { const { user, token } = props; const [open, setOpen] = useState(false); const cardStatus = (c) => c.active_status === 'card_active' ? 'Yes' : 'No'; const card = user.cards[0]; return (
Cards / Access
Your Cards
{user.member.card_photo ?

Click here to view your card image.

:

Upload a photo to generate a card image.

} {user.cards.length ? user.cards.length > 1 ? Number Notes Last Scan Active {user.cards.map(x => {x.card_number} {x.notes} {x.last_seen ? x.last_seen > '2021-11-14T02:01:35.415685Z' ? moment.utc(x.last_seen).tz('America/Edmonton').format('lll') : moment.utc(x.last_seen).tz('America/Edmonton').format('ll') : 'Unknown' } {cardStatus(x)} )}
: Number: {card.card_number} Notes: {card.notes} Last Seen: {card.last_seen ? card.last_seen > '2021-11-14T02:01:35.415685Z' ? moment.utc(card.last_seen).tz('America/Edmonton').format('lll') : moment.utc(card.last_seen).tz('America/Edmonton').format('ll') : 'Unknown' } Active: {cardStatus(card)} :

No cards yet! Ask a director for one after you are vetted.

} {!!user.door_code &&
Door Alarm Code

Only share this with vetted Protospace members:

{user.door_code}

} {!!user.wifi_pass &&
Wi-Fi Password

Only share this with Protospace members and guests:

{user.wifi_pass}

}
API Key

Don't share this with anyone! Treat it like your password:

{open ?

{token}

API Docs

To learn how to use this, refer to the API docs:
https://docs.my.protospace.ca/api.html

API Examples

Get your user info with Bash (curl):

$ curl -H "Authorization: Token {token}" https://api.my.protospace.ca/user/

Get your user info with Python 3 (and requests):

import json, requests

SECRET_API_KEY = '{token}'

headers = {'{'}'Authorization': 'Token '+SECRET_API_KEY{'}'}
r = requests.get('https://api.my.protospace.ca/user/', headers=headers)

print(json.dumps(r.json(), indent=4))
:

}
); };