diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-12-04 01:46:17 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-12-04 01:46:17 +0530 |
commit | a6087d0a4f177973b9d27e544f85736d90039089 (patch) | |
tree | 7f1edc54a6a1175552cbfbabf32283f37aa8bf32 /invoice/controller.go | |
parent | f169571cffeb3ac0404d56ac01ece90c33338113 (diff) |
added API route to get drafts onlyv0.3.0
Diffstat (limited to 'invoice/controller.go')
-rw-r--r-- | invoice/controller.go | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/invoice/controller.go b/invoice/controller.go index 7260834..6bd5ad5 100644 --- a/invoice/controller.go +++ b/invoice/controller.go @@ -74,7 +74,32 @@ func handleGetInvoices (ctx *gin.Context) { userId := uId.(uint) - err := getInvoices(&invoices, userId) + err := getInvoices(&invoices, userId, false) + if err != nil { + ctx.Error(err) + ctx.Abort() + return + } + + ctx.JSON(http.StatusOK, gin.H{ + "message": "success", + "data": invoices, + }) +} + +func handleGetDrafts (ctx *gin.Context) { + var invoices []Invoice + + uId, ok := ctx.Get("UserID") + if !ok { + ctx.Error(e.ErrUnauthorized) + ctx.Abort() + return + } + + userId := uId.(uint) + + err := getInvoices(&invoices, userId, true) if err != nil { ctx.Error(err) ctx.Abort() |