fix(onboarding): could not create user (#848)

fix: onboarding not working
This commit is contained in:
ze0s 2023-04-17 20:56:17 +02:00 committed by GitHub
parent d03561d61c
commit 7f05dd1efd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 182 additions and 130 deletions

View file

@ -44,7 +44,7 @@ func (h actionHandler) getActions(w http.ResponseWriter, r *http.Request) {
// encode error
}
h.encoder.StatusResponse(r.Context(), w, actions, http.StatusOK)
h.encoder.StatusResponse(w, http.StatusOK, actions)
}
func (h actionHandler) storeAction(w http.ResponseWriter, r *http.Request) {
@ -63,7 +63,7 @@ func (h actionHandler) storeAction(w http.ResponseWriter, r *http.Request) {
// encode error
}
h.encoder.StatusResponse(ctx, w, action, http.StatusCreated)
h.encoder.StatusResponse(w, http.StatusCreated, action)
}
func (h actionHandler) updateAction(w http.ResponseWriter, r *http.Request) {
@ -82,37 +82,33 @@ func (h actionHandler) updateAction(w http.ResponseWriter, r *http.Request) {
// encode error
}
h.encoder.StatusResponse(ctx, w, action, http.StatusCreated)
h.encoder.StatusResponse(w, http.StatusCreated, action)
}
func (h actionHandler) deleteAction(w http.ResponseWriter, r *http.Request) {
var ctx = r.Context()
actionID, err := parseInt(chi.URLParam(r, "id"))
if err != nil {
h.encoder.StatusResponse(ctx, w, errors.New("bad param id"), http.StatusBadRequest)
h.encoder.StatusResponse(w, http.StatusBadRequest, errors.New("bad param id"))
}
if err := h.service.Delete(actionID); err != nil {
// encode error
}
h.encoder.StatusResponse(ctx, w, nil, http.StatusNoContent)
h.encoder.StatusResponse(w, http.StatusNoContent, nil)
}
func (h actionHandler) toggleActionEnabled(w http.ResponseWriter, r *http.Request) {
var ctx = r.Context()
actionID, err := parseInt(chi.URLParam(r, "id"))
if err != nil {
h.encoder.StatusResponse(ctx, w, errors.New("bad param id"), http.StatusBadRequest)
h.encoder.StatusResponse(w, http.StatusBadRequest, errors.New("bad param id"))
}
if err := h.service.ToggleEnabled(actionID); err != nil {
// encode error
}
h.encoder.StatusResponse(ctx, w, nil, http.StatusCreated)
h.encoder.StatusResponse(w, http.StatusCreated, nil)
}
func parseInt(s string) (int, error) {