Remove add transaction form from member page

This commit is contained in:
Tanner Collin 2020-08-08 22:02:45 +00:00
parent daee96ce3f
commit 218dc60fb4

View File

@ -180,57 +180,18 @@ export function AdminTransactions(props) {
export function AdminMemberTransactions(props) { export function AdminMemberTransactions(props) {
const { token, result, refreshResult } = props; const { token, result, refreshResult } = props;
const transactions = result.transactions; const transactions = result.transactions;
const [open, setOpen] = useState(false);
const [input, setInput] = useState({ date: moment().format('YYYY-MM-DD'), info_source: 'Web' });
const [error, setError] = useState(false);
const [loading, setLoading] = useState(false);
const [success, setSuccess] = useState(false);
const { id } = useParams(); const { id } = useParams();
const handleSubmit = (e) => {
if (loading) return;
setLoading(true);
setSuccess(false);
const data = { ...input, member_id: id };
requester('/transactions/', 'POST', token, data)
.then(res => {
setSuccess(res.id);
setInput({});
setLoading(false);
setError(false);
refreshResult();
})
.catch(err => {
setLoading(false);
console.log(err);
setError(err.data);
});
};
return ( return (
<div> <div>
<Header size='medium'>Edit Member Transactions</Header> <Header size='medium'>Member Transactions</Header>
<Form onSubmit={handleSubmit}> <Link to='/admintrans'>Add a transaction</Link>
<Header size='small'>Add a Transaction</Header>
<TransactionEditor noMemberSearch input={input} setInput={setInput} error={error} />
<Form.Button loading={loading} error={error.non_field_errors}>
Submit
</Form.Button>
{success && <p>Added! <Link to={'/transactions/'+success}>View the transaction.</Link></p>}
</Form>
<Header size='small'>Current Transactions</Header> <Header size='small'>Current Transactions</Header>
{transactions.length ? {transactions.length ?
open ? <TransactionList noMember transactions={transactions} />
<TransactionList noMember transactions={transactions} />
:
<Button onClick={() => setOpen(true)}>
View / Edit Transactions
</Button>
: :
<p>None</p> <p>None</p>
} }