diff --git a/src/components/admin/selectPlanSlider/SelectPlanSlide.vue b/src/components/admin/selectPlanSlider/SelectPlanSlide.vue index 1d8238bb..0b1c40bb 100644 --- a/src/components/admin/selectPlanSlider/SelectPlanSlide.vue +++ b/src/components/admin/selectPlanSlider/SelectPlanSlide.vue @@ -91,6 +91,7 @@
@@ -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 @@ -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, @@ -292,7 +290,10 @@ export default { selectedNetwork: "", marketPairs: [], coupon:"", + coupons:[], + applied:false, isLoading:false, + fullPage: true, options: { currency: [ { @@ -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 = { @@ -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"); } @@ -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) } @@ -371,7 +386,7 @@ export default { } }, resetAllValues() { - this.couponCount = 0; + this.coupons = []; this.showCoupon = false; this.discount = 0; this.couponDiscount = 0; @@ -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 }, @@ -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 }, @@ -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 }, @@ -462,7 +476,6 @@ export default { ]; // this.selectedNetwork = "ETH"; } - this.grandTotal; } }, getHidPrice() { @@ -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); diff --git a/src/components/participant/NavBar.vue b/src/components/participant/NavBar.vue index efcf72c3..aa2beba5 100644 --- a/src/components/participant/NavBar.vue +++ b/src/components/participant/NavBar.vue @@ -19,7 +19,7 @@ color: white !important; Home @@ -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' } } }, diff --git a/src/mixins/fieldValidationMixin.js b/src/mixins/fieldValidationMixin.js index 8decac02..7d5491b7 100644 --- a/src/mixins/fieldValidationMixin.js +++ b/src/mixins/fieldValidationMixin.js @@ -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: diff --git a/src/views/participant/Event.vue b/src/views/participant/Event.vue index d5943205..79f92b54 100644 --- a/src/views/participant/Event.vue +++ b/src/views/participant/Event.vue @@ -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. diff --git a/src/views/superAdmin/Home.vue b/src/views/superAdmin/Home.vue index 46d75fe0..df8ff1a2 100644 --- a/src/views/superAdmin/Home.vue +++ b/src/views/superAdmin/Home.vue @@ -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 { @@ -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 = ""); @@ -572,7 +572,6 @@ export default { url = url.replace("", resource.value.trim()); } url = url.replace("", masterKey); - console.log(url); const Url = new URL(this.$config.studioServer.BASE_URL); const headers = { Orign: Url.origin, @@ -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; } @@ -624,7 +624,6 @@ export default { this.notifyErr(e.message); } finally { this.Loading = false; - this.clearAll(); this.getAllCoupon(); } }, @@ -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();