diff --git a/webclient/src/Transactions.js b/webclient/src/Transactions.js
index 2a4efec..63bda25 100644
--- a/webclient/src/Transactions.js
+++ b/webclient/src/Transactions.js
@@ -147,11 +147,6 @@ function EditTransaction(props) {
const [success, setSuccess] = useState(false);
const { id } = useParams();
- const handleValues = (e, v) => setInput({ ...input, [v.name]: v.value });
- const handleUpload = (e, v) => setInput({ ...input, [v.name]: e.target.files[0] });
- const handleChange = (e) => handleValues(e, e.currentTarget);
- const handleCheck = (e, v) => setInput({ ...input, [v.name]: v.checked });
-
const handleSubmit = (e) => {
setLoading(true);
setSuccess(false);
@@ -182,7 +177,70 @@ function EditTransaction(props) {
- Save
+ {transaction.report_type ? 'Save & Unreport' : 'Save'}
+
+ {success && Success!
}
+
+
+ );
+};
+
+function ReportTransaction(props) {
+ const { transaction, setTransaction, token, refreshUser } = props;
+ const [input, setInput] = useState(transaction);
+ const [error, setError] = useState(false);
+ const [loading, setLoading] = useState(false);
+ const [success, setSuccess] = useState(false);
+ const { id } = useParams();
+
+ const handleValues = (e, v) => setInput({ ...input, [v.name]: v.value });
+ const handleUpload = (e, v) => setInput({ ...input, [v.name]: e.target.files[0] });
+ const handleChange = (e) => handleValues(e, e.currentTarget);
+ const handleCheck = (e, v) => setInput({ ...input, [v.name]: v.checked });
+
+ const handleSubmit = (e) => {
+ setLoading(true);
+ setSuccess(false);
+ requester('/transactions/'+id+'/report/', 'POST', token, input)
+ .then(res => {
+ setLoading(false);
+ setSuccess(true);
+ setError(false);
+ if (refreshUser) {
+ refreshUser();
+ }
+ })
+ .catch(err => {
+ setLoading(false);
+ console.log(err);
+ setError(err.data);
+ });
+ };
+
+ const makeProps = (name) => ({
+ name: name,
+ onChange: handleChange,
+ value: input[name] || '',
+ error: error[name],
+ });
+
+ return (
+
+
+
+
If this transaction was made in error or there is anything incorrect about it, please report it using this form.
+
A staff member will review the report as soon as possible.
+
Follow up with directors@protospace.ca.
+
+
+
+
+ Submit Report
{success &&
Success!
}
@@ -254,7 +312,7 @@ export function TransactionDetail(props) {
console.log(err);
setError(true);
});
- }, []);
+ }, [ownTransaction]);
return (
@@ -329,9 +387,15 @@ export function TransactionDetail(props) {
- {isAdmin(user) &&
-
- }
+ {isAdmin(user) ?
+
+
+
+ :
+
+
+
+ }