Add cards to webclient

This commit is contained in:
Tanner Collin 2020-01-09 10:44:44 +00:00
parent 3762f3458d
commit 38e2363dfd
2 changed files with 91 additions and 17 deletions

View File

@ -368,7 +368,7 @@ function Transactions(props) {
return ( return (
<Container> <Container>
<Header size='large'>Protospace Transactions</Header> <Header size='large'>Transactions</Header>
<Table basic='very'> <Table basic='very'>
<Table.Header> <Table.Header>
@ -454,7 +454,69 @@ function TransactionDetail(props) {
: :
<NotFound /> <NotFound />
); );
} };
function Cards(props) {
const { user } = props;
const cardStatus = (c) => c.active_status === 'card_active' ? 'Yes' : 'No';
const card = user.cards[0];
return (
<Container>
<Header size='large'>Member Cards</Header>
{user.cards.length ?
user.cards.length > 1 ?
<Table basic='very'>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Number</Table.HeaderCell>
<Table.HeaderCell>Notes</Table.HeaderCell>
<Table.HeaderCell>Last Seen</Table.HeaderCell>
<Table.HeaderCell>Active</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
{user.cards.map((x, i) =>
<Table.Row key={i}>
<Table.Cell>{x.card_number}</Table.Cell>
<Table.Cell>{x.notes}</Table.Cell>
<Table.Cell>{x.last_seen_at}</Table.Cell>
<Table.Cell>{cardStatus(x)}</Table.Cell>
</Table.Row>
)}
</Table.Body>
</Table>
:
<Table unstackable basic='very'>
<Table.Body>
<Table.Row>
<Table.Cell>Number:</Table.Cell>
<Table.Cell>{card.card_number}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Notes:</Table.Cell>
<Table.Cell>{card.notes}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Last Seen:</Table.Cell>
<Table.Cell>{card.last_seen_at}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>Active:</Table.Cell>
<Table.Cell>{cardStatus(card)}</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
:
<p>No cards yet! Ask a director for one after you are vetted.</p>
}
</Container>
);
};
function PleaseLogin() { function PleaseLogin() {
return ( return (
@ -538,6 +600,8 @@ function App() {
/> />
<Dropdown.Item <Dropdown.Item
content='Cards' content='Cards'
as={Link}
to='/cards'
/> />
</Dropdown.Menu> </Dropdown.Menu>
</Dropdown> </Dropdown>
@ -568,6 +632,7 @@ function App() {
<Home token={token} setTokenCache={setTokenCache} user={user} setUserCache={setUserCache} /> <Home token={token} setTokenCache={setTokenCache} user={user} setUserCache={setUserCache} />
</Route> </Route>
<div className='topPadding'>
{user ? {user ?
<Switch> <Switch>
<Route path='/transactions/:id'> <Route path='/transactions/:id'>
@ -577,6 +642,10 @@ function App() {
<Transactions user={user} /> <Transactions user={user} />
</Route> </Route>
<Route path='/cards'>
<Cards user={user} />
</Route>
<Route path='/:page'> <Route path='/:page'>
<NotFound /> <NotFound />
</Route> </Route>
@ -586,6 +655,7 @@ function App() {
<PleaseLogin /> <PleaseLogin />
</Route> </Route>
} }
</div>
</Router> </Router>
) )

View File

@ -25,3 +25,7 @@ body {
#ps-menu .dropdown.icon { #ps-menu .dropdown.icon {
display: none; display: none;
} }
.topPadding {
padding-top: 1rem;
}