@shopbite-de/storefront 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/app/app.vue CHANGED
@@ -9,7 +9,7 @@ const toast = useToast();
9
9
  const appConfig = useAppConfig();
10
10
  const runtimeConfig = useRuntimeConfig();
11
11
  const { apiClient } = useShopwareContext();
12
- const { refresh: refreshToppings } = usePizzaToppings();
12
+ const { refresh: refreshToppings } = useShopBiteConfig();
13
13
  const { refreshCart } = useCart();
14
14
  const { getWishlistProducts } = useWishlist();
15
15
 
@@ -13,7 +13,7 @@ const emit = defineEmits<{
13
13
  (e: "update:valid", value: boolean): void;
14
14
  }>();
15
15
 
16
- const { deliveryTime } = usePizzaToppings();
16
+ const { deliveryTime } = useShopBiteConfig();
17
17
 
18
18
  const selected = ref<string>(props.modelValue ?? "");
19
19
  const now = ref<Date>(new Date());
@@ -7,7 +7,7 @@ const { selectedPaymentMethod, selectedShippingMethod } = useCheckout();
7
7
  const { createOrder } = useCheckout();
8
8
  const { refreshCart } = useCart();
9
9
  const { isLoggedIn, isGuestSession } = useUser();
10
- const { isCheckoutEnabled, refresh } = usePizzaToppings();
10
+ const { isCheckoutEnabled, refresh } = useShopBiteConfig();
11
11
 
12
12
  const toast = useToast();
13
13
 
@@ -7,7 +7,7 @@ const route = useRoute();
7
7
  const toast = useToast();
8
8
 
9
9
  const { isLoggedIn, user, logout } = useUser();
10
- const { isCheckoutEnabled } = usePizzaToppings();
10
+ const { isCheckoutEnabled } = useShopBiteConfig();
11
11
  const { count } = useCart();
12
12
  const runtimeConfig = useRuntimeConfig();
13
13
 
@@ -7,7 +7,7 @@ const props = defineProps<{
7
7
  withAddToCartButton: boolean;
8
8
  }>();
9
9
 
10
- const { isCheckoutEnabled } = usePizzaToppings();
10
+ const { isCheckoutEnabled } = useShopBiteConfig();
11
11
 
12
12
  const { product, withFavoriteButton, withAddToCartButton } = toRefs(props);
13
13
 
@@ -18,7 +18,7 @@ function isTimeWithinBounds(
18
18
  }
19
19
 
