Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolved update profile bug #366

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions server/action/profile/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type user struct {
LastName string `json:"last_name"`
DisplayName string `json:"display_name" validate:"required"`
Slug string `json:"slug" validate:"required"`
BirthDate time.Time `json:"birth_date"`
BirthDate string `json:"birth_date"`
Gender string `json:"gender"`
FeaturedMediumID uint `json:"featured_medium_id"`
Description string `json:"description"`
Expand Down Expand Up @@ -85,18 +85,16 @@ func update(w http.ResponseWriter, r *http.Request) {
"meta": req.Meta,
}

if !req.BirthDate.IsZero() {
birthDate := req.BirthDate.Format("2006-01-02") // format birth_date to YYYY-MM-DD

if req.BirthDate != "" {
timeLayout := "2006-01-02"
birth_date, err := time.Parse(timeLayout, req.BirthDate)
if err != nil {
tx.Rollback()
loggerx.Error(err)
errorx.Render(w, errorx.Parser(errorx.DecodeError()))
errorx.Render(w, errorx.Parser(errorx.GetMessage("invalid birth_date", http.StatusUnprocessableEntity)))
return
}
updateUser["birth_date"] = birthDate
} else {
updateUser["birth_date"] = nil
updateUser["birth_date"] = birth_date
}

if req.FeaturedMediumID == 0 {
Expand Down