2020-01-09 22:11:56 +00:00
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
import { BrowserRouter as Router, Switch, Route, Link, useParams } from 'react-router-dom';
|
|
|
|
import './light.css';
|
|
|
|
import { Container, Divider, Dropdown, Form, Grid, Header, Icon, Image, Menu, Message, Segment, Table } from 'semantic-ui-react';
|
2020-01-20 02:54:44 +00:00
|
|
|
import { statusColor, BasicTable, staticUrl, requester } from './utils.js';
|
2020-01-09 22:11:56 +00:00
|
|
|
import { LoginForm, SignupForm } from './LoginSignup.js';
|
2020-01-13 03:18:41 +00:00
|
|
|
import { AccountForm } from './Account.js';
|
2020-01-09 22:11:56 +00:00
|
|
|
|
|
|
|
function MemberInfo(props) {
|
|
|
|
const user = props.user;
|
|
|
|
const member = user.member;
|
|
|
|
|
2020-01-20 00:29:28 +00:00
|
|
|
const lastTrans = user.transactions && user.transactions.slice(0,3);
|
2020-01-09 22:11:56 +00:00
|
|
|
const lastCard = user.cards && user.cards.sort((a, b) => a.last_seen_at < b.last_seen_at)[0];
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Grid stackable>
|
2020-01-12 04:58:29 +00:00
|
|
|
<Grid.Column width={5}>
|
|
|
|
<Image
|
|
|
|
size='small'
|
|
|
|
src={member.photo_medium ? staticUrl + '/' + member.photo_medium : '/nophoto.png'}
|
2020-01-11 06:27:30 +00:00
|
|
|
/>
|
2020-01-09 22:11:56 +00:00
|
|
|
</Grid.Column>
|
|
|
|
|
2020-01-12 04:58:29 +00:00
|
|
|
<Grid.Column width={11}>
|
2020-01-20 02:54:44 +00:00
|
|
|
<Header size='large'>{member.preferred_name} {member.last_name}</Header>
|
2020-01-09 22:11:56 +00:00
|
|
|
|
2020-01-12 04:58:29 +00:00
|
|
|
<BasicTable>
|
|
|
|
<Table.Body>
|
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Status:</Table.Cell>
|
2020-01-20 02:54:44 +00:00
|
|
|
<Table.Cell>
|
|
|
|
<Icon name='circle' color={statusColor[member.status]} />
|
|
|
|
{member.status || 'Unknown'}
|
|
|
|
</Table.Cell>
|
2020-01-12 04:58:29 +00:00
|
|
|
</Table.Row>
|
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Expiry:</Table.Cell>
|
|
|
|
<Table.Cell>{member.expire_date}</Table.Cell>
|
|
|
|
</Table.Row>
|
|
|
|
</Table.Body>
|
|
|
|
</BasicTable>
|
2020-01-09 22:11:56 +00:00
|
|
|
</Grid.Column>
|
|
|
|
</Grid>
|
|
|
|
|
2020-01-26 10:39:59 +00:00
|
|
|
{!member.photo_medium && <Message>
|
|
|
|
<Message.Header>Welcome, new member!</Message.Header>
|
|
|
|
<p>
|
|
|
|
<a href={staticUrl + '/' + member.member_forms} target='_blank'>
|
|
|
|
Click here
|
|
|
|
</a> to view your appliction forms.
|
|
|
|
</p>
|
|
|
|
</Message>}
|
|
|
|
|
2020-01-13 08:01:42 +00:00
|
|
|
{!member.photo_medium && <Message warning>
|
|
|
|
<Message.Header>Please set a member photo!</Message.Header>
|
|
|
|
<p>Visit the <Link to='/account'>account settings</Link> page to set one.</p>
|
|
|
|
</Message>}
|
|
|
|
|
2020-01-09 22:11:56 +00:00
|
|
|
<Header size='medium'>Details</Header>
|
2020-01-11 23:53:42 +00:00
|
|
|
<BasicTable>
|
2020-01-09 22:11:56 +00:00
|
|
|
<Table.Body>
|
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Application:</Table.Cell>
|
2020-01-12 08:16:09 +00:00
|
|
|
<Table.Cell>{member.application_date || 'Unknown'}</Table.Cell>
|
2020-01-09 22:11:56 +00:00
|
|
|
</Table.Row>
|
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Start:</Table.Cell>
|
2020-01-12 08:16:09 +00:00
|
|
|
<Table.Cell>{member.current_start_date || 'Unknown'}</Table.Cell>
|
2020-01-09 22:11:56 +00:00
|
|
|
</Table.Row>
|
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Vetted:</Table.Cell>
|
|
|
|
<Table.Cell>{member.vetted_date || 'Not vetted'}</Table.Cell>
|
|
|
|
</Table.Row>
|
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Monthly:</Table.Cell>
|
2020-01-12 08:16:09 +00:00
|
|
|
<Table.Cell>${member.monthly_fees || 'Unknown'}</Table.Cell>
|
2020-01-09 22:11:56 +00:00
|
|
|
</Table.Row>
|
|
|
|
<Table.Row>
|
|
|
|
<Table.Cell>Card Number:</Table.Cell>
|
|
|
|
<Table.Cell>{lastCard && lastCard.card_number || 'None'}</Table.Cell>
|
|
|
|
</Table.Row>
|
|
|
|
</Table.Body>
|
2020-01-11 23:53:42 +00:00
|
|
|
</BasicTable>
|
2020-01-09 22:11:56 +00:00
|
|
|
|
2020-01-26 10:39:59 +00:00
|
|
|
{member.photo_medium && <p>
|
|
|
|
<a href={staticUrl + '/' + member.member_forms} target='_blank'>
|
|
|
|
View application forms
|
|
|
|
</a>
|
|
|
|
</p>}
|
|
|
|
|
2020-01-09 22:11:56 +00:00
|
|
|
<Header size='medium'>Latest Transactions</Header>
|
2020-01-11 23:53:42 +00:00
|
|
|
<BasicTable>
|
2020-01-09 22:11:56 +00:00
|
|
|
<Table.Body>
|
|
|
|
{lastTrans.length ?
|
2020-01-18 01:36:53 +00:00
|
|
|
lastTrans.map(x =>
|
|
|
|
<Table.Row key={x.id}>
|
2020-01-10 00:29:52 +00:00
|
|
|
<Table.Cell>
|
|
|
|
<Link to={'/transactions/'+x.id}>{x.date}</Link>
|
|
|
|
</Table.Cell>
|
2020-01-09 22:11:56 +00:00
|
|
|
<Table.Cell>{x.account_type}</Table.Cell>
|
|
|
|
<Table.Cell>${x.amount}</Table.Cell>
|
|
|
|
</Table.Row>
|
|
|
|
)
|
|
|
|
:
|
2020-01-11 04:20:07 +00:00
|
|
|
<Table.Row><Table.Cell>None</Table.Cell></Table.Row>
|
2020-01-09 22:11:56 +00:00
|
|
|
}
|
|
|
|
</Table.Body>
|
2020-01-11 23:53:42 +00:00
|
|
|
</BasicTable>
|
2020-01-09 22:11:56 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export function Home(props) {
|
2020-01-19 06:58:51 +00:00
|
|
|
const { user } = props;
|
2020-01-09 22:11:56 +00:00
|
|
|
return (
|
|
|
|
<Container>
|
|
|
|
<Grid stackable padded columns={2}>
|
|
|
|
<Grid.Column>
|
|
|
|
{user ?
|
|
|
|
user.member.set_details ?
|
|
|
|
<MemberInfo user={user} />
|
|
|
|
:
|
2020-01-19 06:58:51 +00:00
|
|
|
<AccountForm {...props} />
|
2020-01-09 22:11:56 +00:00
|
|
|
:
|
|
|
|
<div>
|
2020-01-19 06:58:51 +00:00
|
|
|
<LoginForm {...props} />
|
2020-01-09 22:11:56 +00:00
|
|
|
|
|
|
|
<Divider section horizontal>Or</Divider>
|
|
|
|
|
2020-01-19 06:58:51 +00:00
|
|
|
<SignupForm {...props} />
|
2020-01-09 22:11:56 +00:00
|
|
|
</div>
|
|
|
|
}
|
|
|
|
</Grid.Column>
|
|
|
|
<Grid.Column>
|
|
|
|
<Segment>
|
2020-01-11 06:27:30 +00:00
|
|
|
<Header size='medium'>Home</Header>
|
2020-01-09 22:11:56 +00:00
|
|
|
<p>Welcome to the Protospace member portal! Here you can view member info, join classes, and manage your membership.</p>
|
|
|
|
|
|
|
|
<Header size='medium'>Quick Links</Header>
|
|
|
|
<p><a href='http://protospace.ca/' target='_blank' rel='noopener noreferrer'>Main Website</a></p>
|
|
|
|
<p><a href='http://wiki.protospace.ca/Welcome_to_Protospace' target='_blank' rel='noopener noreferrer'>Protospace Wiki</a></p>
|
|
|
|
<p><a href='https://groups.google.com/forum/#!forum/protospace-discuss' target='_blank' rel='noopener noreferrer'>Discussion Google Group</a></p>
|
2020-02-04 06:49:39 +00:00
|
|
|
<p><a href='https://groups.google.com/forum/#!forum/protospace-administration' target='_blank' rel='noopener noreferrer'>Admin Google Group</a></p>
|
2020-01-09 22:11:56 +00:00
|
|
|
<p><a href='https://drive.google.com/open?id=0By-vvp6fxFekfmU1cmdxaVRlaldiYXVyTE9rRnNVNjhkc3FjdkFIbjBwQkZ3MVVQX2Ezc3M' target='_blank' rel='noopener noreferrer'>Google Drive</a></p>
|
|
|
|
|
|
|
|
<Header size='medium'>Protospace Stats</Header>
|
|
|
|
<p>Next member meeting: Jan 01, 2099</p>
|
|
|
|
<p>Next monthly clean: Jan 01, 2099</p>
|
|
|
|
<p>Current member count: 200</p>
|
|
|
|
<p>Due members: 20</p>
|
|
|
|
<p>Expired members: 100</p>
|
|
|
|
<p>Bay 108 temperature: 21 C</p>
|
|
|
|
<p>Bay 110 temperature: 22 C</p>
|
|
|
|
|
|
|
|
</Segment>
|
|
|
|
</Grid.Column>
|
|
|
|
</Grid>
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
};
|