Skip to content

Commit

Permalink
Merge pull request #1332 from /issues/1322
Browse files Browse the repository at this point in the history
Issues/1322
  • Loading branch information
Vishwas1 authored Jun 21, 2022
2 parents ddb05a3 + 0eab228 commit a6c830a
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 86 deletions.
50 changes: 22 additions & 28 deletions src/components/participant/Action.vue
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
<template>
<div
class="accordion mt-3 mx-auto overflow-hidden"
role="tablist"
style="max-width: 600px"
>
<loading
:active.sync="isLoading"
:can-cancel="true"
:is-full-page="fullPage"
></loading>
<Profile :user="userProfile" />
<template v-for="(actionItem, index) in ActionSchema">
<component v-if="actionItem.type==='INFO_TEXT'"
:is="CapitaliseString(actionItem.type)"
:key="index"
:idValue="index"
:data="actionItem"
@input="updateUserInfo(actionItem, $event)"
></component>
<div class="accordion mt-3 mx-auto overflow-hidden" role="tablist" style="max-width: 600px" @click=" checkIfUserHasLoggedIn()">
<loading :active.sync="isLoading" :can-cancel="true" :is-full-page="fullPage"></loading>
<Profile v-if="userProfile" :user="userProfile" />

<template v-for="(actionItem, index) in ActionSchema" >
<component v-if="actionItem.type==='INFO_TEXT'" :is="CapitaliseString(actionItem.type)" :key="index"
:idValue="index" :data="actionItem" @input="updateUserInfo(actionItem, $event)"></component>
</template>
<prize-card v-if="isPrizedata" :prizeData="prizeData" />
<prize-card v-if="isPrizedata" :prizeData="prizeData" />

