show a default message if the user only has 1 voucher
This commit is contained in:
parent
ce36e584dd
commit
c57aa220e6
@ -181,8 +181,18 @@ func (h *MenuHandlers) GetVoucherList(ctx context.Context, sym string, input []b
|
||||
return res, fmt.Errorf("missing session")
|
||||
}
|
||||
|
||||
code := codeFromCtx(ctx)
|
||||
l := gotext.NewLocale(translationDir, code)
|
||||
l.AddDomain("default")
|
||||
|
||||
userStore := h.userdataStore
|
||||
|
||||
// Fetch session data
|
||||
_, _, activeSym, _, _, _, err := h.getSessionData(ctx, sessionId)
|
||||
if err != nil {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// Read vouchers from the store
|
||||
voucherData, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_VOUCHER_SYMBOLS)
|
||||
logg.InfoCtxf(ctx, "reading voucherData in GetVoucherList", "sessionId", sessionId, "key", storedb.DATA_VOUCHER_SYMBOLS, "voucherData", voucherData)
|
||||
@ -191,6 +201,11 @@ func (h *MenuHandlers) GetVoucherList(ctx context.Context, sym string, input []b
|
||||
return res, err
|
||||
}
|
||||
|
||||
if len(voucherData) == 0 {
|
||||
res.Content = l.Get("Your active voucher %s is already set", string(activeSym))
|
||||
return res, nil
|
||||
}
|
||||
|
||||
voucherBalances, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_VOUCHER_BALANCES)
|
||||
logg.InfoCtxf(ctx, "reading voucherBalances in GetVoucherList", "sessionId", sessionId, "key", storedb.DATA_VOUCHER_BALANCES, "voucherBalances", voucherBalances)
|
||||
if err != nil {
|
||||
@ -203,7 +218,7 @@ func (h *MenuHandlers) GetVoucherList(ctx context.Context, sym string, input []b
|
||||
|
||||
logg.InfoCtxf(ctx, "final output for GetVoucherList", "sessionId", sessionId, "finalOutput", finalOutput)
|
||||
|
||||
res.Content = finalOutput
|
||||
res.Content = l.Get("Select number or symbol from your vouchers:\n%s", finalOutput)
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@ -1,2 +1 @@
|
||||
Select number or symbol from your vouchers:
|
||||
{{.get_vouchers}}
|
||||
Loading…
Reference in New Issue
Block a user