feat: order action per status change

This commit is contained in:
2026-04-16 14:19:27 +02:00
parent 7bce04e05a
commit 16f92e53ff
33 changed files with 748 additions and 61 deletions

View File

@@ -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 {

View File

@@ -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