Skip to content

Commit 52c29d2

Browse files
author
Marcin Kwiatkowski
committed
refactor: refactores types and composables to new ones from theme
1 parent d9c8202 commit 52c29d2

File tree

25 files changed

+127
-37
lines changed

25 files changed

+127
-37
lines changed

packages/theme/components/CurrencySelector/CurrenciesModal.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</SfList>
3131
</SfBottomModal>
3232
</template>
33-
<script>
33+
<script lang="ts">
3434
import {
3535
defineComponent, computed, onMounted,
3636
} from '@nuxtjs/composition-api';
@@ -41,7 +41,7 @@ import {
4141
} from '@storefront-ui/vue';
4242
import {
4343
useCurrency,
44-
} from '@vue-storefront/magento';
44+
} from '~/composables';
4545
import { useHandleChanges } from '~/helpers/magentoConfig/handleChanges';
4646
4747
export default defineComponent({
@@ -58,10 +58,10 @@ export default defineComponent({
5858
emits: ['closeModal'],
5959
setup() {
6060
const {
61-
currencies,
61+
currency: currencies,
6262
change: changeCurrency,
6363
load: loadCurrencies,
64-
} = useCurrency('header-currency');
64+
} = useCurrency();
6565
6666
const { handleChanges } = useHandleChanges();
6767

packages/theme/components/StoreSwitcher/StoresModal.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<script>
5050
import { defineComponent, onMounted, computed } from '@nuxtjs/composition-api';
5151
import { SfList, SfBottomModal, SfCharacteristic } from '@storefront-ui/vue';
52-
import { useStore } from '@vue-storefront/magento';
52+
import { useStore } from '~/composables';
5353
import { storeGetters, storeConfigGetters } from '~/getters';
5454
import { useHandleChanges } from '~/helpers/magentoConfig/handleChanges';
5555
@@ -72,7 +72,7 @@ export default defineComponent({
7272
stores,
7373
change: changeStore,
7474
load: loadStores,
75-
} = useStore('header-stores');
75+
} = useStore();
7676
7777
const availableStores = computed(() => stores.value ?? []);
7878

packages/theme/composables/types.d.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { CustomQuery } from '@vue-storefront/core/lib/src/types';
2+
import {FacetSearchResult} from "@vue-storefront/core";
3+
import {FacetResultsData, Filter} from "@vue-storefront/magento";
24

35
export declare type ComposableFunctionArgs<T> = T & {
46
customQuery?: CustomQuery;
@@ -2320,6 +2322,11 @@ export interface CustomerAddress {
23202322
telephone?: Maybe<Scalars['String']>;
23212323
/** The customer's Value-added tax (VAT) number (for corporate customers) */
23222324
vat_id?: Maybe<Scalars['String']>;
2325+
/** The customer's email **/
2326+
email: Scalars['String']
2327+
/** The customer's phone **/
2328+
phone: Maybe<Scalars['String']>
2329+
23232330
}
23242331
export interface CustomerAddressAttribute {
23252332
/** Attribute code */
@@ -51444,3 +51451,55 @@ export declare type WishlistQuery = {
5144451451
} | null | undefined>;
5144551452
} | null | undefined;
5144651453
};
51454+
51455+
export declare type Category = CategoryTree | CategorySearchQuery['categoryList'][0];
51456+
export interface Product extends ProductInterface, ConfigurableProduct, Omit<BundleProduct, 'items'>, Omit<GroupedProduct, 'items'>, Omit<DownloadableProduct, 'items'>, Omit<VirtualProduct, 'items'> {
51457+
}
51458+
export declare type Countries = CountriesListQuery['countries'][0];
51459+
51460+
export interface TransformedCustomerAddress extends CustomerAddress {
51461+
street: string,
51462+
apartment: string,
51463+
neighborhood: string,
51464+
extra: string,
51465+
}
51466+
51467+
export interface AddressGetter {
51468+
countriesList(countries: Countries[]): {
51469+
id: string;
51470+
label: string;
51471+
englishLabel: string;
51472+
abbreviation: string;
51473+
}[];
51474+
regionList(country: Country): {
51475+
id: number;
51476+
label: string;
51477+
abbreviation: string;
51478+
}[];
51479+
}
51480+
51481+
export declare type CartItem = CartItemInterface;
51482+
51483+
export interface AgnosticPaymentMethod {
51484+
label: string;
51485+
value: string;
51486+
}
51487+
51488+
export declare type ShippingMethod = AvailableShippingMethod;
51489+
51490+
export declare type SearchData = FacetSearchResult<FacetResultsData>;
51491+
export declare type ReviewMetadata = ProductReviewRatingsMetadataQuery['productReviewRatingsMetadata']['items'][0];
51492+
export interface AgnosticReviewMetadata {
51493+
id: string;
51494+
name: string;
51495+
values: {
51496+
label: string | number;
51497+
id: string;
51498+
}[];
51499+
}
51500+
51501+
export declare type AvailableStores = AvailableStoresQuery['availableStores'];
51502+
51503+
export interface ReviewsGetter {
51504+
reviews: Array<ProductReviews>
51505+
}

packages/theme/composables/useAddresses/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Ref, ref, useContext } from '@nuxtjs/composition-api';
22
import { Logger } from '@vue-storefront/core';
3-
import { transformUserCreateAddressInput, transformUserUpdateAddressInput } from '@vue-storefront/magento';
3+
import { transformUserCreateAddressInput, transformUserUpdateAddressInput } from '~/helpers/userAddressManipulator';
44
import { ComposableFunctionArgs } from '~/composables/types';
55
import { UseAddressesInterface, UseAddressesParamsInput, UseAddressesErrors } from '~/composables/useAddresses/useAddresses';
66

packages/theme/composables/useConfig/useConfig.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ComputedRef, Ref } from '@nuxtjs/composition-api';
2-
import { StoreConfig } from '@vue-storefront/magento';
2+
import { StoreConfig } from '~/composables/types';
33

44
export interface UseConfigErrors {
55
load: Error | null;

packages/theme/composables/useCurrency/useCurrency.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ComposableFunctionArgs } from '@vue-storefront/core';
22
import { ComputedRef, Ref } from '@nuxtjs/composition-api';
3-
import { Currency } from '@vue-storefront/magento-api';
3+
import { Currency } from '~/modules/GraphQL/types';
44

55
export interface UseCurrencyErrors {
66
load: Error | null;
@@ -9,7 +9,7 @@ export interface UseCurrencyErrors {
99

1010
export interface UseCurrency {
1111
load: (params?: ComposableFunctionArgs<{}>) => Promise<void>;
12-
change: (params: ComposableFunctionArgs<{ id: string }>) => void;
12+
change: (params: ComposableFunctionArgs<{ id: string }>) => Promise<void>;
1313
currency: ComputedRef<Currency>;
1414
loading: Ref<boolean>;
1515
error: Ref<UseCurrencyErrors>;

packages/theme/composables/useMagentoConfiguration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { computed, ComputedRef, useContext } from '@nuxtjs/composition-api';
12
import {
23
StoreConfig,
3-
} from '@vue-storefront/magento';
4+
} from '~/composables/types';
45
import { storeConfigGetters } from '~/getters';
56

6-
import { computed, ComputedRef, useContext } from '@nuxtjs/composition-api';
77
import cookieNames from '~/enums/cookieNameEnum';
88
import { useConfig } from '~/composables';
99

packages/theme/composables/useStore/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
ref, Ref, useContext,
44
} from '@nuxtjs/composition-api';
55
import { Logger } from '@vue-storefront/core';
6-
import { StoreConfig } from '@vue-storefront/magento';
6+
import { StoreConfig } from '~/composables/types';
77
import { storeConfigGetters } from '~/getters';
88
import { UseStoreInterface, UseStore, UseStoreErrors } from '~/composables/useStore/useStore';
99
import { useConfigStore } from '~/stores/config';

packages/theme/getters/_utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AgnosticAttribute } from '@vue-storefront/core';
2-
import { Product } from '@vue-storefront/magento';
2+
import { Product } from '~/composables/types';
33

44
export const getAttributeValue = (attribute) => attribute.values;
55

packages/theme/getters/addressGetter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Countries, Country, AddressGetter } from '@vue-storefront/magento';
1+
import { Countries, Country, AddressGetter } from '~/composables/types';
22

33
const countriesList: AddressGetter['countriesList'] = (countries: Countries[]) => countries
44
.filter((c) => c.id && c.full_name_english && c.full_name_locale)

0 commit comments

Comments
 (0)