20
20
  export function useDeliveryTime(now: Ref<Date>) {
21
- const { deliveryTime } = usePizzaToppings();
21
+ const { deliveryTime } = useShopBiteConfig();
22
22
  const earliest = computed<Date>(() =>
23
23
  getEarliestSelectableTime(now.value, deliveryTime.value),
24
24
  );
@@ -1,21 +1,21 @@
1
1
  import { useContext, useShopwareContext } from "#imports";
2
2
  import type { Schemas } from "#shopware";
3
3
 
4
- type usePizzaToppingsReturn = {
4
+ type useShopBiteConfigReturn = {
5
5
  deliveryTime: ComputedRef<number>;
6
6
  isCheckoutEnabled: ComputedRef<boolean>;
7
- refresh(): Promise<Schemas["PizzaToppings"]>;
7
+ refresh(): Promise<Schemas["ShopBiteConfig"]>;
8
8
  };
9
9
 
10
- export function usePizzaToppings(): usePizzaToppingsReturn {
10
+ export function useShopBiteConfig(): useShopBiteConfigReturn {
11
11
  const { apiClient } = useShopwareContext();
12
12
 
13
13
  const _deliveryTime = useContext<number>("deliveryTime");
14
14
  const _isCheckoutEnabled = useContext<boolean>("isCheckoutActive");
15
15
 
16
- async function refresh(): Promise<Schemas["PizzaToppings"]> {
16
+ async function refresh(): Promise<Schemas["ShopBiteConfig"]> {
17
17
  const { data } = await apiClient.invoke(
18
- "pizza-toppings.get get /pizza-toppings",
18
+ "shopbite.config.get get /shopbite/config",
19
19
  );
20
20
  _deliveryTime.value = data.deliveryTime;
21
21
  _isCheckoutEnabled.value = data.isCheckoutEnabled;
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  const { count } = useWishlist();
3
- const { refresh } = usePizzaToppings();
3
+ const { refresh } = useShopBiteConfig();
4
4
 
5
5
  onMounted(() => {
6
6
  refresh();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopbite-de/storefront",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "main": "nuxt.config.ts",
5
5
  "description": "Shopware storefront for food delivery shops",
6
6
  "keywords": [
@@ -1,13 +1,13 @@
1
1
  import { describe, it, expect, vi, beforeEach } from "vitest";
2
2
  import { mockNuxtImport } from "@nuxt/test-utils/runtime";
3
3
  import { ref } from "vue";
4
- import { useDeliveryTime } from "../../app/composables/useDeliveryTime";
4
+ import { useDeliveryTime } from "~/composables/useDeliveryTime";
5
5
 
6
6
  const { mockDeliveryTime } = vi.hoisted(() => ({
7
7
  mockDeliveryTime: { value: 45 }, // Use object to keep reference
8
8
  }));
9
9
 
10
- mockNuxtImport("usePizzaToppings", () => () => ({
10
+ mockNuxtImport("useShopBiteConfig", () => () => ({
11
11
  deliveryTime: mockDeliveryTime,
12
12
  }));
13
13
 
@@ -1,6 +1,6 @@
1
1
  import { describe, it, expect, vi, beforeEach } from "vitest";
2
2
  import { mockNuxtImport } from "@nuxt/test-utils/runtime";
3
- import { usePizzaToppings } from "../../app/composables/usePizzaToppings";
3
+ import { useShopBiteConfig } from "~/composables/useShopBiteConfig";
4
4
 
5
5
  const {
6
6
  mockInvoke,
@@ -24,7 +24,7 @@ mockNuxtImport("useContext", () => (key: string) => {
24
24
  return { value: null };
25
25
  });
26
26
 
27
- describe("usePizzaToppings", () => {
27
+ describe("useShopBiteConfig", () => {
28
28
  beforeEach(() => {
29
29
  vi.clearAllMocks();
30
30
  mockDeliveryTime.value = 0;
@@ -34,7 +34,7 @@ describe("usePizzaToppings", () => {
34
34
  it("should initialize with values from context", () => {
35
35
  mockDeliveryTime.value = 30;
36
36
  mockIsCheckoutEnabled.value = true;
37
- const { deliveryTime, isCheckoutEnabled } = usePizzaToppings();
37
+ const { deliveryTime, isCheckoutEnabled } = useShopBiteConfig();
38
38
  expect(deliveryTime.value).toBe(30);
39
39
  expect(isCheckoutEnabled.value).toBe(true);
40
40
  });
@@ -47,10 +47,12 @@ describe("usePizzaToppings", () => {
47
47
  }
48
48
  });
49
49
 
50
- const { refresh, deliveryTime, isCheckoutEnabled } = usePizzaToppings();
50
+ const { refresh, deliveryTime, isCheckoutEnabled } = useShopBiteConfig();
51
51
  await refresh();
52
52
 
53
- expect(mockInvoke).toHaveBeenCalledWith("pizza-toppings.get get /pizza-toppings");
53
+ expect(mockInvoke).toHaveBeenCalledWith(
54
+ "shopbite.config.get get /shopbite/config",
55
+ );
54
56
  expect(deliveryTime.value).toBe(45);
55
57
  expect(isCheckoutEnabled.value).toBe(true);
56
58
  expect(mockDeliveryTime.value).toBe(45);