diff --git a/webclient/src/Admin.js b/webclient/src/Admin.js index 6f63577..b7af65e 100644 --- a/webclient/src/Admin.js +++ b/webclient/src/Admin.js @@ -1,8 +1,71 @@ import React, { useState, useEffect } from 'react'; import { BrowserRouter as Router, Switch, Route, Link, useParams, useHistory } from 'react-router-dom'; import './light.css'; -import { Container, Checkbox, Divider, Dropdown, Form, Grid, Header, Icon, Image, Menu, Message, Segment, Table } from 'semantic-ui-react'; +import { Button, Container, Checkbox, Divider, Dropdown, Form, Grid, Header, Icon, Image, Menu, Message, Segment, Table } from 'semantic-ui-react'; +import moment from 'moment'; import { BasicTable, staticUrl, requester } from './utils.js'; +import { TransactionList, TransactionEditor } from './Transactions.js'; + +export function AdminTransactions(props) { + const { token, result, refreshResult } = props; + 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 handleSubmit = (e) => { + 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 ( +
None
+ } + +Loading...
diff --git a/webclient/src/Transactions.js b/webclient/src/Transactions.js index 7cb0b88..a95f782 100644 --- a/webclient/src/Transactions.js +++ b/webclient/src/Transactions.js @@ -5,7 +5,7 @@ import { Container, Divider, Dropdown, Form, Grid, Header, Icon, Image, Menu, Me import { isAdmin, BasicTable, requester } from './utils.js'; import { NotFound, PleaseLogin } from './Misc.js'; -function TransactionEditor(props) { +export function TransactionEditor(props) { const { input, setInput, error } = props; const handleValues = (e, v) => setInput({ ...input, [v.name]: v.value }); @@ -178,6 +178,40 @@ function EditTransaction(props) { ); }; +export function TransactionList(props) { + const { transactions } = props; + + return ( +