ordering-ui-admin-external 1.43.85 → 1.43.87

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.
Files changed (47) hide show
  1. package/_bundles/{ordering-ui-admin.d6cacbc361078db81280.js → ordering-ui-admin.508bc29611b368682b89.js} +2 -2
  2. package/_modules/components/Delivery/DriversGroupAddForm/BusinessesForm/index.js +54 -10
  3. package/_modules/components/Delivery/DriversGroupBusinesses/index.js +45 -1
  4. package/_modules/components/Delivery/DriversGroupDrivers/index.js +45 -1
  5. package/_modules/components/Delivery/DriversGroupsList/index.js +32 -44
  6. package/_modules/components/Delivery/DriversGroupsListing/index.js +6 -2
  7. package/_modules/components/Orders/AllInOne/index.js +38 -38
  8. package/_modules/components/Orders/DeliveriesManager/index.js +13 -15
  9. package/_modules/components/Orders/DriversGroupTypeSelector/index.js +4 -8
  10. package/_modules/components/Orders/OrderContactInformation/index.js +4 -2
  11. package/_modules/components/Orders/OrderDetails/index.js +3 -1
  12. package/_modules/components/Orders/OrdersContentHeader/index.js +4 -2
  13. package/_modules/components/Orders/OrdersFilterGroup/index.js +1 -2
  14. package/_modules/components/Orders/OrdersHeaderFilterGroup/index.js +4 -2
  15. package/_modules/components/Orders/OrdersManager/index.js +35 -33
  16. package/_modules/components/Shared/Pagination/styles.js +1 -1
  17. package/_modules/components/Stores/BusinessDeliveryGroupsDetails/index.js +6 -2
  18. package/_modules/components/Stores/BusinessPaymentMethods/index.js +39 -2
  19. package/_modules/components/Stores/PaymentOptionStripeLink/index.js +347 -0
  20. package/_modules/components/Stores/PaymentOptionStripeLink/styles.js +57 -0
  21. package/_modules/components/Stores/index.js +7 -0
  22. package/_modules/index.js +6 -0
  23. package/_modules/styles/Select/index.js +28 -4
  24. package/package.json +2 -2
  25. package/src/components/Delivery/DriversGroupAddForm/BusinessesForm/index.js +50 -2
  26. package/src/components/Delivery/DriversGroupBusinesses/index.js +50 -2
  27. package/src/components/Delivery/DriversGroupDrivers/index.js +50 -3
  28. package/src/components/Delivery/DriversGroupsList/index.js +22 -31
  29. package/src/components/Delivery/DriversGroupsListing/index.js +5 -1
  30. package/src/components/Orders/AllInOne/index.js +5 -2
  31. package/src/components/Orders/DeliveriesManager/index.js +3 -2
  32. package/src/components/Orders/DriversGroupTypeSelector/index.js +5 -10
  33. package/src/components/Orders/OrderContactInformation/index.js +3 -1
  34. package/src/components/Orders/OrderDetails/index.js +3 -1
  35. package/src/components/Orders/OrdersContentHeader/index.js +3 -1
  36. package/src/components/Orders/OrdersFilterGroup/index.js +0 -2
  37. package/src/components/Orders/OrdersHeaderFilterGroup/index.js +3 -1
  38. package/src/components/Orders/OrdersManager/index.js +7 -2
  39. package/src/components/Shared/Pagination/styles.js +2 -1
  40. package/src/components/Stores/BusinessDeliveryGroupsDetails/index.js +5 -1
  41. package/src/components/Stores/BusinessPaymentMethods/index.js +41 -0
  42. package/src/components/Stores/PaymentOptionStripeLink/index.js +357 -0
  43. package/src/components/Stores/PaymentOptionStripeLink/styles.js +171 -0
  44. package/src/components/Stores/index.js +2 -0
  45. package/src/index.js +2 -0
  46. package/src/styles/Select/index.js +37 -4
  47. /package/_bundles/{ordering-ui-admin.d6cacbc361078db81280.js.LICENSE.txt → ordering-ui-admin.508bc29611b368682b89.js.LICENSE.txt} +0 -0
