@fadyshawky/react-native-magic 2.0.5 → 2.0.7
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 +21 -16
- 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/appSlice.ts +2 -2
- package/template/src/core/store/app/appState.ts +1 -1
- 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/MainNavigation.tsx +2 -3
- 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/core/store/Categories/categoryActions.ts +0 -33
- package/template/src/core/store/Categories/categorySlice.ts +0 -75
- package/template/src/core/store/Categories/categoryState.ts +0 -41
- package/template/src/core/store/Providers/providersActions.ts +0 -102
- package/template/src/core/store/Providers/providersSlice.ts +0 -136
- package/template/src/core/store/Providers/providersState.ts +0 -37
- package/template/src/core/store/Services/servicesActions.ts +0 -191
- package/template/src/core/store/Services/servicesSlice.ts +0 -205
- package/template/src/core/store/Services/servicesState.ts +0 -466
- 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,196 +0,0 @@
|
|
|
1
|
-
export const posLocalization = {
|
|
2
|
-
en: {
|
|
3
|
-
// Common Labels
|
|
4
|
-
serialNumber: 'Serial Number',
|
|
5
|
-
serviceName: 'Service Name',
|
|
6
|
-
providerName: 'Provider Name',
|
|
7
|
-
customerNumber: 'Customer Number',
|
|
8
|
-
value: 'Value',
|
|
9
|
-
serviceCost: 'Service Cost',
|
|
10
|
-
operationNumber: 'Operation Number',
|
|
11
|
-
referenceNumber: 'Reference Number',
|
|
12
|
-
time: 'Time',
|
|
13
|
-
total: 'Total',
|
|
14
|
-
|
|
15
|
-
// Input Methods
|
|
16
|
-
scanner: 'Scanner',
|
|
17
|
-
keypad: 'Keypad',
|
|
18
|
-
keyboard: 'Keyboard',
|
|
19
|
-
touchPanel: 'Touch Panel',
|
|
20
|
-
button: 'Button',
|
|
21
|
-
|
|
22
|
-
// Actions
|
|
23
|
-
print: 'Print',
|
|
24
|
-
save: 'Save',
|
|
25
|
-
cancel: 'Cancel',
|
|
26
|
-
delete: 'Delete',
|
|
27
|
-
submit: 'Submit',
|
|
28
|
-
|
|
29
|
-
// Messages
|
|
30
|
-
success: 'Success',
|
|
31
|
-
error: 'Error',
|
|
32
|
-
required: 'This field is required',
|
|
33
|
-
invalidInput: 'Invalid input',
|
|
34
|
-
|
|
35
|
-
// Validation
|
|
36
|
-
enterValidAmount: 'Please enter a valid amount',
|
|
37
|
-
enterValidNumber: 'Please enter a valid number',
|
|
38
|
-
enterValidDate: 'Please enter a valid date',
|
|
39
|
-
|
|
40
|
-
// Printer
|
|
41
|
-
printerError: 'Printer Error',
|
|
42
|
-
printingError: 'Printing Error',
|
|
43
|
-
paperFeedError: 'Paper Feed Error',
|
|
44
|
-
qrCodeError: 'QR Code Error',
|
|
45
|
-
barcodeError: 'Barcode Error',
|
|
46
|
-
tableError: 'Table Error',
|
|
47
|
-
bufferError: 'Buffer Error',
|
|
48
|
-
|
|
49
|
-
// Bill
|
|
50
|
-
billAmount: 'Bill Amount',
|
|
51
|
-
billDetails: 'Bill Details',
|
|
52
|
-
billNumber: 'Bill Number',
|
|
53
|
-
billDate: 'Bill Date',
|
|
54
|
-
billStatus: 'Bill Status',
|
|
55
|
-
|
|
56
|
-
// Service
|
|
57
|
-
serviceDetails: 'Service Details',
|
|
58
|
-
serviceType: 'Service Type',
|
|
59
|
-
serviceStatus: 'Service Status',
|
|
60
|
-
serviceDate: 'Service Date',
|
|
61
|
-
|
|
62
|
-
// Customer
|
|
63
|
-
customerDetails: 'Customer Details',
|
|
64
|
-
customerName: 'Customer Name',
|
|
65
|
-
customerPhone: 'Customer Phone',
|
|
66
|
-
customerEmail: 'Customer Email',
|
|
67
|
-
|
|
68
|
-
// Payment
|
|
69
|
-
paymentMethod: 'Payment Method',
|
|
70
|
-
paymentStatus: 'Payment Status',
|
|
71
|
-
paymentDate: 'Payment Date',
|
|
72
|
-
paymentAmount: 'Payment Amount',
|
|
73
|
-
|
|
74
|
-
// Receipt
|
|
75
|
-
receiptNumber: 'Receipt Number',
|
|
76
|
-
receiptDate: 'Receipt Date',
|
|
77
|
-
receiptTime: 'Receipt Time',
|
|
78
|
-
receiptTotal: 'Receipt Total',
|
|
79
|
-
receiptStatus: 'Receipt Status',
|
|
80
|
-
expiryDate: 'Expiry Date',
|
|
81
|
-
|
|
82
|
-
// Printer Status
|
|
83
|
-
printerStatus_1: 'The printer works normally',
|
|
84
|
-
printerStatus_2: 'Preparing printer',
|
|
85
|
-
printerStatus_3: 'Abnormal communication',
|
|
86
|
-
printerStatus_4: 'The printer is out of paper',
|
|
87
|
-
printerStatus_5: 'Printer overheated',
|
|
88
|
-
printerStatus_6: 'Printer cover is open',
|
|
89
|
-
printerStatus_7: 'Unknown printer error',
|
|
90
|
-
|
|
91
|
-
title: 'Transaction Details',
|
|
92
|
-
trans_id: 'Transaction ID',
|
|
93
|
-
service: 'Service',
|
|
94
|
-
service_type: 'Service Type',
|
|
95
|
-
amount: 'Amount',
|
|
96
|
-
fees: 'Fees',
|
|
97
|
-
info_text: 'Details',
|
|
98
|
-
},
|
|
99
|
-
ar: {
|
|
100
|
-
// Common Labels
|
|
101
|
-
serialNumber: 'الرقم التسلسلي',
|
|
102
|
-
serviceName: 'اسم الخدمة',
|
|
103
|
-
providerName: 'اسم المقدم',
|
|
104
|
-
customerNumber: 'رقم العميل',
|
|
105
|
-
value: 'القيمة',
|
|
106
|
-
serviceCost: 'تكلفة الخدمة',
|
|
107
|
-
operationNumber: 'رقم العملية',
|
|
108
|
-
referenceNumber: 'الرقم المرجعي',
|
|
109
|
-
time: 'الوقت',
|
|
110
|
-
total: 'الإجمالي',
|
|
111
|
-
|
|
112
|
-
// Input Methods
|
|
113
|
-
scanner: 'الماسح الضوئي',
|
|
114
|
-
keypad: 'لوحة المفاتيح الرقمية',
|
|
115
|
-
keyboard: 'لوحة المفاتيح',
|
|
116
|
-
touchPanel: 'شاشة اللمس',
|
|
117
|
-
button: 'زر',
|
|
118
|
-
|
|
119
|
-
// Actions
|
|
120
|
-
print: 'طباعة',
|
|
121
|
-
save: 'حفظ',
|
|
122
|
-
cancel: 'إلغاء',
|
|
123
|
-
delete: 'حذف',
|
|
124
|
-
submit: 'إرسال',
|
|
125
|
-
|
|
126
|
-
// Messages
|
|
127
|
-
success: 'نجاح',
|
|
128
|
-
error: 'خطأ',
|
|
129
|
-
required: 'هذا الحقل مطلوب',
|
|
130
|
-
invalidInput: 'إدخال غير صالح',
|
|
131
|
-
|
|
132
|
-
// Validation
|
|
133
|
-
enterValidAmount: 'الرجاء إدخال مبلغ صحيح',
|
|
134
|
-
enterValidNumber: 'الرجاء إدخال رقم صحيح',
|
|
135
|
-
enterValidDate: 'الرجاء إدخال تاريخ صحيح',
|
|
136
|
-
|
|
137
|
-
// Printer
|
|
138
|
-
printerError: 'خطأ في الطابعة',
|
|
139
|
-
printingError: 'خطأ في الطباعة',
|
|
140
|
-
paperFeedError: 'خطأ في تغذية الورق',
|
|
141
|
-
qrCodeError: 'خطأ في رمز QR',
|
|
142
|
-
barcodeError: 'خطأ في الباركود',
|
|
143
|
-
tableError: 'خطأ في الجدول',
|
|
144
|
-
bufferError: 'خطأ في المخزن المؤقت',
|
|
145
|
-
|
|
146
|
-
// Bill
|
|
147
|
-
billAmount: 'مبلغ الفاتورة',
|
|
148
|
-
billDetails: 'تفاصيل الفاتورة',
|
|
149
|
-
billNumber: 'رقم الفاتورة',
|
|
150
|
-
billDate: 'تاريخ الفاتورة',
|
|
151
|
-
billStatus: 'حالة الفاتورة',
|
|
152
|
-
|
|
153
|
-
// Service
|
|
154
|
-
serviceDetails: 'تفاصيل الخدمة',
|
|
155
|
-
serviceType: 'نوع الخدمة',
|
|
156
|
-
serviceStatus: 'حالة الخدمة',
|
|
157
|
-
serviceDate: 'تاريخ الخدمة',
|
|
158
|
-
|
|
159
|
-
// Customer
|
|
160
|
-
customerDetails: 'تفاصيل العميل',
|
|
161
|
-
customerName: 'اسم العميل',
|
|
162
|
-
customerPhone: 'هاتف العميل',
|
|
163
|
-
customerEmail: 'بريد العميل',
|
|
164
|
-
|
|
165
|
-
// Payment
|
|
166
|
-
paymentMethod: 'طريقة الدفع',
|
|
167
|
-
paymentStatus: 'حالة الدفع',
|
|
168
|
-
paymentDate: 'تاريخ الدفع',
|
|
169
|
-
paymentAmount: 'مبلغ الدفع',
|
|
170
|
-
|
|
171
|
-
// Receipt
|
|
172
|
-
receiptNumber: 'رقم الإيصال',
|
|
173
|
-
receiptDate: 'تاريخ الإيصال',
|
|
174
|
-
receiptTime: 'وقت الإيصال',
|
|
175
|
-
receiptTotal: 'إجمالي الإيصال',
|
|
176
|
-
receiptStatus: 'حالة الإيصال',
|
|
177
|
-
expiryDate: 'تاريخ الانتهاء',
|
|
178
|
-
|
|
179
|
-
// Printer Status
|
|
180
|
-
printerStatus_1: 'الطابعة تعمل بشكل طبيعي',
|
|
181
|
-
printerStatus_2: 'جاري تجهيز الطابعة',
|
|
182
|
-
printerStatus_3: 'خطأ في الاتصال بالطابعة',
|
|
183
|
-
printerStatus_4: 'نفذ الورق من الطابعة',
|
|
184
|
-
printerStatus_5: 'الطابعة ساخنة جداً',
|
|
185
|
-
printerStatus_6: 'غطاء الطابعة مفتوح',
|
|
186
|
-
printerStatus_7: 'خطأ غير معروف في الطابعة',
|
|
187
|
-
|
|
188
|
-
title: 'تفاصيل المعاملة',
|
|
189
|
-
trans_id: 'معرف المعاملة',
|
|
190
|
-
service: 'الخدمة',
|
|
191
|
-
service_type: 'نوع الخدمة',
|
|
192
|
-
amount: 'المبلغ',
|
|
193
|
-
fees: 'مصاريف',
|
|
194
|
-
info_text: 'التفاصيل',
|
|
195
|
-
},
|
|
196
|
-
};
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import React, {useState, useEffect} from 'react';
|
|
2
|
-
import {
|
|
3
|
-
View,
|
|
4
|
-
Text,
|
|
5
|
-
StyleSheet,
|
|
6
|
-
TouchableOpacity,
|
|
7
|
-
ScrollView,
|
|
8
|
-
Alert,
|
|
9
|
-
} from 'react-native';
|
|
10
|
-
import SunmiPrinter from '../utils/SunmiPrinter';
|
|
11
|
-
|
|
12
|
-
const PrinterExample = () => {
|
|
13
|
-
const [isPrinterAvailable, setIsPrinterAvailable] = useState(false);
|
|
14
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
15
|
-
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
checkPrinterAvailability();
|
|
18
|
-
}, []);
|
|
19
|
-
|
|
20
|
-
const checkPrinterAvailability = async () => {
|
|
21
|
-
try {
|
|
22
|
-
const available = await SunmiPrinter.isPrinterAvailable();
|
|
23
|
-
setIsPrinterAvailable(available);
|
|
24
|
-
} catch (error) {
|
|
25
|
-
console.error('Error checking printer availability:', error);
|
|
26
|
-
setIsPrinterAvailable(false);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const handlePrintText = async () => {
|
|
31
|
-
if (!isPrinterAvailable) {
|
|
32
|
-
Alert.alert('Printer Error', 'Printer is not available');
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
setIsLoading(true);
|
|
37
|
-
try {
|
|
38
|
-
await SunmiPrinter.printText(
|
|
39
|
-
'Hello, Sunmi Printer!\n',
|
|
40
|
-
SunmiPrinter.FONT_SIZE_LARGE,
|
|
41
|
-
);
|
|
42
|
-
await SunmiPrinter.feedPaper(3);
|
|
43
|
-
Alert.alert('Success', 'Text printed successfully');
|
|
44
|
-
} catch (error) {
|
|
45
|
-
console.error('Error printing text:', error);
|
|
46
|
-
Alert.alert('Print Error', error.message || 'Failed to print text');
|
|
47
|
-
} finally {
|
|
48
|
-
setIsLoading(false);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const handlePrintCenteredText = async () => {
|
|
53
|
-
if (!isPrinterAvailable) {
|
|
54
|
-
Alert.alert('Printer Error', 'Printer is not available');
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
setIsLoading(true);
|
|
59
|
-
try {
|
|
60
|
-
await SunmiPrinter.printTextWithAlignment(
|
|
61
|
-
'Centered Text Example\n',
|
|
62
|
-
SunmiPrinter.FONT_SIZE_LARGE,
|
|
63
|
-
SunmiPrinter.ALIGN_CENTER,
|
|
64
|
-
);
|
|
65
|
-
await SunmiPrinter.feedPaper(3);
|
|
66
|
-
Alert.alert('Success', 'Centered text printed successfully');
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.error('Error printing centered text:', error);
|
|
69
|
-
Alert.alert(
|
|
70
|
-
'Print Error',
|
|
71
|
-
error.message || 'Failed to print centered text',
|
|
72
|
-
);
|
|
73
|
-
} finally {
|
|
74
|
-
setIsLoading(false);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const handlePrintDivider = async () => {
|
|
79
|
-
if (!isPrinterAvailable) {
|
|
80
|
-
Alert.alert('Printer Error', 'Printer is not available');
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
setIsLoading(true);
|
|
85
|
-
try {
|
|
86
|
-
await SunmiPrinter.printDivider();
|
|
87
|
-
await SunmiPrinter.feedPaper(3);
|
|
88
|
-
Alert.alert('Success', 'Divider printed successfully');
|
|
89
|
-
} catch (error) {
|
|
90
|
-
console.error('Error printing divider:', error);
|
|
91
|
-
Alert.alert('Print Error', error.message || 'Failed to print divider');
|
|
92
|
-
} finally {
|
|
93
|
-
setIsLoading(false);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const handlePrintSampleReceipt = async () => {
|
|
98
|
-
if (!isPrinterAvailable) {
|
|
99
|
-
Alert.alert('Printer Error', 'Printer is not available');
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
setIsLoading(true);
|
|
104
|
-
try {
|
|
105
|
-
await SunmiPrinter.printSampleReceipt();
|
|
106
|
-
Alert.alert('Success', 'Sample receipt printed successfully');
|
|
107
|
-
} catch (error) {
|
|
108
|
-
console.error('Error printing sample receipt:', error);
|
|
109
|
-
Alert.alert(
|
|
110
|
-
'Print Error',
|
|
111
|
-
error.message || 'Failed to print sample receipt',
|
|
112
|
-
);
|
|
113
|
-
} finally {
|
|
114
|
-
setIsLoading(false);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
return (
|
|
119
|
-
<ScrollView style={styles.container}>
|
|
120
|
-
<Text style={styles.title}>Sunmi Printer Example</Text>
|
|
121
|
-
|
|
122
|
-
<View style={styles.statusContainer}>
|
|
123
|
-
<Text style={styles.statusLabel}>Printer Status:</Text>
|
|
124
|
-
<Text
|
|
125
|
-
style={[
|
|
126
|
-
styles.statusValue,
|
|
127
|
-
{color: isPrinterAvailable ? 'green' : 'red'},
|
|
128
|
-
]}>
|
|
129
|
-
{isPrinterAvailable ? 'Available' : 'Not Available'}
|
|
130
|
-
</Text>
|
|
131
|
-
</View>
|
|
132
|
-
|
|
133
|
-
<TouchableOpacity
|
|
134
|
-
style={[styles.button, isLoading && styles.buttonDisabled]}
|
|
135
|
-
onPress={handlePrintText}
|
|
136
|
-
disabled={isLoading}>
|
|
137
|
-
<Text style={styles.buttonText}>Print Text</Text>
|
|
138
|
-
</TouchableOpacity>
|
|
139
|
-
|
|
140
|
-
<TouchableOpacity
|
|
141
|
-
style={[styles.button, isLoading && styles.buttonDisabled]}
|
|
142
|
-
onPress={handlePrintCenteredText}
|
|
143
|
-
disabled={isLoading}>
|
|
144
|
-
<Text style={styles.buttonText}>Print Centered Text</Text>
|
|
145
|
-
</TouchableOpacity>
|
|
146
|
-
|
|
147
|
-
<TouchableOpacity
|
|
148
|
-
style={[styles.button, isLoading && styles.buttonDisabled]}
|
|
149
|
-
onPress={handlePrintDivider}
|
|
150
|
-
disabled={isLoading}>
|
|
151
|
-
<Text style={styles.buttonText}>Print Divider</Text>
|
|
152
|
-
</TouchableOpacity>
|
|
153
|
-
|
|
154
|
-
<TouchableOpacity
|
|
155
|
-
style={[styles.button, isLoading && styles.buttonDisabled]}
|
|
156
|
-
onPress={handlePrintSampleReceipt}
|
|
157
|
-
disabled={isLoading}>
|
|
158
|
-
<Text style={styles.buttonText}>Print Sample Receipt</Text>
|
|
159
|
-
</TouchableOpacity>
|
|
160
|
-
|
|
161
|
-
<TouchableOpacity
|
|
162
|
-
style={[
|
|
163
|
-
styles.button,
|
|
164
|
-
styles.refreshButton,
|
|
165
|
-
isLoading && styles.buttonDisabled,
|
|
166
|
-
]}
|
|
167
|
-
onPress={checkPrinterAvailability}
|
|
168
|
-
disabled={isLoading}>
|
|
169
|
-
<Text style={styles.buttonText}>Refresh Printer Status</Text>
|
|
170
|
-
</TouchableOpacity>
|
|
171
|
-
</ScrollView>
|
|
172
|
-
);
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
const styles = StyleSheet.create({
|
|
176
|
-
container: {
|
|
177
|
-
flex: 1,
|
|
178
|
-
padding: 16,
|
|
179
|
-
backgroundColor: '#f5f5f5',
|
|
180
|
-
},
|
|
181
|
-
title: {
|
|
182
|
-
fontSize: 24,
|
|
183
|
-
fontWeight: 'bold',
|
|
184
|
-
marginBottom: 24,
|
|
185
|
-
textAlign: 'center',
|
|
186
|
-
},
|
|
187
|
-
statusContainer: {
|
|
188
|
-
flexDirection: 'row',
|
|
189
|
-
alignItems: 'center',
|
|
190
|
-
marginBottom: 24,
|
|
191
|
-
padding: 16,
|
|
192
|
-
backgroundColor: '#fff',
|
|
193
|
-
borderRadius: 8,
|
|
194
|
-
elevation: 2,
|
|
195
|
-
},
|
|
196
|
-
statusLabel: {
|
|
197
|
-
fontSize: 16,
|
|
198
|
-
fontWeight: 'bold',
|
|
199
|
-
marginRight: 8,
|
|
200
|
-
},
|
|
201
|
-
statusValue: {
|
|
202
|
-
fontSize: 16,
|
|
203
|
-
fontWeight: 'bold',
|
|
204
|
-
},
|
|
205
|
-
button: {
|
|
206
|
-
backgroundColor: '#2196F3',
|
|
207
|
-
padding: 16,
|
|
208
|
-
borderRadius: 8,
|
|
209
|
-
marginBottom: 16,
|
|
210
|
-
alignItems: 'center',
|
|
211
|
-
elevation: 2,
|
|
212
|
-
},
|
|
213
|
-
buttonDisabled: {
|
|
214
|
-
backgroundColor: '#cccccc',
|
|
215
|
-
},
|
|
216
|
-
buttonText: {
|
|
217
|
-
color: '#fff',
|
|
218
|
-
fontSize: 16,
|
|
219
|
-
fontWeight: 'bold',
|
|
220
|
-
},
|
|
221
|
-
refreshButton: {
|
|
222
|
-
backgroundColor: '#4CAF50',
|
|
223
|
-
},
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
export default PrinterExample;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import {createAsyncThunk} from '@reduxjs/toolkit';
|
|
2
|
-
import {handleFetchJsonResponse} from '../../api/responseHandlers';
|
|
3
|
-
import {post} from '../../api/serverHeaders';
|
|
4
|
-
import {RootState} from '../rootReducer';
|
|
5
|
-
import {extractServerError} from '../../api/errorHandler';
|
|
6
|
-
|
|
7
|
-
export const getCategories = createAsyncThunk(
|
|
8
|
-
'categories/list',
|
|
9
|
-
async (
|
|
10
|
-
{data: {limit}}: {data: {limit?: number}},
|
|
11
|
-
{rejectWithValue, getState, dispatch}: any,
|
|
12
|
-
) => {
|
|
13
|
-
try {
|
|
14
|
-
const token = (getState() as RootState).user.accessToken;
|
|
15
|
-
|
|
16
|
-
const response = await post({
|
|
17
|
-
url: 'serviceMangement/Category/get_categories',
|
|
18
|
-
data: {limit},
|
|
19
|
-
config: {
|
|
20
|
-
headers: {
|
|
21
|
-
Authorization: `${token}`,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
return handleFetchJsonResponse(response);
|
|
27
|
-
} catch (e: any) {
|
|
28
|
-
// Extract the server error from the Axios error
|
|
29
|
-
const serverError = extractServerError(e);
|
|
30
|
-
return rejectWithValue(serverError);
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
);
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import {createSlice} from '@reduxjs/toolkit';
|
|
2
|
-
import {newState} from '../../../common/utils/newState';
|
|
3
|
-
import {handleErrorResponse} from '../../api/responseHandlers';
|
|
4
|
-
import {getCategories} from './categoryActions';
|
|
5
|
-
import {
|
|
6
|
-
CategoriesInitialState,
|
|
7
|
-
CategoriesState,
|
|
8
|
-
Category,
|
|
9
|
-
CategoryPayload,
|
|
10
|
-
} from './categoryState';
|
|
11
|
-
import {LoadState} from '../../../../types';
|
|
12
|
-
|
|
13
|
-
function getCategoriesHandler(
|
|
14
|
-
state: CategoriesState,
|
|
15
|
-
payload: {payload: CategoryPayload},
|
|
16
|
-
) {
|
|
17
|
-
return newState(state, {
|
|
18
|
-
categories: payload.payload.categories,
|
|
19
|
-
settings: payload.payload.settings,
|
|
20
|
-
loadState: LoadState.allIsLoaded,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
function getCategoriesLoadingHandler(state: CategoriesState) {
|
|
24
|
-
return newState(state, {
|
|
25
|
-
loadState: LoadState.loadingMore,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function getCategoriesErrorHandler(
|
|
30
|
-
state: CategoriesState,
|
|
31
|
-
payload: {payload: {message: string}},
|
|
32
|
-
) {
|
|
33
|
-
handleErrorResponse(payload.payload.message || 'Categories fetch failed');
|
|
34
|
-
return newState(state, {
|
|
35
|
-
loadState: LoadState.error,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function categoriesLogoutHandler(state: CategoriesState) {
|
|
40
|
-
return newState(state, CategoriesInitialState);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function selectedCategoryHandler(
|
|
44
|
-
state: CategoriesState,
|
|
45
|
-
payload: {payload: Category},
|
|
46
|
-
) {
|
|
47
|
-
return newState(state, {
|
|
48
|
-
selectedCategory: payload.payload,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function clearSelectedCategoryHandler(state: CategoriesState) {
|
|
53
|
-
return newState(state, {
|
|
54
|
-
selectedCategory: CategoriesInitialState.selectedCategory,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const {reducer: CategoriesReducer, actions} = createSlice({
|
|
59
|
-
name: 'categories',
|
|
60
|
-
initialState: CategoriesInitialState,
|
|
61
|
-
reducers: {
|
|
62
|
-
setCategoriesLogout: categoriesLogoutHandler,
|
|
63
|
-
setSelectedCategory: selectedCategoryHandler,
|
|
64
|
-
clearSelectedCategory: clearSelectedCategoryHandler,
|
|
65
|
-
},
|
|
66
|
-
extraReducers: builder => {
|
|
67
|
-
builder
|
|
68
|
-
.addCase(getCategories.fulfilled, getCategoriesHandler)
|
|
69
|
-
.addCase(getCategories.rejected, getCategoriesErrorHandler)
|
|
70
|
-
.addCase(getCategories.pending, getCategoriesLoadingHandler);
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
export const {setCategoriesLogout, setSelectedCategory, clearSelectedCategory} =
|
|
75
|
-
actions;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import {LoadState} from '../../../../types';
|
|
2
|
-
|
|
3
|
-
export type PosSettings = {
|
|
4
|
-
id: number;
|
|
5
|
-
name: string;
|
|
6
|
-
function_name: string;
|
|
7
|
-
is_active: boolean;
|
|
8
|
-
createdAt: string;
|
|
9
|
-
updatedAt: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export interface CategoriesState {
|
|
13
|
-
categories: Category[];
|
|
14
|
-
loadState: LoadState;
|
|
15
|
-
settings: PosSettings[];
|
|
16
|
-
selectedCategory: Category | null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface Category {
|
|
20
|
-
createdAt?: string | null;
|
|
21
|
-
externalId?: null;
|
|
22
|
-
id: number;
|
|
23
|
-
img_url: string;
|
|
24
|
-
name: string;
|
|
25
|
-
name_en?: string | null;
|
|
26
|
-
parent_id: number;
|
|
27
|
-
priority: number;
|
|
28
|
-
updatedAt: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface CategoryPayload {
|
|
32
|
-
categories: Category[];
|
|
33
|
-
settings: PosSettings[];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const CategoriesInitialState: CategoriesState = {
|
|
37
|
-
categories: [],
|
|
38
|
-
loadState: LoadState.idle,
|
|
39
|
-
settings: [],
|
|
40
|
-
selectedCategory: null,
|
|
41
|
-
};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import {createAsyncThunk} from '@reduxjs/toolkit';
|
|
2
|
-
import {handleFetchJsonResponse} from '../../api/responseHandlers';
|
|
3
|
-
import {get, post} from '../../api/serverHeaders';
|
|
4
|
-
import {RootState} from '../rootReducer';
|
|
5
|
-
import {extractServerError} from '../../api/errorHandler';
|
|
6
|
-
import {ensureString} from '../../utils/stringUtils';
|
|
7
|
-
|
|
8
|
-
export const getProviders = createAsyncThunk(
|
|
9
|
-
'providers/getProviders',
|
|
10
|
-
async (
|
|
11
|
-
{
|
|
12
|
-
data: {limit, category_id},
|
|
13
|
-
}: {data: {limit?: number; category_id?: number}},
|
|
14
|
-
{rejectWithValue, getState, dispatch}: any,
|
|
15
|
-
) => {
|
|
16
|
-
try {
|
|
17
|
-
const token = (getState() as RootState).user.accessToken;
|
|
18
|
-
|
|
19
|
-
const response = await post({
|
|
20
|
-
url: 'serviceProvider_category',
|
|
21
|
-
data: {limit, category_id},
|
|
22
|
-
config: {
|
|
23
|
-
headers: {
|
|
24
|
-
Authorization: `${token}`,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
return handleFetchJsonResponse(response);
|
|
30
|
-
} catch (e: any) {
|
|
31
|
-
const serverError = extractServerError(e);
|
|
32
|
-
|
|
33
|
-
return rejectWithValue({
|
|
34
|
-
...serverError,
|
|
35
|
-
message: ensureString(serverError.message),
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
export const getProviderById = createAsyncThunk(
|
|
42
|
-
'providers/getProviderById',
|
|
43
|
-
async (
|
|
44
|
-
{data: {BillerId}}: {data: {BillerId?: number}},
|
|
45
|
-
{rejectWithValue, getState, dispatch}: any,
|
|
46
|
-
) => {
|
|
47
|
-
try {
|
|
48
|
-
const token = (getState() as RootState).user.accessToken;
|
|
49
|
-
|
|
50
|
-
const response = await get({
|
|
51
|
-
url: `serviceMangement/get-single-provider/${BillerId}`,
|
|
52
|
-
config: {
|
|
53
|
-
headers: {
|
|
54
|
-
Authorization: `${token}`,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
return handleFetchJsonResponse(response);
|
|
60
|
-
} catch (e: any) {
|
|
61
|
-
const serverError = extractServerError(e);
|
|
62
|
-
|
|
63
|
-
return rejectWithValue({
|
|
64
|
-
...serverError,
|
|
65
|
-
message: ensureString(serverError.message),
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
export const getHomeProviders = createAsyncThunk(
|
|
72
|
-
'providers/getHomeProviders',
|
|
73
|
-
async (
|
|
74
|
-
{
|
|
75
|
-
data: {limit, category_id},
|
|
76
|
-
}: {data: {limit?: number; category_id?: number}},
|
|
77
|
-
{rejectWithValue, getState, dispatch}: any,
|
|
78
|
-
) => {
|
|
79
|
-
try {
|
|
80
|
-
const token = (getState() as RootState).user.accessToken;
|
|
81
|
-
|
|
82
|
-
const response = await post({
|
|
83
|
-
url: 'serviceProvider_category',
|
|
84
|
-
data: {limit, category_id},
|
|
85
|
-
config: {
|
|
86
|
-
headers: {
|
|
87
|
-
Authorization: `${token}`,
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
return handleFetchJsonResponse(response);
|
|
93
|
-
} catch (e: any) {
|
|
94
|
-
const serverError = extractServerError(e);
|
|
95
|
-
|
|
96
|
-
return rejectWithValue({
|
|
97
|
-
...serverError,
|
|
98
|
-
message: ensureString(serverError.message),
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
);
|