go back on 0 input for navigation
This commit is contained in:
parent
fe534b1181
commit
e7a3e63cd5
@ -560,6 +560,13 @@ func (h *MenuHandlers) ValidateAmount(ctx context.Context, sym string, input []b
|
|||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
flag_invalid_amount, _ := h.flagManager.GetFlag("flag_invalid_amount")
|
flag_invalid_amount, _ := h.flagManager.GetFlag("flag_invalid_amount")
|
||||||
|
|
||||||
|
inputStr := string(input)
|
||||||
|
if inputStr == "0" {
|
||||||
|
res.FlagReset = append(res.FlagReset, flag_invalid_amount)
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
userStore := h.userdataStore
|
userStore := h.userdataStore
|
||||||
|
|
||||||
var balanceValue float64
|
var balanceValue float64
|
||||||
@ -577,7 +584,7 @@ func (h *MenuHandlers) ValidateAmount(ctx context.Context, sym string, input []b
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extract numeric part from the input amount
|
// Extract numeric part from the input amount
|
||||||
amountStr := strings.TrimSpace(string(input))
|
amountStr := strings.TrimSpace(inputStr)
|
||||||
inputAmount, err := strconv.ParseFloat(amountStr, 64)
|
inputAmount, err := strconv.ParseFloat(amountStr, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.FlagSet = append(res.FlagSet, flag_invalid_amount)
|
res.FlagSet = append(res.FlagSet, flag_invalid_amount)
|
||||||
@ -585,7 +592,7 @@ func (h *MenuHandlers) ValidateAmount(ctx context.Context, sym string, input []b
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if inputAmount > balanceValue || inputAmount < 0.1{
|
if inputAmount > balanceValue || inputAmount < 0.1 {
|
||||||
res.FlagSet = append(res.FlagSet, flag_invalid_amount)
|
res.FlagSet = append(res.FlagSet, flag_invalid_amount)
|
||||||
res.Content = amountStr
|
res.Content = amountStr
|
||||||
return res, nil
|
return res, nil
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user