@@ -0,0 +1,357 @@
1
+ import React, { useState, useEffect } from 'react'
2
+ import { useLocation } from 'react-router-dom'
3
+ import { useLanguage, PaymentOptionStripeLink as PaymentOptionStripeLinkController } from 'ordering-components-admin-external'
4
+ import RiCheckboxBlankLine from '@meronex/icons/ri/RiCheckboxBlankLine'
5
+ import RiCheckboxFill from '@meronex/icons/ri/RiCheckboxFill'
6
+ import { Button, Input, IconButton, Checkbox, DefaultSelect as Select } from '../../../styles'
7
+ import { useWindowSize } from '../../../hooks/useWindowSize'
8
+ import { useTheme } from 'styled-components'
9
+ import { ThreeDots, XLg } from 'react-bootstrap-icons'
10
+ import { Dropdown, DropdownButton } from 'react-bootstrap'
11
+ import { Confirm } from '../../Shared'
12
+ import { addQueryToUrl } from '../../../utils'
13
+
14
+ import {
15
+ Container,
16
+ SandboxWrapper,
17
+ FieldName,
18
+ Header,
19
+ CloseButton,
20
+ TabOption,
21
+ TabOptionName,
22
+ ActionSelectorWrapper,
23
+ Option
24
+ } from './styles'
25
+ import { Tab, TabsContainer } from '../BusinessMenu/styles'
26
+
27
+ const PaymentOptionStripeLinkUI = (props) => {
28
+ const {
29
+ open,
30
+ onClose,
31
+ orderTypes,
32
+ sitesState,
33
+ configsState,
34
+ changesState,
35
+ handleChangeBusinessPaymentState,
36
+ cleanChangesState,
37
+ actionState,
38
+ handleChangeSandbox,
39
+ handleChangeInput,
40
+ handleSaveClick,
41
+ businessPaymethod,
42
+ handleDeletePaymethod,
43
+ handleUpdateConfigs
44
+ } = props
45
+
46
+ const query = new URLSearchParams(useLocation().search)
47
+ const theme = useTheme()
48
+ const [, t] = useLanguage()
49
+ const { width } = useWindowSize()
50
+ const [isMenuOpen, setIsMenuOpen] = useState(false)
51
+ const [paymentTabs, setPaymentTabs] = useState(0)
52
+ const [confirm, setConfirm] = useState({ open: false, content: null, handleOnAccept: null })
53
+ const [localState, setLocalState] = useState({ allowed_order_types: businessPaymethod?.allowed_order_types, sites: businessPaymethod?.sites })
54
+ const filteredOptions = localState?.sites ?? businessPaymethod?.sites?.filter(a => sitesState?.sites?.find(b => a.id === b.id))
55
+ const [all, setAll] = useState(!filteredOptions?.length)
56
+
57
+ const configsToShow = {
58
+ allow_text_messages_sms: true,
59
+ allow_text_messages_whatsapp: true
60
+ }
61
+
62
+ const setPaymethodInfo = (values) => {
63
+ const data = {}
64
+ if (values?.value === 'All') {
65
+ data[values.key] = []
66
+ setAll(!all)
67
+ } else {
68
+ let array = changesState?.[values.key] ?? (values.key === 'allowed_order_types'
69
+ ? businessPaymethod?.[values.key]
70
+ : businessPaymethod?.[values.key]?.map(i => i.id)) ?? []
71
+
72
+ array = [...new Set(
73
+ array.includes(values.value)
74
+ ? array.filter(item => item !== values.value)
75
+ : [...array, values.value]
76
+ )]
77
+
78
+ data[values.key] = array.length > 0 ? array : []
79
+ if (values.key === 'sites') {
80
+ setAll(!data?.sites?.length)
81
+ }
82
+ }
83
+
84
+ handleChangeBusinessPaymentState(data)
85
+ }
86
+
87
+ const actionSidebar = (value) => {
88
+ if (!value) {
89
+ props.onClose()
90
+ }
91
+ setIsMenuOpen(value)
92
+ }
93
+ const onClickDeletePaymethod = () => {
94
+ setConfirm({
95
+ open: true,
96
+ content: t('QUESTION_DELETE_ITEM', 'Are you sure to delete this _item_?').replace('_item_', t('PAYMETHOD_ID', 'Paymethod')),
97
+ handleOnAccept: () => {
98
+ setConfirm({ ...confirm, open: false })
99
+ handleDeletePaymethod(businessPaymethod?.paymethod?.id)
100
+ }
101
+ })
102
+ }
103
+ useEffect(() => {
104
+ if (isMenuOpen) {
105
+ if (width < 1000) {
106
+ document.getElementById('stripe_link').style.width = '100%'
107
+ } else {
108
+ document.getElementById('stripe_link').style.width = '500px'
109
+ }
110
+ }
111
+ }, [width])
112
+
113
+ useEffect(() => {
114
+ if (!open) return
115
+ actionSidebar(true)
116
+ }, [open])
117
+
118
+ useEffect(() => {
119
+ const initState = {
120
+ sandbox: businessPaymethod?.sandbox,
121
+ allowed_order_types: businessPaymethod?.allowed_order_types || [1, 2, 3, 4, 5]
122
+ }
123
+ if (businessPaymethod?.data) {
124
+ initState.data = businessPaymethod.data
125
+ }
126
+ if (businessPaymethod?.data_sandbox) {
127
+ initState.data_sandbox = businessPaymethod.data_sandbox
128
+ }
129
+ cleanChangesState(initState)
130
+ }, [])
131
+
132
+ useEffect(() => {
133
+ const changes = {}
134
+ if (changesState?.allowed_order_types) changes.allowed_order_types = changesState?.allowed_order_types
135
+ if (changesState?.sites) changes.sites = changesState?.sites
136
+ if (Object.keys(changes).length > 0) setLocalState(JSON.parse(JSON.stringify(changes)))
137
+ }, [changesState?.sites, changesState?.allowed_order_types])
138
+
139
+ const handleTabClick = (tab, isInitialRender) => {
140
+ setPaymentTabs(tab)
141
+ if (!isInitialRender) {
142
+ addQueryToUrl({ payemthod_tab: tab })
143
+ }
144
+ }
145
+
146
+ useEffect(() => {
147
+ const payemthodTab = query.get('payemthod_tab')
148
+ if (payemthodTab) {
149
+ handleTabClick(Number(payemthodTab), true)
150
+ } else {
151
+ handleTabClick(0)
152
+ }
153
+ }, [])
154
+
155
+ return (
156
+ <>
157
+ <Container id='stripe_link'>
158
+ <Header>
159
+ <h1>{t('STRIPE_LINK', 'Stripe link (Only for callcenter)')}</h1>
160
+ <ActionSelectorWrapper>
161
+ <DropdownButton
162
+ menuAlign={theme?.rtl ? 'left' : 'right'}
163
+ title={<ThreeDots />}
164
+ id={theme?.rtl ? 'dropdown-menu-align-left' : 'dropdown-menu-align-right'}
165
+ >
166
+ <Dropdown.Item
167
+ onClick={() => onClickDeletePaymethod()}
168
+ >
169
+ {t('DELETE', 'Delete')}
170
+ </Dropdown.Item>
171
+ </DropdownButton>
172
+ </ActionSelectorWrapper>
173
+ <CloseButton>
174
+ <IconButton
175
+ color='black'
176
+ onClick={() => onClose()}
177
+ >
178
+ <XLg />
179
+ </IconButton>
180
+ </CloseButton>
181
+ </Header>
182
+ <p className='message'>{t('STRIPE_AND_TWILIO_CONFIGS_REQUIERED', 'Stripe and Twilio keys are requiered to use this Payment Method')}</p>
183
+ <TabsContainer>
184
+ <Tab
185
+ active={paymentTabs === 0}
186
+ onClick={() => handleTabClick(0)}
187
+ >
188
+ {t('GENERAL', 'General')}
189
+ </Tab>
190
+ {sitesState?.sites?.length > 0 && (
191
+ <Tab
192
+ active={paymentTabs === 1}
193
+ onClick={() => handleTabClick(1)}
194
+ >
195
+ {t('CHANNELS', 'Channels')}
196
+ </Tab>
197
+ )}
198
+ <Tab
199
+ active={paymentTabs === 2}
200
+ onClick={() => handleTabClick(2)}
201
+ >
202
+ {t('ORDER_TYPE', 'Order type')}
203
+ </Tab>
204
+ </TabsContainer>
205
+
206
+ {paymentTabs === 0 && (
207
+ <>
208
+ <SandboxWrapper>
209
+ <Checkbox
210
+ checked={changesState?.sandbox ?? businessPaymethod?.sandbox ?? false}
211
+ onChange={e => handleChangeSandbox(e.target.checked)}
212
+ />
213
+ <span>{t('SANDBOX', 'Sandbox')}</span>
214
+ </SandboxWrapper>
215
+ <FieldName>{t('PUBLISHABLE_KEY', 'Publishable key')}</FieldName>
216
+ <Input
217
+ name='publishable'
218
+ defaultValue={
219
+ changesState?.data?.publishable
220
+ ? changesState?.data?.publishable
221
+ : businessPaymethod?.data?.publishable
222
+ }
223
+ placeholder={t('PUBLISHABLE_KEY', 'Publishable key')}
224
+ onChange={e => handleChangeInput(e, false)}
225
+ />
226
+ <FieldName>{t('SECRET_KEY', 'Secret key')}</FieldName>
227
+ <Input
228
+ name='secret'
229
+ defaultValue={
230
+ changesState?.data?.secret
231
+ ? changesState?.data?.secret
232
+ : businessPaymethod?.data?.secret
233
+ }
234
+ placeholder={t('SECRET_KEY', 'Secret key')}
235
+ onChange={e => handleChangeInput(e, false)}
236
+ />
237
+ <FieldName>{t('PUBLISHABLE_KEY', 'Publishable key')} ({t('SANDBOX', 'Sandbox')})</FieldName>
238
+ <Input
239
+ name='publishable'
240
+ defaultValue={
241
+ changesState?.data_sandbox?.publishable
242
+ ? changesState?.data_sandbox?.publishable
243
+ : businessPaymethod?.data_sandbox?.publishable
244
+ }
245
+ placeholder={`${t('PUBLISHABLE_KEY', 'Publishable key')} (${t('SANDBOX', 'Sandbox')})`}
246
+ onChange={e => handleChangeInput(e, true)}
247
+ />
248
+ <FieldName>{t('SECRECT_KEY', 'Secret key')} ({t('SANDBOX', 'Sandbox')})</FieldName>
249
+ <Input
250
+ name='secret'
251
+ defaultValue={
252
+ changesState?.data_sandbox?.secret
253
+ ? changesState?.data_sandbox?.secret
254
+ : businessPaymethod?.data_sandbox?.secret
255
+ }
256
+ placeholder={`${t('SECRECT_KEY', 'Secret key')} (${t('SANDBOX', 'Sandbox')})`}
257
+ onChange={e => handleChangeInput(e, true)}
258
+ />
259
+ <p className='alert-message'>{t('TWILIO_CONFIGURATION_MESSAGE', '*Enable these options after twilio configuration')}</p>
260
+ {!configsState?.loading && configsState?.configs?.filter(config => configsToShow[config?.key]).map(config => {
261
+ const options = config?.options?.map(item => {
262
+ return { value: item.value, content: <Option>{t(item.text.toUpperCase())}</Option> }
263
+ })
264
+ return (
265
+ <>
266
+ <FieldName>{config?.name}</FieldName>
267
+ {config?.type === 2 && options && (
268
+ <Select
269
+ notAsync
270
+ defaultValue={config?.value}
271
+ options={options}
272
+ onChange={(typeValue) => handleUpdateConfigs(config?.id, { value: typeValue })}
273
+ placeholder={t('SELECT_A_OPTION', 'Select a option')}
274
+ />
275
+ )}
276
+ </>
277
+ )
278
+ })}
279
+ </>
280
+ )}
281
+
282
+ {paymentTabs === 1 && sitesState?.sites?.length > 0 && (
283
+ <>
284
+ <TabOption
285
+ key='all'
286
+ onClick={() => setPaymethodInfo({ key: 'sites', value: 'All' })}
287
+ >
288
+ {all ? (
289
+ <RiCheckboxFill className='fill' />
290
+ ) : (
291
+ <RiCheckboxBlankLine />
292
+ )}
293
+ <TabOptionName>{t('ALL', 'All')}</TabOptionName>
294
+ </TabOption>
295
+ {!all && sitesState?.sites.map(site => (
296
+ <TabOption
297
+ key={site.id}
298
+ onClick={() => setPaymethodInfo({ key: 'sites', value: site.id })}
299
+ >
300
+ {(localState?.sites ?? businessPaymethod?.sites?.map(s => s.id))?.includes(site.id) ? (
301
+ <RiCheckboxFill className='fill' />
302
+ ) : (
303
+ <RiCheckboxBlankLine />
304
+ )}
305
+ <TabOptionName>{site.name}</TabOptionName>
306
+ </TabOption>
307
+ ))}
308
+ </>
309
+ )}
310
+
311
+ {paymentTabs === 2 && (
312
+ orderTypes.map(type => (
313
+ <TabOption
314
+ key={type.value}
315
+ onClick={() => setPaymethodInfo({ key: 'allowed_order_types', value: type.value })}
316
+ >
317
+ {(localState?.allowed_order_types ?? businessPaymethod?.allowed_order_types)?.includes(type.value) ? (
318
+ <RiCheckboxFill className='fill' />
319
+ ) : (
320
+ <RiCheckboxBlankLine />
321
+ )}
322
+ <TabOptionName>{type.text}</TabOptionName>
323
+ </TabOption>
324
+ ))
325
+ )}
326
+
327
+ <Button
328
+ borderRadius='5px'
329
+ color='primary'
330
+ disabled={actionState.loading || Object.keys(changesState).length === 0}
331
+ onClick={() => handleSaveClick(businessPaymethod.id)}
332
+ >
333
+ {actionState.loading ? t('LOADING', 'Loading') : t('SAVE', 'Save')}
334
+ </Button>
335
+ </Container>
336
+ <Confirm
337
+ width='700px'
338
+ title={t('WEB_APPNAME', 'Ordering')}
339
+ content={confirm.content}
340
+ acceptText={t('ACCEPT', 'Accept')}
341
+ open={confirm.open}
342
+ onClose={() => setConfirm({ ...confirm, open: false })}
343
+ onCancel={() => setConfirm({ ...confirm, open: false })}
344
+ onAccept={confirm.handleOnAccept}
345
+ closeOnBackdrop={false}
346
+ />
347
+ </>
348
+ )
349
+ }
350
+
351
+ export const PaymentOptionStripeLink = (props) => {
352
+ const paymentOptionStripeLinkProps = {
353
+ ...props,
354
+ UIComponent: PaymentOptionStripeLinkUI
355
+ }
356
+ return <PaymentOptionStripeLinkController {...paymentOptionStripeLinkProps} />
357
+ }
@@ -0,0 +1,171 @@
1
+ import styled, { css } from 'styled-components'
2
+ import { darken } from 'polished'
3
+
4
+ export const Container = styled.div`
5
+ padding: 20px;
6
+ overflow: auto;
7
+ transition: 0.3s;
8
+ box-sizing: border-box;
9
+ display: flex;
10
+ flex-direction: column;
11
+
12
+ > button {
13
+ margin-top: 20px;
14
+ padding: 5px 15px 35px;
15
+ position: sticky;
16
+ top: 100%;
17
+ width: fit-content;
18
+ height: 42px;
19
+ }
20
+
21
+ .message {
22
+ margin: 0px;
23
+ font-size: 12px;
24
+ }
25
+
26
+ .alert-message {
27
+ margin: 30px 0 0 0;
28
+ font-weight: 700;
29
+ }
30
+
31
+ .select {
32
+ width: 100%;
33
+ > div:first-child {
34
+ padding: 8px 15px;
35
+ }
36
+ }
37
+
38
+ @media (min-width: 1000px) {
39
+ width: 0;
40
+ ${props => props.theme?.rtl ? css`
41
+ border-right: 1px solid #E9ECEF;
42
+ ` : css`
43
+ border-left: 1px solid #E9ECEF;
44
+ `}
45
+ }
46
+ `
47
+
48
+ export const Option = styled.div`
49
+ display: flex;
50
+ align-items: center;
51
+ column-gap: 10px;
52
+ font-size: 13px;
53
+ line-height: 2;
54
+ font-weight: 500;
55
+ `
56
+
57
+ export const SandboxWrapper = styled.div`
58
+ margin-top: 30px;
59
+ display: flex;
60
+ align-items: center;
61
+ color: ${props => props.theme.colors.headingColor};
62
+ span {
63
+ ${props => props.theme?.rtl ? css`
64
+ margin-right: 10px;
65
+ ` : css`
66
+ margin-left: 10px;
67
+ `}
68
+ }
69
+ `
70
+
71
+ export const FieldName = styled.p`
72
+ color: ${props => props.theme.colors.headingColor};
73
+ margin: 30px 0 10px;
74
+ `
75
+
76
+ export const Header = styled.div`
77
+ display: flex;
78
+ align-items: center;
79
+ h1 {
80
+ font-size: 20px;
81
+ color: ${props => props.theme.colors.headingColor};
82
+ font-weight: 700;
83
+ flex: 1;
84
+ margin: 0;
85
+ }
86
+ `
87
+
88
+ export const CloseButton = styled.div`
89
+ display: none;
90
+ @media (min-width: 1000px) {
91
+ display: flex;
92
+ align-items: center;
93
+ }
94
+ `
95
+ export const TabOption = styled.div`
96
+ display: flex;
97
+ align-items: center;
98
+ padding: 12px 0;
99
+ cursor: pointer;
100
+ color: ${props => props.theme.colors.headingColor};
101
+
102
+ > svg {
103
+ font-size: 20px;
104
+ &.fill {
105
+ color: ${props => props.theme.colors.primary};
106
+ }
107
+ }
108
+ `
109
+
110
+ export const TabOptionName = styled.span`
111
+ color: ${props => props.theme.colors.headingColor};
112
+ ${props => props.theme?.rtl ? css`
113
+ margin-right: 10px;
114
+ ` : css`
115
+ margin-left: 10px;
116
+ `}
117
+ `
118
+ export const ActionSelectorWrapper = styled.div`
119
+ margin: 0 10px;
120
+ button {
121
+ background: transparent !important;
122
+ border: none;
123
+ padding: 0px 5px;
124
+ &:active,
125
+ &:focus {
126
+ border-color: unset !important;
127
+ box-shadow: none !important;
128
+ }
129
+ svg {
130
+ color: ${props => props.theme.colors.headingColor};
131
+ font-size: 20px;
132
+ }
133
+
134
+ &:after {
135
+ display: none;
136
+ }
137
+
138
+ &:hover {
139
+ background: ${props => darken(0.04, props.theme.colors.secundary)} !important;
140
+ }
141
+ &:active {
142
+ background: ${props => darken(0.1, props.theme.colors.secundary)} !important;
143
+ }
144
+ }
145
+
146
+ .show {
147
+ button {
148
+ background: ${props => darken(0.04, props.theme.colors.secundary)} !important;
149
+ }
150
+ >div {
151
+ border: 1px solid ${props => props.theme.colors.borderColor};
152
+ box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.12);
153
+ }
154
+ }
155
+
156
+ > div {
157
+ > div {
158
+ border-radius: 8px;
159
+ .dropdown-item {
160
+ font-size: 12px;
161
+ color: ${props => props.theme.colors.headingColor};
162
+ &:active {
163
+ background: ${props => darken(0.1, props.theme.colors.secundary)} !important;
164
+ }
165
+ }
166
+ .dropdown-item:last-child {
167
+ color: #E63757;
168
+ }
169
+ }
170
+ }
171
+ `
@@ -44,6 +44,7 @@ import { BusinessMenuOptions } from './BusinessMenuOptions'
44
44
  import { BusinessDeliveryDetails } from './BusinessDeliveryDetails'
