diff --git a/internal/handlers/ussd/menuhandler.go b/internal/handlers/ussd/menuhandler.go index 6bc00ec..acd3dd4 100644 --- a/internal/handlers/ussd/menuhandler.go +++ b/internal/handlers/ussd/menuhandler.go @@ -1398,18 +1398,7 @@ func (h *Handlers) GetProfileInfo(ctx context.Context, sym string, input []byte) offerings := getEntryOrDefault(store.ReadEntry(ctx, sessionId, common.DATA_OFFERINGS)) // Construct the full name - name := defaultValue - if familyName != defaultValue { - if firstName != defaultValue { - name = firstName + " " + familyName - } else { - name = familyName - } - } else { - if firstName != defaultValue { - name = firstName - } - } + name := utils.ConstructName(firstName, familyName, defaultValue) // Calculate age from year of birth age := defaultValue diff --git a/internal/utils/name.go b/internal/utils/name.go new file mode 100644 index 0000000..4665d02 --- /dev/null +++ b/internal/utils/name.go @@ -0,0 +1,17 @@ +package utils + +func ConstructName(firstName, familyName, defaultValue string) string { + name := defaultValue + if familyName != defaultValue { + if firstName != defaultValue { + name = firstName + " " + familyName + } else { + name = familyName + } + } else { + if firstName != defaultValue { + name = firstName + } + } + return name +} \ No newline at end of file