import React, { useState } from 'react'; import './light.css'; import moment from 'moment-timezone'; import { Button, Container, Header, Table } from 'semantic-ui-react'; import { BasicTable, staticUrl, useIsMobile } from './utils.js'; export function Cards(props) { const { user, token } = props; const [open, setOpen] = useState(false); const isMobile = useIsMobile(); const cardStatus = (c) => c.active_status === 'card_active' ? 'Yes' : 'No'; const card = user.cards[0]; return (
Cards / Access
Your Cards
{user.member.card_photo ?

View your card image.

:

Upload a photo to generate a card image.

} {user.cards.length ? user.cards.length > 1 ? {!isMobile && Number Notes Last Scan Active } {user.cards.map(x => {x.card_number} {isMobile && 'Notes: '}{x.notes} {isMobile && 'Last Scan: '}{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' } {isMobile && 'Active: '}{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))
:

}
); };