Skip to content

Commit

Permalink
feat: only populate other in the email if not nil or empty string (#735)
Browse files Browse the repository at this point in the history
* feat: only populate other in the email if not nil or empty string
  • Loading branch information
StevenWadeOddball authored Oct 5, 2023
1 parent 6642762 commit 14b48ba
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pkg/graph/resolvers/send_feedback_email.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,24 @@ func humanizeFeedbackAllowContact(allowFeedback *bool) string {
}

func humanizeFeedbackMINTUses(usedFor []model.MintUses, usedForOther *string) []string {
//TODO: SW implement

uses := []string{}
containsOther := false
for _, use := range usedFor {
humanized := humanizeFeedbackMINTUse(use)
if humanized == "" {
continue
}
if humanized == "Other" {
containsOther = true
if models.ValueOrEmpty(usedForOther) != "" { // only add the text if isn't nil or empty.
humanized = humanized + " - " + *usedForOther
}
}
uses = append(uses, humanized)
}
if usedForOther != nil {
use := "Other"
if *usedForOther != "" {
use = use + " - " + *usedForOther
}
if !containsOther && models.ValueOrEmpty(usedForOther) != "" { // It other wasn't selected, but the optional text was filled out include it anyways
use := "Other - " + *usedForOther
uses = append(uses, use)
}

Expand All @@ -104,7 +108,7 @@ func humanizeFeedbackMINTUse(use model.MintUses) string {
case model.MintUsesViewHelp:
return "To view the Help Center"
case model.MintUsesOther:
return "" // TODO: SW should we include the actual word other?
return "Other"
default:
return string(use)
}
Expand Down

0 comments on commit 14b48ba

Please sign in to comment.