Skip to content

Commit

Permalink
feat: #82 run lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Baroshem committed Sep 12, 2021
1 parent bf64e70 commit e5a6845
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/composables/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export type SearchResultValue<SEARCH_DATA, SEARCH_INPUT> = {
input?: SEARCH_INPUT;
}

export { OrderAddress } from '@vue-storefront/vendure-api';
export { OrderAddress, Order } from '@vue-storefront/vendure-api';

// TODO: Replace later with types from vendure-api after implementing api-client functions
export interface ForgotPasswordResult {
Expand Down
12 changes: 7 additions & 5 deletions packages/theme/helpers/checkout.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { ARRANGING_PAYMENT } from './constants'
import { Context } from '@nuxt/types';
import { Order } from '@vue-storefront/vendure';
import { ARRANGING_PAYMENT } from './constants';

export const canEnterPayment = cart => canEnterShipping(cart) && canEnterBilling(cart) && cart?.shipping && cart?.state === ARRANGING_PAYMENT;
export const canEnterThankYou = (context: Context): boolean => Boolean(context.route.query?.order);

export const canEnterThankYou = query => Boolean(query?.order);
export const canEnterShipping = (cart: Order): boolean => Boolean(cart?.customer);

export const canEnterShipping = cart => Boolean(cart?.customer);
export const canEnterBilling = (cart: Order): boolean => Boolean(cart?.shippingAddress?.streetLine1 && cart?.shippingAddress?.country);

export const canEnterBilling = cart => cart?.shippingAddress?.streetLine1 && cart?.shippingAddress?.country
export const canEnterPayment = (cart: Order): boolean => canEnterShipping(cart) && canEnterBilling(cart) && cart?.shipping && cart?.state === ARRANGING_PAYMENT;
3 changes: 1 addition & 2 deletions packages/theme/middleware/checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { canEnterShipping, canEnterBilling, canEnterPayment, canEnterThankYou }

export default async ({ app, $vsf }) => {
const currentPath = app.context.route.fullPath.split('/checkout/')[1];
const currentQuery = app.context.route.query;

if (!currentPath) return;

Expand All @@ -28,7 +27,7 @@ export default async ({ app, $vsf }) => {
}
break;
case 'thank-you':
if (!canEnterThankYou(currentQuery)) {
if (!canEnterThankYou(app.context)) {
app.context.redirect('/');
}
break;
Expand Down
4 changes: 2 additions & 2 deletions packages/theme/pages/Checkout/Customer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ export default {
form.value = {
firstName: customer?.firstName,
lastName: customer?.lastName,
emailAddress: customer?.emailAddress,
}
emailAddress: customer?.emailAddress
};
}
});
Expand Down

0 comments on commit e5a6845

Please sign in to comment.