package authhttp import ( "errors" authsvc "legalgo-BE-go/internal/services/auth" "legalgo-BE-go/internal/utilities/response" "net/http" "github.com/go-chi/chi/v5" ) func GetStaffProfile( router chi.Router, authSvc authsvc.AuthIntf, ) { router.Get("/staff/{id}/profile", func(w http.ResponseWriter, r *http.Request) { ctx := r.Context() id := chi.URLParam(r, "id") if id == "" { response.ResponseWithErrorCode( ctx, w, errors.New("provided id is empty"), response.ErrBadRequest.Code, response.ErrBadRequest.HttpCode, "required params is not provided", ) return } staffProfile, err := authSvc.GetStaffProfile(id) if err != nil { response.ResponseWithErrorCode( ctx, w, err, response.ErrBadRequest.Code, response.ErrBadRequest.HttpCode, err.Error(), ) return } response.RespondJsonSuccess(ctx, w, staffProfile) }) } func GetUserProfile( router chi.Router, authSvc authsvc.AuthIntf, ) { router.Get("/user/{id}/profile", func(w http.ResponseWriter, r *http.Request) { ctx := r.Context() id := chi.URLParam(r, "id") if id == "" { response.ResponseWithErrorCode( ctx, w, errors.New("provided id is empty"), response.ErrBadRequest.Code, response.ErrBadRequest.HttpCode, "required params is not provided", ) return } userProfile, err := authSvc.GetUserProfile(id) if err != nil { response.ResponseWithErrorCode( ctx, w, err, response.ErrBadRequest.Code, response.ErrBadRequest.HttpCode, err.Error(), ) return } response.RespondJsonSuccess(ctx, w, userProfile) }) }