Skip to content

Commit 0235259

Browse files
committed
Show Stripe after customer details are valid
1 parent 651ce35 commit 0235259

File tree

4 files changed

+36
-13
lines changed

4 files changed

+36
-13
lines changed

public/js/app.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16755,9 +16755,9 @@ var mutations = {
1675516755
var customer = _ref3.customer;
1675616756
Object.assign(customer, payload);
1675716757
},
16758-
SET_CHECKOUT_FORM_VALID: function SET_CHECKOUT_FORM_VALID(_ref4, payload) {
16759-
var checkoutFormIsValid = _ref4.checkoutFormIsValid;
16760-
Object.assign(checkoutFormIsValid, payload);
16758+
SET_CHECKOUT_FORM_VALID: function SET_CHECKOUT_FORM_VALID(state, payload) {
16759+
var copyState = state;
16760+
copyState.checkoutFormIsValid = payload;
1676116761
}
1676216762
};
1676316763
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (mutations);
@@ -16851,13 +16851,15 @@ __webpack_require__.r(__webpack_exports__);
1685116851
errors = _useForm.errors,
1685216852
handleSubmit = _useForm.handleSubmit;
1685316853

16854-
var onSubmit = handleSubmit(function (values, _ref) {
16855-
var resetForm = _ref.resetForm;
16854+
var onSubmit = handleSubmit(function (values) {
1685616855
store.dispatch('saveCustomerDetails', values);
1685716856

1685816857
if (meta.value.valid) {
16858+
console.log('Valid!');
1685916859
store.dispatch('setCheckoutFormToValid', true);
16860-
resetForm();
16860+
} else {
16861+
console.log('Not valid');
16862+
store.dispatch('setCheckoutFormToValid', false);
1686116863
}
1686216864
});
1686316865

@@ -17674,6 +17676,9 @@ var _hoisted_23 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(
1767417676
var _hoisted_24 = {
1767517677
"class": "text-lg text-red-500"
1767617678
};
17679+
var _hoisted_25 = {
17680+
"class": "flex justify-center w-full align-center"
17681+
};
1767717682

1767817683
(0,vue__WEBPACK_IMPORTED_MODULE_0__.popScopeId)();
1767917684

@@ -17762,7 +17767,12 @@ var render = /*#__PURE__*/_withId(function (_ctx, _cache, $props, $setup, $data,
1776217767
/* NEED_PATCH */
1776317768
), [[vue__WEBPACK_IMPORTED_MODULE_0__.vModelText, _ctx.email]]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("span", _hoisted_24, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(_ctx.errors.email), 1
1776417769
/* TEXT */
17765-
)])])])])]);
17770+
)]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_25, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("button", {
17771+
"class": "submitButton",
17772+
onClick: _cache[8] || (_cache[8] = function () {
17773+
return _ctx.onSubmit && _ctx.onSubmit.apply(_ctx, arguments);
17774+
})
17775+
}, " Save Details ")])])])])]);
1776617776
});
1776717777

1776817778
/***/ }),
@@ -17938,7 +17948,7 @@ var render = /*#__PURE__*/_withId(function (_ctx, _cache, $props, $setup, $data,
1793817948
/* CLASS, PROPS */
1793917949
, ["disabled"])])], 512
1794017950
/* NEED_PATCH */
17941-
), [[vue__WEBPACK_IMPORTED_MODULE_0__.vShow, _ctx.checkoutFormIsValid]])];
17951+
), [[vue__WEBPACK_IMPORTED_MODULE_0__.vShow, _ctx.customerDetails.firstName && _ctx.checkoutFormIsValid]])];
1794217952
}),
1794317953
_: 1
1794417954
/* STABLE */

resources/js/components/Checkout/CustomerDetailsForm.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@
9494
errors.email
9595
}}</span>
9696
</div>
97+
<div class="flex justify-center w-full align-center">
98+
<button
99+
class="submitButton"
100+
@click="onSubmit"
101+
>
102+
Save Details
103+
</button>
104+
</div>
97105
</div>
98106
</div>
99107
</section>
@@ -126,11 +134,15 @@ export default defineComponent({
126134
validationSchema: schema,
127135
});
128136
129-
const onSubmit = handleSubmit((values, { resetForm }) => {
137+
const onSubmit = handleSubmit((values) => {
130138
store.dispatch('saveCustomerDetails', values);
139+
131140
if (meta.value.valid) {
141+
console.log('Valid!');
132142
store.dispatch('setCheckoutFormToValid', true);
133-
resetForm();
143+
} else {
144+
console.log('Not valid');
145+
store.dispatch('setCheckoutFormToValid', false);
134146
}
135147
});
136148

resources/js/components/Checkout/OrderCheckout.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
<customer-details-form />
8282
</div>
8383
<transition name="fade">
84-
<div v-show="checkoutFormIsValid">
84+
<div v-show="customerDetails.firstName && checkoutFormIsValid">
8585
<div class="flex justify-center w-full align-center">
8686
<span
8787
class="h-10 p-4 text-lg font-bold text-center text-red-500"

resources/js/store/modules/mutations.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ const mutations = {
3232
SAVE_CUSTOMER_DETAILS({ customer }, payload) {
3333
Object.assign(customer, payload);
3434
},
35-
SET_CHECKOUT_FORM_VALID({ checkoutFormIsValid }, payload) {
36-
Object.assign(checkoutFormIsValid, payload);
35+
SET_CHECKOUT_FORM_VALID(state, payload) {
36+
const copyState = state;
37+
copyState.checkoutFormIsValid = payload;
3738
},
3839
};
3940

0 commit comments

Comments
 (0)