Make shelf buttons clickable and add to Home
This commit is contained in:
parent
3d6666cc40
commit
9ec850abfe
|
@ -1,9 +1,9 @@
|
||||||
import React, { useState, useEffect, useReducer } from 'react';
|
import React, { useState, useEffect, useReducer } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link, useParams, useHistory } from 'react-router-dom';
|
||||||
import moment from 'moment-timezone';
|
import moment from 'moment-timezone';
|
||||||
import QRCode from 'react-qr-code';
|
import QRCode from 'react-qr-code';
|
||||||
import './light.css';
|
import './light.css';
|
||||||
import { Container, Divider, Grid, Header, Icon, Image, Message, Popup, Segment, Table } from 'semantic-ui-react';
|
import { Button, Container, Divider, Grid, Header, Icon, Image, Message, Popup, Segment, Table } from 'semantic-ui-react';
|
||||||
import { statusColor, BasicTable, siteUrl, staticUrl, requester, isAdmin } from './utils.js';
|
import { statusColor, BasicTable, siteUrl, staticUrl, requester, isAdmin } from './utils.js';
|
||||||
import { LoginForm, SignupForm } from './LoginSignup.js';
|
import { LoginForm, SignupForm } from './LoginSignup.js';
|
||||||
import { AccountForm } from './Account.js';
|
import { AccountForm } from './Account.js';
|
||||||
|
@ -13,6 +13,7 @@ import { PayPalSubscribeDeal } from './PayPal.js';
|
||||||
function MemberInfo(props) {
|
function MemberInfo(props) {
|
||||||
const user = props.user;
|
const user = props.user;
|
||||||
const member = user.member;
|
const member = user.member;
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
const lastTrans = user.transactions?.slice(0,3);
|
const lastTrans = user.transactions?.slice(0,3);
|
||||||
const lastTrain = user.training?.sort((a, b) => a.session.datetime < b.session.datetime ? 1 : -1).slice(0,3);
|
const lastTrain = user.training?.sort((a, b) => a.session.datetime < b.session.datetime ? 1 : -1).slice(0,3);
|
||||||
|
@ -20,6 +21,11 @@ function MemberInfo(props) {
|
||||||
|
|
||||||
const unpaidTraining = user.training?.filter(x => x.attendance_status === 'Waiting for payment');
|
const unpaidTraining = user.training?.filter(x => x.attendance_status === 'Waiting for payment');
|
||||||
|
|
||||||
|
const handleStorageButton = (e, id) => {
|
||||||
|
e.preventDefault();
|
||||||
|
history.push('/storage/' + id);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{member.protocoin < 0 && <Message error>
|
{member.protocoin < 0 && <Message error>
|
||||||
|
@ -57,6 +63,24 @@ function MemberInfo(props) {
|
||||||
<Table.Cell>Protocoin:</Table.Cell>
|
<Table.Cell>Protocoin:</Table.Cell>
|
||||||
<Table.Cell>₱ {member.protocoin.toFixed(2)} <Link to='/paymaster'>[buy]</Link></Table.Cell>
|
<Table.Cell>₱ {member.protocoin.toFixed(2)} <Link to='/paymaster'>[buy]</Link></Table.Cell>
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
|
<Table.Row>
|
||||||
|
<Table.Cell>Shelf:</Table.Cell>
|
||||||
|
<Table.Cell>
|
||||||
|
{user.storage.length ?
|
||||||
|
user.storage.map((x, i) =>
|
||||||
|
<Button
|
||||||
|
className='storage-button'
|
||||||
|
onClick={(e) => handleStorageButton(e, x.id)}
|
||||||
|
size='tiny'
|
||||||
|
>
|
||||||
|
{x.shelf_id}
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
:
|
||||||
|
'None'
|
||||||
|
}
|
||||||
|
</Table.Cell>
|
||||||
|
</Table.Row>
|
||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.Cell>Expiry:</Table.Cell>
|
<Table.Cell>Expiry:</Table.Cell>
|
||||||
<Table.Cell>{member.expire_date ? moment(member.expire_date).format('ll') : 'Unknown'}</Table.Cell>
|
<Table.Cell>{member.expire_date ? moment(member.expire_date).format('ll') : 'Unknown'}</Table.Cell>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React, { useState, useEffect, useReducer } from 'react';
|
import React, { useState, useEffect, useReducer } from 'react';
|
||||||
import { Link, useParams } from 'react-router-dom';
|
import { Link, useParams, useHistory } from 'react-router-dom';
|
||||||
import './light.css';
|
import './light.css';
|
||||||
import { Button, Container, Dropdown, Grid, Header, Icon, Image, Input, Item, Segment, Table } from 'semantic-ui-react';
|
import { Button, Container, Dropdown, Grid, Header, Icon, Image, Input, Item, Segment, Table } from 'semantic-ui-react';
|
||||||
import { statusColor, isAdmin, isInstructor, BasicTable, staticUrl, requester } from './utils.js';
|
import { statusColor, isAdmin, isInstructor, BasicTable, staticUrl, requester } from './utils.js';
|
||||||
|
@ -99,6 +99,7 @@ export function Members(props) {
|
||||||
const [search, setSearch] = useState(searchCache);
|
const [search, setSearch] = useState(searchCache);
|
||||||
const [controller, setController] = useState(false);
|
const [controller, setController] = useState(false);
|
||||||
const { token, user } = props;
|
const { token, user } = props;
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
const makeRequest = ({loadPage, q, sort_key}) => {
|
const makeRequest = ({loadPage, q, sort_key}) => {
|
||||||
let pageNum = 0;
|
let pageNum = 0;
|
||||||
|
@ -165,6 +166,11 @@ export function Members(props) {
|
||||||
doSearch(q);
|
doSearch(q);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleStorageButton = (e, id) => {
|
||||||
|
e.preventDefault();
|
||||||
|
history.push('/storage/' + id);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!responseCache) {
|
if (!responseCache) {
|
||||||
doSort('recently_vetted');
|
doSort('recently_vetted');
|
||||||
|
@ -243,7 +249,7 @@ export function Members(props) {
|
||||||
x.member.storage.map((x, i) =>
|
x.member.storage.map((x, i) =>
|
||||||
<Button
|
<Button
|
||||||
className='storage-button'
|
className='storage-button'
|
||||||
onClick={(e) => e.preventDefault()}
|
onClick={(e) => handleStorageButton(e, x.id)}
|
||||||
size='tiny'
|
size='tiny'
|
||||||
>
|
>
|
||||||
{x.shelf_id}
|
{x.shelf_id}
|
||||||
|
|
|
@ -95,19 +95,19 @@ function EditStorage(props) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Header size='medium'>Edit Storage</Header>
|
<Header size='medium'>Edit Storage {storage.shelf_id}</Header>
|
||||||
|
|
||||||
<Form onSubmit={handleSubmit}>
|
<Form onSubmit={handleSubmit}>
|
||||||
|
<Form.Button floated='right' onClick={saveAndNext} loading={loading} error={error.non_field_errors}>
|
||||||
|
Save and edit next
|
||||||
|
</Form.Button>
|
||||||
|
|
||||||
<StorageEditor token={token} input={input} setInput={setInput} error={error} />
|
<StorageEditor token={token} input={input} setInput={setInput} error={error} />
|
||||||
|
|
||||||
<Form.Group widths='equal'>
|
<Form.Group widths='equal'>
|
||||||
<Form.Button loading={loading} error={error.non_field_errors}>
|
<Form.Button loading={loading} error={error.non_field_errors}>
|
||||||
Save
|
Save
|
||||||
</Form.Button>
|
</Form.Button>
|
||||||
|
|
||||||
<Form.Button floated='right' onClick={saveAndNext} loading={loading} error={error.non_field_errors}>
|
|
||||||
Save and edit next
|
|
||||||
</Form.Button>
|
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
{success && <div>Success!</div>}
|
{success && <div>Success!</div>}
|
||||||
</Form>
|
</Form>
|
||||||
|
|
|
@ -170,6 +170,7 @@ body {
|
||||||
.ui.button.storage-button {
|
.ui.button.storage-button {
|
||||||
padding-left: 0.5rem;
|
padding-left: 0.5rem;
|
||||||
padding-right: 0.5rem;
|
padding-right: 0.5rem;
|
||||||
|
margin-top: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ui.tag.label {
|
.ui.tag.label {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user