@riosst100/pwa-marketplace 2.1.1 → 2.1.3
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/package.json +4 -4
- package/src/components/FavoriteSeller/AddToListButton/addToListButton.js +54 -0
- package/src/components/FavoriteSeller/AddToListButton/addToListButton.module.css +17 -0
- package/src/components/FavoriteSeller/AddToListButton/index.js +1 -0
- package/src/components/FavoriteSeller/AddToListButton/useCommonToasts.js +33 -0
- package/src/components/FavoriteSellerPage/favoriteSeller.js +32 -0
- package/src/components/FavoriteSellerPage/index.js +14 -0
- package/src/components/FavoriteSellerPage/item.js +140 -0
- package/src/components/SellerDetail/sellerDetail.js +19 -19
- package/src/intercept.js +1 -1
- package/src/overwrites/peregrine/lib/talons/AccountMenu/useAccountMenuItems.js +1 -1
- package/src/overwrites/venia-ui/lib/components/Header/header.js +0 -5
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/productFullDetail.js +0 -6
- package/src/talons/FavoriteSeller/AddToListButton/addToListButton.gql.js +30 -0
- package/src/talons/FavoriteSeller/AddToListButton/useAddToFavoriteListButton.js +154 -0
- package/src/talons/Seller/useSeller.js +19 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riosst100/pwa-marketplace",
|
|
3
3
|
"author": "riosst100@gmail.com",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.3",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"pwa-studio": {
|
|
7
7
|
"targets": {
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"axios": "^1.6.5",
|
|
13
|
+
"formik": "^2.4.6",
|
|
13
14
|
"iconsax-react": "^0.0.8",
|
|
14
15
|
"react-countdown": "^2.3.5",
|
|
15
|
-
"react-phone-number-input": "^3.3.9",
|
|
16
|
-
"react-slick": "^0.30.2",
|
|
17
16
|
"react-datepicker": "4.10.0",
|
|
18
17
|
"react-dropzone": "^14.2.3",
|
|
19
|
-
"
|
|
18
|
+
"react-phone-number-input": "^3.3.9",
|
|
19
|
+
"react-slick": "^0.30.2",
|
|
20
20
|
"yup": "^1.4.0"
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { element, func, shape, string } from 'prop-types';
|
|
3
|
+
import { Heart } from 'react-feather';
|
|
4
|
+
import { useAddToFavoriteListButton } from '@riosst100/pwa-marketplace/src/talons/FavoriteSeller/AddToListButton/useAddToFavoriteListButton';
|
|
5
|
+
import { useButton } from 'react-aria';
|
|
6
|
+
|
|
7
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
8
|
+
import Icon from '@magento/venia-ui/lib/components/Icon';
|
|
9
|
+
import defaultClasses from './addToListButton.module.css';
|
|
10
|
+
import { useCommonToasts } from '@magento/venia-ui/lib/components/Wishlist/AddToListButton/useCommonToasts';
|
|
11
|
+
|
|
12
|
+
const HeartIcon = <Heart color='#f76b1c' size={14} variant="Outline" className='stroke-[#f76b1c]' />;
|
|
13
|
+
|
|
14
|
+
const AddToFavoriteListButton = props => {
|
|
15
|
+
const talonProps = useAddToFavoriteListButton(props);
|
|
16
|
+
const buttonRef = useRef();
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
buttonProps,
|
|
20
|
+
buttonText,
|
|
21
|
+
errorToastProps,
|
|
22
|
+
isSelected,
|
|
23
|
+
loginToastProps,
|
|
24
|
+
successToastProps
|
|
25
|
+
} = talonProps;
|
|
26
|
+
|
|
27
|
+
useCommonToasts({ errorToastProps, loginToastProps, successToastProps });
|
|
28
|
+
const { buttonProps: ariaButtonProps } = useButton(buttonProps, buttonRef);
|
|
29
|
+
|
|
30
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
31
|
+
const buttonClass = isSelected ? classes.root_selected : classes.root;
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<button ref={buttonRef} className={buttonClass} {...ariaButtonProps}>
|
|
35
|
+
{props.icon}
|
|
36
|
+
</button>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default AddToFavoriteListButton;
|
|
41
|
+
|
|
42
|
+
AddToFavoriteListButton.defaultProps = {
|
|
43
|
+
icon: HeartIcon
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
AddToFavoriteListButton.propTypes = {
|
|
47
|
+
afterAdd: func,
|
|
48
|
+
beforeAdd: func,
|
|
49
|
+
classes: shape({
|
|
50
|
+
root: string,
|
|
51
|
+
root_selected: string
|
|
52
|
+
}),
|
|
53
|
+
icon: element
|
|
54
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
composes: gap-x-2xs from global;
|
|
3
|
+
composes: inline-flex from global;
|
|
4
|
+
composes: items-center from global;
|
|
5
|
+
min-height: 3rem;
|
|
6
|
+
composes: min-w-[3rem] from global;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.root_selected {
|
|
10
|
+
composes: root;
|
|
11
|
+
|
|
12
|
+
--selectedColor: rgb(var(--venia-global-color-red-400));
|
|
13
|
+
--fill: var(--selectedColor);
|
|
14
|
+
--stroke: var(--selectedColor);
|
|
15
|
+
|
|
16
|
+
composes: no-underline from global;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './addToListButton';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { AlertCircle, Check, Info } from 'react-feather';
|
|
3
|
+
import { useToasts } from '@magento/peregrine';
|
|
4
|
+
|
|
5
|
+
import Icon from '@magento/venia-ui/lib/components/Icon';
|
|
6
|
+
|
|
7
|
+
const CheckIcon = <Icon size={20} src={Check} />;
|
|
8
|
+
const ErrorIcon = <Icon size={20} src={AlertCircle} />;
|
|
9
|
+
const InfoIcon = <Icon size={20} src={Info} />;
|
|
10
|
+
|
|
11
|
+
export const useCommonToasts = props => {
|
|
12
|
+
const { errorToastProps, loginToastProps, successToastProps } = props;
|
|
13
|
+
|
|
14
|
+
const [, { addToast }] = useToasts();
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (loginToastProps) {
|
|
18
|
+
addToast({ ...loginToastProps, icon: InfoIcon });
|
|
19
|
+
}
|
|
20
|
+
}, [addToast, loginToastProps]);
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (successToastProps) {
|
|
24
|
+
addToast({ ...successToastProps, icon: CheckIcon });
|
|
25
|
+
}
|
|
26
|
+
}, [addToast, successToastProps]);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (errorToastProps) {
|
|
30
|
+
addToast({ ...errorToastProps, icon: ErrorIcon });
|
|
31
|
+
}
|
|
32
|
+
}, [addToast, errorToastProps]);
|
|
33
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StoreTitle } from '@magento/venia-ui/lib/components/Head';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
import Item from './item';
|
|
5
|
+
|
|
6
|
+
const favoriteSeller = () => {
|
|
7
|
+
|
|
8
|
+
const { formatMessage } = useIntl();
|
|
9
|
+
const PAGE_TITLE = formatMessage({
|
|
10
|
+
id: 'favoriteSellerPage.pageTitleText',
|
|
11
|
+
defaultMessage: 'Favorite Seller'
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className='relative'>
|
|
16
|
+
<StoreTitle>{PAGE_TITLE}</StoreTitle>
|
|
17
|
+
<div aria-live="polite" className="text-xl font-medium text-left mb-[30px]">
|
|
18
|
+
{PAGE_TITLE}
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<div className='flex flex-col gap-5'>
|
|
22
|
+
{
|
|
23
|
+
[...Array(5)].map(() => (
|
|
24
|
+
<Item />
|
|
25
|
+
))
|
|
26
|
+
}
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default favoriteSeller
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import FavoriteSeller from './favoriteSeller'
|
|
2
|
+
import AccountLayout from '@riosst100/pwa-marketplace/src/components/AccountLayout';
|
|
3
|
+
|
|
4
|
+
import React from 'react'
|
|
5
|
+
|
|
6
|
+
const index = () => {
|
|
7
|
+
return (
|
|
8
|
+
<AccountLayout>
|
|
9
|
+
<FavoriteSeller />
|
|
10
|
+
</AccountLayout>
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default index
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Form } from 'informed';
|
|
3
|
+
import Button from '@magento/venia-ui/lib/components/Button';
|
|
4
|
+
import Image from '@magento/venia-ui/lib/components/Image';
|
|
5
|
+
import Verify from '@riosst100/pwa-marketplace/src/components/CrossSeller/verifyIcon';
|
|
6
|
+
import Star from '@riosst100/pwa-marketplace/src/components/CrossSeller/starIcon';
|
|
7
|
+
import logoImage from '@riosst100/pwa-marketplace/src/components/CrossSeller/logo_seller.png';
|
|
8
|
+
import { Share, Trash } from 'iconsax-react';
|
|
9
|
+
import SocialShare from '@riosst100/pwa-marketplace/src/components/SocialMediaShare';
|
|
10
|
+
import { X } from 'react-feather';
|
|
11
|
+
import Modal from '@riosst100/pwa-marketplace/src/components/Modal';
|
|
12
|
+
import cn from 'classnames';
|
|
13
|
+
import { primary900 } from '@riosst100/pwa-marketplace/src/theme/vars';
|
|
14
|
+
import { FormattedMessage } from 'react-intl';
|
|
15
|
+
|
|
16
|
+
const item = () => {
|
|
17
|
+
const [open, setOpen] = React.useState(false);
|
|
18
|
+
|
|
19
|
+
const handleRemoveFromFavorite = () => {
|
|
20
|
+
alert('remove fav seller')
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const handleGoToSellerPage = () => {
|
|
24
|
+
alert('to seller page')
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
<Modal
|
|
30
|
+
open={open}
|
|
31
|
+
setOpen={setOpen}
|
|
32
|
+
className={cn(
|
|
33
|
+
'max-w-max !min-h-auto px-[30px] pt-[30px] pb-10',
|
|
34
|
+
)}
|
|
35
|
+
>
|
|
36
|
+
<div className='social_share-container flex flex-col gap-y-7'>
|
|
37
|
+
<div className='flex justify-between'>
|
|
38
|
+
<div className='text-lg font-medium'>
|
|
39
|
+
Share to your friends
|
|
40
|
+
</div>
|
|
41
|
+
<button onClick={() => { setOpen(!open) }} >
|
|
42
|
+
<X size={24} color={primary900} />
|
|
43
|
+
</button>
|
|
44
|
+
</div>
|
|
45
|
+
<div className='flex flex-row border border-gray-100 rounded-md px-5 py-2.5 gap-x-2.5 items-center'>
|
|
46
|
+
<div className='flex flex-col'>
|
|
47
|
+
<div className='text-[14px] font-normal'>
|
|
48
|
+
Zen Market.TCG
|
|
49
|
+
</div>
|
|
50
|
+
<div className='text-[12px] font-normal text-gray-200'>
|
|
51
|
+
zenmarket-tcg.link
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
<SocialShare rootClassName="justify-center" />
|
|
56
|
+
</div>
|
|
57
|
+
</Modal>
|
|
58
|
+
<div className='border border-gray-100 rounded-md p-5 flex flex-col md_flex-row justify-between gap-y-4'>
|
|
59
|
+
<div className='seller_info-container flex flex-row gap-x-[15px]'>
|
|
60
|
+
<div className='logo_wrapper w-[100px] h-[100px]'>
|
|
61
|
+
<Image
|
|
62
|
+
alt='seller name'
|
|
63
|
+
className="relative mt-[-5px]"
|
|
64
|
+
src={logoImage}
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
<div className='flex flex-col gap-y-[15px]'>
|
|
68
|
+
<div className='flex flex-col gap-[6px]'>
|
|
69
|
+
<div className='seller_summary-wrapper flex flex-row gap-x-2.5 items-center'>
|
|
70
|
+
<div className='seller_name text-lg font-medium leading-6'>
|
|
71
|
+
Zen Market
|
|
72
|
+
</div>
|
|
73
|
+
<div className='seller_badge flex flex-row gap-x-[5px] items-center leading-6'>
|
|
74
|
+
<Verify />
|
|
75
|
+
<span className='text-xs font-medium text-gray-600-transparent capitalize'>
|
|
76
|
+
Verified
|
|
77
|
+
</span>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
<div className='flex flex-row gap-x-[5px] items-center'>
|
|
81
|
+
<span className='font-normal text-[12px] text-gray-200 '>
|
|
82
|
+
Jurong West
|
|
83
|
+
</span>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
<div className='flex gap-4'>
|
|
87
|
+
<Button
|
|
88
|
+
classes={{
|
|
89
|
+
content: 'gap-1.5 grid-flow-col inline-grid items-center justify-center justify-items-center capitalize font-medium text-[14px]',
|
|
90
|
+
rootClass: 'py-[0px] h-9 hover_border-blue-700'
|
|
91
|
+
}}
|
|
92
|
+
onClick={handleGoToSellerPage}
|
|
93
|
+
>
|
|
94
|
+
<FormattedMessage
|
|
95
|
+
id={'favoriteSeller.visitStore'}
|
|
96
|
+
defaultMessage={'Visit Store'}
|
|
97
|
+
/>
|
|
98
|
+
</Button>
|
|
99
|
+
<div
|
|
100
|
+
className='flex items-center justify-center gap-[5px] p-[9px] relative rounded-[30px] overflow-hidden border border-solid border-blue-600 hover_border-blue-700 cursor-pointer w-9 h-9'
|
|
101
|
+
onClick={() => { setOpen(!open) }}
|
|
102
|
+
>
|
|
103
|
+
<Share
|
|
104
|
+
size="15"
|
|
105
|
+
className='text-blue-600 group-hover_text-blue-800 left-[-1px]'
|
|
106
|
+
/>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
<div className='flex flex-row justify-between md_justify-center items-center gap-5'>
|
|
112
|
+
<div className='flex flex-col gap-y-2'>
|
|
113
|
+
<div className='rating_sales flex flex-row gap-x-[5px] items-center'>
|
|
114
|
+
<Star width={18} height={18} />
|
|
115
|
+
<p className='font-medium text-[18px] text-gray-600'>
|
|
116
|
+
4.7
|
|
117
|
+
</p>
|
|
118
|
+
</div>
|
|
119
|
+
<span className='text-gray-800 text-xs'>
|
|
120
|
+
<FormattedMessage
|
|
121
|
+
id={'favoriteSeller.RatingAndReviews'}
|
|
122
|
+
defaultMessage={'Rating & Reviews'}
|
|
123
|
+
/>
|
|
124
|
+
</span>
|
|
125
|
+
|
|
126
|
+
</div>
|
|
127
|
+
<Button
|
|
128
|
+
data-cy="Product-Section-removeFavorite"
|
|
129
|
+
onClick={handleRemoveFromFavorite}
|
|
130
|
+
className="min-w-min border border-gray-200 rounded-full border-solid w-7 h-7 flex items-center justify-center hover_border-gray-600"
|
|
131
|
+
>
|
|
132
|
+
<Trash size="16" color="#999999" />
|
|
133
|
+
</Button>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
</>
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export default item
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { Fragment, useState } from 'react';
|
|
1
|
+
import React, { Fragment, Suspense, useState } from 'react';
|
|
2
2
|
import { FormattedMessage } from 'react-intl';
|
|
3
3
|
import { useSeller } from '@riosst100/pwa-marketplace/src/talons/Seller/useSeller';
|
|
4
4
|
import ErrorView from '@magento/venia-ui/lib/components/ErrorView';
|
|
@@ -22,13 +22,14 @@ import Image from '@magento/venia-ui/lib/components/Image';
|
|
|
22
22
|
import LiveChat from '@riosst100/pwa-marketplace/src/components/LiveChat';
|
|
23
23
|
import Button from '@magento/venia-ui/lib/components/Button';
|
|
24
24
|
import cn from 'classnames';
|
|
25
|
+
const FavoriteSellerButton = React.lazy(() => import('@riosst100/pwa-marketplace/src/components/FavoriteSeller/AddToListButton'));
|
|
25
26
|
|
|
26
27
|
const SellerDetail = props => {
|
|
27
28
|
const talonProps = useSeller({
|
|
28
29
|
mapSeller
|
|
29
30
|
});
|
|
30
31
|
|
|
31
|
-
const { error, loading, seller } = talonProps;
|
|
32
|
+
const { error, loading, seller, favoriteSellerButtonProps } = talonProps;
|
|
32
33
|
|
|
33
34
|
if (loading && !seller)
|
|
34
35
|
return '';
|
|
@@ -71,6 +72,10 @@ const SellerDetail = props => {
|
|
|
71
72
|
setOpenChat(!openChat);
|
|
72
73
|
}
|
|
73
74
|
|
|
75
|
+
const addToFavourite = () => {
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
74
79
|
return (
|
|
75
80
|
<div className=' py-8'>
|
|
76
81
|
<Slider seller={seller} rootClassname='mb-[30px]' />
|
|
@@ -113,36 +118,31 @@ const SellerDetail = props => {
|
|
|
113
118
|
</div>
|
|
114
119
|
</div>
|
|
115
120
|
</button>
|
|
116
|
-
{/* <button class="flex items-center justify-center gap-[5px] xs_p-[11px] lg_px-[20px] lg_py-[8px] relative bg-[#280135] rounded-[30px] border border-solid border-[#280135]">
|
|
117
|
-
<div class="flex items-center justify-center gap-[10px] relative">
|
|
118
|
-
<Message color='#FFFFFF' size={14} variant="Outline" className='stroke-[#FFFFFF]' />
|
|
119
|
-
<div class="relative xs_hidden lg_flex w-fit font-medium text-[#fff] text-base tracking-[0] leading-[20px] whitespace-nowrap">
|
|
120
|
-
Chat With Seller
|
|
121
|
-
</div>
|
|
122
|
-
</div>
|
|
123
|
-
</button> */}
|
|
124
121
|
<Button
|
|
125
122
|
priority='high'
|
|
126
123
|
classes={{
|
|
127
124
|
content: "flex justify-center gap-x-2.5 items-center text-[14px] font-medium capitalize"
|
|
128
125
|
}}
|
|
129
|
-
className=
|
|
130
|
-
"bg-darkblue-900 px-6 py-2 rounded-full text-white border",
|
|
131
|
-
"border-darkblue-900 hover_bg-blue-900 hover_border-blue-900 focus-visible_outline-none"
|
|
132
|
-
)}
|
|
126
|
+
className='flex items-center justify-center gap-[5px] xs_p-[11px] lg_px-[20px] lg_py-[8px] relative bg-[#280135] rounded-[30px] border border-solid border-[#280135]'
|
|
133
127
|
onClick={toggleChat}
|
|
134
128
|
>
|
|
135
129
|
<Message color='#FFFFFF' size={14} variant="Outline" className='stroke-[#FFFFFF]' />
|
|
136
|
-
<
|
|
130
|
+
<div class="relative xs_hidden lg_flex w-fit font-medium text-[#fff] text-base tracking-[0] leading-[20px] whitespace-nowrap">
|
|
137
131
|
<FormattedMessage
|
|
138
132
|
id={'seller.chatWithSeller'}
|
|
139
133
|
defaultMessage={'Chat With Seller'}
|
|
140
134
|
/>
|
|
141
|
-
</
|
|
135
|
+
</div>
|
|
142
136
|
</Button>
|
|
143
|
-
<
|
|
144
|
-
<
|
|
145
|
-
|
|
137
|
+
<Suspense fallback={null}>
|
|
138
|
+
<FavoriteSellerButton
|
|
139
|
+
classes={{
|
|
140
|
+
root: 'flex items-center justify-center gap-[5px] p-[11px] relative bg-white rounded-[30px] overflow-hidden border border-solid border-[#f76b1c]'
|
|
141
|
+
}}
|
|
142
|
+
{...favoriteSellerButtonProps}
|
|
143
|
+
buttonText={''}
|
|
144
|
+
/>
|
|
145
|
+
</Suspense>
|
|
146
146
|
<button class="flex items-center justify-center gap-[5px] p-[11px] relative bg-white rounded-[30px] overflow-hidden border border-solid border-[#f76b1c]">
|
|
147
147
|
<Share color='#f76b1c' size={14} variant="Outline" className='stroke-[#f76b1c]' />
|
|
148
148
|
</button>
|
package/src/intercept.js
CHANGED
|
@@ -133,7 +133,7 @@ module.exports = targets => {
|
|
|
133
133
|
exact: true,
|
|
134
134
|
name: "FavoriteSeller",
|
|
135
135
|
pattern: "/favorite-seller",
|
|
136
|
-
path: require.resolve("./components/
|
|
136
|
+
path: require.resolve("./components/FavoriteSellerPage/index.js"),
|
|
137
137
|
authed: true,
|
|
138
138
|
},
|
|
139
139
|
{
|
|
@@ -125,11 +125,6 @@ const Header = props => {
|
|
|
125
125
|
<div className='flex w-full justify-end lg_hidden'>
|
|
126
126
|
<SearchNormal size="25" color="#280135" variant="Outline" className='mr-4' />
|
|
127
127
|
</div>
|
|
128
|
-
<Suspense fallback={searchBarFallback}>
|
|
129
|
-
<Route>
|
|
130
|
-
<SearchBar isOpen={true} ref={searchRef} />
|
|
131
|
-
</Route>
|
|
132
|
-
</Suspense>
|
|
133
128
|
</div>
|
|
134
129
|
<div className={cn(classes.secondaryActions, 'lg_gap-x-5 pl-5 border-l-[1px] border-gray-100')}>
|
|
135
130
|
{/* <SearchTrigger
|
|
@@ -691,12 +691,6 @@ const ProductFullDetail = props => {
|
|
|
691
691
|
<div className='block lg_hidden'>
|
|
692
692
|
<ProductDetailsCollapsible data={dataTabs} />
|
|
693
693
|
</div>
|
|
694
|
-
<Tabs
|
|
695
|
-
data={dataTabs}
|
|
696
|
-
tabContentWrapperClassName='!p-0'
|
|
697
|
-
hasContent
|
|
698
|
-
tabWrapperClassName='xl_gap-x-[60px] justify-center'
|
|
699
|
-
/>
|
|
700
694
|
</section>
|
|
701
695
|
|
|
702
696
|
<section className='pt-8 lg_pt-10'>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
export const ADD_TO_FAVORITE_SELLER_LIST = gql`
|
|
4
|
+
mutation AddSellerToFavoriteList(
|
|
5
|
+
$sellerId: ID!
|
|
6
|
+
) {
|
|
7
|
+
addSellerToFavoritelist(
|
|
8
|
+
sellerId: $sellerId
|
|
9
|
+
) {
|
|
10
|
+
favorite {
|
|
11
|
+
id
|
|
12
|
+
customer_id
|
|
13
|
+
creation_time
|
|
14
|
+
status
|
|
15
|
+
}
|
|
16
|
+
error
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
export const GET_SELLER_IN_FAVORITE_LISTS = gql`
|
|
22
|
+
query GetProductsInWishlistsForGallery {
|
|
23
|
+
customerWishlistProducts @client
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
export default {
|
|
28
|
+
addToFavoriteSellerMutation: ADD_TO_FAVORITE_SELLER_LIST,
|
|
29
|
+
getSellerInFavoriteListsQuery: GET_SELLER_IN_FAVORITE_LISTS
|
|
30
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { useMutation, useQuery } from '@apollo/client';
|
|
4
|
+
|
|
5
|
+
import { useUserContext } from '@magento/peregrine/lib/context/user';
|
|
6
|
+
import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
|
|
7
|
+
|
|
8
|
+
import defaultOperations from './addToListButton.gql';
|
|
9
|
+
|
|
10
|
+
export const useAddToFavoriteListButton = props => {
|
|
11
|
+
const { afterAdd, beforeAdd, item } = props;
|
|
12
|
+
|
|
13
|
+
const operations = mergeOperations(defaultOperations, props.operations);
|
|
14
|
+
|
|
15
|
+
const [
|
|
16
|
+
addToFavoriteSeller,
|
|
17
|
+
{
|
|
18
|
+
data: addSellerData,
|
|
19
|
+
error: errorAddingProduct,
|
|
20
|
+
loading: isAddingToList
|
|
21
|
+
}
|
|
22
|
+
] = useMutation(operations.addToFavoriteSellerMutation);
|
|
23
|
+
|
|
24
|
+
// const {
|
|
25
|
+
// client,
|
|
26
|
+
// data: { customerFavoriteSellers }
|
|
27
|
+
// } = useQuery(operations.getSellerInFavoriteListsQuery);
|
|
28
|
+
|
|
29
|
+
// const isSelected = useMemo(() => {
|
|
30
|
+
// return (
|
|
31
|
+
// customerFavoriteSellers.includes(item.seller_id) || isAddingToList
|
|
32
|
+
// );
|
|
33
|
+
// }, [customerFavoriteSellers, isAddingToList, item.seller_id]);
|
|
34
|
+
const isSelected = false;
|
|
35
|
+
|
|
36
|
+
const [showLoginToast, setShowLoginToast] = useState(0);
|
|
37
|
+
|
|
38
|
+
const { formatMessage } = useIntl();
|
|
39
|
+
const [{ isSignedIn }] = useUserContext();
|
|
40
|
+
|
|
41
|
+
const handleClick = useCallback(async () => {
|
|
42
|
+
console.log(item)
|
|
43
|
+
if (!isSignedIn) {
|
|
44
|
+
setShowLoginToast(current => ++current);
|
|
45
|
+
} else {
|
|
46
|
+
try {
|
|
47
|
+
if (beforeAdd) {
|
|
48
|
+
await beforeAdd();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
await addToFavoriteSeller({
|
|
52
|
+
variables: { sellerId: item.seller_id }
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// client.writeQuery({
|
|
56
|
+
// query: operations.getSellerInFavoriteListsQuery,
|
|
57
|
+
// data: {
|
|
58
|
+
// customerFavoriteSellers: [
|
|
59
|
+
// ...customerFavoriteSellers,
|
|
60
|
+
// item.seller_id
|
|
61
|
+
// ]
|
|
62
|
+
// }
|
|
63
|
+
// });
|
|
64
|
+
|
|
65
|
+
// if (afterAdd) {
|
|
66
|
+
// afterAdd();
|
|
67
|
+
// }
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error(error);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}, [
|
|
73
|
+
addToFavoriteSeller,
|
|
74
|
+
afterAdd,
|
|
75
|
+
beforeAdd,
|
|
76
|
+
// client,
|
|
77
|
+
// customerFavoriteSellers,
|
|
78
|
+
isSignedIn,
|
|
79
|
+
item,
|
|
80
|
+
// operations.getSellerInFavoriteListsQuery
|
|
81
|
+
]);
|
|
82
|
+
|
|
83
|
+
const loginToastProps = useMemo(() => {
|
|
84
|
+
if (showLoginToast) {
|
|
85
|
+
return {
|
|
86
|
+
type: 'info',
|
|
87
|
+
message: formatMessage({
|
|
88
|
+
id: 'favoriteSeller.galleryButton.loginMessage',
|
|
89
|
+
defaultMessage:
|
|
90
|
+
'Please sign-in to your Account to save seller for later.'
|
|
91
|
+
}),
|
|
92
|
+
timeout: 5000
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return null;
|
|
97
|
+
}, [formatMessage, showLoginToast]);
|
|
98
|
+
|
|
99
|
+
const successToastProps = useMemo(() => {
|
|
100
|
+
if (addSellerData) {
|
|
101
|
+
return {
|
|
102
|
+
type: 'success',
|
|
103
|
+
message: formatMessage({
|
|
104
|
+
id: 'favoriteSeller.galleryButton.successMessageGeneral',
|
|
105
|
+
defaultMessage:
|
|
106
|
+
'Seller successfully added to your favorites list.'
|
|
107
|
+
}),
|
|
108
|
+
timeout: 5000
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return null;
|
|
113
|
+
}, [addSellerData, formatMessage]);
|
|
114
|
+
|
|
115
|
+
const errorToastProps = useMemo(() => {
|
|
116
|
+
if (errorAddingProduct) {
|
|
117
|
+
return {
|
|
118
|
+
type: 'error',
|
|
119
|
+
message: formatMessage({
|
|
120
|
+
id: 'favoriteSeller.galleryButton.addError',
|
|
121
|
+
defaultMessage:
|
|
122
|
+
'Something went wrong adding the product to your favorite seller list.'
|
|
123
|
+
}),
|
|
124
|
+
timeout: 5000
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return null;
|
|
129
|
+
}, [errorAddingProduct, formatMessage]);
|
|
130
|
+
|
|
131
|
+
const buttonProps = useMemo(
|
|
132
|
+
() => ({
|
|
133
|
+
'aria-label': formatMessage({
|
|
134
|
+
id: 'favoriteSellerButton.addText',
|
|
135
|
+
defaultMessage: 'Add to Favorites'
|
|
136
|
+
}),
|
|
137
|
+
isDisabled: false,
|
|
138
|
+
onPress: handleClick,
|
|
139
|
+
type: 'button'
|
|
140
|
+
}),
|
|
141
|
+
[formatMessage, handleClick]
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
buttonProps,
|
|
146
|
+
buttonText: props.buttonText && props.buttonText(isSelected),
|
|
147
|
+
// customerFavoriteSellers,
|
|
148
|
+
errorToastProps,
|
|
149
|
+
handleClick,
|
|
150
|
+
isSelected,
|
|
151
|
+
loginToastProps,
|
|
152
|
+
successToastProps
|
|
153
|
+
};
|
|
154
|
+
};
|
|
@@ -2,6 +2,7 @@ import { useQuery } from '@apollo/client';
|
|
|
2
2
|
import { useEffect, useMemo } from 'react';
|
|
3
3
|
import { useLocation } from 'react-router-dom';
|
|
4
4
|
import { useAppContext } from '@magento/peregrine/lib/context/app';
|
|
5
|
+
import { useIntl } from 'react-intl';
|
|
5
6
|
|
|
6
7
|
import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
|
|
7
8
|
import DEFAULT_OPERATIONS from './seller.gql';
|
|
@@ -9,6 +10,8 @@ import DEFAULT_OPERATIONS from './seller.gql';
|
|
|
9
10
|
export const useSeller = props => {
|
|
10
11
|
const { mapSeller } = props;
|
|
11
12
|
|
|
13
|
+
const { formatMessage } = useIntl();
|
|
14
|
+
|
|
12
15
|
const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
|
|
13
16
|
const { getStoreConfigData, getSellerDetailQuery } = operations;
|
|
14
17
|
const { pathname } = useLocation();
|
|
@@ -63,9 +66,24 @@ export const useSeller = props => {
|
|
|
63
66
|
setPageLoading(isBackgroundLoading);
|
|
64
67
|
}, [isBackgroundLoading, setPageLoading]);
|
|
65
68
|
|
|
69
|
+
const favoriteSellerOptions = useMemo(() => {
|
|
70
|
+
const options = {
|
|
71
|
+
seller_id: seller.seller_id
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return options;
|
|
75
|
+
}, [seller]);
|
|
76
|
+
|
|
77
|
+
const favoriteSellerButtonProps = {
|
|
78
|
+
buttonText: '',
|
|
79
|
+
item: favoriteSellerOptions,
|
|
80
|
+
storeConfig: storeConfigData ? storeConfigData.storeConfig : {}
|
|
81
|
+
};
|
|
82
|
+
|
|
66
83
|
return {
|
|
67
84
|
error,
|
|
68
85
|
loading,
|
|
69
|
-
seller
|
|
86
|
+
seller,
|
|
87
|
+
favoriteSellerButtonProps
|
|
70
88
|
};
|
|
71
89
|
};
|