Skip to content

Commit f762afe

Browse files
updated conenect wallet component and added 404 error
1 parent 337a12a commit f762afe

File tree

6 files changed

+89
-23
lines changed

6 files changed

+89
-23
lines changed

cloud/queries.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,14 @@ Moralis.Cloud.define(
242242
}
243243
}
244244
];
245+
let m = {};
246+
if(request.params.player){
247+
m.player = {
248+
$eq: request.params.player
249+
}
250+
pipeline.push(m);
251+
}
252+
245253
const results = await query.aggregate(pipeline, { useMasterKey: true });
246254
return results;
247255
}

pythia-frontend/src/components/Market/MarketDisplay.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
<div v-if="!$store.state.chainCorrect">
1212
<Alert background='#ff000080' color='white' message='Error:' text='Incorrect network, please switch to Kovan'/>
1313
</div>
14+
<div v-if="!marketExists">
15+
<PageNotFound/>
16+
</div>
17+
1418
</template>
1519

1620
<script>
@@ -28,10 +32,13 @@ export default {
2832
Alert: defineAsyncComponent(() =>
2933
import('../subcomponents/AlertWindow.vue')
3034
),
35+
PageNotFound: defineAsyncComponent(() =>
36+
import('../subcomponents/PageNotFound.vue')
37+
)
3138
},
3239
data(){
3340
return {
34-
marketExists: false,
41+
marketExists: true,
3542
marketData: {
3643
marketInfo: null,
3744
playerInfo: {
Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,45 @@
11
<template>
2-
<button v-if="!isLoggedIn" @click="logIn" class="login-button">
2+
<button v-if="!isLoggedIn" @click="logIn" class="login-button" style="height:35px">
33
<img src = "https://raw.githubusercontent.com/blakewood84/react-metamask/main/public/images/metamask.svg" alt="My Happy SVG" width='12' height='12'/>
44
Connect Wallet
55
</button>
6-
<button
7-
v-if="isLoggedIn"
8-
@click="logOut"
9-
class="login-button">
10-
<img src = "https://raw.githubusercontent.com/blakewood84/react-metamask/main/public/images/metamask.svg" alt="My Happy SVG" width='12' height='12'/>
11-
Disconnect
12-
</button>
6+
<div v-if="isLoggedIn" class="login-container">
7+
<span class="expert-score-display">
8+
{{expertLevel}}
9+
</span>
10+
<button
11+
style="position: relative;right: 0px;top: 0px;height: 100%;"
12+
@click="logOut"
13+
class="login-button">
14+
<img src = "https://raw.githubusercontent.com/blakewood84/react-metamask/main/public/images/metamask.svg" alt="My Happy SVG" width='12' height='12'/>
15+
Disconnect
16+
</button>
17+
</div>
1318
</template>
1419

1520
<script>
21+
import {determineExpertise} from '../../utils.js'
22+
import Moralis from '../../main.js'
1623
1724
export default {
25+
data(){
26+
return {
27+
expertLevel: 'Novice'
28+
}
29+
},
1830
methods: {
1931
async logIn(){
20-
await this.$store.commit('logIn')
21-
console.log('logged in')
32+
await Moralis.authenticate();
33+
await this.$store.commit('logIn');
34+
let player = this.$store.state.user.get('ethAddress');
35+
this.expertLevel = await determineExpertise(player);
2236
},
2337
async logOut(){
38+
await Moralis.User.logOut();
2439
await this.$store.commit('logOut')
25-
console.log('logged out');
2640
27-
}
41+
42+
},
2843
},
2944
computed: {
3045
isLoggedIn(){
@@ -40,24 +55,38 @@ export default {
4055

4156
<style scoped>
4257
58+
.login-container {
59+
display:flex;
60+
justify-content: space-between;
61+
position: relative;
62+
background-color: #183362;
63+
gap: 10px;
64+
height: 35px;
65+
border-radius: 15px;
66+
}
67+
4368
.login-button {
4469
background: #3a46c4;
4570
box-shadow: 1px 1px 8px #121212;
4671
color: #ffffff;
4772
border: none;
4873
border-radius: 15px;
4974
font-size: 12px;
50-
padding-left: 12px;
51-
padding-right: 12px;
52-
padding-top: 8px;
53-
padding-bottom: 8px;
54-
font-family: 'MontSerrat';
55-
font-weight: 450;
56-
z-index: 5;
57-
margin-left: 5px;
75+
min-width:120px;
5876
}
5977
6078
.login-button:hover{
6179
background-color: #3a46c4;
6280
}
81+
82+
.expert-score-display{
83+
color: #4cd9b2;
84+
height: 100%;
85+
display: flex;
86+
align-items: center;
87+
font-size: 13px;
88+
padding-left: 10px;
89+
font-family: system-ui;
90+
font-weight: 650;
91+
}
6392
</style>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<div style="display: flex;align-items: center;justify-content: center;height: 70vh;font-family: system-ui;">
3+
<h1 style="color:white">404 error: Page not found</h1>
4+
</div>
5+
</template>

pythia-frontend/src/main.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ const store = createStore({
2525
},
2626
mutations: {
2727
async logIn(state) {
28-
await Moralis.authenticate();
2928
state.user = Moralis.User.current();
3029
},
3130
async logOut(state) {
32-
await Moralis.User.logOut();
3331
state.user = null;
3432
},
3533

pythia-frontend/src/utils.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,23 @@ export const roundNum = (num) => {
6767
} else {
6868
return Math.round(num * 1000) / 1000
6969
}
70+
}
71+
72+
export const determineExpertise = async (player) => {
73+
const results = await Moralis.Cloud.run(
74+
'getTopPerformers',
75+
player
76+
)
77+
const expertScore = results[0].expertScore;
78+
if(expertScore < 100){
79+
return 'Novice';
80+
}else if(expertScore < 1000){
81+
return 'Investor'
82+
}else if(expertScore < 10000){
83+
return 'Expert'
84+
}else{
85+
return 'Crypto grandmaster'
86+
}
87+
88+
7089
}

0 commit comments

Comments
 (0)