ordering-ui-react-native 0.17.47 → 0.17.49
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
|
@@ -14,6 +14,8 @@ Sound.setCategory('Playback')
|
|
|
14
14
|
|
|
15
15
|
const windowWidth = Dimensions.get('screen').width
|
|
16
16
|
|
|
17
|
+
const SOUND_LOOP = 3
|
|
18
|
+
|
|
17
19
|
const NewOrderNotificationUI = (props: any) => {
|
|
18
20
|
const { isBusinessApp } = props
|
|
19
21
|
const [events] = useEvent()
|
|
@@ -22,8 +24,7 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
22
24
|
const [{ user, token }] = useSession()
|
|
23
25
|
const [ordering] = useApi()
|
|
24
26
|
const { getCurrentLocation } = useLocation();
|
|
25
|
-
const [
|
|
26
|
-
let [currentEvent, setCurrentEvent] = useState<any>(null)
|
|
27
|
+
const [currentEvent, setCurrentEvent] = useState<any>(null)
|
|
27
28
|
|
|
28
29
|
const evtList: any = {
|
|
29
30
|
1: {
|
|
@@ -43,29 +44,27 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
43
44
|
},
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
const notificationSound = new Sound(theme.sounds.notification
|
|
47
|
+
const notificationSound = new Sound(theme.sounds.notification);
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
times = times + 1
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
setSoundTimeout(_timeout)
|
|
58
|
-
if (times === 3) {
|
|
59
|
-
clearInterval(_timeout)
|
|
60
|
-
clearInterval(soundTimeout)
|
|
61
|
-
}
|
|
62
|
-
}, 2500)
|
|
49
|
+
let _timeout: any = null
|
|
50
|
+
|
|
51
|
+
const handleCloseEvents = () => {
|
|
52
|
+
notificationSound.stop()
|
|
53
|
+
setCurrentEvent(null)
|
|
54
|
+
clearInterval(_timeout)
|
|
63
55
|
}
|
|
64
56
|
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
57
|
+
const handlePlayNotificationSound = (eventObj: any = null) => {
|
|
58
|
+
setCurrentEvent(eventObj)
|
|
59
|
+
let times = 1
|
|
60
|
+
if (times < SOUND_LOOP) {
|
|
61
|
+
_timeout = setInterval(() => {
|
|
62
|
+
notificationSound.setVolume(1).play(success => success && (times = times + 1))
|
|
63
|
+
if (times === SOUND_LOOP) {
|
|
64
|
+
clearInterval(_timeout)
|
|
65
|
+
}
|
|
66
|
+
}, 2500)
|
|
67
|
+
}
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
const handleEventNotification = async (evtType: number, value: any) => {
|
|
@@ -79,26 +78,15 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
79
78
|
}),
|
|
80
79
|
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` }
|
|
81
80
|
})
|
|
82
|
-
} catch
|
|
83
|
-
console.log(error)
|
|
84
|
-
}
|
|
81
|
+
} catch {}
|
|
85
82
|
const duration = moment.duration(moment().diff(moment.utc(value?.last_driver_assigned_at)))
|
|
86
83
|
const assignedSecondsDiff = duration.asSeconds()
|
|
87
84
|
if (assignedSecondsDiff < 5 && !isBusinessApp) {
|
|
88
|
-
handlePlayNotificationSound()
|
|
89
|
-
clearInterval(soundTimeout)
|
|
90
|
-
currentEvent = { evt: 2, orderId: value?.id }
|
|
91
|
-
setCurrentEvent({ evt: 2, orderId: value?.id })
|
|
85
|
+
handlePlayNotificationSound({ evt: 2, orderId: value?.id })
|
|
92
86
|
}
|
|
93
87
|
}
|
|
94
88
|
if (evtType === 3 || value.author_id === user.id) return
|
|
95
|
-
handlePlayNotificationSound(
|
|
96
|
-
clearInterval(soundTimeout)
|
|
97
|
-
currentEvent = {
|
|
98
|
-
evt: evtType,
|
|
99
|
-
orderId: evtList[evtType].event === 'messages' ? value?.order_id : value?.id
|
|
100
|
-
}
|
|
101
|
-
setCurrentEvent({
|
|
89
|
+
handlePlayNotificationSound({
|
|
102
90
|
evt: evtType,
|
|
103
91
|
orderId: evtList[evtType].event === 'messages' ? value?.order_id : value?.id
|
|
104
92
|
})
|
|
@@ -116,10 +104,7 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
116
104
|
}, [])
|
|
117
105
|
|
|
118
106
|
useEffect(() => {
|
|
119
|
-
|
|
120
|
-
return () => {
|
|
121
|
-
notificationSound.release();
|
|
122
|
-
}
|
|
107
|
+
return () => handleCloseEvents()
|
|
123
108
|
}, [])
|
|
124
109
|
|
|
125
110
|
return (
|
|
@@ -133,7 +118,7 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
133
118
|
<View style={styles.modalView}>
|
|
134
119
|
<TouchableOpacity
|
|
135
120
|
style={styles.wrapperIcon}
|
|
136
|
-
onPress={() =>
|
|
121
|
+
onPress={() => handleCloseEvents()}
|
|
137
122
|
>
|
|
138
123
|
<Icon name="x" size={30} />
|
|
139
124
|
</TouchableOpacity>
|
|
@@ -1134,8 +1134,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
1134
1134
|
)}
|
|
1135
1135
|
<Total>
|
|
1136
1136
|
<Table>
|
|
1137
|
-
<OText size={
|
|
1138
|
-
<OText size={
|
|
1137
|
+
<OText size={14} style={{ fontWeight: 'bold' }} color={theme.colors.textNormal}>{t('TOTAL', 'Total')}</OText>
|
|
1138
|
+
<OText size={14} style={{ fontWeight: 'bold' }} color={theme.colors.textNormal}>
|
|
1139
1139
|
{parsePrice(order?.summary?.total ?? order?.total)}
|
|
1140
1140
|
</OText>
|
|
1141
1141
|
</Table>
|
|
@@ -34,10 +34,12 @@ export const OTabs = styled.View`
|
|
|
34
34
|
flex-direction: row;
|
|
35
35
|
width: 100%;
|
|
36
36
|
flex-wrap: wrap;
|
|
37
|
+
padding-vertical: 5px;
|
|
37
38
|
`;
|
|
38
39
|
|
|
39
40
|
export const OTab = styled.View`
|
|
40
41
|
padding-horizontal: 10px;
|
|
42
|
+
padding-vertical: 10px;
|
|
41
43
|
`;
|
|
42
44
|
|
|
43
45
|
export const LoyaltyContent = styled.View`
|