Skip to content

Commit

Permalink
fix: after refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Fifciuu committed Feb 9, 2021
1 parent 8afcf64 commit c55398e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
/>
<SfProperty
name="Shipping"
v-if="chosenShippingMethod && chosenShippingMethod.zoneRates"
:value="$n(getShippingMethodPrice(chosenShippingMethod), 'currency')"
class="sf-property--full-width sf-property--large property"
/>
Expand Down Expand Up @@ -75,7 +76,7 @@ import {
SfCircleIcon
} from '@storefront-ui/vue';
import { computed, ref } from '@vue/composition-api';
import { useCheckout, useCart, cartGetters } from '<%= options.generate.replace.composables %>';
import { useCheckout, useCart, cartGetters } from '@vue-storefront/commercetools';
import getShippingMethodPrice from '@/helpers/Checkout/getShippingMethodPrice';
export default {
Expand Down
24 changes: 11 additions & 13 deletions packages/commercetools/theme/components/Checkout/ShippingForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
class="sf-heading--left sf-heading--no-underline title"
/>
<div class="form">
<div class="form__radio-group" v-if="isShippingDetailsCompleted && !dirty">
<!-- <div class="form__radio-group" v-if="isShippingDetailsCompleted && !dirty">
<SfRadio
v-for="item in shippingMethods.shippingMethods"
:key="item.id || item.name"
Expand All @@ -202,7 +202,7 @@
</div>
</template>
</SfRadio>
</div>
</div> -->
<div class="form__action">
<nuxt-link
to="/checkout/personal-details"
Expand Down Expand Up @@ -239,7 +239,7 @@ import {
SfRadio,
SfCheckbox
} from '@storefront-ui/vue';
import { useUserShipping, userShippingGetters, useShippingMethod, useUser, useShipping } from '@vue-storefront/commercetools';
import { useUserShipping, userShippingGetters, useUser, useShipping } from '@vue-storefront/commercetools';
import { ValidationProvider, ValidationObserver, extend } from 'vee-validate';
import { required, min, digits } from 'vee-validate/dist/rules';
import { useVSFContext } from '@vue-storefront/core';
Expand Down Expand Up @@ -277,13 +277,12 @@ export default {
},
props: {
isSaving: Object,
handleShippingMethodSubmit: Function,
// handleShippingMethodSubmit: Function,
handleShippingAddressSubmit: Function
},
setup(props, context) {
const { $ct: { config } } = useVSFContext();
const { shipping: address } = useShipping();
const { shippingMethods } = useShippingMethod();
const { isAuthenticated } = useUser();
const { shipping: userShipping, load: loadUserShipping, setDefaultAddress } = useUserShipping();
Expand All @@ -305,12 +304,12 @@ export default {
});
const handleStepSubmit = () => context.emit('stepSubmit');
const handleMethodSubmit = async (reset, shippingMethod) => {
chosenShippingMethod.value = shippingMethod;
await props.handleShippingMethodSubmit(shippingMethod);
reset();
isShippingMethodCompleted.value = true;
};
// const handleMethodSubmit = async (reset, shippingMethod) => {
// chosenShippingMethod.value = shippingMethod;
// await props.handleShippingMethodSubmit(shippingMethod);
// reset();
// isShippingMethodCompleted.value = true;
// };
const handleAddressSubmit = (reset) => async () => {
const addressId = currentAddressId.value;
Expand Down Expand Up @@ -387,7 +386,6 @@ export default {
shippingDetails,
chosenShippingMethod,
countries: config.countries,
shippingMethods,
setAsDefault,
canAddNewAddress,
currentAddressId,
Expand All @@ -397,7 +395,7 @@ export default {
isShippingMethodCompleted,
isShippingDetailsCompleted,
handleMethodSubmit,
// handleMethodSubmit,
handleAddressSubmit,
handleStepSubmit,
handleAddNewAddressBtnClick,
Expand Down
4 changes: 2 additions & 2 deletions packages/commercetools/theme/pages/Checkout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<script>
import { SfSteps, SfButton } from '@storefront-ui/vue';
import CartPreview from '~/components/checkout/CartPreview';
import OrderReview from '~/components/checkout/OrderReview';
import CartPreview from '~/components/Checkout/CartPreview';
import OrderReview from '~/components/Checkout/OrderReview';
import { ref, computed } from '@vue/composition-api';
import { useUser } from '@vue-storefront/commercetools';
Expand Down
28 changes: 11 additions & 17 deletions packages/commercetools/theme/pages/CheckoutV2/Shipping.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
/>
<ShippingForm
:isSaving="isSaving"
:handleShippingMethodSubmit="handleShippingMethodSubmit"
:handleShippingAddressSubmit="handleShippingAddressSubmit"
@stepSubmit="handleStepSubmit"
/>
Expand All @@ -18,7 +17,7 @@
import {
SfHeading
} from '@storefront-ui/vue';
import { useShipping, useShippingMethod } from '@vue-storefront/commercetools';
import { useShipping } from '@vue-storefront/commercetools';
import { onSSR } from '@vue-storefront/core';
import { reactive } from '@vue/composition-api';
import ShippingForm from '@/components/Checkout/ShippingForm';
Expand All @@ -35,11 +34,6 @@ export default {
load: loadShipping,
error: shippingError
} = useShipping();
const {
save: saveShippingMethod,
load: loadShippingMethod,
error: shippingMethodError
} = useShippingMethod();
const isSaving = reactive({
details: false,
Expand All @@ -56,25 +50,25 @@ export default {
if (shippingError.value.save) {
return;
}
await loadShippingMethod();
// await loadShippingMethod();
isSaving.details = false;
};
const handleShippingMethodSubmit = async shippingMethod => {
isSaving.method = true;
await saveShippingMethod({ shippingMethod });
if (shippingMethodError.value.save) {
return;
}
isSaving.method = false;
};
// const handleShippingMethodSubmit = async shippingMethod => {
// isSaving.method = true;
// await saveShippingMethod({ shippingMethod });
// if (shippingMethodError.value.save) {
// return;
// }
// isSaving.method = false;
// };
const handleStepSubmit = () => context.root.$router.push('/checkout/payment');
return {
isSaving,
handleShippingAddressSubmit,
handleShippingMethodSubmit,
// handleShippingMethodSubmit,
handleStepSubmit
};
}
Expand Down

0 comments on commit c55398e

Please sign in to comment.