diff --git a/internal/handlers/ussd/menuhandler.go b/internal/handlers/ussd/menuhandler.go index daf4b29..7a188c6 100644 --- a/internal/handlers/ussd/menuhandler.go +++ b/internal/handlers/ussd/menuhandler.go @@ -2015,15 +2015,16 @@ func (h *Handlers) insertProfileItems(ctx context.Context, sessionId string, res for index, profileItem := range h.profile.ProfileItems { // Ensure the profileItem is not "0"(is set) if profileItem != "0" { - err = store.WriteEntry(ctx, sessionId, profileDataKeys[index], []byte(profileItem)) - if err != nil { - logg.ErrorCtxf(ctx, "failed to write profile entry with", "key", profileDataKeys[index], "value", profileItem, "error", err) - return err - } - - // Get the flag for the current index flag, _ := h.flagManager.GetFlag(profileFlagNames[index]) - res.FlagSet = append(res.FlagSet, flag) + isProfileItemSet := h.st.MatchFlag(flag, true) + if !isProfileItemSet { + err = store.WriteEntry(ctx, sessionId, profileDataKeys[index], []byte(profileItem)) + if err != nil { + logg.ErrorCtxf(ctx, "failed to write profile entry with", "key", profileDataKeys[index], "value", profileItem, "error", err) + return err + } + res.FlagSet = append(res.FlagSet, flag) + } } } return nil diff --git a/menutraversal_test/group_test.json b/menutraversal_test/group_test.json index 8f43ff5..5ffe615 100644 --- a/menutraversal_test/group_test.json +++ b/menutraversal_test/group_test.json @@ -430,7 +430,7 @@ }, { "input": "1234", - "expectedContent": "My profile:\nName: foo bar\nGender: male\nAge: 84\nLocation: Kilifi\nYou provide: Bananas\n\n0:Back" + "expectedContent": "My profile:\nName: foo bar\nGender: male\nAge: 79\nLocation: Kilifi\nYou provide: Bananas\n\n0:Back" }, { "input": "0", diff --git a/services/registration/edit_offerings.vis b/services/registration/edit_offerings.vis index ddbc9e0..9c1e747 100644 --- a/services/registration/edit_offerings.vis +++ b/services/registration/edit_offerings.vis @@ -10,5 +10,4 @@ CATCH _ flag_back_set 1 RELOAD save_offerings INCMP _ 0 CATCH pin_entry flag_offerings_set 1 -CATCH pin_entry flag_offerings_set 0 INCMP update_profile_items * diff --git a/services/registration/select_gender.vis b/services/registration/select_gender.vis index c1a00f5..e41da10 100644 --- a/services/registration/select_gender.vis +++ b/services/registration/select_gender.vis @@ -11,3 +11,4 @@ INCMP _ 0 INCMP set_male 1 INCMP set_female 2 INCMP set_unspecified 3 +INCMP . *