Skip to content

Commit

Permalink
feat: #49 (theme) remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
Baroshem committed Aug 22, 2021
1 parent 423c6e6 commit 9a9b46a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
19 changes: 4 additions & 15 deletions packages/theme/components/Checkout/CartPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import {
SfInput,
SfCircleIcon
} from '@storefront-ui/vue';
import { computed, ref, watch } from '@vue/composition-api';
import { computed, ref } from '@vue/composition-api';
import { useCart, cartGetters } from '@vue-storefront/vendure';
import { getCalculatedPrice } from '~/helpers';
Expand All @@ -88,14 +88,8 @@ export default {
SfInput,
SfCircleIcon
},
props: {
selectedShippingMethod: {
type: Object,
required: false
}
},
setup (props) {
const { cart, removeItem, updateItemQty, applyCoupon, load } = useCart();
setup () {
const { cart, removeItem, updateItemQty, applyCoupon } = useCart();
const listIsHidden = ref(false);
const promoCode = ref('');
Expand All @@ -107,10 +101,6 @@ export default {
const discounts = computed(() => cartGetters.getDiscounts(cart.value));
const shippingCost = computed(() => getCalculatedPrice(cart?.value?.shipping));
watch(() => props.selectedShippingMethod, async () => {
await load();
});
return {
discounts,
totalItems,
Expand Down Expand Up @@ -144,8 +134,7 @@ export default {
shippingCost,
hasSpecialPrice: computed(() => totals.value.special > 0 && totals.value.special < totals.value.subtotal),
getCalculatedPrice,
cart
getCalculatedPrice
};
}
};
Expand Down
15 changes: 4 additions & 11 deletions packages/theme/pages/Checkout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
:key="key"
:name="step"
>
<nuxt-child @shippingMethodSelected="updateShippingInCartPreview"/>
<nuxt-child />
</SfStep>
</SfSteps>
<nuxt-child v-else />
Expand All @@ -23,7 +23,7 @@
class="checkout__aside desktop-only"
>
<transition name="fade">
<CartPreview key="order-summary" :selectedShippingMethod="selectedShippingMethod" />
<CartPreview key="order-summary" />
</transition>
</div>
</div>
Expand All @@ -33,7 +33,7 @@
import { SfSteps, SfButton } from '@storefront-ui/vue';
import CartPreview from '~/components/Checkout/CartPreview';
import { computed, ref } from '@vue/composition-api';
import { computed } from '@vue/composition-api';
const STEPS = {
shipping: 'Shipping',
Expand All @@ -52,25 +52,18 @@ export default {
const currentStep = computed(() => context.root.$route.path.split('/').pop());
const currentStepIndex = computed(() => Object.keys(STEPS).findIndex(s => s === currentStep.value));
const isThankYou = computed(() => currentStep.value === 'thank-you');
const selectedShippingMethod = ref(null);
const handleStepClick = (stepIndex) => {
const key = Object.keys(STEPS)[stepIndex];
context.root.$router.push(`/checkout/${key}`);
};
const updateShippingInCartPreview = (shippingMethod) => {
selectedShippingMethod.value = shippingMethod;
};
return {
handleStepClick,
STEPS,
currentStepIndex,
isThankYou,
currentStep,
updateShippingInCartPreview,
selectedShippingMethod
currentStep
};
}
};
Expand Down

0 comments on commit 9a9b46a

Please sign in to comment.