@licklist/design 0.69.3 → 0.69.5
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/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.d.ts +2 -1
- package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.d.ts.map +1 -1
- package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.js +3 -2
- package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.d.ts +2 -1
- package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.d.ts.map +1 -1
- package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.js +31 -28
- package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.d.ts +2 -1
- package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.d.ts.map +1 -1
- package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.js +14 -3
- package/dist/events/edit-event-modal/utils/getDefaultProductSet.d.ts.map +1 -1
- package/dist/events/edit-event-modal/utils/getDefaultProductSet.js +3 -1
- package/dist/iframe/activity-card/ActivityCard.d.ts +5 -4
- package/dist/iframe/activity-card/ActivityCard.d.ts.map +1 -1
- package/dist/iframe/activity-card/ActivityCard.js +52 -40
- package/dist/index.js +1 -0
- package/dist/modals/confirmation/ConfirmModal.d.ts +3 -1
- package/dist/modals/confirmation/ConfirmModal.d.ts.map +1 -1
- package/dist/modals/confirmation/ConfirmModal.js +172 -8
- package/dist/product-set/card/ProductSetCard.d.ts +6 -2
- package/dist/product-set/card/ProductSetCard.d.ts.map +1 -1
- package/dist/product-set/card/ProductSetCard.js +30 -11
- package/dist/product-set/control/ProductSetControl.d.ts +4 -0
- package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
- package/dist/product-set/control/ProductSetControl.js +30 -3
- package/dist/product-set/control/ProductSetImageControl.d.ts +2 -0
- package/dist/product-set/control/ProductSetImageControl.d.ts.map +1 -0
- package/dist/product-set/control/ProductSetImageControl.js +279 -0
- package/dist/product-set/form/MobileFooter.d.ts.map +1 -1
- package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
- package/dist/product-set/form/ProductSetForm.js +8 -0
- package/dist/product-set/form/ProductSetNameControl.d.ts +6 -0
- package/dist/product-set/form/ProductSetNameControl.d.ts.map +1 -0
- package/dist/product-set/form/ProductSetNameControl.js +35 -0
- package/dist/product-set/form/index.d.ts +1 -0
- package/dist/product-set/form/index.d.ts.map +1 -1
- package/dist/product-set/utils/index.d.ts +7 -0
- package/dist/product-set/utils/index.d.ts.map +1 -1
- package/dist/product-set/utils/index.js +10 -1
- package/dist/styles/activity-card/{GridActivitiesCard.scss → ActivitiesCard.scss} +19 -5
- package/dist/styles/activity-card/ListActivitiesCard.scss +12 -42
- package/dist/styles/activity-card/_index.scss +1 -1
- package/dist/typeahead/Typeahead.d.ts +5 -1
- package/dist/typeahead/Typeahead.d.ts.map +1 -1
- package/dist/typeahead/Typeahead.js +9 -2
- package/package.json +5 -5
- package/src/events/edit-event-modal/component/EditEventForm/EditEventForm.tsx +3 -0
- package/src/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.tsx +86 -85
- package/src/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.tsx +11 -1
- package/src/events/edit-event-modal/utils/getDefaultProductSet.ts +2 -0
- package/src/iframe/activity-card/ActivityCard.tsx +35 -24
- package/src/modals/confirmation/ConfirmModal.tsx +19 -3
- package/src/product-set/card/ProductSetCard.tsx +47 -8
- package/src/product-set/control/ProductSetControl.tsx +52 -52
- package/src/product-set/control/ProductSetImageControl.tsx +97 -0
- package/src/product-set/form/MobileFooter.tsx +1 -3
- package/src/product-set/form/ProductSetForm.tsx +10 -0
- package/src/product-set/form/ProductSetNameControl.tsx +27 -0
- package/src/product-set/form/index.ts +1 -0
- package/src/product-set/utils/index.ts +11 -0
- package/src/styles/activity-card/{GridActivitiesCard.scss → ActivitiesCard.scss} +19 -5
- package/src/styles/activity-card/ListActivitiesCard.scss +12 -42
- package/src/styles/activity-card/_index.scss +1 -1
- package/src/typeahead/Typeahead.tsx +15 -1
- package/yarn.lock +63 -45
package/src/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.tsx
CHANGED
|
@@ -5,9 +5,11 @@ import { useId } from '@react-aria/utils'
|
|
|
5
5
|
import { Controller, useFormContext } from 'react-hook-form'
|
|
6
6
|
import { HasPermissionProp } from '@licklist/plugins/dist/types/permission/Permission'
|
|
7
7
|
import { ProductSet } from '@licklist/core/dist/DataMapper/Product/ProductSetDataMapper'
|
|
8
|
+
import { getTypeHeadItemsFromMenus } from '../../../../product-set/utils'
|
|
8
9
|
import { ConfirmModal } from '../../../../modals/confirmation/ConfirmModal'
|
|
9
10
|
import { EditEventFormValues } from '../EditEventForm/EditEventForm'
|
|
10
11
|
import { EditEventProductSet } from './component/EditEventProductSet'
|
|
12
|
+
import { Typeahead } from '../../../../typeahead'
|
|
11
13
|
|
|
12
14
|
interface SelectEventProductSetProps extends HasPermissionProp {
|
|
13
15
|
productSets?: ProductSet[]
|
|
@@ -17,6 +19,7 @@ interface SelectEventProductSetProps extends HasPermissionProp {
|
|
|
17
19
|
setEditProductSetId: (value: string) => void
|
|
18
20
|
timeZone: string
|
|
19
21
|
eventProductSet?: ProductSet
|
|
22
|
+
overrideNameError?: string
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
export const SelectEventProductSet = ({
|
|
@@ -27,6 +30,7 @@ export const SelectEventProductSet = ({
|
|
|
27
30
|
setShowEditProductSet,
|
|
28
31
|
timeZone,
|
|
29
32
|
eventProductSet,
|
|
33
|
+
overrideNameError,
|
|
30
34
|
}: SelectEventProductSetProps) => {
|
|
31
35
|
const productSets = eventProductSet
|
|
32
36
|
? [..._productSets, eventProductSet]
|
|
@@ -48,6 +52,21 @@ export const SelectEventProductSet = ({
|
|
|
48
52
|
const productSetId = watch('productSetId')
|
|
49
53
|
const editedProductSet = watch('editedProductSet')
|
|
50
54
|
|
|
55
|
+
const typeheadValues = getTypeHeadItemsFromMenus(
|
|
56
|
+
editedProductSet
|
|
57
|
+
? productSets.map((productSet) => {
|
|
58
|
+
if (productSet.id === editedProductSet.id) {
|
|
59
|
+
return editedProductSet
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return productSet
|
|
63
|
+
})
|
|
64
|
+
: productSets,
|
|
65
|
+
)
|
|
66
|
+
const selectedProductSetTypeheadValue = productSetId
|
|
67
|
+
? typeheadValues?.find((typeheadValue) => typeheadValue.id === productSetId)
|
|
68
|
+
: undefined
|
|
69
|
+
|
|
51
70
|
const onEditProductSet = useCallback(
|
|
52
71
|
() => {
|
|
53
72
|
setEditProductSetId(String(productSetId))
|
|
@@ -101,6 +120,7 @@ export const SelectEventProductSet = ({
|
|
|
101
120
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
102
121
|
const onSubmit = (value: EditEventFormValues['editedProductSet']) => {
|
|
103
122
|
setShowEditProductSet(false)
|
|
123
|
+
setValue('productSetId', value.id)
|
|
104
124
|
setValue('editedProductSet', value)
|
|
105
125
|
}
|
|
106
126
|
|
|
@@ -116,93 +136,73 @@ export const SelectEventProductSet = ({
|
|
|
116
136
|
<Controller
|
|
117
137
|
control={control}
|
|
118
138
|
name='productSetId'
|
|
119
|
-
render={(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
)}
|
|
179
|
-
{showEditProductSet && (
|
|
180
|
-
<Button
|
|
181
|
-
variant=''
|
|
182
|
-
className='btn product-set-button'
|
|
183
|
-
onClick={revertEditProductSet}
|
|
184
|
-
>
|
|
185
|
-
{t('cancelAndRevert')}
|
|
186
|
-
</Button>
|
|
187
|
-
)}
|
|
188
|
-
{!showEditProductSet && editedProductSet && (
|
|
189
|
-
<Button
|
|
190
|
-
variant=''
|
|
191
|
-
className='btn product-set-button ml-4 text-danger'
|
|
192
|
-
onClick={revertEditProductSet}
|
|
193
|
-
>
|
|
194
|
-
{t('undoChanges')}
|
|
195
|
-
</Button>
|
|
196
|
-
)}
|
|
197
|
-
</div>
|
|
139
|
+
render={() => (
|
|
140
|
+
<>
|
|
141
|
+
<div className='d-flex align-items-center flex-row w-100'>
|
|
142
|
+
<ConfirmModal>
|
|
143
|
+
{(confirm) => (
|
|
144
|
+
<Typeahead
|
|
145
|
+
name='productSetId'
|
|
146
|
+
value={selectedProductSetTypeheadValue}
|
|
147
|
+
containerStyles={{ width: '100%' }}
|
|
148
|
+
onChangeValue={(typeheadValue) => {
|
|
149
|
+
onChangeProductSet(Number(typeheadValue.id), confirm)
|
|
150
|
+
}}
|
|
151
|
+
isInvalid={!!overrideNameError}
|
|
152
|
+
options={typeheadValues}
|
|
153
|
+
placeholder={t('Design:choose')}
|
|
154
|
+
noOptionsMessage={t('Design:noAvailableProductSets')}
|
|
155
|
+
/>
|
|
156
|
+
)}
|
|
157
|
+
</ConfirmModal>
|
|
158
|
+
|
|
159
|
+
<div className='buttons-container'>
|
|
160
|
+
{!showEditProductSet && !editedProductSet && (
|
|
161
|
+
<Button
|
|
162
|
+
variant=''
|
|
163
|
+
className='btn product-set-button mr-4'
|
|
164
|
+
onClick={handleCreateProductSet}
|
|
165
|
+
>
|
|
166
|
+
{t('addNewProductSet')}
|
|
167
|
+
</Button>
|
|
168
|
+
)}
|
|
169
|
+
{showOverrideProductSet && (
|
|
170
|
+
<Button
|
|
171
|
+
variant=''
|
|
172
|
+
className='btn product-set-button'
|
|
173
|
+
onClick={onEditProductSet}
|
|
174
|
+
>
|
|
175
|
+
{isOverrideProductSet
|
|
176
|
+
? t('editOverrides')
|
|
177
|
+
: t('editProductSet')}
|
|
178
|
+
</Button>
|
|
179
|
+
)}
|
|
180
|
+
{showEditProductSet && (
|
|
181
|
+
<Button
|
|
182
|
+
variant=''
|
|
183
|
+
className='btn product-set-button'
|
|
184
|
+
onClick={revertEditProductSet}
|
|
185
|
+
>
|
|
186
|
+
{t('cancelAndRevert')}
|
|
187
|
+
</Button>
|
|
188
|
+
)}
|
|
189
|
+
{!showEditProductSet && editedProductSet && (
|
|
190
|
+
<Button
|
|
191
|
+
variant=''
|
|
192
|
+
className='btn product-set-button ml-4 text-danger'
|
|
193
|
+
onClick={revertEditProductSet}
|
|
194
|
+
>
|
|
195
|
+
{t('undoChanges')}
|
|
196
|
+
</Button>
|
|
197
|
+
)}
|
|
198
198
|
</div>
|
|
199
|
+
</div>
|
|
199
200
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}}
|
|
201
|
+
<div className='manual-form-error'>
|
|
202
|
+
{errors?.productSetId?.message || overrideNameError}
|
|
203
|
+
</div>
|
|
204
|
+
</>
|
|
205
|
+
)}
|
|
206
206
|
/>
|
|
207
207
|
</Form.Group>
|
|
208
208
|
</div>
|
|
@@ -213,6 +213,7 @@ export const SelectEventProductSet = ({
|
|
|
213
213
|
productSetId === editedProductSet?.id && editedProductSet
|
|
214
214
|
}
|
|
215
215
|
timeZone={timeZone}
|
|
216
|
+
overrideNameError={overrideNameError}
|
|
216
217
|
/>
|
|
217
218
|
)}
|
|
218
219
|
</>
|
|
@@ -23,12 +23,14 @@ interface EditEventProductSetProps {
|
|
|
23
23
|
onSubmit: (value: EditEventFormValues['editedProductSet']) => void
|
|
24
24
|
defaultValues?: EditEventFormValues['editedProductSet']
|
|
25
25
|
timeZone: string
|
|
26
|
+
overrideNameError?: string
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export const EditEventProductSet = ({
|
|
29
30
|
onSubmit,
|
|
30
31
|
defaultValues,
|
|
31
32
|
timeZone,
|
|
33
|
+
overrideNameError,
|
|
32
34
|
}: EditEventProductSetProps) => {
|
|
33
35
|
const { companyId } = useParams<{
|
|
34
36
|
companyId: string
|
|
@@ -64,7 +66,15 @@ export const EditEventProductSet = ({
|
|
|
64
66
|
mode: 'onChange',
|
|
65
67
|
})
|
|
66
68
|
|
|
67
|
-
const { reset, handleSubmit, watch } = form
|
|
69
|
+
const { reset, handleSubmit, watch, setError } = form
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (!overrideNameError) {
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
setError('name', { message: overrideNameError })
|
|
76
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77
|
+
}, [overrideNameError])
|
|
68
78
|
|
|
69
79
|
const formValues = watch()
|
|
70
80
|
|
|
@@ -12,6 +12,8 @@ export const getDefaultValues = (
|
|
|
12
12
|
): ProductSetFormValues => ({
|
|
13
13
|
id: productSet?.id ?? 0,
|
|
14
14
|
name: productSet?.name ?? '',
|
|
15
|
+
description: productSet?.description ?? '',
|
|
16
|
+
image: productSet?.image,
|
|
15
17
|
type: productSet?.type ?? DEFAULT_PRODUCT_SET_TYPE,
|
|
16
18
|
termsAndConditions: productSet?.termsAndConditions ?? '',
|
|
17
19
|
operationalCost: productSet?.operationalCost ?? DEFAULT_OPERATIONAL_COST_TYPE,
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import { ReactNode } from 'react'
|
|
2
2
|
import clsx from 'clsx'
|
|
3
|
+
import { Image } from '@licklist/core/dist/DataMapper/Media/ImageDataMapper'
|
|
3
4
|
|
|
4
5
|
export const LAYOUT_GRID = 'grid'
|
|
5
6
|
export const LAYOUT_LIST = 'list'
|
|
6
7
|
|
|
7
|
-
type Layout = typeof LAYOUT_GRID | typeof LAYOUT_LIST
|
|
8
|
-
|
|
9
8
|
export type ActivityCardProps = {
|
|
10
9
|
title: ReactNode
|
|
11
10
|
duration: ReactNode
|
|
12
11
|
price: ReactNode
|
|
12
|
+
description?: ReactNode
|
|
13
13
|
onSelect: () => void
|
|
14
14
|
isSelected: boolean
|
|
15
|
-
layout?:
|
|
15
|
+
layout?: typeof LAYOUT_GRID | typeof LAYOUT_LIST
|
|
16
16
|
availableTimes?: string | null
|
|
17
|
+
image?: Image | null
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export const ActivityCard = ({
|
|
20
21
|
title,
|
|
21
22
|
duration,
|
|
22
23
|
price,
|
|
24
|
+
description,
|
|
23
25
|
availableTimes,
|
|
24
|
-
|
|
26
|
+
image,
|
|
25
27
|
onSelect,
|
|
26
28
|
isSelected,
|
|
27
29
|
layout = LAYOUT_GRID,
|
|
@@ -30,39 +32,48 @@ export const ActivityCard = ({
|
|
|
30
32
|
return (
|
|
31
33
|
<button
|
|
32
34
|
type='button'
|
|
33
|
-
className={clsx('activity-card', isSelected
|
|
35
|
+
className={clsx('activity-card', { active: isSelected })}
|
|
34
36
|
onClick={onSelect}
|
|
35
37
|
>
|
|
36
|
-
|
|
38
|
+
{image && (
|
|
39
|
+
<img src={image.url} alt={typeof title === 'string' ? title : ''} />
|
|
40
|
+
)}
|
|
41
|
+
|
|
42
|
+
<div>
|
|
37
43
|
<div className='activity-card-title'>{title}</div>
|
|
38
44
|
{duration && <div>{duration}</div>}
|
|
39
|
-
|
|
40
45
|
{price && <div>{price}</div>}
|
|
46
|
+
{description && (
|
|
47
|
+
<div className='mt-2 activity-card-description'>{description}</div>
|
|
48
|
+
)}
|
|
41
49
|
</div>
|
|
42
50
|
</button>
|
|
43
51
|
)
|
|
44
52
|
}
|
|
45
53
|
|
|
46
54
|
return (
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
<div>
|
|
58
|
-
<p>{duration}</p>
|
|
59
|
-
</div>
|
|
60
|
-
)}
|
|
55
|
+
<button
|
|
56
|
+
type='button'
|
|
57
|
+
onClick={onSelect}
|
|
58
|
+
className={clsx('activity-card list-activity-card', {
|
|
59
|
+
active: isSelected,
|
|
60
|
+
})}
|
|
61
|
+
>
|
|
62
|
+
{image && (
|
|
63
|
+
<img src={image.url} alt={typeof title === 'string' ? title : ''} />
|
|
64
|
+
)}
|
|
61
65
|
|
|
62
|
-
|
|
63
|
-
</div>
|
|
66
|
+
<div className='activity-card-info'>
|
|
67
|
+
<div className='activity-card-title mb-2'>{title}</div>
|
|
68
|
+
{availableTimes && <div>{availableTimes}</div>}
|
|
69
|
+
{duration && <div>{duration}</div>}
|
|
70
|
+
{price && <div>{price}</div>}
|
|
71
|
+
{description && (
|
|
72
|
+
<div className='mt-2 activity-card-description'>{description}</div>
|
|
73
|
+
)}
|
|
64
74
|
</div>
|
|
75
|
+
|
|
65
76
|
<hr className='list-activity-card-hr' />
|
|
66
|
-
</
|
|
77
|
+
</button>
|
|
67
78
|
)
|
|
68
79
|
}
|
|
@@ -20,6 +20,9 @@ export type ConfirmModalTypes =
|
|
|
20
20
|
export interface ConfirmModalProps {
|
|
21
21
|
type?: ConfirmModalTypes
|
|
22
22
|
children?: (confirm: (action: ConfirmAction) => void) => ReactNode
|
|
23
|
+
// confirm function memoize the callback function. It's an alternative function
|
|
24
|
+
confirmationHandler?: () => Promise<boolean | undefined>
|
|
25
|
+
disabledButtons?: boolean
|
|
23
26
|
title?: string
|
|
24
27
|
content?: string | ReactNode
|
|
25
28
|
onClose?: () => void
|
|
@@ -37,7 +40,9 @@ export function ConfirmModal({
|
|
|
37
40
|
type = 'default',
|
|
38
41
|
children,
|
|
39
42
|
onClose,
|
|
43
|
+
confirmationHandler,
|
|
40
44
|
title,
|
|
45
|
+
disabledButtons,
|
|
41
46
|
content,
|
|
42
47
|
hideButtons = false,
|
|
43
48
|
}: ConfirmModalProps) {
|
|
@@ -52,10 +57,16 @@ export function ConfirmModal({
|
|
|
52
57
|
setIsOpen(() => true)
|
|
53
58
|
}
|
|
54
59
|
|
|
55
|
-
const handleConfirmation = (e) => {
|
|
60
|
+
const handleConfirmation = async (e) => {
|
|
56
61
|
e.stopPropagation()
|
|
57
|
-
if (!actionRef.current) return
|
|
58
|
-
|
|
62
|
+
if (!actionRef.current && !confirmationHandler) return
|
|
63
|
+
if (confirmationHandler) {
|
|
64
|
+
const res = await confirmationHandler()
|
|
65
|
+
if (res) {
|
|
66
|
+
setIsOpen(() => false)
|
|
67
|
+
}
|
|
68
|
+
return
|
|
69
|
+
}
|
|
59
70
|
actionRef.current()
|
|
60
71
|
setIsOpen(() => false)
|
|
61
72
|
}
|
|
@@ -88,6 +99,7 @@ export function ConfirmModal({
|
|
|
88
99
|
<Button
|
|
89
100
|
variant='danger'
|
|
90
101
|
className='btn-sm rounded'
|
|
102
|
+
disabled={disabledButtons}
|
|
91
103
|
onClick={handleClose}
|
|
92
104
|
data-id={CONFIRM_MODAL_ACTION_DECLINE}
|
|
93
105
|
>
|
|
@@ -105,12 +117,14 @@ export function ConfirmModal({
|
|
|
105
117
|
variant='outline'
|
|
106
118
|
className='cancel-button'
|
|
107
119
|
onClick={handleClose}
|
|
120
|
+
disabled={disabledButtons}
|
|
108
121
|
data-id={CONFIRM_MODAL_ACTION_DECLINE}
|
|
109
122
|
>
|
|
110
123
|
{t('cancel')}
|
|
111
124
|
</Button>
|
|
112
125
|
<Button
|
|
113
126
|
variant='danger'
|
|
127
|
+
disabled={disabledButtons}
|
|
114
128
|
onClick={handleConfirmation}
|
|
115
129
|
data-id={CONFIRM_MODAL_ACTION_CONFIRM}
|
|
116
130
|
>
|
|
@@ -121,6 +135,7 @@ export function ConfirmModal({
|
|
|
121
135
|
<>
|
|
122
136
|
<Button
|
|
123
137
|
variant='danger'
|
|
138
|
+
disabled={disabledButtons}
|
|
124
139
|
onClick={handleClose}
|
|
125
140
|
data-id={CONFIRM_MODAL_ACTION_DECLINE}
|
|
126
141
|
>
|
|
@@ -128,6 +143,7 @@ export function ConfirmModal({
|
|
|
128
143
|
</Button>
|
|
129
144
|
<Button
|
|
130
145
|
variant='success'
|
|
146
|
+
disabled={disabledButtons}
|
|
131
147
|
onClick={handleConfirmation}
|
|
132
148
|
data-id={CONFIRM_MODAL_ACTION_CONFIRM}
|
|
133
149
|
>
|
|
@@ -9,15 +9,20 @@ import RouteService from '@licklist/plugins/dist/services/Route/RouteService'
|
|
|
9
9
|
import { FaEllipsisH, FaEye, FaTrashAlt } from 'react-icons/fa'
|
|
10
10
|
import { ConfirmModal } from '../../modals'
|
|
11
11
|
import { MenuButton } from '../../table/MenuButton'
|
|
12
|
+
import { ProductSetNameControl } from '../form/ProductSetNameControl'
|
|
12
13
|
|
|
13
14
|
export interface ProductSetCardProps extends HasPermissionProp {
|
|
14
15
|
name: string
|
|
15
16
|
rrule?: string
|
|
16
17
|
href: string
|
|
17
|
-
|
|
18
|
+
duplicateProductSetName: string
|
|
19
|
+
onChangeDuplicateProductSetName: (value: string) => void
|
|
20
|
+
onCopy: () => Promise<boolean | undefined>
|
|
18
21
|
onRemove: () => void
|
|
22
|
+
isLoading?: boolean
|
|
19
23
|
className?: string
|
|
20
24
|
override?: number
|
|
25
|
+
duplicateProductSetError?: string
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
export function ProductSetCard({
|
|
@@ -26,6 +31,10 @@ export function ProductSetCard({
|
|
|
26
31
|
href,
|
|
27
32
|
onCopy,
|
|
28
33
|
onRemove,
|
|
34
|
+
onChangeDuplicateProductSetName,
|
|
35
|
+
duplicateProductSetName,
|
|
36
|
+
duplicateProductSetError,
|
|
37
|
+
isLoading,
|
|
29
38
|
className = '',
|
|
30
39
|
hasPermission = true,
|
|
31
40
|
override = 0,
|
|
@@ -35,19 +44,23 @@ export function ProductSetCard({
|
|
|
35
44
|
const productSetCardClasses = `product-set-card ${className}`
|
|
36
45
|
const [isOverlayVisibile, setIsOverlayVisible] = useState(false)
|
|
37
46
|
|
|
47
|
+
const onCardClick = () => {
|
|
48
|
+
RouteService.redirectTo(href)
|
|
49
|
+
}
|
|
38
50
|
return (
|
|
51
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
39
52
|
<div
|
|
40
53
|
role='button'
|
|
41
54
|
tabIndex={0}
|
|
42
55
|
className='border-0 product-set-card-wrapper w-100 pb-0'
|
|
43
|
-
onClick={
|
|
44
|
-
onKeyUp={() => RouteService.redirectTo(href)}
|
|
56
|
+
onClick={onCardClick}
|
|
45
57
|
>
|
|
46
58
|
<div className={productSetCardClasses}>
|
|
47
59
|
<div className='product-set-card-link'>
|
|
48
60
|
<div className='d-flex flex-column'>
|
|
49
61
|
<div>
|
|
50
|
-
{name}
|
|
62
|
+
{name}
|
|
63
|
+
{rrule && `(${RRule.fromString(rrule).toText()})`}
|
|
51
64
|
</div>
|
|
52
65
|
{!!override && (
|
|
53
66
|
<div className='h6 bold ml-1'>
|
|
@@ -79,14 +92,33 @@ export function ProductSetCard({
|
|
|
79
92
|
>
|
|
80
93
|
{hasPermission && (
|
|
81
94
|
<>
|
|
82
|
-
<ListGroup.Item
|
|
95
|
+
<ListGroup.Item
|
|
96
|
+
action
|
|
97
|
+
as='div'
|
|
98
|
+
role='button'
|
|
99
|
+
tabIndex={0}
|
|
100
|
+
onClick={(e) => e.stopPropagation()}
|
|
101
|
+
>
|
|
83
102
|
{Boolean(onCopy) && (
|
|
84
|
-
<ConfirmModal
|
|
103
|
+
<ConfirmModal
|
|
104
|
+
// confirm function memoize the callback function and it leads to bugs
|
|
105
|
+
confirmationHandler={onCopy}
|
|
106
|
+
disabledButtons={isLoading}
|
|
107
|
+
content={
|
|
108
|
+
<ProductSetNameControl
|
|
109
|
+
value={duplicateProductSetName}
|
|
110
|
+
onChange={onChangeDuplicateProductSetName}
|
|
111
|
+
error={duplicateProductSetError}
|
|
112
|
+
/>
|
|
113
|
+
}
|
|
114
|
+
>
|
|
85
115
|
{(confirm) => (
|
|
86
116
|
<MenuButton
|
|
87
117
|
onClick={() => {
|
|
88
118
|
setIsOverlayVisible(false)
|
|
89
|
-
|
|
119
|
+
onChangeDuplicateProductSetName(name)
|
|
120
|
+
// confirm function memoize the callback function and it leads to bugs
|
|
121
|
+
confirm(() => {})
|
|
90
122
|
}}
|
|
91
123
|
name={t('duplicate')}
|
|
92
124
|
className='product-set-card-menu-item-text'
|
|
@@ -95,7 +127,14 @@ export function ProductSetCard({
|
|
|
95
127
|
</ConfirmModal>
|
|
96
128
|
)}
|
|
97
129
|
</ListGroup.Item>
|
|
98
|
-
<ListGroup.Item
|
|
130
|
+
<ListGroup.Item
|
|
131
|
+
action
|
|
132
|
+
className='text-danger'
|
|
133
|
+
as='div'
|
|
134
|
+
role='button'
|
|
135
|
+
tabIndex={0}
|
|
136
|
+
onClick={(e) => e.stopPropagation()}
|
|
137
|
+
>
|
|
99
138
|
{Boolean(onRemove) && (
|
|
100
139
|
<ConfirmModal>
|
|
101
140
|
{(confirm) => (
|