add a separate function to handle ConstructName
This commit is contained in:
parent
0f21b01813
commit
ba430a5849
@ -1398,18 +1398,7 @@ func (h *Handlers) GetProfileInfo(ctx context.Context, sym string, input []byte)
|
|||||||
offerings := getEntryOrDefault(store.ReadEntry(ctx, sessionId, common.DATA_OFFERINGS))
|
offerings := getEntryOrDefault(store.ReadEntry(ctx, sessionId, common.DATA_OFFERINGS))
|
||||||
|
|
||||||
// Construct the full name
|
// Construct the full name
|
||||||
name := defaultValue
|
name := utils.ConstructName(firstName, familyName, defaultValue)
|
||||||
if familyName != defaultValue {
|
|
||||||
if firstName != defaultValue {
|
|
||||||
name = firstName + " " + familyName
|
|
||||||
} else {
|
|
||||||
name = familyName
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if firstName != defaultValue {
|
|
||||||
name = firstName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate age from year of birth
|
// Calculate age from year of birth
|
||||||
age := defaultValue
|
age := defaultValue
|
||||||
|
17
internal/utils/name.go
Normal file
17
internal/utils/name.go
Normal file
@ -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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user