@akinon/projectzero 1.91.0-rc.2 → 1.91.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.
@@ -1,106 +0,0 @@
1
- 'use client';
2
-
3
- import { useLocalization } from '@akinon/next/hooks';
4
- import { Basket } from '@akinon/next/types';
5
- import { Button, LoaderSpinner, Link } from '@theme/components';
6
- import { BasketItem, Summary } from '@theme/views/basket';
7
- import { ROUTES } from '@theme/routes';
8
- import PluginModule, { Component } from '@akinon/next/components/plugin-module';
9
- import { useEffect, useState } from 'react';
10
- import { pushCartView } from '@theme/utils/gtm';
11
-
12
- interface BasketContentProps {
13
- initialBasket: Basket;
14
- multiBasket: boolean;
15
- }
16
-
17
- export function BasketContent({
18
- initialBasket,
19
- multiBasket
20
- }: BasketContentProps) {
21
- const { t } = useLocalization();
22
- const [basket, setBasket] = useState<Basket>(initialBasket);
23
-
24
- useEffect(() => {
25
- if (basket) {
26
- const products = basket.basketitem_set.map((basketItem) => ({
27
- ...basketItem.product
28
- }));
29
- pushCartView(products);
30
- }
31
- }, [basket]);
32
-
33
- const handleBasketUpdate = (updatedBasket: Basket) => {
34
- setBasket(updatedBasket);
35
- };
36
-
37
- if (!basket) {
38
- return (
39
- <div className="flex justify-center w-full">
40
- <LoaderSpinner />
41
- </div>
42
- );
43
- }
44
-
45
- return (
46
- <div className="max-w-screen-xl p-4 flex flex-col text-primary-800 lg:p-8 xl:flex-row xl:mx-auto">
47
- {basket.basketitem_set && basket.basketitem_set.length > 0 ? (
48
- <>
49
- <div className="flex-1 xl:mr-16">
50
- <div className="flex items-center justify-between py-2 border-b border-gray-200 lg:py-3">
51
- <h2 className="text-xl lg:text-2xl font-light">
52
- {t('basket.my_cart')}
53
- </h2>
54
- <Link
55
- href={ROUTES.HOME}
56
- className="text-xs hover:text-secondary-500"
57
- >
58
- {t('basket.back_to_shopping')}
59
- </Link>
60
- </div>
61
- <ul>
62
- {multiBasket ? (
63
- <PluginModule
64
- component={Component.MultiBasket}
65
- props={{
66
- BasketItem,
67
- onBasketUpdate: handleBasketUpdate
68
- }}
69
- />
70
- ) : (
71
- basket.basketitem_set.map((basketItem, index) => (
72
- <BasketItem
73
- key={index}
74
- basketItem={basketItem}
75
- onBasketUpdate={handleBasketUpdate}
76
- />
77
- ))
78
- )}
79
- </ul>
80
- </div>
81
- <Summary basket={basket} onBasketUpdate={handleBasketUpdate} />
82
- </>
83
- ) : (
84
- <div className="flex flex-col items-center container max-w-screen-sm py-4 px-4 xs:py-6 xs:px-6 sm:py-8 sm:px-8 lg:max-w-screen-xl">
85
- <h1
86
- className="w-full text-xl font-light text-secondary text-center sm:text-2xl"
87
- data-testid="basket-empty"
88
- >
89
- {t('basket.empty.title')}
90
- </h1>
91
-
92
- <div className="w-full text-sm text-black-800 text-center my-4 mb-2 sm:text-base">
93
- <p>{t('basket.empty.content_first')}</p>
94
- <p>{t('basket.empty.content_second')}.</p>
95
- </div>
96
-
97
- <Link href={ROUTES.HOME} passHref>
98
- <Button className="px-10 mt-2" appearance="filled">
99
- {t('basket.empty.button')}
100
- </Button>
101
- </Link>
102
- </div>
103
- )}
104
- </div>
105
- );
106
- }