add wallet address to user

This commit is contained in:
João Geonizeli
2021-08-18 15:58:04 -03:00
parent 00337665bd
commit d21bd33436
14 changed files with 125 additions and 86 deletions

View File

@@ -10,10 +10,10 @@ class UserDashboard < Administrate::BaseDashboard
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
id: Field::Number,
full_name: Field::String,
email: Field::String,
first_name: Field::String,
last_name: Field::String,
email: Field::String,
wallet_address: Field::String,
created_at: Field::DateTime,
updated_at: Field::DateTime,
}.freeze
@@ -23,16 +23,16 @@ class UserDashboard < Administrate::BaseDashboard
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = [:full_name, :email].freeze
COLLECTION_ATTRIBUTES = [:id, :first_name, :last_name, :wallet_address, :email].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = [:id, :first_name, :last_name, :email, :created_at, :updated_at].freeze
SHOW_PAGE_ATTRIBUTES = [:id, :first_name, :last_name, :wallet_address, :email, :created_at, :updated_at].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = [:first_name, :last_name].freeze
FORM_ATTRIBUTES = [:first_name, :last_name, :wallet_address].freeze
# COLLECTION_FILTERS
# a hash that defines filters that can be used while searching via the search

View File

@@ -7,9 +7,9 @@ module Types
graphql_name "User"
field :id, ID, null: false
field :email, String, null: false
field :first_name, String, null: false
field :last_name, String, null: false
field :full_name, String, null: false
field :email, String, null: false
field :wallet_address, String, null: true
end
end

View File

@@ -506,7 +506,7 @@ type StakeOrderEdge {
type User {
email: String!
firstName: String!
fullName: String!
id: ID!
lastName: String!
walletAddress: String
}

View File

@@ -27,6 +27,7 @@ query AppQuery {
fragment UserProvider_user on User {
firstName
walletAddress
}
*/
@@ -78,6 +79,13 @@ const node: ConcreteRequest = {
"name": "firstName",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "walletAddress",
"storageKey": null
},
{
"alias": null,
"args": null,
@@ -91,12 +99,12 @@ const node: ConcreteRequest = {
]
},
"params": {
"cacheID": "ce9692d3fdea00e7368e2a6404748f16",
"cacheID": "56b4be302cf9b9ec226ad8145170961b",
"id": null,
"metadata": {},
"name": "AppQuery",
"operationKind": "query",
"text": "query AppQuery {\n currentUser {\n ...UserProvider_user\n id\n }\n}\n\nfragment UserProvider_user on User {\n firstName\n}\n"
"text": "query AppQuery {\n currentUser {\n ...UserProvider_user\n id\n }\n}\n\nfragment UserProvider_user on User {\n firstName\n walletAddress\n}\n"
}
};
(node as any).hash = 'aac57a65620cf50754d54f3c8d6495cf';

View File

@@ -8,6 +8,7 @@ import type { UserProvider_user$key } from "./__generated__/UserProvider_user.gr
type CurrentUserContext = {
user: {
firstName: string;
walletAddress: string | null;
} | null;
isAuthenticated: boolean;
};
@@ -32,6 +33,7 @@ export const UserProvider: FC<Props> = ({ userRef, children }) => {
graphql`
fragment UserProvider_user on User {
firstName
walletAddress
}
`,
userRef
@@ -40,6 +42,7 @@ export const UserProvider: FC<Props> = ({ userRef, children }) => {
const user = userData
? {
firstName: userData.firstName,
walletAddress: userData.walletAddress,
}
: null;

View File

@@ -6,6 +6,7 @@ import { ReaderFragment } from "relay-runtime";
import { FragmentRefs } from "relay-runtime";
export type UserProvider_user = {
readonly firstName: string;
readonly walletAddress: string | null;
readonly " $refType": "UserProvider_user";
};
export type UserProvider_user$data = UserProvider_user;
@@ -28,10 +29,17 @@ const node: ReaderFragment = {
"kind": "ScalarField",
"name": "firstName",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "walletAddress",
"storageKey": null
}
],
"type": "User",
"abstractKey": null
};
(node as any).hash = '352cdd208485d062f3f7c2e22e287a99';
(node as any).hash = 'ef997d2646b4d39178c6f3318509a7cb';
export default node;

View File

@@ -12,6 +12,7 @@
# remember_created_at :datetime
# reset_password_sent_at :datetime
# reset_password_token :string
# wallet_address :string
# created_at :datetime not null
# updated_at :datetime not null
#
@@ -34,10 +35,6 @@ class User < ApplicationRecord
validates :first_name, :last_name, :email, presence: true
validates :email, uniqueness: true
def full_name
"#{first_name} #{last_name}"
end
after_create do
create_balances
end