ordering-ui-react-native 0.22.2 → 0.22.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
CHANGED
|
@@ -48,7 +48,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
48
48
|
readMessages,
|
|
49
49
|
messagesReadList,
|
|
50
50
|
handleAssignDriver,
|
|
51
|
-
handleChangeOrderStatus,
|
|
52
51
|
isFromCheckout,
|
|
53
52
|
driverLocation,
|
|
54
53
|
actions,
|
|
@@ -76,6 +75,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
76
75
|
const [openModalForMapView, setOpenModalForMapView] = useState(false);
|
|
77
76
|
const [isDriverModalVisible, setIsDriverModalVisible] = useState(false);
|
|
78
77
|
const [printerSettings, setPrinterSettings] = useState('')
|
|
78
|
+
const [autoPrintEnabled, setAutoPrintEnabled] = useState<boolean>(false)
|
|
79
79
|
|
|
80
80
|
if (order?.status === 7 || order?.status === 4) {
|
|
81
81
|
if (drivers?.length > 0 && drivers) {
|
|
@@ -126,6 +126,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
const handleChangeOrderStatus = async (status: any, isAcceptOrReject: any = {}) => {
|
|
130
|
+
if (props.handleChangeOrderStatus) {
|
|
131
|
+
const order: any = await props.handleChangeOrderStatus(status, isAcceptOrReject)
|
|
132
|
+
|
|
133
|
+
if (order?.status !== 0 && autoPrintEnabled && printerSettings) {
|
|
134
|
+
handleViewSummaryOrder()
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
129
139
|
const getFormattedSubOptionName = ({ quantity, name, position, price }: any) => {
|
|
130
140
|
if (name !== 'No') {
|
|
131
141
|
const pos = position && position !== 'whole' ? `(${t(position.toUpperCase(), position)})` : '';
|
|
@@ -412,12 +422,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
412
422
|
}, [driverLocation]);
|
|
413
423
|
|
|
414
424
|
useEffect(() => {
|
|
415
|
-
const
|
|
416
|
-
|
|
425
|
+
const getStorageData = async () => {
|
|
426
|
+
const printer = await _retrieveStoreData('printer')
|
|
427
|
+
const autoPrint = await _retrieveStoreData('auto_print_after_accept_order')
|
|
417
428
|
setPrinterSettings(printer)
|
|
429
|
+
setAutoPrintEnabled(!!autoPrint)
|
|
418
430
|
}
|
|
419
431
|
|
|
420
|
-
|
|
432
|
+
getStorageData()
|
|
421
433
|
}, [])
|
|
422
434
|
|
|
423
435
|
const styles = StyleSheet.create({
|
|
@@ -6,16 +6,18 @@ import FeatherIcon from 'react-native-vector-icons/Feather'
|
|
|
6
6
|
import MCIcons from 'react-native-vector-icons/MaterialCommunityIcons'
|
|
7
7
|
import FAIcons from 'react-native-vector-icons/FontAwesome'
|
|
8
8
|
import { useTheme } from 'styled-components/native'
|
|
9
|
+
import ToggleSwitch from 'toggle-switch-react-native';
|
|
9
10
|
import { useLanguage } from 'ordering-components/native'
|
|
10
11
|
|
|
11
12
|
import { _setStoreData, _retrieveStoreData } from '../../providers/StoreUtil'
|
|
12
|
-
import { Container } from './styles'
|
|
13
|
+
import { Container, EnabledAutoPrint } from './styles'
|
|
13
14
|
import { OText, OInput} from '../shared'
|
|
14
15
|
|
|
15
16
|
export const PrinterSettings = (props: any) => {
|
|
16
17
|
const { onClose } = props
|
|
17
18
|
|
|
18
19
|
const [currentPrinter, setCurrentPrinter] = useState<any>(null)
|
|
20
|
+
const [autoPrintEnabled, setAutoPrintEnabled] = useState<boolean>(false)
|
|
19
21
|
const [layoutWidth, setLayoutWidth] = useState<any>({ actionsBtns: 0 })
|
|
20
22
|
|
|
21
23
|
const WIDTH_SCREEN = Dimensions.get('window').width
|
|
@@ -58,6 +60,9 @@ export const PrinterSettings = (props: any) => {
|
|
|
58
60
|
borderWidth: 1,
|
|
59
61
|
borderRadius: 8,
|
|
60
62
|
},
|
|
63
|
+
label: {
|
|
64
|
+
color: theme.colors.textGray
|
|
65
|
+
},
|
|
61
66
|
})
|
|
62
67
|
|
|
63
68
|
const printerList = [
|
|
@@ -111,13 +116,20 @@ export const PrinterSettings = (props: any) => {
|
|
|
111
116
|
onClose && onClose()
|
|
112
117
|
}
|
|
113
118
|
|
|
119
|
+
const handleAutoPrint = async () => {
|
|
120
|
+
setAutoPrintEnabled(!autoPrintEnabled)
|
|
121
|
+
await _setStoreData('auto_print_after_accept_order', !autoPrintEnabled)
|
|
122
|
+
}
|
|
123
|
+
|
|
114
124
|
useEffect(() => {
|
|
115
|
-
const
|
|
125
|
+
const getStorageData = async () => {
|
|
116
126
|
const printer = await _retrieveStoreData('printer')
|
|
127
|
+
const autoPrint = await _retrieveStoreData('auto_print_after_accept_order')
|
|
117
128
|
setCurrentPrinter(printer)
|
|
129
|
+
setAutoPrintEnabled(!!autoPrint)
|
|
118
130
|
}
|
|
119
131
|
|
|
120
|
-
|
|
132
|
+
getStorageData()
|
|
121
133
|
}, [])
|
|
122
134
|
|
|
123
135
|
useEffect(() => {
|
|
@@ -131,7 +143,25 @@ export const PrinterSettings = (props: any) => {
|
|
|
131
143
|
<OText size={24} style={{ paddingLeft: 30 }}>
|
|
132
144
|
{t('PRINTER_SETTINGS', 'Printer Settings')}
|
|
133
145
|
</OText>
|
|
134
|
-
<
|
|
146
|
+
<EnabledAutoPrint>
|
|
147
|
+
<View style={{ flex: 1 }}>
|
|
148
|
+
<OText
|
|
149
|
+
numberOfLines={2}
|
|
150
|
+
adjustsFontSizeToFit
|
|
151
|
+
style={{ ...styles.label, paddingHorizontal: 0 }}>
|
|
152
|
+
{t('AUTO_PRINT_AFTER_ACCEPTING_ORDER', 'Auto print after accepting order')}
|
|
153
|
+
</OText>
|
|
154
|
+
</View>
|
|
155
|
+
<ToggleSwitch
|
|
156
|
+
isOn={autoPrintEnabled}
|
|
157
|
+
onColor={theme.colors.primary}
|
|
158
|
+
offColor={theme.colors.offColor}
|
|
159
|
+
size="small"
|
|
160
|
+
onToggle={() => handleAutoPrint()}
|
|
161
|
+
animationSpeed={200}
|
|
162
|
+
/>
|
|
163
|
+
</EnabledAutoPrint>
|
|
164
|
+
<View style={{ paddingHorizontal: 30 }}>
|
|
135
165
|
{printerList.map((item: any, i: number) => (
|
|
136
166
|
<Container
|
|
137
167
|
key={i}
|
|
@@ -8,3 +8,10 @@ export const Container = styled.View`
|
|
|
8
8
|
border-bottom-width: 1px;
|
|
9
9
|
border-bottom-color: ${(props: any) => props.theme.colors.lightGray};
|
|
10
10
|
`
|
|
11
|
+
|
|
12
|
+
export const EnabledAutoPrint = styled.View`
|
|
13
|
+
flex-direction: row;
|
|
14
|
+
justify-content: space-between;
|
|
15
|
+
align-items: center;
|
|
16
|
+
padding: 20px 30px 10px;
|
|
17
|
+
`;
|
|
@@ -392,7 +392,7 @@ export interface OrderDetailsParams {
|
|
|
392
392
|
urlToShare?: string;
|
|
393
393
|
messages?: any;
|
|
394
394
|
handleAssignDriver?: (id: any) => {};
|
|
395
|
-
handleChangeOrderStatus?: (status: any) => {};
|
|
395
|
+
handleChangeOrderStatus?: (status: any, isAcceptOrReject: any) => {};
|
|
396
396
|
order?: any;
|
|
397
397
|
isFromRoot?: any;
|
|
398
398
|
handleOrderRedirect?: () => {};
|