2023-05-25 19:22:46 -04:00
|
|
|
package webhandlers
|
|
|
|
|
|
|
|
import (
|
2023-05-25 22:07:53 -04:00
|
|
|
"fmt"
|
2023-05-25 19:22:46 -04:00
|
|
|
"net/http"
|
|
|
|
|
2023-05-25 22:07:53 -04:00
|
|
|
"git.agecem.com/agecem/bottin/v4/data"
|
2023-05-25 19:22:46 -04:00
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
)
|
|
|
|
|
|
|
|
func GetIndex(c echo.Context) error {
|
|
|
|
return c.Render(http.StatusOK, "index-html", nil)
|
|
|
|
}
|
2023-05-25 22:07:53 -04:00
|
|
|
|
|
|
|
func GetMembre(c echo.Context) error {
|
2023-06-02 02:46:08 -04:00
|
|
|
apiClient := data.NewApiClientFromViper()
|
2023-05-25 22:07:53 -04:00
|
|
|
|
|
|
|
membreID := c.QueryParam("membre_id")
|
|
|
|
|
|
|
|
membre, err := apiClient.GetMembre(membreID)
|
|
|
|
if err != nil {
|
|
|
|
return c.Render(http.StatusBadRequest, "index-html", struct {
|
|
|
|
Result string
|
|
|
|
}{
|
|
|
|
Result: fmt.Sprintln("👎", err.Error()),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
membreResult := fmt.Sprintf(`👍
|
|
|
|
Membre trouvéE: [%s]`, membre.ID)
|
|
|
|
|
|
|
|
if membre.PreferedName != "" {
|
|
|
|
membreResult = fmt.Sprintf("%s -> %s", membreResult, membre.PreferedName)
|
|
|
|
} else {
|
|
|
|
membreResult = fmt.Sprintf("%s -> %s, %s", membreResult, membre.LastName, membre.FirstName)
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.Render(http.StatusOK, "index-html", struct {
|
|
|
|
Result string
|
|
|
|
}{
|
|
|
|
Result: membreResult,
|
|
|
|
})
|
|
|
|
}
|