Skip to content

Commit

Permalink
Merge pull request #369 from consensusnetworks/update/user-schema
Browse files Browse the repository at this point in the history
Update/user schema
  • Loading branch information
ccali11 committed Jul 6, 2023
2 parents 5f12c3b + b7b7779 commit 4197640
Show file tree
Hide file tree
Showing 9 changed files with 311 additions and 237 deletions.
14 changes: 13 additions & 1 deletion apps/web/src/composables/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,17 @@ export default function useUsers () {
return await fetch(`${usersBaseURL}/user/update-primary-account`, requestOptions)
}

async function updateUserAgreement(agreed: boolean) {
const requestOptions = {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ agreed })
}
return await fetch(`${usersBaseURL}/user/update-user-agreement/${user.value?.id}`, requestOptions)
}

return {
session,
user: readonly(user),
Expand All @@ -341,6 +352,7 @@ export default function useUsers () {
removeAccount,
setUser,
setUserAccountBalances,
updatePrimaryAddress
updatePrimaryAddress,
updateUserAgreement
}
}
5 changes: 4 additions & 1 deletion apps/web/src/pages/overview/components/Staking.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import TermsOfService from '@/components/TermsOfService.vue'
const { deposit, getDepositFees } = useContracts()
const { getEthersBalance } = useEthers()
const { user } = useUsers()
const { user, updateUserAgreement } = useUsers()
const { getCurrentPrice } = usePrice()
const selectedProvider = ref<ProviderString>('')
Expand Down Expand Up @@ -140,6 +140,8 @@ watch(formattedAmountToStake, async () => {
watch(user, () => {
aggregateAddressesByProvider()
termsOfServiceCheckbox.value = user.value?.agreedToTermsOfService as boolean
console.log('user.value.agreedToTermsOfService :>> ', user.value?.agreedToTermsOfService)
})
onMounted(async () => {
Expand Down Expand Up @@ -344,6 +346,7 @@ const handleDeposit = async () => {
v-model="termsOfServiceCheckbox"
type="checkbox"
class="card_checkbox"
@change="updateUserAgreement(termsOfServiceCheckbox)"
>
<button
id="termsOfServiceButton"
Expand Down
3 changes: 2 additions & 1 deletion common/data/src/interfaces/JsonSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export interface JsonSchema {
properties: {
[key: string]: {
type: string,
description: string
description: string,
default: string | number | boolean | null
}
},
uniqueFields?: string[],
Expand Down
5 changes: 4 additions & 1 deletion common/data/src/providers/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ export class Schema {

const comment = property.description
if (comment.includes('PK')) column += ' PRIMARY KEY'


const defaultValue = property.default
if (defaultValue !== undefined) column += ` DEFAULT ${defaultValue}`

return column
})

Expand Down
6 changes: 6 additions & 0 deletions common/data/src/schemas/user.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
"type": "string",
"description": "The account last update date in ISO 8601 format"
},
"agreed_to_terms_of_service": {
"type": "boolean",
"description": "The user aggreement status",
"default": false
},
"wallet_provider": {
"type": "string",
"description": "The wallet provider used set a primary user account"
Expand All @@ -30,6 +35,7 @@
"created_at",
"id",
"updated_at",
"user_aggreement",
"wallet_provider"
]
}
2 changes: 2 additions & 0 deletions common/types/src/interfaces/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export interface User {
id: number
/* ISO Timestamp of when user was last updated */
updatedAt?: string
/* Did user agree to terms of service? */
agreedToTermsOfService: boolean
/* Wallet provider (e.g. metamask) */
walletProvider: ProviderString
}
Loading

0 comments on commit 4197640

Please sign in to comment.