<template v-for="(actionItem, index) in ActionSchema">
<component v-if="actionItem.type!=='INFO_TEXT'"
:is="CapitaliseString(actionItem.type)"
:key="index"
:idValue="index"
:data="actionItem"
@input="updateUserInfo(actionItem, $event)"
></component>
<template v-for="(actionItem, index) in ActionSchema" >
<component v-if="actionItem.type!=='INFO_TEXT'" :is="CapitaliseString(actionItem.type)" :key="index"
:idValue="index" :data="actionItem" @input="updateUserInfo(actionItem, $event)"></component>
</template>
</div>
</template>
Expand Down Expand Up @@ -175,6 +158,17 @@ export default {
},
},
methods: {
checkIfUserHasLoggedIn() {
if (!this.userProfile) {
document.querySelectorAll(".card-header").forEach(e => {
const nodeVal = e.attributes['aria-controls'].nodeValue
document.getElementById(nodeVal).style.display = "none";
})
return this.notifyErr(Messsages.EVENT_ACTIONS.UNAUTHENTICATED);
} else {
console.log('User is authenticated')
}
},
CapitaliseString(string) {
let res = string.split("_");
let first = res[0][0].toUpperCase() + res[0].substring(1).toLowerCase();
Expand Down
67 changes: 40 additions & 27 deletions src/components/participant/ActionInputs/EthereumErc20.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@
:disabled="true"
:required="data.isManadatory"
></b-form-input>
<button class="btn text-black" @click="invokeMetamask()" v-if="!done">
<!-- <button
class="btn text-black"
@click="invokeMetamask()"
v-if="!done"
>
<img
src="../../../assets/metamask.svg"
height="25px"
width="25px"
/>
</button>
</button> -->
</div>
</b-col>
</b-row>
Expand All @@ -57,17 +61,20 @@
</b-col>
</b-row>
<b-row v-if="!done">
<b-col cols="12" sm="12" md="12" >
<button class="btn btn-link center" @click="update()">Continue</button>
<b-col class= "btn-group" cols="12" sm="8" md="8" style="text-align: center">
<button class="btn btn-link btn-sm" @click="invokeMetamask()">Connect Metamask</button>
<button class="btn btn-link btn-sm" @click="update()">Continue</button>
</b-col>
</b-row>
</b-card-body>
</b-collapse>
</b-card>
</template>
<style scoped>
.center{
display: block; margin-left: auto;margin-right: auto
.center {
display: block;
margin-left: auto;
margin-right: auto;
}
</style>

Expand Down Expand Up @@ -107,13 +114,13 @@ export default {
value: {
contractAddress: "",
userWalletAddress: "",
thresholdBalance: 0
}
thresholdBalance: 0,
},
};
},
mounted() {
if(this.data.value){
Object.assign(this.value, {...JSON.parse(this.data.value) })
if (this.data.value) {
Object.assign(this.value, { ...JSON.parse(this.data.value) });
}
eventBus.$on(`disableInput${this.data._id}`, this.disableInput);
this.checkWeb3Injection();
Expand Down Expand Up @@ -144,23 +151,26 @@ export default {
const wallet = await ethereum.request({
method: "eth_requestAccounts",
});
this.signature = await this.signMessage();
const generatedWalletAddr = await this.web3.eth.personal.ecRecover(this.message_sign, this.signature)
let isSigVerified = false;
if(generatedWalletAddr === wallet[0]){
isSigVerified = true;
}
this.signature = await this.signMessage();
const generatedWalletAddr = await this.web3.eth.personal.ecRecover(
this.message_sign,
this.signature
);
let isSigVerified = false;
if (generatedWalletAddr === wallet[0]) {
isSigVerified = true;
}
if (isSigVerified) {
this.value.userWalletAddress = wallet[0];
} else{
return this.notifyErr(Messages.EVENT_ACTIONS.ETH.INVALID_SIG)
} else {
return this.notifyErr(Messages.EVENT_ACTIONS.ETH.INVALID_SIG);
}
}
}
} catch (error) {
return this.notifyErr(error.message)
return this.notifyErr(error.message);
}
},
async update() {
Expand All @@ -171,15 +181,18 @@ export default {
let balance = await this.fetchBalance();
if (balance !== undefined) {
if (balance >= Number.parseFloat(this.value.thresholdBalance)) {
this.$emit("input", JSON.stringify({
...this.value,
}));
this.$emit(
"input",
JSON.stringify({
...this.value,
})
);
} else {
throw new Error(Messages.EVENT_ACTIONS.ETH.INSUFFICIENT_BALANCE);
}
}
} catch (error) {
this.data.value = ""
this.data.value = "";
return this.notifyErr(error);
}
}
Expand Down
23 changes: 12 additions & 11 deletions src/utils/messages/participants/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ const EVENT = {
BANNER: {

},
PROFILE:{
PROFILE: {
TEXT_COPIED: "Text copied to clipboard",
ERROR_WHILE_COPYING: "Error in copying text: "
ERROR_WHILE_COPYING: "Error in copying text: "
},
EVENT_IS_OVER: {

Expand All @@ -18,11 +18,12 @@ const EVENT = {
}

const ACTIONS = {
UPDATE_FAILED: "Error: could not update the action",
NO_ACTION_FOUND: "Error: no actions found with user",
SOME_ERROR: "Error: some error occurred"
UPDATE_FAILED: "Error: could not update the action",
NO_ACTION_FOUND: "Error: no actions found with user",
SOME_ERROR: "Error: some error occurred"
}
const EVENT_ACTIONS = {
UNAUTHENTICATED: "Error: Please login to proceed",
INVALID_INPUT: "Error: Field value is invalid",
URL_NOT_VISITED: "Error: Please visit the link",
WENT_WRONG: "Error: Something Went Wrong",
Expand All @@ -34,15 +35,15 @@ const EVENT_ACTIONS = {
TELEGRAM_AUTH: "Error: Please authorize telegram to proceed",
AUTH_FAILED: "Authentication Failed! Try again",
FETCH_USERNAME_FAILED: "Could not fetch the username after telegram authentication",
JOIN_TG:"Please Join and then try again",
ASK_ADMIN_TO_SET_GROUPID:"Please ask organizer to set proper group username at the admin panel or make sure you added the bot to your channel or group"
JOIN_TG: "Please Join and then try again",
ASK_ADMIN_TO_SET_GROUPID: "Please ask organizer to set proper group username at the admin panel or make sure you added the bot to your channel or group"
},
DISCORD_JOIN: {
DISCORD_AUTH: "Error: Please authorize discord to proceed",
AUTH_FAILED: "Authentication Failed! Try again",
},
TWITTER_FOLLOW: {
TWITTER_AUTH:"Error: Please authorize and follow",
TWITTER_AUTH: "Error: Please authorize and follow",
FOLLOW_FIRST: "Error: Please follow first",
TWITTER_SCREENS_BLANK: "Error: Source or target twitter screen name is blank",
},
Expand All @@ -52,13 +53,13 @@ const EVENT_ACTIONS = {
ETH: {
INVALIDWEB3: "Web3 provider not found. Please install Metamask wallet",
INVALID_SIG: "Invalid signature",
CONNECT_METAMASK:"Connect your metamask wallet",
INSUFFICIENT_BALANCE : "Insufficient balance"
CONNECT_METAMASK: "Connect your metamask wallet",
INSUFFICIENT_BALANCE: "Insufficient balance"
},
REEF: {
CONNECT_REEF_WALLET: "Connect your reef wallet by selcting address options"
},
SUBS:{
SUBS: {
SUBS_NOTIFICATION: "Click On Subscribe Notificaion"
}
}
Expand Down
57 changes: 37 additions & 20 deletions src/views/participant/Event.vue
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
<template>
<div>
<loading
:active.sync="isLoading"
:can-cancel="true"
:is-full-page="fullPage"
></loading>
<b-card no-body class="mx-auto overflow-hidden mt-3 border-0" style="max-width: 600px;">
<Metrics :authToken="authToken" @getLeaderBoard="fetchLeaderBoard" :leaderBoardData="leaderBoardData" :userScore="userEventData && userEventData.numberOfReferals? userEventData.numberOfReferals : 0" :totalEntries="eventData && eventData.count ? eventData.count : 0" :timeLeft="timeLeft" />
<Banner :eventName="eventData.projectName" :themeColor="eventData.themeColor" :fontColor="eventData.fontColor" :fromDate="new Date(eventData.fromDate).toLocaleString()" :toDate="new Date(eventData.toDate).toLocaleString()" :logoUrl="eventData.logoUrl" />
<template v-if="authToken == '' || authToken == null">
<Login :themeColor="eventData.themeColor" :fontColor="eventData.fontColor" @AuthTokenUpdateEvent="updateAuthentication" />
</template>
<loading :active.sync="isLoading" :can-cancel="true" :is-full-page="fullPage"></loading>
<b-card no-body class="mx-auto overflow-hidden mt-3 border-0 mainContentWdth">
<Metrics :authToken="authToken" @getLeaderBoard="fetchLeaderBoard" :leaderBoardData="leaderBoardData"
:userScore="userEventData && userEventData.numberOfReferals? userEventData.numberOfReferals : 0"
:totalEntries="eventData && eventData.count ? eventData.count : 0" :timeLeft="timeLeft" />
<Banner :eventName="eventData.projectName" :themeColor="eventData.themeColor" :fontColor="eventData.fontColor"
:fromDate="new Date(eventData.fromDate).toLocaleString()" :toDate="new Date(eventData.toDate).toLocaleString()"
:logoUrl="eventData.logoUrl" />
</b-card>

<template v-if="authToken == '' || authToken == null">
<Login class="mx-auto overflow-hidden mt-3 border-0 mainContentWdth" :themeColor="eventData.themeColor"
:fontColor="eventData.fontColor" @AuthTokenUpdateEvent="updateAuthentication" />

<Action v-if="eventData.projectStatus" :userProfile="null" :ActionSchema="eventActionsToShow"
:prizeData="prizeData" @UserUpdateEvent="updateUserData" />
</template>


<template v-if="authToken != '' && authToken != null">
<ErrorMessage v-if="!eventData.projectStatus" errorMessage="Event is over" />
<Action v-if="eventData.projectStatus" :userProfile="userProfileData" :ActionSchema="eventActionsToShow" :prizeData="prizeData" @UserUpdateEvent="updateUserData" />
<div class="footer mx-auto overflow-hidden" style="max-width:600px;align-items:center;padding-top:20px" >
<b>Disclaimer:</b>
Anyone can create campaigns on HyperFyre, rewards are distributed by the campaign creator and HyperFyre is not responsible for reward distribution.
<Action v-if="eventData.projectStatus" :userProfile="userProfileData" :ActionSchema="eventActionsToShow"
:prizeData="prizeData" @UserUpdateEvent="updateUserData" />

<div class="footer mx-auto overflow-hidden mainContentWdth" style="align-items:center;padding-top:20px">
<b>Disclaimer:</b>
Anyone can create campaigns on HyperFyre, rewards are distributed by the campaign creator and HyperFyre is not
responsible for reward distribution.
</div>
</template>
</template>

</div>
</template>
<script>
Expand Down Expand Up @@ -240,7 +250,7 @@ export default {
try{
this.isLoading= true
if (this.authToken != "" && this.authToken && this.userAuthData.email) {
this.userProfileData = this.userAuthData
const url = `${this.$config.studioServer.BASE_URL}api/v1/investor?email=${this.userAuthData.email}&projectId=${this.eventData._id}`;
let headers = {
Expand Down Expand Up @@ -277,7 +287,6 @@ export default {
return x.type !=='PRIZE_CARD'
})
const eventActions = actionWithoutPrize;
if (this.userEventData.actions && this.userEventData.actions.length > 0) {
this.eventActionsToShow = eventActions.map(ea => {
const doneAction = this.userEventData.actions.find(ua => ua._id == ea._id)
Expand All @@ -291,8 +300,13 @@ export default {
})
} else {
this.eventActionsToShow = eventActions
this.eventActionsToShow = eventActions;
}
} else {
this.eventActionsToShow = this.eventData.actions;
this.prizeData = this.eventData.actions.filter((x) => {
return x.type === 'PRIZE_CARD'
})
}
}catch(e){
eventBus.$emit('logout')
Expand Down Expand Up @@ -363,6 +377,9 @@ export default {
</script>
<style scoped>
.mainContentWdth{
max-width: 600px;
}
.content {
margin-top: 20px;
padding: 2px;
Expand Down

0 comments on commit a6c830a

Please sign in to comment.