Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #1558

Merged
merged 16 commits into from
Aug 12, 2022
Merged

Develop #1558

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 30 additions & 15 deletions src/components/admin/selectPlanSlider/SelectPlanSlide.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<div class="col-lg-6 col-md-9 px-0">
<input type="text" class="form-control w-100"
placeholder="Enter Coupon Code"
@keydown="handleInput($event)"
v-model="coupon">
</div>
<div class="col-lg-4 col-md-3 " style="display:block">
Expand Down Expand Up @@ -267,14 +268,12 @@ export default {
}
else{

total = this.plan.price;
this.plan.grandTotal = total;

}
return this.plan.grandTotal
},
},

data() {
return {
/// TODO: Need to do it in a neat way
Expand All @@ -283,7 +282,6 @@ export default {
// {"actionTypes":["INPUT_TEXT","INPUT_NUMBER","TWITTER_FOLLOW","TWITTER_RETWEET","TELEGRAM_JOIN","DISCORD_JOIN","BLOCKCHAIN_ETH","BLOCKCHAIN_TEZ","HYPERSIGN_AUTH"],"length":9}
authToken: localStorage.getItem("authToken"),
showCoupon:false,
couponCount:0,
subTotal: 0,
discount: 0,
couponDiscount: 0,
Expand All @@ -292,7 +290,10 @@ export default {
selectedNetwork: "",
marketPairs: [],
coupon:"",
coupons:[],
applied:false,
isLoading:false,
fullPage: true,
options: {
currency: [
{
Expand Down Expand Up @@ -324,13 +325,24 @@ export default {
this.fetchTokenPriceCMC();
},
methods: {
handleInput(e){
if (e.key === "Backspace" || e.key === "Delete") {
this.applied = false;
this.couponDiscount=0;
this.coupons = []
}
},
async applyCoupon(){

try{
if(this.selectedCurrency !== "" && this.selectedNetwork !== "")
{
if(!this.couponCount>0){

this.applied = true;
if(!this.coupon){
throw new Error('Enter Coupon and Apply')
}
if(!this.coupons.includes(this.coupon)){
this.grandTotal
this.isLoading = true;
const url = `${this.$config.studioServer.BASE_URL}api/v1/subscription/coupon/verify`;
let headers = {
Expand All @@ -351,7 +363,7 @@ export default {
if (!resp.ok) {
return this.notifyErr(json);
} else {
this.couponCount = 1;
this.coupons.push(this.coupon)
this.couponDiscount = (this.plan.grandTotal * this.fetchedCouponDiscount) / 100;
return this.notifySuccess("Coupon Applied");
}
Expand All @@ -360,9 +372,12 @@ export default {
}
}
else{
return this.notifyErr("Coupon applied already")
return this.notifyErr("coupon code already applied")
}
}
else{
return this.notifyErr(Messages.SUBSCRIPTIONS.SELECT_CURRENCY_AND_NETWORK)
}
}catch(e){
return this.notifyErr(e.message)
}
Expand All @@ -371,7 +386,7 @@ export default {
}
},
resetAllValues() {
this.couponCount = 0;
this.coupons = [];
this.showCoupon = false;
this.discount = 0;
this.couponDiscount = 0;
Expand All @@ -387,16 +402,17 @@ export default {
},
resetAllPayment(){
this.coupon = "";
this.showCoupon = false;
this.discount = 0;
this.couponDiscount = 0;
this.couponCount = 0;
this.coupons = []
},
setDiscount(__arg) {
if (__arg) {
if (__arg == "HID") {
this.resetAllPayment();
if(this.selectedNetwork==="BSC"){
this.selectedNetwork = "";
}
this.options.network = [
{ text: "Ethereum", value: "ETH", disabled: false },
{ text: "Polygon", value: "MATIC", disabled: false },
Expand Down Expand Up @@ -442,7 +458,6 @@ export default {
}
if (__arg == "USDT") {
this.resetAllPayment();
this.selectedNetwork = "";
this.options.network = [
{ text: "Ethereum", value: "ETH", disabled: false },
{ text: "Polygon", value: "MATIC", disabled: false },
Expand All @@ -453,7 +468,6 @@ export default {
}
if (__arg == "USDC") {
this.resetAllPayment();
this.selectedNetwork = "";
this.options.network = [
{ text: "Ethereum", value: "ETH", disabled: false },
{ text: "Polygon", value: "MATIC", disabled: false },
Expand All @@ -462,7 +476,6 @@ export default {
];
// this.selectedNetwork = "ETH";
}
this.grandTotal;
}
},
getHidPrice() {
Expand Down Expand Up @@ -510,7 +523,9 @@ export default {
var planbody = {};
this.plan.selectedCurrency = this.selectedCurrency;
this.plan.selectedNetwork = this.selectedNetwork;
this.plan.coupon_name = this.coupon;
if(this.applied===true){
this.plan.coupon_name = this.coupon;
}
this.plan.coupon_code = "Dummy30";
planbody = Object.assign(planbody, this.plan);

Expand Down
5 changes: 3 additions & 2 deletions src/components/participant/NavBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ color: white !important;
</b-navbar-brand>
<b-nav-item-dropdown size="sm" right class=" m-2 menu ml-auto text-white text-decoration-none">
<template #button-content>
<b-icon style="color:white" icon="menu-button-wide"></b-icon>
<b-icon style="color:var(--theme-text-color)" icon="menu-button-wide"></b-icon>
</template>
<b-dropdown-item to="/user/home/" @click="updateIsForm">
Home
Expand Down Expand Up @@ -57,7 +57,8 @@ export default {
computed: {
themeCss(){
return{
'--theme-bg-color': (this.themeData.themeColor && this.isForm) ? this.themeData.themeColor : config.app.themeBgColor
'--theme-bg-color': (this.themeData.themeColor && this.isForm) ? this.themeData.themeColor : config.app.themeBgColor,
'--theme-text-color': (this.themeData.buttonTextColor && this.isForm) ? this.themeData.buttonTextColor : 'white'
}
}
},
Expand Down
8 changes: 7 additions & 1 deletion src/mixins/fieldValidationMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,13 @@ export function checkValue(arr, prop) {
return actionValue;

}

export function isFloat(n) {
if(n === n && n % 1 !== 0){
return true;
}else{
return false;
}
}
export function urlSanitizer(url, endsWith) {
switch (endsWith) {
case true:
Expand Down
3 changes: 2 additions & 1 deletion src/views/participant/Event.vue
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ export default {

eventBus.$emit('UpdateThemeEvent', {
logoPath: this.eventData['orgData'].logoPath,
themeColor: this.eventData['orgData'].themeColor
themeColor: this.eventData['orgData'].themeColor,
buttonTextColor: this.eventData['orgData'].buttonTextColor
})

/// deleting data wich is not required.
Expand Down
28 changes: 14 additions & 14 deletions src/views/superAdmin/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ import Loading from "vue-loading-overlay";
import "vue-loading-overlay/dist/vue-loading.css";
import notificationMixins from "../../mixins/notificationMixins";
import Datepicker from "vuejs-datetimepicker";
import { isValidSlug } from "../../mixins/fieldValidationMixin";
import { isValidURL,isFloat } from "../../mixins/fieldValidationMixin";
import masterKeyPopupMixin from "../../mixins/masterKeyPopupMixin.js";
import dayjs from "dayjs";
export default {
Expand Down Expand Up @@ -479,9 +479,9 @@ export default {
if (x.id === 5) {
return (x.value = {
name: "",
discount: "",
discount: 0,
expiredAt: null,
maxClaimCount: "",
maxClaimCount: 0,
});
}
return (x.value = "");
Expand Down Expand Up @@ -572,7 +572,6 @@ export default {
url = url.replace("<PARAM>", resource.value.trim());
}
url = url.replace("<SECRET_KEY>", masterKey);
console.log(url);
const Url = new URL(this.$config.studioServer.BASE_URL);
const headers = {
Orign: Url.origin,
Expand Down Expand Up @@ -615,6 +614,7 @@ export default {
this.schedules.unshift(schedule);
}
} else if (json.discount) {
this.notifySuccess("Coupon"+" "+ json.name + " "+ "successfully created");
this.couponTable.unshift(json);
this.isEdit = false;
}
Expand All @@ -624,7 +624,6 @@ export default {
this.notifyErr(e.message);
} finally {
this.Loading = false;
this.clearAll();
this.getAllCoupon();
}
},
Expand All @@ -641,27 +640,28 @@ export default {
if (!resource.value.name) {
throw new Error("Enter coupon code");
}

// if (isValidSlug(resource.value.name)) {
// throw new Error("Enter valid coupon code");
// }
if(isValidURL(resource.value.name)){
throw new Error("Coupon should not be a url")
}
if(resource.value.name.trim().includes(' ')){
throw new Error('There should not be space in coupon')
}

if (!resource.value.expiredAt) {
throw new Error("Enter expiry date time");
}

if (
resource.value.maxClaimCount <= 0 ||
isNaN(parseInt(resource.value.maxClaimCount))
resource.value.maxClaimCount <= 0 || isFloat(resource.value.maxClaimCount)
) {
throw new Error("Enter Valid number for max limit");
throw new Error("Limit should be a number greater than 0");
}

if (
!resource.value.discount || (resource.value.discount <= 0 || resource.value.discount >= 70) ||
!resource.value.discount || (resource.value.discount <= 0 || resource.value.discount > 70) ||
isNaN(parseInt(resource.value.discount))
) {
throw new Error("Enter valid coupon discount ");
throw new Error("Discount value should be a number greater than 0 and less than 70");
}

const ToDate = new Date();
Expand Down