45
45
  import { BusinessPickupDetails } from './BusinessPickupDetails'
46
46
  import { PaymentOptionStripeDirect } from './PaymentOptionStripeDirect'
47
+ import { PaymentOptionStripeLink } from './PaymentOptionStripeLink'
47
48
  import { PaymentOption } from './PaymentOption'
48
49
  import { PaymethodOptionPaypalExpress } from './PaymethodOptionPaypalExpress'
49
50
  import { PaymethodOptionStripeRedirect } from './PaymethodOptionStripeRedirect'
@@ -163,6 +164,7 @@ export {
163
164
  BusinessDeliveryDetails,
164
165
  BusinessPickupDetails,
165
166
  PaymentOptionStripeDirect,
167
+ PaymentOptionStripeLink,
166
168
  PaymentOption,
167
169
  PaymethodOptionPaypalExpress,
168
170
  PaymethodOptionStripeRedirect,
package/src/index.js CHANGED
@@ -254,6 +254,7 @@ import {
254
254
  BusinessDeliveryDetails,
255
255
  BusinessPickupDetails,
256
256
  PaymentOptionStripeDirect,
257
+ PaymentOptionStripeLink,
257
258
  PaymentOption,
258
259
  PaymethodOptionPaypalExpress,
259
260
  PaymethodOptionStripeRedirect,
@@ -685,6 +686,7 @@ export {
685
686
  BusinessDeliveryDetails,
686
687
  BusinessPickupDetails,
687
688
  PaymentOptionStripeDirect,
689
+ PaymentOptionStripeLink,
688
690
  PaymentOption,
689
691
  PaymethodOptionPaypalExpress,
690
692
  PaymethodOptionStripeRedirect,
@@ -3,7 +3,7 @@ import { useSession } from 'ordering-components-admin-external'
3
3
  import { usePopper } from 'react-popper'
4
4
  import { CaretDownFill } from 'react-bootstrap-icons'
5
5
  import FiChevronDown from '@meronex/icons/fi/FiChevronDown'
6
- import { SearchBar } from '../../components/Shared'
6
+ import { Pagination, SearchBar } from '../../components/Shared'
7
7
 
8
8
  import {
9
9
  Selected,
@@ -19,6 +19,7 @@ import {
19
19
  HeaderItem,
20
20
  PopoverBody
21
21
  } from './styles'
22
+ import { PaginationWrapper } from '../MultiSelect/styles'
22
23
 
23
24
  export const Select = (props) => {
24
25
  const {
@@ -38,7 +39,12 @@ export const Select = (props) => {
38
39
  className,
39
40
  isShowCustomOption,
40
41
  customOptionTitle,
41
- handleCustomOptionClick
42
+ handleCustomOptionClick,
43
+ pagination,
44
+ handleChangePage,
45
+ handleChangePageSize,
46
+ useLazyPagination,
47
+ isHidePagecontrol
42
48
  } = props
43
49
  const defaultOption = options?.find(
44
50
  (option) => option.value === defaultValue
@@ -89,6 +95,11 @@ export const Select = (props) => {
89
95
  }
90
96
  }
91
97
 
98
+ const handlerChangePage = (page) => {
99
+ setOpen(true)
100
+ handleChangePage(page)
101
+ }
102
+
92
103
  useEffect(() => {
93
104
  window.addEventListener('mouseup', handleClickOutside)
94
105
  window.addEventListener('keydown', handleKeyDown)
@@ -104,7 +115,9 @@ export const Select = (props) => {
104
115
  const _defaultOption = options?.find(
105
116
  (option) => option.value === defaultValue
106
117
  )
107
- setSelectedOption(_defaultOption)
118
+ if (!(useLazyPagination && pagination)) {
119
+ setSelectedOption(_defaultOption)
120
+ }
108
121
  setValue(defaultValue)
109
122
  }
110
123
  }, [defaultValue, options, searchValue])
@@ -124,6 +137,14 @@ export const Select = (props) => {
124
137
  setOpen(!open)
125
138
  }
126
139
 
140
+ const filterFunction = (_, index) => {
141
+ if (!pagination || useLazyPagination) return true
142
+ const validation = pagination?.currentPage === 1
143
+ ? index < (pagination.pageSize * pagination.currentPage)
144
+ : (index >= (pagination.pageSize * (pagination.currentPage - 1))) && (index < (pagination.pageSize * pagination.currentPage))
145
+ return validation
146
+ }
147
+
127
148
  const popStyle = { ...styles.popper, display: open ? 'block' : 'none', minWidth: referenceElement?.current?.offsetWidth || '100px' }
128
149
  if (!open) {
129
150
  popStyle.transform = 'translate3d(0px, 0px, 0px)'
@@ -173,7 +194,7 @@ export const Select = (props) => {
173
194
  optionInnerMargin={props.optionInnerMargin}
174
195
  optionInnerMaxHeight={props.optionInnerMaxHeight}
175
196
  >
176
- {options.map((option, i) => (
197
+ {options.filter(filterFunction).map((option, i) => (
177
198
  <Option
178
199
  key={i}
179
200
  selected={value === option.value}
@@ -200,6 +221,18 @@ export const Select = (props) => {
200
221
  {customOptionTitle}
201
222
  </Option>
202
223
  )}
224
+ {pagination && handleChangePageSize && handleChangePage && (
225
+ <PaginationWrapper>
226
+ <Pagination
227
+ currentPage={pagination?.currentPage}
228
+ totalPages={pagination?.totalPages}
229
+ handleChangePage={handlerChangePage}
230
+ handleChangePageSize={handleChangePageSize}
231
+ defaultPageSize={pagination?.pageSize}
232
+ isHidePagecontrol={isHidePagecontrol}
233
+ />
234
+ </PaginationWrapper>
235
+ )}
203
236
  </Options>
204
237
  </PopoverBody>
205
238
  </div>