@akinon/next 1.76.0-rc.0 → 2.0.0-beta.1

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.
@@ -1,72 +0,0 @@
1
- import { Cache, CacheKey } from '../../lib/cache';
2
- import { basket } from '../../data/urls';
3
- import { Basket } from '../../types';
4
- import appFetch from '../../utils/app-fetch';
5
- import { ServerVariables } from '../../utils/server-variables';
6
- import logger from '../../utils/log';
7
-
8
- type GetBasketParams = {
9
- locale?: string;
10
- currency?: string;
11
- namespace?: string;
12
- };
13
-
14
- const getBasketDataHandler = ({
15
- locale,
16
- currency,
17
- namespace
18
- }: GetBasketParams) => {
19
- return async function () {
20
- try {
21
- const url = namespace
22
- ? basket.getBasketDetail(namespace)
23
- : basket.getBasket;
24
-
25
- const basketData = await appFetch<{ basket: Basket }>({
26
- url,
27
- locale,
28
- currency,
29
- init: {
30
- headers: {
31
- Accept: 'application/json',
32
- 'Content-Type': 'application/json'
33
- }
34
- }
35
- });
36
-
37
- if (!basketData?.basket) {
38
- logger.warn('Basket data is undefined', {
39
- handler: 'getBasketDataHandler',
40
- namespace
41
- });
42
- }
43
-
44
- return basketData;
45
- } catch (error) {
46
- logger.error('Error fetching basket data', {
47
- handler: 'getBasketDataHandler',
48
- error,
49
- namespace
50
- });
51
- throw error;
52
- }
53
- };
54
- };
55
-
56
- export const getBasketData = async ({
57
- locale = ServerVariables.locale,
58
- currency = ServerVariables.currency,
59
- namespace
60
- }: GetBasketParams = {}) => {
61
- return Cache.wrap(
62
- CacheKey.Basket(namespace),
63
- locale,
64
- getBasketDataHandler({ locale, currency, namespace }),
65
- {
66
- expire: 0,
67
- cache: false
68
- }
69
- );
70
- };
71
-
72
-