Refactor user render

Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-02-27 11:51:40 +01:00
parent a68fcc238d
commit 664e2cdd78
2 changed files with 5 additions and 31 deletions

View File

@@ -15,35 +15,15 @@
package types
import (
"time"
"github.com/getprobo/probo/pkg/usrmgr/coredata"
)
type UserType struct {
ID string
Email string
CreatedAt time.Time
UpdatedAt time.Time
}
// NewUser creates a new UserType from a coredata.User
func NewUser(u *coredata.User) *UserType {
return &UserType{
ID: u.ID.String(),
func NewUser(u *coredata.User) *User {
return &User{
ID: u.ID,
Email: u.EmailAddress,
FullName: u.FullName,
CreatedAt: u.CreatedAt,
UpdatedAt: u.UpdatedAt,
}
}
// AddUserToOrganizationInput is the input for adding a user to an organization
type AddUserToOrganizationInput struct {
UserID string
OrganizationID string
}
// AddUserToOrganizationPayload is the payload for adding a user to an organization
type AddUserToOrganizationPayload struct {
User *UserType
}

View File

@@ -334,13 +334,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
// Viewer is the resolver for the viewer field.
func (r *queryResolver) Viewer(ctx context.Context) (*types.User, error) {
user := UserFromContext(ctx)
return &types.User{
ID: user.ID,
Email: user.EmailAddress,
FullName: user.FullName,
CreatedAt: user.CreatedAt,
UpdatedAt: user.UpdatedAt,
}, nil
return types.NewUser(user), nil
}
// StateTransisions is the resolver for the stateTransisions field.