ordering-ui-react-native 0.14.51 → 0.14.52
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
CHANGED
|
@@ -34,7 +34,9 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
34
34
|
timeSelected,
|
|
35
35
|
handleBusinessClick,
|
|
36
36
|
handleChangeDate,
|
|
37
|
-
handleChangeTime
|
|
37
|
+
handleChangeTime,
|
|
38
|
+
handleAsap,
|
|
39
|
+
isAsap
|
|
38
40
|
} = props
|
|
39
41
|
|
|
40
42
|
const theme = useTheme()
|
|
@@ -43,10 +45,11 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
43
45
|
const [{ configs }] = useConfig()
|
|
44
46
|
const [orderState] = useOrder()
|
|
45
47
|
const [selectedPreorderType, setSelectedPreorderType] = useState(0)
|
|
46
|
-
const [menu, setMenu] = useState({})
|
|
48
|
+
const [menu, setMenu] = useState<any>({})
|
|
47
49
|
const [timeList, setTimeList] = useState<any>([])
|
|
48
50
|
const [selectDate, setSelectedDate] = useState<any>(null)
|
|
49
51
|
const [datesWhitelist, setDateWhitelist] = useState<any>([{ start: null, end: null }])
|
|
52
|
+
const [isEnabled, setIsEnabled] = useState(false)
|
|
50
53
|
|
|
51
54
|
const styles = StyleSheet.create({
|
|
52
55
|
container: {
|
|
@@ -137,7 +140,13 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
137
140
|
{ key: 'business_menu', name: t('BUSINESS_MENU', 'Business menu') }
|
|
138
141
|
]
|
|
139
142
|
|
|
143
|
+
const validateSelectedDate = (curdate: any, menu: any) => {
|
|
144
|
+
const day = moment(curdate).format('d')
|
|
145
|
+
setIsEnabled(menu?.schedule[day]?.enabled || false)
|
|
146
|
+
}
|
|
147
|
+
|
|
140
148
|
const getTimes = (curdate: any, menu: any) => {
|
|
149
|
+
validateSelectedDate(curdate, menu)
|
|
141
150
|
const date = new Date()
|
|
142
151
|
var dateSeleted = new Date(curdate)
|
|
143
152
|
var times = []
|
|
@@ -240,26 +249,11 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
240
249
|
}
|
|
241
250
|
|
|
242
251
|
useEffect(() => {
|
|
243
|
-
if (
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const _timeLists = hoursList.map((hour: any) => {
|
|
249
|
-
return {
|
|
250
|
-
value: hour.startTime,
|
|
251
|
-
text: configs?.format_time?.value === '12' ? (
|
|
252
|
-
hour.startTime.includes('12')
|
|
253
|
-
? `${hour.startTime}PM`
|
|
254
|
-
: parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'hh:mma' })
|
|
255
|
-
) : (
|
|
256
|
-
parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'HH:mm' })
|
|
257
|
-
)
|
|
258
|
-
}
|
|
259
|
-
})
|
|
260
|
-
setTimeList(_timeLists)
|
|
261
|
-
}
|
|
262
|
-
}, [selectDate, hoursList, menu])
|
|
252
|
+
if (selectDate === null) return
|
|
253
|
+
const selectedMenu = Object.keys(menu).length > 0 ? (menu?.use_business_schedule ? business : menu) : business
|
|
254
|
+
const _times = getTimes(selectDate, selectedMenu)
|
|
255
|
+
setTimeList(_times)
|
|
256
|
+
}, [selectDate, menu])
|
|
263
257
|
|
|
264
258
|
useEffect(() => {
|
|
265
259
|
if (selectedPreorderType === 0 && Object.keys(menu).length > 0) setMenu({})
|
|
@@ -273,6 +267,10 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
273
267
|
}
|
|
274
268
|
}, [dateSelected])
|
|
275
269
|
|
|
270
|
+
useEffect(() => {
|
|
271
|
+
handleAsap && handleAsap()
|
|
272
|
+
}, [])
|
|
273
|
+
|
|
276
274
|
return (
|
|
277
275
|
<>
|
|
278
276
|
<PreOrderContainer contentContainerStyle={{ paddingVertical: 32, paddingHorizontal: 40 }}>
|
|
@@ -413,24 +411,38 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
413
411
|
)}
|
|
414
412
|
</View>
|
|
415
413
|
<TimeListWrapper nestedScrollEnabled={true}>
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
<
|
|
420
|
-
<
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
414
|
+
{(isEnabled && timeList?.length > 0) ? (
|
|
415
|
+
<TimeContentWrapper>
|
|
416
|
+
{timeList.map((time: any, i: number) => (
|
|
417
|
+
<TouchableOpacity key={i} onPress={() => handleChangeTime(time.value)}>
|
|
418
|
+
<TimeItem active={timeSelected === time.value}>
|
|
419
|
+
<OText
|
|
420
|
+
size={14}
|
|
421
|
+
color={timeSelected === time.value ? theme.colors.primary : theme.colors.textNormal}
|
|
422
|
+
style={{
|
|
423
|
+
lineHeight: 24
|
|
424
|
+
}}
|
|
425
|
+
>{time.text}</OText>
|
|
426
|
+
</TimeItem>
|
|
427
|
+
</TouchableOpacity>
|
|
428
|
+
))}
|
|
429
|
+
{timeList.length % 3 === 2 && (
|
|
430
|
+
<TimeItem style={{ backgroundColor: 'transparent' }} />
|
|
431
|
+
)}
|
|
432
|
+
</TimeContentWrapper>
|
|
433
|
+
) : (
|
|
434
|
+
<OText
|
|
435
|
+
size={16}
|
|
436
|
+
style={{
|
|
437
|
+
fontWeight: '600',
|
|
438
|
+
lineHeight: 24,
|
|
439
|
+
marginBottom: 12,
|
|
440
|
+
textAlign: 'center'
|
|
441
|
+
}}
|
|
442
|
+
>
|
|
443
|
+
{t('ERROR_ADD_PRODUCT_BUSINESS_CLOSED', 'The business is closed at the moment')}
|
|
444
|
+
</OText>
|
|
445
|
+
)}
|
|
434
446
|
</TimeListWrapper>
|
|
435
447
|
</OrderTimeWrapper>
|
|
436
448
|
<OButton
|
|
@@ -438,6 +450,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
438
450
|
textStyle={{ color: 'white' }}
|
|
439
451
|
style={{ borderRadius: 7.6, marginBottom: 20, marginTop: 30 }}
|
|
440
452
|
onClick={() => handleClickBusiness()}
|
|
453
|
+
isDisabled={isAsap || !(dateSelected && timeSelected)}
|
|
441
454
|
/>
|
|
442
455
|
</PreOrderContainer>
|
|
443
456
|
<Spinner visible={orderState.loading} />
|
|
@@ -240,7 +240,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
240
240
|
{isFarAway && (
|
|
241
241
|
<FarAwayMessage style={styles.farAwayMsg}>
|
|
242
242
|
<Ionicons name='md-warning-outline' style={styles.iconStyle} />
|
|
243
|
-
<OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', '
|
|
243
|
+
<OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'You are far from this address')}</OText>
|
|
244
244
|
</FarAwayMessage>
|
|
245
245
|
)}
|
|
246
246
|
<OrderControlContainer>
|