@fadyshawky/react-native-magic 2.0.5 → 2.0.6
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 +1 -1
- package/template/App.tsx +28 -19
- package/template/ios/reactnativemagic/AppDelegate.mm +5 -0
- package/template/src/common/ImageResources.g.ts +1 -33
- package/template/src/common/components/Background.tsx +7 -7
- package/template/src/common/components/Container.tsx +7 -10
- package/template/src/common/localization/LocalizationProvider.tsx +14 -17
- package/template/src/common/localization/RTLInitializer.tsx +90 -0
- package/template/src/common/localization/intlFormatter.ts +37 -0
- package/template/src/common/localization/localization.ts +1 -3
- package/template/src/common/localization/translations/commonLocalization.ts +11 -81
- package/template/src/common/localization/translations/emptyLocalization.ts +6 -2
- package/template/src/common/localization/translations/errorsLocalization.ts +33 -13
- package/template/src/common/localization/translations/homeLocalization.ts +4 -24
- package/template/src/common/localization/translations/loginLocalization.ts +26 -29
- package/template/src/common/localization/translations/mainNavigationLocalization.ts +2 -2
- package/template/src/common/localization/translations/onboardingLocalization.ts +40 -9
- package/template/src/common/localization/translations/otpLocalization.ts +8 -8
- package/template/src/common/localization/translations/pagesLocalization.ts +13 -1
- package/template/src/common/localization/translations/passwordLocalization.ts +3 -3
- package/template/src/common/localization/translations/profileLocalization.ts +4 -4
- package/template/src/core/store/app/appState.ts +2 -2
- package/template/src/core/theme/colors.ts +106 -70
- package/template/src/core/theme/commonConsts.ts +1 -1
- package/template/src/core/theme/commonSizes.ts +119 -94
- package/template/src/core/theme/commonStyles.ts +22 -22
- package/template/src/core/theme/fonts.ts +13 -14
- package/template/src/core/theme/shadows.ts +135 -0
- package/template/src/core/theme/themes.ts +386 -75
- package/template/src/core/theme/types.ts +201 -15
- package/template/src/navigation/HeaderComponents.tsx +6 -30
- package/template/src/navigation/MainStack.tsx +6 -97
- package/template/src/screens/Login/Login.tsx +5 -7
- package/template/src/screens/OTP/OTPScreen.tsx +12 -13
- package/template/src/screens/home/HomeScreen.tsx +2 -295
- package/template/src/screens/profile/Profile.tsx +2 -290
- package/template/src/common/localization/translations/posLocalization.ts +0 -196
- package/template/src/components/PrinterExample.js +0 -226
- package/template/src/modules/SunmiCard.js +0 -212
- package/template/src/modules/SunmiPrepaid.ts +0 -122
- package/template/src/screens/Categories/Categories.tsx +0 -141
- package/template/src/screens/Categories/hooks/useCategoriesData.ts +0 -33
- package/template/src/screens/Categories/types.ts +0 -7
- package/template/src/screens/Favorites/Favorites.tsx +0 -130
- package/template/src/screens/ForceChangePassword/ForceChangePasswordScreen.tsx +0 -155
- package/template/src/screens/History/History.tsx +0 -430
- package/template/src/screens/History/hooks/useHistoryData.ts +0 -49
- package/template/src/screens/History/types.ts +0 -7
- package/template/src/screens/InquiredBill/InquiredBill.tsx +0 -443
- package/template/src/screens/InquiredBill/hooks/useInquiredData.ts +0 -91
- package/template/src/screens/PaymentConfirmation/PaymentConfirmation.tsx +0 -326
- package/template/src/screens/Providers/Providers.tsx +0 -166
- package/template/src/screens/Providers/hooks/useProvidersData.ts +0 -33
- package/template/src/screens/Providers/types.ts +0 -7
- package/template/src/screens/ReceiptScreen/ReceiptScreen.tsx +0 -181
- package/template/src/screens/ReceiptScreen/hooks/useReceiptData.ts +0 -46
- package/template/src/screens/ReceiptScreen/utils/utils.tsx +0 -156
- package/template/src/screens/Services/Services.tsx +0 -144
- package/template/src/screens/Services/hooks/useServicesData.ts +0 -41
- package/template/src/screens/SingleService/Components/FawryInputs.tsx +0 -446
- package/template/src/screens/SingleService/SingleService.tsx +0 -229
- package/template/src/screens/SingleService/hooks/useServiceData.ts +0 -164
- package/template/src/services/SunmiPrinterInternal.js +0 -268
- package/template/src/types/sunmiPrepaid.d.ts +0 -20
- package/template/src/utils/SunmiPrinter.ts +0 -442
- package/template/src/utils/feesCalculator.ts +0 -92
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import {useState} from 'react';
|
|
2
|
-
import {useAppDispatch, useAppSelector} from '../../../core/store/reduxHelpers';
|
|
3
|
-
import {RootState} from '../../../core/store/rootReducer';
|
|
4
|
-
import {
|
|
5
|
-
enquireService,
|
|
6
|
-
getService,
|
|
7
|
-
payService,
|
|
8
|
-
} from '../../../core/store/Services/servicesActions';
|
|
9
|
-
import {BillTypeRefKeyEntity} from '../../../core/store/Services/servicesState';
|
|
10
|
-
import {useNavigation} from '@react-navigation/native';
|
|
11
|
-
import {NativeStackNavigationProp} from '@react-navigation/native-stack';
|
|
12
|
-
import {RootStackParamList} from '../../../navigation/types';
|
|
13
|
-
import {
|
|
14
|
-
clearInquiry,
|
|
15
|
-
clearPayment,
|
|
16
|
-
} from '../../../core/store/Services/servicesSlice';
|
|
17
|
-
import {initFees} from '../../../common/utils';
|
|
18
|
-
interface InputParameter {
|
|
19
|
-
BillingAcct: string;
|
|
20
|
-
ExtraBillingAcctKey: BillTypeRefKeyEntity[];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function useServiceData(serviceID?: string) {
|
|
24
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
25
|
-
const dispatch = useAppDispatch();
|
|
26
|
-
const {service} = useAppSelector((state: RootState) => state.services);
|
|
27
|
-
|
|
28
|
-
const [cardRead, setCardRead] = useState<any>(null);
|
|
29
|
-
const {selectedProvider} = useAppSelector(
|
|
30
|
-
(state: RootState) => state.providers,
|
|
31
|
-
);
|
|
32
|
-
const navigation =
|
|
33
|
-
useNavigation<NativeStackNavigationProp<RootStackParamList>>();
|
|
34
|
-
const [selectedPaymentRange, setSelectedPaymentRange] = useState<any>(null);
|
|
35
|
-
const [quantity, setQuantity] = useState<string>('1');
|
|
36
|
-
const [vatValue, setVatValue] = useState<string>('');
|
|
37
|
-
const [customProperties, setCustomProperties] = useState<any>(null);
|
|
38
|
-
const [beeInputParameters, setBeeInputParameters] = useState<any>([]);
|
|
39
|
-
const [fawryInputParameters, setFawryInputParameters] =
|
|
40
|
-
useState<InputParameter>({
|
|
41
|
-
BillingAcct: '',
|
|
42
|
-
ExtraBillingAcctKey:
|
|
43
|
-
service?.BillTypeExtraRefKeys?.BillTypeRefKey?.map(i => {
|
|
44
|
-
return {...i, Value: ''};
|
|
45
|
-
}) || [],
|
|
46
|
-
});
|
|
47
|
-
const fees = initFees(service, selectedPaymentRange);
|
|
48
|
-
|
|
49
|
-
const handlePayment = async () => {
|
|
50
|
-
setIsLoading(false);
|
|
51
|
-
navigation.navigate('PaymentConfirmation', {
|
|
52
|
-
paymentData: {
|
|
53
|
-
amountToBePaid: selectedPaymentRange,
|
|
54
|
-
...(service?.PmtType === 'VOCH' && {quantity}),
|
|
55
|
-
fawryInputParameters,
|
|
56
|
-
fees,
|
|
57
|
-
...(vatValue && {vatValue}),
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const handleEnquireService = async () => {
|
|
63
|
-
setIsLoading(true);
|
|
64
|
-
dispatch(clearInquiry());
|
|
65
|
-
dispatch(clearPayment());
|
|
66
|
-
try {
|
|
67
|
-
const data = {
|
|
68
|
-
BillTypeCode: service.BillTypeCode,
|
|
69
|
-
PmtType: service?.PmtType,
|
|
70
|
-
BillingAcct: fawryInputParameters?.BillingAcct,
|
|
71
|
-
ExtraBillingAcctKeys:
|
|
72
|
-
fawryInputParameters?.ExtraBillingAcctKey.filter(
|
|
73
|
-
k => !!k.Value || k.EnumValues,
|
|
74
|
-
).length > 0
|
|
75
|
-
? {
|
|
76
|
-
ExtraBillingAcctKey:
|
|
77
|
-
fawryInputParameters?.ExtraBillingAcctKey?.filter(
|
|
78
|
-
k => !!k.Value || k.EnumValues,
|
|
79
|
-
).map(item => ({
|
|
80
|
-
...(item.Value && {Key: item.Key}),
|
|
81
|
-
...(item.Value && {Value: item.Value}),
|
|
82
|
-
...(item.EnumValues && {
|
|
83
|
-
EnumValues: item.EnumValues,
|
|
84
|
-
}),
|
|
85
|
-
})),
|
|
86
|
-
}
|
|
87
|
-
: undefined,
|
|
88
|
-
...(service?.ServiceType === 'UTL' &&
|
|
89
|
-
customProperties && {
|
|
90
|
-
CustomProperties: {CustomProperty: customProperties},
|
|
91
|
-
}),
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
if (service?.PmtType === 'PREP' || service?.PmtType === 'VOCH') {
|
|
95
|
-
handlePayment();
|
|
96
|
-
} else {
|
|
97
|
-
const response = await dispatch(enquireService({data}));
|
|
98
|
-
if (response.type.includes('fulfilled')) {
|
|
99
|
-
navigation.navigate('InquiredBill');
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
} catch (error) {
|
|
103
|
-
console.log('error: ', error);
|
|
104
|
-
} finally {
|
|
105
|
-
if (service?.PmtType === 'POST') {
|
|
106
|
-
setIsLoading(false);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const fetchData = async () => {
|
|
112
|
-
if (!serviceID) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
try {
|
|
116
|
-
setIsLoading(true);
|
|
117
|
-
const data =
|
|
118
|
-
selectedProvider?.provider === 'Fawry'
|
|
119
|
-
? {fawry_service_id: serviceID}
|
|
120
|
-
: {bee_service_id: serviceID};
|
|
121
|
-
const res = await dispatch(getService({data}));
|
|
122
|
-
|
|
123
|
-
setFawryInputParameters({
|
|
124
|
-
...fawryInputParameters,
|
|
125
|
-
ExtraBillingAcctKey:
|
|
126
|
-
res.payload.service?.BillTypeExtraRefKeys?.BillTypeRefKey?.map(
|
|
127
|
-
(i: BillTypeRefKeyEntity) => {
|
|
128
|
-
return {...i, Value: ''};
|
|
129
|
-
},
|
|
130
|
-
) || [],
|
|
131
|
-
});
|
|
132
|
-
} catch (error) {
|
|
133
|
-
console.error('Error fetching service data:', error);
|
|
134
|
-
} finally {
|
|
135
|
-
setIsLoading(false);
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const refreshData = () => {
|
|
140
|
-
fetchData();
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
return {
|
|
144
|
-
beeInputParameters,
|
|
145
|
-
setBeeInputParameters,
|
|
146
|
-
fawryInputParameters,
|
|
147
|
-
setFawryInputParameters,
|
|
148
|
-
isLoading,
|
|
149
|
-
refreshData,
|
|
150
|
-
fetchData,
|
|
151
|
-
selectedPaymentRange,
|
|
152
|
-
setSelectedPaymentRange,
|
|
153
|
-
quantity,
|
|
154
|
-
setQuantity,
|
|
155
|
-
vatValue,
|
|
156
|
-
setVatValue,
|
|
157
|
-
selectedProvider,
|
|
158
|
-
handleEnquireService,
|
|
159
|
-
handlePayment,
|
|
160
|
-
fees,
|
|
161
|
-
customProperties,
|
|
162
|
-
setCustomProperties,
|
|
163
|
-
};
|
|
164
|
-
}
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import {NativeModules, Platform} from 'react-native';
|
|
2
|
-
|
|
3
|
-
const {SunmiPrinterInternal} = NativeModules;
|
|
4
|
-
|
|
5
|
-
// Create a wrapper with error handling
|
|
6
|
-
const SunmiPrinterInternalWrapper = {
|
|
7
|
-
// Check if the module is available
|
|
8
|
-
isAvailable: () => {
|
|
9
|
-
return (
|
|
10
|
-
!!SunmiPrinterInternal &&
|
|
11
|
-
typeof SunmiPrinterInternal === 'object' &&
|
|
12
|
-
Object.keys(SunmiPrinterInternal).length > 0
|
|
13
|
-
);
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
// Get the status of the printer
|
|
17
|
-
getStatus: async () => {
|
|
18
|
-
if (!SunmiPrinterInternalWrapper.isAvailable()) {
|
|
19
|
-
console.error('SunmiPrinterInternal module is not available');
|
|
20
|
-
return {
|
|
21
|
-
connected: false,
|
|
22
|
-
error: 'SunmiPrinterInternal module is not available',
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
try {
|
|
27
|
-
if (SunmiPrinterInternal.getStatus) {
|
|
28
|
-
return await SunmiPrinterInternal.getStatus();
|
|
29
|
-
} else {
|
|
30
|
-
return {
|
|
31
|
-
connected: false,
|
|
32
|
-
error: 'getStatus method is not available',
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
} catch (error) {
|
|
36
|
-
console.error('Error getting printer status:', error);
|
|
37
|
-
return {
|
|
38
|
-
connected: false,
|
|
39
|
-
error: error.message || 'Unknown error',
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
// Print text
|
|
45
|
-
printText: async text => {
|
|
46
|
-
if (!SunmiPrinterInternalWrapper.isAvailable()) {
|
|
47
|
-
console.error('SunmiPrinterInternal module is not available');
|
|
48
|
-
throw new Error('SunmiPrinterInternal module is not available');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!SunmiPrinterInternal.printText) {
|
|
52
|
-
console.error('printText method is not available');
|
|
53
|
-
throw new Error('printText method is not available');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
try {
|
|
57
|
-
return await SunmiPrinterInternal.printText(text);
|
|
58
|
-
} catch (error) {
|
|
59
|
-
console.error('Error printing text:', error);
|
|
60
|
-
throw error;
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
// Print text with font
|
|
65
|
-
printTextWithFont: async (text, typeface = '', fontSize = 24) => {
|
|
66
|
-
if (!SunmiPrinterInternalWrapper.isAvailable()) {
|
|
67
|
-
console.error('SunmiPrinterInternal module is not available');
|
|
68
|
-
throw new Error('SunmiPrinterInternal module is not available');
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!SunmiPrinterInternal.printTextWithFont) {
|
|
72
|
-
console.error('printTextWithFont method is not available');
|
|
73
|
-
throw new Error('printTextWithFont method is not available');
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
return await SunmiPrinterInternal.printTextWithFont(
|
|
78
|
-
text,
|
|
79
|
-
typeface,
|
|
80
|
-
fontSize,
|
|
81
|
-
);
|
|
82
|
-
} catch (error) {
|
|
83
|
-
console.error('Error printing text with font:', error);
|
|
84
|
-
throw error;
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
// Print bold text
|
|
89
|
-
printBoldText: async text => {
|
|
90
|
-
if (!SunmiPrinterInternalWrapper.isAvailable()) {
|
|
91
|
-
console.error('SunmiPrinterInternal module is not available');
|
|
92
|
-
throw new Error('SunmiPrinterInternal module is not available');
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (!SunmiPrinterInternal.printBoldText) {
|
|
96
|
-
console.error('printBoldText method is not available');
|
|
97
|
-
throw new Error('printBoldText method is not available');
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
try {
|
|
101
|
-
return await SunmiPrinterInternal.printBoldText(text);
|
|
102
|
-
} catch (error) {
|
|
103
|
-
console.error('Error printing bold text:', error);
|
|
104
|
-
throw error;
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
// Print barcode
|
|
109
|
-
printBarCode: async (
|
|
110
|
-
data,
|
|
111
|
-
symbology = 8,
|
|
112
|
-
height = 80,
|
|
113
|
-
width = 2,
|
|
114
|
-
textPosition = 2,
|
|
115
|
-
) => {
|
|
116
|
-
if (!SunmiPrinterInternalWrapper.isAvailable()) {
|
|
117
|
-
console.error('SunmiPrinterInternal module is not available');
|
|
118
|
-
throw new Error('SunmiPrinterInternal module is not available');
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (!SunmiPrinterInternal.printBarCode) {
|
|
122
|
-
console.error('printBarCode method is not available');
|
|
123
|
-
throw new Error('printBarCode method is not available');
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
try {
|
|
127
|
-
return await SunmiPrinterInternal.printBarCode(
|
|
128
|
-
data,
|
|
129
|
-
symbology,
|
|
130
|
-
height,
|
|
131
|
-
width,
|
|
132
|
-
textPosition,
|
|
133
|
-
);
|
|
134
|
-
} catch (error) {
|
|
135
|
-
console.error('Error printing barcode:', error);
|
|
136
|
-
throw error;
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
-
// Print QR code
|
|
141
|
-
printQRCode: async (data, moduleSize = 8, errorLevel = 0) => {
|
|
142
|
-
if (!SunmiPrinterInternalWrapper.isAvailable()) {
|
|
143
|
-
console.error('SunmiPrinterInternal module is not available');
|
|
144
|
-
throw new Error('SunmiPrinterInternal module is not available');
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (!SunmiPrinterInternal.printQRCode) {
|
|
148
|
-
console.error('printQRCode method is not available');
|
|
149
|
-
throw new Error('printQRCode method is not available');
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
try {
|
|
153
|
-
return await SunmiPrinterInternal.printQRCode(
|
|
154
|
-
data,
|
|
155
|
-
moduleSize,
|
|
156
|
-
errorLevel,
|
|
157
|
-
);
|
|
158
|
-
} catch (error) {
|
|
159
|
-
console.error('Error printing QR code:', error);
|
|
160
|
-
throw error;
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
// Print image
|
|
165
|
-
printImage: async base64Image => {
|
|
166
|
-
if (!SunmiPrinterInternalWrapper.isAvailable()) {
|
|
167
|
-
console.error('SunmiPrinterInternal module is not available');
|
|
168
|
-
throw new Error('SunmiPrinterInternal module is not available');
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (!SunmiPrinterInternal.printImage) {
|
|
172
|
-
console.error('printImage method is not available');
|
|
173
|
-
throw new Error('printImage method is not available');
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
try {
|
|
177
|
-
return await SunmiPrinterInternal.printImage(base64Image);
|
|
178
|
-
} catch (error) {
|
|
179
|
-
console.error('Error printing image:', error);
|
|
180
|
-
throw error;
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
// Line wrap
|
|
185
|
-
lineWrap: async (lines = 3) => {
|
|
186
|
-
if (!SunmiPrinterInternalWrapper.isAvailable()) {
|
|
187
|
-
console.error('SunmiPrinterInternal module is not available');
|
|
188
|
-
throw new Error('SunmiPrinterInternal module is not available');
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (!SunmiPrinterInternal.lineWrap) {
|
|
192
|
-
console.error('lineWrap method is not available');
|
|
193
|
-
throw new Error('lineWrap method is not available');
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
try {
|
|
197
|
-
return await SunmiPrinterInternal.lineWrap(lines);
|
|
198
|
-
} catch (error) {
|
|
199
|
-
console.error('Error line wrapping:', error);
|
|
200
|
-
throw error;
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
// Cut paper
|
|
205
|
-
cutPaper: async () => {
|
|
206
|
-
if (!SunmiPrinterInternalWrapper.isAvailable()) {
|
|
207
|
-
console.error('SunmiPrinterInternal module is not available');
|
|
208
|
-
throw new Error('SunmiPrinterInternal module is not available');
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (!SunmiPrinterInternal.cutPaper) {
|
|
212
|
-
console.error('cutPaper method is not available');
|
|
213
|
-
throw new Error('cutPaper method is not available');
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
try {
|
|
217
|
-
return await SunmiPrinterInternal.cutPaper();
|
|
218
|
-
} catch (error) {
|
|
219
|
-
console.error('Error cutting paper:', error);
|
|
220
|
-
throw error;
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
|
-
|
|
224
|
-
// Print receipt
|
|
225
|
-
printReceipt: async receiptData => {
|
|
226
|
-
if (!SunmiPrinterInternalWrapper.isAvailable()) {
|
|
227
|
-
console.error('SunmiPrinterInternal module is not available');
|
|
228
|
-
throw new Error('SunmiPrinterInternal module is not available');
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
try {
|
|
232
|
-
// Print header
|
|
233
|
-
await SunmiPrinterInternalWrapper.printBoldText(receiptData.header);
|
|
234
|
-
await SunmiPrinterInternalWrapper.lineWrap(1);
|
|
235
|
-
|
|
236
|
-
// Print items
|
|
237
|
-
for (const item of receiptData.items) {
|
|
238
|
-
await SunmiPrinterInternalWrapper.printText(
|
|
239
|
-
`${item.name} x${item.quantity} $${item.price}`,
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
await SunmiPrinterInternalWrapper.lineWrap(1);
|
|
244
|
-
|
|
245
|
-
// Print total
|
|
246
|
-
await SunmiPrinterInternalWrapper.printBoldText(
|
|
247
|
-
`Total: $${receiptData.total}`,
|
|
248
|
-
);
|
|
249
|
-
|
|
250
|
-
// Print footer
|
|
251
|
-
await SunmiPrinterInternalWrapper.lineWrap(2);
|
|
252
|
-
await SunmiPrinterInternalWrapper.printText(receiptData.footer);
|
|
253
|
-
|
|
254
|
-
// Cut paper
|
|
255
|
-
await SunmiPrinterInternalWrapper.lineWrap(3);
|
|
256
|
-
if (SunmiPrinterInternal.cutPaper) {
|
|
257
|
-
await SunmiPrinterInternalWrapper.cutPaper();
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
return true;
|
|
261
|
-
} catch (error) {
|
|
262
|
-
console.error('Error printing receipt:', error);
|
|
263
|
-
throw error;
|
|
264
|
-
}
|
|
265
|
-
},
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
export default SunmiPrinterInternalWrapper;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
declare module 'SunmiPrepaid' {
|
|
2
|
-
interface PrepaidResponse {
|
|
3
|
-
success: boolean;
|
|
4
|
-
message: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
interface ServiceStatus {
|
|
8
|
-
isInitialized: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface SunmiPrepaidInterface {
|
|
12
|
-
initializePrepaid(): Promise<PrepaidResponse>;
|
|
13
|
-
initializeUtilityType(utilityType: string): Promise<PrepaidResponse>;
|
|
14
|
-
forceCardFacadeDetection(): Promise<PrepaidResponse>;
|
|
15
|
-
getServiceStatus(): Promise<ServiceStatus>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const SunmiPrepaid: SunmiPrepaidInterface;
|
|
19
|
-
export default SunmiPrepaid;
|
|
20
|
-
}
|