From 29062dddba1ccc05f404721ad3b67f662862a0be Mon Sep 17 00:00:00 2001 From: MrNaif2018 Date: Sun, 7 Mar 2021 17:03:19 +0300 Subject: [PATCH] Made email optional --- components/Checkout.vue | 5 +++-- store/index.js | 14 ++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/components/Checkout.vue b/components/Checkout.vue index 4535a7a..7b08f50 100644 --- a/components/Checkout.vue +++ b/components/Checkout.vue @@ -9,11 +9,11 @@ label.label(for="email") Email .control.has-icons-left.has-icons-right input.input#email(type="email", - required, + :required="emailRequired", placeholder="name@example.com", name="email", @input="setUserEmail($event.target.value)" - v-validate="'required|email'", + v-validate="'email'", :class="{ 'is-danger': errors.has('email') }") span.icon.is-small.is-left i.fa.fa-envelope @@ -66,6 +66,7 @@ export default { computed: { ...mapGetters("checkout", ["isStripeCardCompleted", "status", "isLoading"]), ...mapGetters("cart", ["userEmail"]), + ...mapGetters(["emailRequired"]), }, methods: { ...mapActions("cart", [ diff --git a/store/index.js b/store/index.js index 4920996..9b8a432 100644 --- a/store/index.js +++ b/store/index.js @@ -4,6 +4,7 @@ export const state = () => ({ currentPage: 1, url: "", services: {}, + policies: {}, path: "/", onion: false, storeID: 1, @@ -34,6 +35,9 @@ export const mutations = { onion(state, val) { state.onion = val }, + policies(state, val) { + state.policies = val + }, } export const getters = { url: ({ url }) => url, @@ -48,16 +52,14 @@ export const getters = { apiURL({ onion, env }, { apiOnionURL }) { return onion && apiOnionURL ? apiOnionURL : env.URL }, + emailRequired: ({ policies }) => policies.email_required, } export const actions = { async nuxtServerInit({ commit, dispatch }, { req, $axios, params }) { await dispatch("loadEnv", { env: this.$config, req }) - let storeID - if (params.id) storeID = params.id - else { - const { data } = await $axios.get("/manage/stores") - storeID = data.pos_id - } + const { data } = await $axios.get("/manage/stores") + commit("policies", data) + const storeID = params.id ? params.id : data.pos_id commit("storeID", storeID) const { data: services } = await $axios.get("/services") commit("services", services)