feat: order action per status change
This commit is contained in:
@@ -14,6 +14,14 @@ func GetLangID(c fiber.Ctx) (uint, bool) {
|
||||
return user_locale.OriginalUser.LangID, true
|
||||
}
|
||||
|
||||
func GetOriginalUserID(c fiber.Ctx) (uint, bool) {
|
||||
user_locale, ok := c.Locals(constdata.USER_LOCALE).(*model.UserLocale)
|
||||
if !ok || user_locale.OriginalUser == nil {
|
||||
return 0, false
|
||||
}
|
||||
return user_locale.OriginalUser.ID, true
|
||||
}
|
||||
|
||||
func GetUserID(c fiber.Ctx) (uint, bool) {
|
||||
user_locale, ok := c.Locals(constdata.USER_LOCALE).(*model.UserLocale)
|
||||
if !ok || user_locale.User == nil {
|
||||
|
||||
@@ -71,6 +71,8 @@ var (
|
||||
// Typed errors for orders handler
|
||||
ErrEmptyCart = errors.New("the cart is empty")
|
||||
ErrUserHasNoSuchOrder = errors.New("user does not have order with given id")
|
||||
ErrInvalidStatus = errors.New("invalid order status")
|
||||
ErrOrderNotFound = errors.New("order not found")
|
||||
|
||||
// Typed errors for price reduction handler
|
||||
ErrInvalidReductionType = errors.New("invalid reduction type: must be 'amount' or 'percentage'")
|
||||
@@ -314,7 +316,8 @@ func GetErrorStatus(err error) int {
|
||||
errors.Is(err, ErrMaxAmtOfAddressesReached),
|
||||
errors.Is(err, ErrUserHasNoSuchAddress),
|
||||
errors.Is(err, ErrInvalidCountryID),
|
||||
errors.Is(err, ErrInvalidAddressJSON):
|
||||
errors.Is(err, ErrInvalidAddressJSON),
|
||||
errors.Is(err, ErrInvalidStatus):
|
||||
return fiber.StatusBadRequest
|
||||
case errors.Is(err, ErrSpecificPriceNotFound):
|
||||
return fiber.StatusNotFound
|
||||
|
||||
Reference in New Issue
Block a user