Skip to content

Commit

Permalink
refactor: Improve imports (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunogarcia authored Oct 19, 2021
1 parent 74b92e2 commit 7beb762
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 43 deletions.
1 change: 1 addition & 0 deletions src/application/services/useShoppingInit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { onMounted } from "vue";

import { useStore } from "@/infrastructure/store";
import { ACTIONS } from "@/infrastructure/store/shopping/shopping.types";

Expand Down
3 changes: 2 additions & 1 deletion src/application/services/useShoppingProducts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { computed } from "vue";
import { useStore } from "@/infrastructure/store";

import { Product, PRODUCT_CODE } from "@/domain/checkout/checkout.types";

import { useStore } from "@/infrastructure/store";
import {
ACTIONS,
GETTERS
Expand Down
3 changes: 2 additions & 1 deletion src/application/services/useShoppingSummary.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { computed } from "vue";
import { useStore } from "@/infrastructure/store";

import { TotalDiscountItem } from "@/domain/checkout/checkout.types";

import { useStore } from "@/infrastructure/store";
import { GETTERS } from "@/infrastructure/store/shopping/shopping.types";

export default function useShopping() {
Expand Down
11 changes: 6 additions & 5 deletions src/domain/checkout/checkout.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { PRODUCT_CODE } from "@/domain/checkout/checkout.types";
import { DISCOUNT_CODE } from "@/domain/discount-rules/discount.rules.types";

import {
PricingRule,
ScannerItem,
TotalDiscountItem
TotalDiscountItem,
PRODUCT_CODE
} from "@/domain/checkout/checkout.types";
import { DiscountRule } from "@/domain/discount-rules/discount.rules.types";
import {
DiscountRule,
DISCOUNT_CODE
} from "@/domain/discount-rules/discount.rules.types";

const { EMPTY } = PRODUCT_CODE;

Expand Down
10 changes: 5 additions & 5 deletions src/domain/discount-rules/discount.rules.factory.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { PRODUCT_CODE } from "@/domain/checkout/checkout.types";
import { DISCOUNT_CODE } from "@/domain/discount-rules/discount.rules.types";

import { ScannerItem } from "@/domain/checkout/checkout.types";
import { DiscountRule } from "@/domain/discount-rules/discount.rules.types";
import { ScannerItem, PRODUCT_CODE } from "@/domain/checkout/checkout.types";
import {
DiscountRule,
DISCOUNT_CODE
} from "@/domain/discount-rules/discount.rules.types";

const { CAP, TSHIRT } = PRODUCT_CODE;
const { TWO_X_ONE, BULK, PROMO_CODE } = DISCOUNT_CODE;
Expand Down
7 changes: 4 additions & 3 deletions src/domain/discount-rules/discount.rules.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { DISCOUNT_CODE } from "@/domain/discount-rules/discount.rules.types";

import { DiscountRule } from "@/domain/discount-rules/discount.rules.types";
import { discountFactory } from "@/domain/discount-rules/discount.rules.factory";
import {
DiscountRule,
DISCOUNT_CODE
} from "@/domain/discount-rules/discount.rules.types";

const { TWO_X_ONE, BULK, PROMO_CODE } = DISCOUNT_CODE;

Expand Down
3 changes: 1 addition & 2 deletions src/domain/discount-rules/discount.rules.types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { PRODUCT_CODE } from "@/domain/checkout/checkout.types";
import { ScannerItem } from "@/domain/checkout/checkout.types";
import { ScannerItem, PRODUCT_CODE } from "@/domain/checkout/checkout.types";

export enum DISCOUNT_CODE {
TWO_X_ONE = "TWO_X_ONE",
Expand Down
2 changes: 1 addition & 1 deletion src/infrastructure/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
useStore as baseUseStore
} from "vuex";

import { StateRoot } from "@/infrastructure/store/store.types";
import Shopping from "@/infrastructure/store/shopping";
import { StateRoot } from "@/infrastructure/store/store.types";

export const key: InjectionKey<VuexStore<StateRoot>> = Symbol();

Expand Down
19 changes: 11 additions & 8 deletions src/infrastructure/store/shopping/actions.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import { ActionContext, ActionTree } from "vuex";

import http from "@/infrastructure/http";
import CheckoutService from "@/domain/checkout/checkout.service";
import { DiscountRule } from "@/domain/discount-rules/discount.rules.types";
import DiscountRulesService from "@/domain/discount-rules/discount.rules.service";

import { StateRoot } from "@/infrastructure/store/store.types";
import { ShoppingActions } from "@/infrastructure/store/shopping/shopping.types";
import { Product, PricingRule } from "@/domain/checkout/checkout.types";
import { DiscountRule } from "@/domain/discount-rules/discount.rules.types";
import CheckoutService from "@/domain/checkout/checkout.service";
import {
Product,
PricingRule,
PRODUCT_CODE
} from "@/domain/checkout/checkout.types";

import { PRODUCT_CODE } from "@/domain/checkout/checkout.types";
import http from "@/infrastructure/http";
import { StateRoot } from "@/infrastructure/store/store.types";
import {
ACTIONS,
MUTATION
MUTATION,
ShoppingActions
} from "@/infrastructure/store/shopping/shopping.types";

let checkoutService: CheckoutService;
Expand Down
8 changes: 5 additions & 3 deletions src/infrastructure/store/shopping/getters.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { GetterTree } from "vuex";

import { GETTERS } from "@/infrastructure/store/shopping/shopping.types";
import { Product, TotalDiscountItem } from "@/domain/checkout/checkout.types";

import { StateRoot } from "@/infrastructure/store/store.types";
import { ShoppingGetters } from "@/infrastructure/store/shopping/shopping.types";
import { Product, TotalDiscountItem } from "@/domain/checkout/checkout.types";
import {
ShoppingGetters,
GETTERS
} from "@/infrastructure/store/shopping/shopping.types";

const getters: GetterTree<StateRoot, StateRoot> & ShoppingGetters = {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/infrastructure/store/shopping/initialState.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StateRoot } from "@/infrastructure/store/store.types";
import { Product, Summary } from "@/domain/checkout/checkout.types";
import { StateRoot } from "@/infrastructure/store/store.types";

const products: Product[] = [];

Expand Down
9 changes: 6 additions & 3 deletions src/infrastructure/store/shopping/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { MutationTree } from "vuex";

import { StateRoot } from "@/infrastructure/store/store.types";
import { MUTATION } from "@/infrastructure/store/shopping/shopping.types";
import { Product, TotalDiscountItem } from "@/domain/checkout/checkout.types";
import { ShoppingMutations } from "@/infrastructure/store/shopping/shopping.types";

import { StateRoot } from "@/infrastructure/store/store.types";
import {
ShoppingMutations,
MUTATION
} from "@/infrastructure/store/shopping/shopping.types";

const mutations: MutationTree<StateRoot> & ShoppingMutations = {
[MUTATION.SAVE_PRODUCTS](state: StateRoot, payload: Product[]) {
Expand Down
9 changes: 6 additions & 3 deletions src/infrastructure/store/shopping/shopping.types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { ActionContext } from "vuex";

import { StateRoot } from "@/infrastructure/store/store.types";
import { Product, TotalDiscountItem } from "@/domain/checkout/checkout.types";
import {
Product,
TotalDiscountItem,
PRODUCT_CODE
} from "@/domain/checkout/checkout.types";

import { PRODUCT_CODE } from "@/domain/checkout/checkout.types";
import { StateRoot } from "@/infrastructure/store/store.types";

export enum MUTATION {
SAVE_PRODUCTS = "SAVE_PRODUCTS",
Expand Down
3 changes: 2 additions & 1 deletion src/infrastructure/store/store.types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Store as VuexStore, CommitOptions, DispatchOptions } from "vuex";

import { Product, Summary } from "@/domain/checkout/checkout.types";
import {
ShoppingMutations,
ShoppingActions,
ShoppingGetters
} from "@/infrastructure/store/shopping/shopping.types";
import { Store as VuexStore, CommitOptions, DispatchOptions } from "vuex";

export interface StateRoot {
products: Product[];
Expand Down
5 changes: 2 additions & 3 deletions src/ui/components/ProductItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@
<script lang="ts">
import { ref, computed, defineComponent } from "vue";
import EVENT from "@/ui/types/event";
import { PRODUCT_CODE } from "@/domain/checkout/checkout.types";
import { Product, PRODUCT_CODE } from "@/domain/checkout/checkout.types";
import { Product } from "@/domain/checkout/checkout.types";
import EVENT from "@/ui/types/event";
import isValidProductCode from "@/ui/utils/isValidProductCode";
import ShopButton from "@/ui/components/core/Button.vue";
Expand Down
8 changes: 5 additions & 3 deletions src/ui/components/SummaryTotal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@

<script lang="ts">
import { defineComponent } from "vue";
import Modal from "@/ui/components/Modal.vue";
import ShopButton from "@/ui/components/core/Button.vue";
import Checkout from "@/ui/components/Checkout.vue";
import useModal from "@/application/services/useModal";
import useShoppingSummary from "@/application/services/useShoppingSummary";
import Modal from "@/ui/components/Modal.vue";
import Checkout from "@/ui/components/Checkout.vue";
import ShopButton from "@/ui/components/core/Button.vue";
export default defineComponent({
name: "SummaryTotal",
Expand Down
1 change: 1 addition & 0 deletions src/ui/views/Products.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<script lang="ts">
import { defineComponent } from "vue";
import Title from "@/ui/components/Title.vue";
import ProductHead from "@/ui/components/ProductHead.vue";
import ProductList from "@/ui/components/ProductList.vue";
Expand Down
1 change: 1 addition & 0 deletions src/ui/views/Summary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<script lang="ts">
import { defineComponent } from "vue";
import Title from "@/ui/components/Title.vue";
import SummaryItems from "@/ui/components/SummaryItems.vue";
import SummaryDiscounts from "@/ui/components/SummaryDiscounts.vue";
Expand Down

0 comments on commit 7beb762

Please sign in to comment.