Skip to content
Snippets Groups Projects
Commit ca35bde7 authored by meskio's avatar meskio :tent:
Browse files

Get my transactions not all of them

parent e78b4ce2
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,7 @@ func Init(dbPath string, signKey string, r *mux.Router) error {
r.HandleFunc("/product/{code:[0-9]+}", a.authAdmin(a.UpdateProduct)).Methods("PUT")
r.HandleFunc("/product/{code:[0-9]+}", a.authAdmin(a.DeleteProduct)).Methods("DELETE")
r.HandleFunc("/transaction", a.auth(a.ListTransactions)).Methods("GET")
r.HandleFunc("/transaction", a.authAdmin(a.ListTransactions)).Methods("GET")
r.HandleFunc("/transaction/{id:[0-9]+}", a.authNumRole(a.GetTransaction)).Methods("GET")
r.HandleFunc("/transaction/mine", a.authNum(a.getTransactionsByMember)).Methods("GET")
......
......@@ -86,6 +86,7 @@ func (a *api) getTransactionsByMember(num int, w http.ResponseWriter, req *http.
err := a.db.Where("member = ?", num).
Preload("Purchase.Product").
Preload(clause.Associations).
Order("date desc").
Find(&transactions).Error
if err != nil {
log.Printf("Can't list transactions: %v", err)
......
......@@ -45,7 +45,7 @@ function TransactionList() {
}
return (
<Fetcher url="/api/transaction" onFetch={setTransactions} >
<Fetcher url="/api/transaction/mine" onFetch={setTransactions} >
<BootstrapTable
keyField="ID"
data={ transactions }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment