@jescon-technologies/react-native-ui-kit 0.0.3 → 0.0.5

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.
Files changed (177) hide show
  1. package/index.d.ts +66 -0
  2. package/index.js +0 -4
  3. package/package.json +3 -34
  4. package/src/Alerts/AAlert.js +3 -3
  5. package/src/Alerts/AAlertIOS.js +3 -3
  6. package/src/{common → Common}/NetworkServiceCall.js +1 -1
  7. package/src/CommonStyle/CommonTheme.js +11 -0
  8. package/src/CommonStyle/ComponentFunctions.js +632 -0
  9. package/src/CommonStyle/PopupStyle.js +146 -0
  10. package/src/CommonStyle/commonStyle.js +93 -0
  11. package/src/CommonStyle/componentStyle.js +545 -0
  12. package/src/CommonStyle/optionListStyles.js +175 -0
  13. package/src/Components/ByProductPage.js +200 -0
  14. package/src/Components/CDropDownListNew.js +153 -0
  15. package/src/Components/CSupplierList.js +88 -0
  16. package/src/Components/CVerificationCard.js +2822 -0
  17. package/src/Components/CustomButton.js +67 -0
  18. package/src/Components/CustomCard.js +127 -0
  19. package/src/Components/CustomTextInput.js +47 -0
  20. package/src/Components/EquipmentPage.js +313 -0
  21. package/src/Components/FilterInput.Copy.js +723 -0
  22. package/src/Components/FilterInput.js +569 -0
  23. package/src/Components/HSubHeading.js +68 -0
  24. package/src/Components/HeaderCard.js +40 -0
  25. package/src/Components/MoreOptionsScreen.js +251 -0
  26. package/src/Components/NonSwipableProductCard.js +226 -0
  27. package/src/Components/NonSwipableSupplierCard.js +348 -0
  28. package/src/Components/ProductCard.js +1336 -0
  29. package/src/Components/QualityProductCard.js +1059 -0
  30. package/src/Components/RateProductCard.js +1452 -0
  31. package/src/Components/RawMaterial.js +261 -0
  32. package/src/Components/SDropDownEdited.js +549 -0
  33. package/src/Components/SDropDownNew.js +529 -0
  34. package/src/Components/SHelpDescription.js +147 -0
  35. package/src/Components/STextInputNew.js +510 -0
  36. package/src/Components/SearchProductCard.js +470 -0
  37. package/src/Components/StageByProduct.js +199 -0
  38. package/src/Components/SupplierCard.js +243 -0
  39. package/src/Components/SupplierInvoiceCard.js +405 -0
  40. package/src/Components/SwipableSupplierCard.js +136 -0
  41. package/src/Components/TagTemplate.js +74 -0
  42. package/src/Components/WrappedComponent.js +25 -0
  43. package/src/Custom/CBooking.js +944 -0
  44. package/src/Custom/CBookingPostpone.js +1822 -0
  45. package/src/Custom/CCalendar.js +560 -0
  46. package/src/Custom/CCard.js +880 -0
  47. package/src/Custom/CDetailCard.js +205 -0
  48. package/src/Custom/CHelpImage.js +52 -0
  49. package/src/Custom/CReport.js +569 -0
  50. package/src/Custom/CScrollView.js +73 -0
  51. package/src/Custom/CSignature.js +112 -0
  52. package/src/Custom/CSliderMenu.js +339 -0
  53. package/src/Custom/CSupplierCard.js +99 -0
  54. package/src/Custom/CTemplateCard.js +438 -0
  55. package/src/Custom/CTokenAllocation.js +1402 -0
  56. package/src/Custom/CTokenListOverlay.js +122 -0
  57. package/src/Custom/CWardStatus.js +444 -0
  58. package/src/Custom/Charts/CBarChart.js +218 -0
  59. package/src/Custom/Charts/CDashBoardList.js +133 -0
  60. package/src/Custom/Charts/CDashBoardTable.js +172 -0
  61. package/src/Custom/Charts/CLineChart.js +193 -0
  62. package/src/Custom/Charts/CPieChart.js +186 -0
  63. package/src/Custom/Loader.js +182 -0
  64. package/src/Custom/OUserView.js +1121 -0
  65. package/src/Custom/PreviewDosage.js +115 -0
  66. package/src/Custom/SearchLoader.js +32 -0
  67. package/src/Custom/TableComponent/CActivityTable.js +707 -0
  68. package/src/Custom/TableComponent/CMoreButtonTable.js +197 -0
  69. package/src/Custom/TableComponent/CTable.js +185 -0
  70. package/src/Custom/TableComponent/CTextBody.js +40 -0
  71. package/src/Custom/TableComponent/CTextHeader.js +17 -0
  72. package/src/Custom/TableComponent/PreviewPrescriptionNew.js +1011 -0
  73. package/src/Custom/TableComponent/SDropdownTable.js +491 -0
  74. package/src/Custom/TableComponent/TagTable.js +1200 -0
  75. package/src/CustomComponents/CAddColumn.js +140 -0
  76. package/src/CustomComponents/CAssessmentDelete.js +307 -0
  77. package/src/CustomComponents/CAwesomeButton.js +83 -0
  78. package/src/CustomComponents/CAwesomeMoreButton.js +54 -0
  79. package/src/CustomComponents/CBackHandler.js +273 -0
  80. package/src/CustomComponents/CCalendar.js +243 -0
  81. package/src/CustomComponents/CCommentOverlay.js +202 -0
  82. package/src/CustomComponents/CComments.js +162 -0
  83. package/src/CustomComponents/CContainerView.js +24 -0
  84. package/src/CustomComponents/CCustomTextInput.js +336 -0
  85. package/src/CustomComponents/CDetailView.js +40 -0
  86. package/src/CustomComponents/CDropDownList.js +153 -0
  87. package/src/CustomComponents/CDropdownSelect.js +555 -0
  88. package/src/CustomComponents/CFooterView.js +42 -0
  89. package/src/CustomComponents/CImagePickerSave.js +316 -0
  90. package/src/CustomComponents/CModalOverlay.js +91 -0
  91. package/src/CustomComponents/CNetworkStatus.js +327 -0
  92. package/src/CustomComponents/CNotesInstructions.js +1000 -0
  93. package/src/CustomComponents/COverlay.js +81 -0
  94. package/src/CustomComponents/CRemarks.js +176 -0
  95. package/src/CustomComponents/CRowAdd.js +143 -0
  96. package/src/CustomComponents/CSummaryDropDown.js +327 -0
  97. package/src/CustomComponents/CText.js +9 -0
  98. package/src/CustomComponents/CVectorIcon.js +34 -0
  99. package/src/CustomComponents/HtmlContentViewer.js +65 -0
  100. package/src/CustomComponents/PdfContentViewer.js +90 -0
  101. package/src/CustomComponents/SDropDownDosage.js +1087 -0
  102. package/src/CustomComponents/SwipableProductCard.js +246 -0
  103. package/src/CustomComponents/SwipableProductImageCard.js +254 -0
  104. package/src/CustomComponents/WorkOrderDetails.js +1216 -0
  105. package/src/CustomComponents/WorkOrderDetailsPage.js +1213 -0
  106. package/src/HOC/ConfirmOverlay.js +2 -2
  107. package/src/HOC/HMoreButton.js +1 -1
  108. package/src/HOC/HNatureHeading.js +1 -1
  109. package/src/HOC/HShadowButton.js +1 -1
  110. package/src/HOC/HShadowCountButton.js +1 -1
  111. package/src/Json/Chart.json +818 -0
  112. package/src/Json/Consultation.json +622 -0
  113. package/src/Json/CreditBill.json +490 -0
  114. package/src/Json/Dropdown.json +216 -0
  115. package/src/Json/DropdownConsultation.json +228 -0
  116. package/src/Json/DynamicReports.json +623 -0
  117. package/src/Json/Footer.json +79 -0
  118. package/src/Media/AudioScreen.js +2 -7
  119. package/src/Media/CCaptureImageWithoutEdit.js +1 -1
  120. package/src/Media/CImageGallery.js +2 -2
  121. package/src/Media/CSingleImage.js +2 -2
  122. package/src/Media/CVideoPlay.js +1 -1
  123. package/src/Media/DocumentScreen.js +2 -7
  124. package/src/Media/DrawingScreen.js +2 -6
  125. package/src/Media/ImageScreen.js +2 -6
  126. package/src/Media/VideoScreen.js +2 -7
  127. package/src/Navigation/PageNavigation.js +224 -0
  128. package/src/Navigation/useFocusEffect.js +2 -0
  129. package/src/Navigation/useFocusEffect.native.js +1 -0
  130. package/src/Navigation/useFocusEffect.web.js +1 -0
  131. package/src/Navigation/useIsFocused.js +1 -0
  132. package/src/Navigation/useIsFocused.native.js +1 -0
  133. package/src/Navigation/useIsFocused.web.js +1 -0
  134. package/src/Navigation/useNavigation.js +2 -0
  135. package/src/Navigation/useNavigation.native.js +1 -0
  136. package/src/Navigation/useNavigation.web.js +1 -0
  137. package/src/Screens/CMedications.js +528 -0
  138. package/src/Screens/CWebViewGallery.js +203 -0
  139. package/src/Screens/ChartScan.js +279 -0
  140. package/src/Screens/ChartScreenNew.js +1579 -0
  141. package/src/Screens/Consultation.js +1500 -0
  142. package/src/Screens/Dashboard.js +778 -0
  143. package/src/Screens/FileExplorer.js +288 -0
  144. package/src/Screens/Footer.js +340 -0
  145. package/src/Screens/ForgotPassword.js +288 -0
  146. package/src/Screens/HeaderBlock.js +353 -0
  147. package/src/Screens/Login.js +328 -0
  148. package/src/Screens/Notification.js +149 -0
  149. package/src/Screens/OcrScreen.js +20 -0
  150. package/src/Screens/PdfPreview.js +507 -0
  151. package/src/Screens/RegistrationDetails.js +467 -0
  152. package/src/Screens/SearchScreen.js +582 -0
  153. package/src/Screens/Splash.js +788 -0
  154. package/src/Screens/SwipeLeftView.js +1867 -0
  155. package/src/StaticComponents/SDatePickerLabel.js +1 -1
  156. package/src/StaticComponents/SDatePickerNew.js +1 -1
  157. package/src/StaticComponents/SDateTimePickerNew.js +2 -2
  158. package/src/StaticComponents/SDropDownGenerate.js +3 -3
  159. package/src/StaticComponents/SDropDownHoc.js +4 -4
  160. package/src/StaticComponents/SDropDownIcon.js +1 -1
  161. package/src/StaticComponents/SMenuBox.js +2 -2
  162. package/src/StaticComponents/SSearch.js +2 -2
  163. package/src/StaticComponents/STextInput.js +1 -1
  164. package/src/StaticComponents/STimePicker.js +1 -1
  165. package/src/StaticComponents/STimingDropDownNew.js +2 -6
  166. package/src/StaticComponents/STimingSwitch.js +1 -1
  167. package/src/layout/CContainerView.js +1 -1
  168. package/src/layout/CDetailView.js +3 -3
  169. package/src/layout/HeaderBlock.js +5 -5
  170. package/src/layout/INVLoginLayout.js +3 -4
  171. package/src/layout/Loader.js +2 -2
  172. package/src/HOC/HAbsolute.js +0 -56
  173. package/src/HOC/HDiscontinue.js +0 -105
  174. package/src/HOC/HOverlay.js +0 -99
  175. package/src/layout/FooterBlock.js +0 -821
  176. /package/src/{common → Common}/ErrorBoundary.tsx +0 -0
  177. /package/src/{common → Common}/Icons.js +0 -0
@@ -0,0 +1,1336 @@
1
+ import { View, Text, Dimensions, TouchableOpacity, FlatList } from 'react-native';
2
+ import React, { useCallback, useContext, useEffect, useState, useMemo } from 'react';
3
+ import ContextBio from '../ContextAPI/ContextBio';
4
+ import { normalize } from '../CommonStyle/componentStyle';
5
+ import { useNavigation } from '../Navigation/useNavigation';
6
+
7
+ //gggggggggggggggggggggggggggggggggggg
8
+ import CTextHeader from '../Custom/TableComponent/CTextHeader';
9
+ import { ScrollView, TouchableWithoutFeedback } from 'react-native';
10
+ import SDropDownNew from '../Components/SDropDownNew';
11
+
12
+ import { Icons } from '@jescon-technologies/react-native-ui-kit';;
13
+ import {
14
+ CButtonShadow,
15
+ isNUQ,
16
+ notifyMessage,
17
+ } from '../CommonStyle/ComponentFunctions';
18
+ import SCheckBox from '../StaticComponents/SCheckBox';
19
+ import SOverlay from '../StaticComponents/SOverlay';
20
+ import { Global } from '../../../../../src/Common/Global';
21
+ import STextInputNew from './STextInputNew';
22
+ import { SwipeRow } from 'react-native-swipe-list-view';
23
+ import HOCIcons from '../HOC/HOCIcons';
24
+
25
+ const BatchRow = ({
26
+ batchdata,
27
+ idx,
28
+ sectionIndex,
29
+ productIndex,
30
+ orderIndex,
31
+ verifyData,
32
+ updateData,
33
+ supplierdata,
34
+ productdata,
35
+ item,
36
+ onBatchUpdate,
37
+ onBatchDelete,
38
+ onNavigation,
39
+ onMediaUpdate,
40
+ onBatchVerify,
41
+ onFreeQuantityUpdate,
42
+ }) => {
43
+ const { setSearchSelect } = useContext(ContextBio);
44
+ const navigation = useNavigation();
45
+ const [recievedQuantity, setRecievedQuantity] = useState(batchdata.quantity || 0);
46
+ const [FilesData, setFilesData] = useState({
47
+ savedaudio: [],
48
+ saveddoc: [],
49
+ savedimages: [],
50
+ savedvideo: [],
51
+ savedpdf: [],
52
+ });
53
+
54
+ // Update local state when batchdata changes
55
+ useEffect(() => {
56
+ setRecievedQuantity(batchdata.quantity || 0);
57
+ }, [batchdata.quantity]);
58
+
59
+ const handleQuantityChange = (val) => {
60
+ const numVal = Number(val);
61
+ setRecievedQuantity(numVal);
62
+ onBatchUpdate('quantity', sectionIndex, productIndex, orderIndex, idx, numVal);
63
+ };
64
+
65
+ const handleFreeQuantityChange = (val) => {
66
+ onFreeQuantityUpdate(sectionIndex, productIndex, orderIndex, idx, val);
67
+ };
68
+
69
+ const handleBatchNameChange = (val) => {
70
+ onBatchUpdate('batchname', sectionIndex, productIndex, orderIndex, idx, val.replace(/\s/g, ''));
71
+ };
72
+
73
+ const handlePackingChange = (val) => {
74
+ onBatchUpdate('packing', sectionIndex, productIndex, orderIndex, idx, val);
75
+ };
76
+
77
+ const handleVerifyChange = (val) => {
78
+ onBatchVerify(sectionIndex, productIndex, orderIndex, idx, val);
79
+ };
80
+
81
+ const handleMediaChange = (val) => {
82
+ setFilesData(val);
83
+ onMediaUpdate(sectionIndex, productIndex, orderIndex, idx, val);
84
+ };
85
+
86
+ const handleDelete = () => {
87
+ onBatchDelete(sectionIndex, productIndex, orderIndex, idx);
88
+ };
89
+
90
+ const handleNavigation = () => {
91
+ if (!(updateData === true && batchdata.flag === 3)) {
92
+ onNavigation(false, batchdata.batchname, batchdata.batchcode, item.productname, orderIndex, idx);
93
+ }
94
+ };
95
+
96
+ const getLength = (params) => {
97
+ if (!Array.isArray(params) || params.length === 0) {
98
+ return 0;
99
+ }
100
+
101
+ const lastItem = params[params.length - 1];
102
+ if (lastItem?.insuproductfree === 0 || lastItem?.insuproductfree === '') {
103
+ return params.length - 1;
104
+ }
105
+
106
+ return params.length;
107
+ };
108
+
109
+ const isEditable = !(verifyData === true || (updateData === true && batchdata.flag === 3));
110
+
111
+ const freeProductsCount = getLength(batchdata.productquantityentry);
112
+ const totalQuantity = Number(batchdata?.totalquantity) || 0;
113
+
114
+ const packingQuantity = batchdata.packingquantity != undefined &&
115
+ batchdata.packingquantity != null &&
116
+ batchdata.packingquantity != '' &&
117
+ !isNaN(batchdata.packingquantity)
118
+ ? Number(batchdata.packingquantity).toFixed(0)
119
+ : '';
120
+
121
+ return (
122
+ <View
123
+ style={{
124
+ flexDirection: 'row',
125
+ marginTop: normalize(1.5),
126
+ backgroundColor: 'white',
127
+ }}>
128
+ {verifyData !== true && updateData === true && batchdata.flag === 3 && (
129
+ <View
130
+ style={{
131
+ height: 1,
132
+ backgroundColor: 'red',
133
+ width: '100%',
134
+ marginVertical: 10,
135
+ position: 'absolute',
136
+ zIndex: 999,
137
+ top: 12,
138
+ }}
139
+ />
140
+ )}
141
+
142
+ {/* Delete Column */}
143
+ <View>
144
+ {verifyData !== true && (
145
+ <CTextHeader
146
+ text={''}
147
+ widthArr={Dimensions.get('screen').width * 0.036}
148
+ bgColor={'rgba(184, 184, 191,0.3)'}
149
+ color={'#094485'}
150
+ borderColor={'white'}
151
+ marginHorizontal={normalize(2)}
152
+ borderRadius={5}
153
+ elevation={0}
154
+ />
155
+ )}
156
+ {verifyData !== true && (
157
+ <TouchableOpacity
158
+ style={{
159
+ elevation: 0,
160
+ borderRadius: 5,
161
+ fontWeight: 'bold',
162
+ color: 'black',
163
+ width: Dimensions.get('screen').width * 0.036,
164
+ paddingTop: 5,
165
+ paddingBottom: 5,
166
+ height: Dimensions.get('screen').height * 0.055,
167
+ textAlign: 'center',
168
+ marginTop: normalize(2),
169
+ marginHorizontal: normalize(3),
170
+ justifyContent: 'center',
171
+ alignItems: 'center',
172
+ }}
173
+ onPress={handleDelete}>
174
+ <Icons.FontAwesome5
175
+ name="trash"
176
+ color="#094485"
177
+ size={normalize(13)}
178
+ />
179
+ </TouchableOpacity>
180
+ )}
181
+ </View>
182
+
183
+ {/* Batch Name */}
184
+ <View>
185
+ <CTextHeader
186
+ text={'BATCH'}
187
+ fontSize={10}
188
+ text2={verifyData !== true ? '*' : ''}
189
+ color2={verifyData !== true ? 'red' : ''}
190
+ fontSize2={11}
191
+ widthArr={Dimensions.get('screen').width * 0.26}
192
+ bgColor={'rgba(184, 184, 191,0.3)'}
193
+ color={'#094485'}
194
+ borderColor={'lightgrey'}
195
+ marginHorizontal={normalize(2)}
196
+ borderRadius={5}
197
+ elevation={0}
198
+ />
199
+ <STextInputNew
200
+ data={{
201
+ borderWidth: 1,
202
+ value: batchdata.batchname,
203
+ borderColor: 'lightgrey',
204
+ elevation: 0,
205
+ borderRadius: 5,
206
+ fontWeight: 'bold',
207
+ color: 'black',
208
+ itemwidth: Dimensions.get('screen').width * 0.26,
209
+ paddingTop: 5,
210
+ paddingBottom: 5,
211
+ height: Dimensions.get('screen').height * 0.054,
212
+ textAlign: 'center',
213
+ marginTop: normalize(2),
214
+ marginHorizontal: normalize(2),
215
+ editable: verifyData === true ? false : isEditable,
216
+ }}
217
+ callBack={handleBatchNameChange}
218
+ />
219
+ </View>
220
+
221
+ {/* Packing */}
222
+ <View>
223
+ <CTextHeader
224
+ text={'PACKING'}
225
+ fontSize={10}
226
+ text2={verifyData !== true ? '*' : ''}
227
+ color2={verifyData !== true ? 'red' : ''}
228
+ fontSize2={11}
229
+ widthArr={Dimensions.get('screen').width * 0.26}
230
+ bgColor={'rgba(184, 184, 191,0.3)'}
231
+ color={'#094485'}
232
+ borderColor={'lightgrey'}
233
+ marginHorizontal={normalize(2)}
234
+ borderRadius={5}
235
+ elevation={0}
236
+ />
237
+ <TouchableWithoutFeedback
238
+ onPress={() => {
239
+ if (verifyData !== true) {
240
+ setSearchSelect(3);
241
+ }
242
+ }}>
243
+ <SDropDownNew
244
+ fontSize={normalize(11)}
245
+ fontWeight={'bold'}
246
+ widthArr={Dimensions.get('screen').width * 0.26}
247
+ heightArr={Dimensions.get('screen').height * 0.056}
248
+ dropdowndata={
249
+ updateData === true
250
+ ? batchdata.packing
251
+ : batchdata.dropdowndata?.[0]?.displayvalue || batchdata.packing
252
+ }
253
+ dropdownapi={
254
+ 'invget/invcommonget/rndddwdropdownselect 1,' +
255
+ 22401 +
256
+ ',' +
257
+ Global.userData.susectiondetail +
258
+ ',' +
259
+ Global.userData.suuser +
260
+ ',' +
261
+ supplierdata.insusupplier +
262
+ ',' +
263
+ productdata.insuproduct +
264
+ ',1'
265
+ }
266
+ onChangeData={handlePackingChange}
267
+ editable={true}
268
+ disabled={!isEditable}
269
+ refreshCount={val =>
270
+ val == undefined
271
+ ? setRefresh(refresh + 1)
272
+ : null
273
+ }
274
+ />
275
+ </TouchableWithoutFeedback>
276
+ </View>
277
+
278
+ {/* Packing Quantity */}
279
+ <View>
280
+ <CTextHeader
281
+ text={'PACKING QUANTITY'}
282
+ fontSize={10}
283
+ widthArr={Dimensions.get('screen').width * 0.26}
284
+ bgColor={'rgba(184, 184, 191,0.3)'}
285
+ color={'#094485'}
286
+ borderColor={'lightgrey'}
287
+ marginHorizontal={normalize(2)}
288
+ borderRadius={5}
289
+ elevation={0}
290
+ />
291
+ <STextInputNew
292
+ data={{
293
+ borderWidth: 1,
294
+ borderColor: 'lightgrey',
295
+ elevation: 0,
296
+ borderRadius: 5,
297
+ fontWeight: 'bold',
298
+ color: 'black',
299
+ itemwidth: Dimensions.get('screen').width * 0.26,
300
+ paddingTop: 5,
301
+ paddingBottom: 5,
302
+ height: Dimensions.get('screen').height * 0.054,
303
+ textAlign: 'center',
304
+ marginTop: normalize(2),
305
+ marginHorizontal: normalize(2),
306
+ value: packingQuantity,
307
+ editable: false,
308
+ }}
309
+ fontWeight={'bold'}
310
+ fontSize={normalize(11)}
311
+ />
312
+ </View>
313
+
314
+ {/* Quantity */}
315
+ <View>
316
+ <CTextHeader
317
+ text={'QUANTITY'}
318
+ fontSize={10}
319
+ text2={verifyData !== true ? '*' : ''}
320
+ color2={verifyData !== true ? 'red' : ''}
321
+ fontSize2={11}
322
+ widthArr={Dimensions.get('screen').width * 0.26}
323
+ bgColor={'rgba(184, 184, 191,0.3)'}
324
+ color={'#094485'}
325
+ borderColor={'lightgrey'}
326
+ marginHorizontal={normalize(2)}
327
+ borderRadius={5}
328
+ elevation={0}
329
+ />
330
+ <STextInputNew
331
+ data={{
332
+ borderWidth: 1,
333
+ borderColor: 'lightgrey',
334
+ elevation: 0,
335
+ borderRadius: 5,
336
+ fontWeight: 'bold',
337
+ color: recievedQuantity > batchdata.orderquantity ? 'red' : 'black',
338
+ itemwidth: Dimensions.get('screen').width * 0.26,
339
+ paddingTop: 5,
340
+ paddingBottom: 5,
341
+ height: Dimensions.get('screen').height * 0.054,
342
+ textAlign: 'center',
343
+ marginTop: normalize(2),
344
+ marginHorizontal: normalize(2),
345
+ value: batchdata.quantity,
346
+ editable: isEditable,
347
+ }}
348
+ callBack={handleQuantityChange}
349
+ keyboardType={'numeric'}
350
+ />
351
+ </View>
352
+
353
+ {/* Total Quantity */}
354
+ <View>
355
+ <CTextHeader
356
+ text={'TOTAL QUANTITY'}
357
+ fontSize={10}
358
+ widthArr={Dimensions.get('screen').width * 0.26}
359
+ bgColor={'rgba(184, 184, 191,0.3)'}
360
+ color={'#094485'}
361
+ borderColor={'lightgrey'}
362
+ marginHorizontal={normalize(2)}
363
+ borderRadius={5}
364
+ elevation={0}
365
+ />
366
+ <View
367
+ style={{
368
+ borderWidth: 1,
369
+ borderColor: 'lightgrey',
370
+ elevation: 0,
371
+ borderRadius: 5,
372
+ width: Dimensions.get('screen').width * 0.26,
373
+ paddingTop: 5,
374
+ paddingBottom: 5,
375
+ height: Dimensions.get('screen').height * 0.056,
376
+ alignItems: 'flex-start',
377
+ justifyContent: 'center',
378
+ paddingHorizontal: normalize(10),
379
+ }}>
380
+ <Text
381
+ style={{
382
+ fontWeight: 'bold',
383
+ color: 'black',
384
+ fontSize: normalize(11),
385
+ }}>
386
+ {totalQuantity}
387
+ </Text>
388
+ </View>
389
+ </View>
390
+
391
+ {/* Free Quantity */}
392
+ <View>
393
+ <CTextHeader
394
+ text={'FREE QUANTITY'}
395
+ fontSize={10}
396
+ widthArr={Dimensions.get('screen').width * 0.26}
397
+ bgColor={'rgba(184, 184, 191,0.3)'}
398
+ color={'#094485'}
399
+ borderColor={'lightgrey'}
400
+ marginHorizontal={normalize(2)}
401
+ borderRadius={5}
402
+ elevation={0}
403
+ />
404
+ <STextInputNew
405
+ data={{
406
+ borderWidth: 1,
407
+ borderColor: 'lightgrey',
408
+ elevation: 0,
409
+ borderRadius: 5,
410
+ fontWeight: 'bold',
411
+ color: 'black',
412
+ itemwidth: Dimensions.get('screen').width * 0.26,
413
+ paddingTop: 5,
414
+ paddingBottom: 5,
415
+ height: Dimensions.get('screen').height * 0.054,
416
+ textAlign: 'center',
417
+ marginTop: normalize(2),
418
+ marginHorizontal: normalize(2),
419
+ value: batchdata.freequantity,
420
+ editable: isEditable,
421
+ }}
422
+ callBack={handleFreeQuantityChange}
423
+ keyboardType={'numeric'}
424
+ />
425
+ </View>
426
+
427
+ {/* Media */}
428
+ <View>
429
+ <CTextHeader
430
+ text={'MEDIA'}
431
+ fontSize={10}
432
+ widthArr={Dimensions.get('screen').width * 0.26}
433
+ bgColor={'rgba(184, 184, 191,0.3)'}
434
+ color={'#094485'}
435
+ borderColor={'lightgrey'}
436
+ marginHorizontal={normalize(2)}
437
+ borderRadius={5}
438
+ elevation={0}
439
+ />
440
+ <View
441
+ style={{
442
+ width: Dimensions.get('screen').width * 0.26,
443
+ height: Dimensions.get('screen').height * 0.056,
444
+ justifyContent: 'center',
445
+ alignItems: 'center',
446
+ borderWidth: 1,
447
+ borderRadius: 5,
448
+ borderColor: 'lightgrey',
449
+ }}>
450
+ <TouchableOpacity
451
+ style={{ marginHorizontal: normalize(5) }}
452
+ onPress={() => {
453
+ navigation.navigate('FileExplorer', {
454
+ visibility: 0,
455
+ data: batchdata.media?.map(item => ({
456
+ ...item,
457
+ savedimages: item.savedimages ? item.savedimages.split(',') : [],
458
+ savedvideo: item.savedvideo ? item.savedvideo.split(',') : [],
459
+ savedaudio: item.savedaudio ? item.savedaudio.split(',') : [],
460
+ savedpdf: item.savedpdf ? item.saveddoc.split(',') : [],
461
+ })) || [],
462
+ callBack: handleMediaChange,
463
+ });
464
+ }}>
465
+ <Icons.FontAwesome5
466
+ name="play"
467
+ color="#094485"
468
+ size={normalize(15)}
469
+ />
470
+ </TouchableOpacity>
471
+ </View>
472
+ </View>
473
+
474
+ {/* Verify Checkbox */}
475
+ {verifyData === true && (
476
+ <View>
477
+ <CTextHeader
478
+ text={'VERIFY'}
479
+ widthArr={Dimensions.get('screen').width * 0.26}
480
+ bgColor={'rgba(184, 184, 191,0.3)'}
481
+ color={'#094485'}
482
+ borderColor={'lightgrey'}
483
+ marginHorizontal={normalize(2)}
484
+ borderRadius={5}
485
+ elevation={0}
486
+ />
487
+ <View
488
+ style={{
489
+ width: Dimensions.get('screen').width * 0.26,
490
+ height: Dimensions.get('screen').height * 0.056,
491
+ justifyContent: 'center',
492
+ alignItems: 'center',
493
+ borderWidth: 1,
494
+ borderRadius: 5,
495
+ borderColor: 'lightgrey',
496
+ }}>
497
+ <SCheckBox
498
+ data={{
499
+ value: batchdata.batchverify,
500
+ size: 20,
501
+ }}
502
+ callBack={handleVerifyChange}
503
+ />
504
+ </View>
505
+ </View>
506
+ )}
507
+
508
+ {/* Free Products */}
509
+ <View>
510
+ <CTextHeader
511
+ text={''}
512
+ widthArr={Dimensions.get('screen').width * 0.3}
513
+ bgColor={'rgba(184, 184, 191,0.3)'}
514
+ color={'#094485'}
515
+ borderColor={'white'}
516
+ marginHorizontal={normalize(2)}
517
+ borderRadius={5}
518
+ elevation={0}
519
+ />
520
+ <View
521
+ style={{
522
+ borderWidth: 0,
523
+ alignItems: 'flex-start',
524
+ justifyContent: 'center',
525
+ height: Dimensions.get('screen').height * 0.056,
526
+ }}>
527
+ <TouchableOpacity
528
+ style={{ marginHorizontal: normalize(5) }}
529
+ onPress={handleNavigation}>
530
+ <View
531
+ style={{
532
+ position: 'absolute',
533
+ right: normalize(-5),
534
+ top: normalize(-10),
535
+ backgroundColor: 'white',
536
+ alignItems: 'center',
537
+ borderRadius: 20,
538
+ width: normalize(15),
539
+ borderWidth: 0.5,
540
+ }}>
541
+ <Text
542
+ style={{
543
+ color: 'black',
544
+ fontSize: normalize(11),
545
+ fontWeight: 'bold',
546
+ }}>
547
+ {freeProductsCount}
548
+ </Text>
549
+ </View>
550
+ <Icons.FontAwesome5
551
+ name="cart-arrow-down"
552
+ color="#094485"
553
+ size={normalize(15)}
554
+ />
555
+ </TouchableOpacity>
556
+ </View>
557
+ </View>
558
+ </View>
559
+ );
560
+ };
561
+
562
+ const OrderSection = ({
563
+ productdata,
564
+ i,
565
+ sectionIndex,
566
+ productIndex,
567
+ verifyData,
568
+ updateData,
569
+ supplierdata,
570
+ item,
571
+ onProductNoteUpdate,
572
+ onOrderDelete,
573
+ onAddRow,
574
+ onBatchUpdate,
575
+ onBatchDelete,
576
+ onNavigation,
577
+ onMediaUpdate,
578
+ onBatchVerify,
579
+ onFreeQuantityUpdate,
580
+ }) => {
581
+ const renderBatchItem = ({ item: batchdata, index }) => (
582
+ <BatchRow
583
+ batchdata={batchdata}
584
+ idx={index}
585
+ sectionIndex={sectionIndex}
586
+ productIndex={productIndex}
587
+ orderIndex={i}
588
+ verifyData={verifyData}
589
+ updateData={updateData}
590
+ supplierdata={supplierdata}
591
+ productdata={productdata}
592
+ item={item}
593
+ onBatchUpdate={onBatchUpdate}
594
+ onBatchDelete={onBatchDelete}
595
+ onNavigation={onNavigation}
596
+ onMediaUpdate={onMediaUpdate}
597
+ onBatchVerify={onBatchVerify}
598
+ onFreeQuantityUpdate={onFreeQuantityUpdate}
599
+ />
600
+ );
601
+
602
+ const batchKeyExtractor = (batch, index) =>
603
+ `${sectionIndex}-${productIndex}-${i}-${index}-${batch.batchcode || index}`;
604
+
605
+ return (
606
+ <View
607
+ key={i}
608
+ style={{
609
+ paddingHorizontal: normalize(5),
610
+ marginHorizontal: normalize(10),
611
+ marginBottom: normalize(10),
612
+ }}>
613
+ <View
614
+ style={{
615
+ justifyContent: 'space-between',
616
+ alignItems: 'center',
617
+ flexDirection: 'row',
618
+ }}>
619
+ <Text
620
+ style={{
621
+ fontWeight: '500',
622
+ fontSize: normalize(10),
623
+ color: '#094485',
624
+ width: '70%',
625
+ }}>
626
+ ORDER DETAILS : {productdata.purchaseorderno}
627
+ </Text>
628
+
629
+ {verifyData !== true && (
630
+ <TouchableOpacity style={{ marginHorizontal: normalize(5) }}>
631
+ <SOverlay
632
+ size={16}
633
+ iconcolor={'#094485'}
634
+ value={''}
635
+ onChangeText={val => {
636
+ onProductNoteUpdate(sectionIndex, productIndex, i, val);
637
+ }}
638
+ />
639
+ </TouchableOpacity>
640
+ )}
641
+ {verifyData !== true && (
642
+ <TouchableOpacity
643
+ style={{
644
+ elevation: 0,
645
+ borderRadius: 5,
646
+ fontWeight: 'bold',
647
+ color: 'black',
648
+ width: Dimensions.get('screen').width * 0.036,
649
+ paddingTop: 5,
650
+ paddingBottom: 5,
651
+ height: Dimensions.get('screen').height * 0.055,
652
+ textAlign: 'center',
653
+ marginTop: normalize(2),
654
+ marginHorizontal: normalize(3),
655
+ justifyContent: 'center',
656
+ alignItems: 'center',
657
+ }}
658
+ onPress={() => onOrderDelete(sectionIndex, productIndex, i, productdata.intrpuorderdetail)}>
659
+ <Icons.FontAwesome5
660
+ name="trash"
661
+ color="#094485"
662
+ size={normalize(13)}
663
+ />
664
+ </TouchableOpacity>
665
+ )}
666
+ </View>
667
+
668
+ <ScrollView
669
+ horizontal={true}
670
+ showsHorizontalScrollIndicator={true}
671
+ keyboardShouldPersistTaps="handled"
672
+ style={{ marginVertical: normalize(3) }}>
673
+ <View
674
+ style={{
675
+ flex: 1,
676
+ marginTop: 0,
677
+ marginVertical: normalize(3),
678
+ alignSelf: 'center',
679
+ }}>
680
+ <FlatList
681
+ nestedScrollEnabled
682
+ data={productdata?.batchdetails}
683
+ renderItem={renderBatchItem}
684
+ keyExtractor={batchKeyExtractor}
685
+ initialNumToRender={6}
686
+ maxToRenderPerBatch={10}
687
+ windowSize={7}
688
+ removeClippedSubviews={true}
689
+ updateCellsBatchingPeriod={50}
690
+ />
691
+ </View>
692
+ </ScrollView>
693
+
694
+ {/* Add new batch */}
695
+ {verifyData !== true && (
696
+ <View
697
+ style={{
698
+ flexDirection: 'row',
699
+ alignItems: 'center',
700
+ justifyContent: 'flex-end',
701
+ }}>
702
+ <TouchableOpacity
703
+ onPress={() => {
704
+ if (productdata.flag != 3) {
705
+ const lastBatch = productdata.batchdetails[productdata.batchdetails.length - 1];
706
+ if (lastBatch?.batchname && lastBatch.batchname !== '') {
707
+ onAddRow(sectionIndex, productIndex, i);
708
+ } else if (productdata.batchdetails.length === 0) {
709
+ onAddRow(sectionIndex, productIndex, i);
710
+ } else {
711
+ notifyMessage('Please fill out last row data');
712
+ }
713
+ } else {
714
+ notifyMessage('Order deleted');
715
+ }
716
+ }}>
717
+ <Icons.MaterialIcons
718
+ name={'playlist-add'}
719
+ color="#094485"
720
+ size={normalize(20)}
721
+ />
722
+ </TouchableOpacity>
723
+ </View>
724
+ )}
725
+ </View>
726
+ );
727
+ };
728
+
729
+ const ProductCard = ({
730
+ sectionIndex,
731
+ productIndex,
732
+ supplierdata,
733
+ props,
734
+ selectall,
735
+ setSelectAll,
736
+ }) => {
737
+ const {
738
+ responseJSON,
739
+ setResponseJSON,
740
+ updateData,
741
+ verifyData,
742
+ setSearchSelect,
743
+ invoiceData,
744
+ setInvoiceData,
745
+ } = useContext(ContextBio);
746
+
747
+ const navigation = useNavigation();
748
+ const [refresh, setRefresh] = useState(0);
749
+
750
+ const item = invoiceData.data[sectionIndex]?.productdetail[productIndex];
751
+
752
+ useEffect(() => {
753
+ if (selectall !== undefined && selectall != null) {
754
+ console.log('Applying select all: true to index', productIndex);
755
+ handleProductVerify(sectionIndex, productIndex, selectall);
756
+ }
757
+ }, [selectall]);
758
+
759
+ // Update local state when invoiceData changes
760
+ useEffect(() => {
761
+ setRefresh(prev => prev + 1);
762
+ }, [invoiceData]);
763
+
764
+ // Optimized data update functions
765
+ const updateInvoiceData = (updater) => {
766
+ setInvoiceData(prevState => ({
767
+ ...prevState,
768
+ data: updater(prevState.data),
769
+ EditStatus: true,
770
+ }));
771
+ };
772
+
773
+ // Navigation function
774
+ const navigationTo = (flag, batchname, batchcode, productname, purchaseIndex, batchIndex) => {
775
+ const freeproductdetails = {
776
+ componentname: 'CFreeProductTable',
777
+ productname: productname,
778
+ batchname: batchname,
779
+ batchcode: batchcode,
780
+ suoptiondetail: props.suoptiondetail,
781
+ flag: flag,
782
+ verification: verifyData,
783
+ productIndex: productIndex,
784
+ purchaseIndex: purchaseIndex,
785
+ batchIndex: batchIndex,
786
+ };
787
+
788
+ setResponseJSON({
789
+ ...responseJSON,
790
+ freeproductdetails: freeproductdetails,
791
+ });
792
+
793
+ navigation.navigate('BiodataEdit', {
794
+ data: freeproductdetails,
795
+ });
796
+ };
797
+
798
+ // Batch operations
799
+ const handleBatchUpdate = (field, sectionIndex, productIndex, orderIndex, batchIndex, val) => {
800
+ updateInvoiceData(prevData => {
801
+ const updatedData = [...prevData];
802
+ const batch = updatedData[sectionIndex].productdetail[productIndex].purchaseorderdetail[orderIndex].batchdetails[batchIndex];
803
+
804
+ let updates = {};
805
+ switch (field) {
806
+ case 'batchname':
807
+ updates = {
808
+ batchname: val,
809
+ batchcode: batchIndex,
810
+ flag: updateData === true && batch.flag !== 3 ? 2 : batch.flag !== 3 ? 1 : batch.flag,
811
+ };
812
+ break;
813
+ case 'quantity':
814
+ updates = {
815
+ quantity: Number(val),
816
+ totalquantity: batch.totalquantity !== undefined ? Number(val) * batch.packingquantity : batch.orderquantity,
817
+ flag: updateData && batch.flag !== 3 ? 2 : batch.flag !== 3 ? 1 : batch.flag,
818
+ };
819
+ break;
820
+ case 'packing':
821
+ updates = {
822
+ dropdowndata: [val],
823
+ packingquantity: val.packingqty,
824
+ insupacking: val.datavalue,
825
+ totalquantity: batch.totalquantity !== undefined ? (batch.quantity || 1) * val.packingqty : batch.orderquantity,
826
+ flag: updateData && batch.flag !== 3 ? 2 : batch.flag !== 3 ? 1 : batch.flag,
827
+ };
828
+ break;
829
+ default:
830
+ return prevData;
831
+ }
832
+
833
+ updatedData[sectionIndex].productdetail[productIndex].purchaseorderdetail[orderIndex].batchdetails[batchIndex] = {
834
+ ...batch,
835
+ ...updates,
836
+ };
837
+
838
+ return updatedData;
839
+ });
840
+ };
841
+
842
+ const handleFreeQuantityUpdate = (sectionIndex, productIndex, orderIndex, batchIndex, val) => {
843
+ updateInvoiceData(prevData => {
844
+ const updatedData = [...prevData];
845
+ const batch = updatedData[sectionIndex].productdetail[productIndex].purchaseorderdetail[orderIndex].batchdetails[batchIndex];
846
+
847
+ updatedData[sectionIndex].productdetail[productIndex].purchaseorderdetail[orderIndex].batchdetails[batchIndex] = {
848
+ ...batch,
849
+ freequantity: Number(val),
850
+ flag: updateData && batch.flag !== 3 ? 2 : batch.flag !== 3 ? 1 : batch.flag,
851
+ };
852
+
853
+ return updatedData;
854
+ });
855
+ };
856
+
857
+ const handleBatchVerify = (sectionIndex, productIndex, orderIndex, batchIndex, val) => {
858
+ updateInvoiceData(prevData => {
859
+ const updatedData = [...prevData];
860
+ updatedData[sectionIndex].productdetail[productIndex].purchaseorderdetail[orderIndex].batchdetails[batchIndex].batchverify = val;
861
+ return updatedData;
862
+ });
863
+ };
864
+
865
+ const handleMediaUpdate = (sectionIndex, productIndex, orderIndex, batchIndex, val) => {
866
+ updateInvoiceData(prevData => {
867
+ const updatedData = [...prevData];
868
+ updatedData[sectionIndex].productdetail[productIndex].purchaseorderdetail[orderIndex].batchdetails[batchIndex].media = [val];
869
+ return updatedData;
870
+ });
871
+ };
872
+
873
+ const handleBatchDelete = (sectionIndex, productIndex, orderIndex, batchIndex) => {
874
+ if (updateData === true) {
875
+ updateInvoiceData(prevData => {
876
+ const updatedData = [...prevData];
877
+ updatedData[sectionIndex].productdetail[productIndex].purchaseorderdetail[orderIndex].batchdetails[batchIndex].flag = 3;
878
+ return updatedData;
879
+ });
880
+ } else {
881
+ updateInvoiceData(prevData => {
882
+ const updatedData = [...prevData];
883
+ updatedData[sectionIndex].productdetail[productIndex].purchaseorderdetail[orderIndex].batchdetails.splice(batchIndex, 1);
884
+ return updatedData;
885
+ });
886
+ }
887
+ };
888
+
889
+ // Product operations
890
+ const handleProductVerify = (sectionIndex, productIndex, val) => {
891
+ updateInvoiceData(prevData => {
892
+ const updatedData = [...prevData];
893
+ const product = updatedData[sectionIndex].productdetail[productIndex];
894
+
895
+ const updatedPurchaseOrders = product.purchaseorderdetail?.map(po => ({
896
+ ...po,
897
+ batchdetails: po.batchdetails?.map(batch => ({
898
+ ...batch,
899
+ batchverify: val,
900
+ })) || [],
901
+ })) || [];
902
+
903
+ updatedData[sectionIndex].productdetail[productIndex] = {
904
+ ...product,
905
+ productverify: val,
906
+ purchaseorderdetail: updatedPurchaseOrders,
907
+ };
908
+
909
+ return updatedData;
910
+ });
911
+ };
912
+
913
+ const groupExpand = (sectionIndex, productIndex) => {
914
+ if (item.flag === 3) {return;}
915
+
916
+ updateInvoiceData(prevData => {
917
+ const updatedData = [...prevData];
918
+ updatedData[sectionIndex].productdetail[productIndex].groupexpand =
919
+ !updatedData[sectionIndex].productdetail[productIndex].groupexpand;
920
+ return updatedData;
921
+ });
922
+ };
923
+
924
+ const handleDeleteProduct = (sectionIndex, productIndex) => {
925
+ if (updateData === true) {
926
+ updateInvoiceData(prevData => {
927
+ const updatedData = [...prevData];
928
+ updatedData[sectionIndex].productdetail[productIndex] = {
929
+ ...updatedData[sectionIndex].productdetail[productIndex],
930
+ flag: 3,
931
+ groupexpand: false,
932
+ };
933
+ return updatedData;
934
+ });
935
+ } else {
936
+ updateInvoiceData(prevData => {
937
+ const updatedData = [...prevData];
938
+ updatedData[sectionIndex].productdetail.splice(productIndex, 1);
939
+ return updatedData;
940
+ });
941
+ }
942
+ };
943
+
944
+ // Order operations
945
+ const handleProductNoteUpdate = (sectionIndex, productIndex, orderIndex, val) => {
946
+ updateInvoiceData(prevData => {
947
+ const updatedData = [...prevData];
948
+ updatedData[sectionIndex].productdetail[productIndex].purchaseorderdetail[orderIndex].productnote = val;
949
+ return updatedData;
950
+ });
951
+ };
952
+
953
+ const handleOrderDelete = (sectionIndex, productIndex, orderIndex, productIdToRemove) => {
954
+ if (updateData !== true) {
955
+ updateInvoiceData(prevData => {
956
+ const updatedData = [...prevData];
957
+ updatedData[sectionIndex].productdetail[productIndex].purchaseorderdetail =
958
+ updatedData[sectionIndex].productdetail[productIndex].purchaseorderdetail.filter(
959
+ product => product.intrpuorderdetail !== productIdToRemove
960
+ );
961
+ return updatedData;
962
+ });
963
+ } else {
964
+ updateInvoiceData(prevData => {
965
+ const updatedData = [...prevData];
966
+ const purchaseOrder = updatedData[sectionIndex].productdetail[productIndex].purchaseorderdetail[orderIndex];
967
+
968
+ updatedData[sectionIndex].productdetail[productIndex].purchaseorderdetail[orderIndex] = {
969
+ ...purchaseOrder,
970
+ flag: 3,
971
+ batchdetails: purchaseOrder.batchdetails.map(batch => ({
972
+ ...batch,
973
+ flag: 3,
974
+ })),
975
+ };
976
+ return updatedData;
977
+ });
978
+ }
979
+ };
980
+
981
+ const addRow = (sectionIndex, productIndex, orderIndex) => {
982
+ updateInvoiceData(prevData => {
983
+ const updatedData = [...prevData];
984
+ const purchaseOrder = updatedData[sectionIndex].productdetail[productIndex].purchaseorderdetail[orderIndex];
985
+
986
+ const getQuantity = (data) => {
987
+ const totalQuantity = data.reduce((sum, item) => sum + (item.quantity || 0), 0);
988
+ const invoicePackingNo = data[0]?.invoicepackingno || 0;
989
+ return invoicePackingNo - totalQuantity;
990
+ };
991
+
992
+ const newBatchDetail = {
993
+ batchname: null,
994
+ insuproduct: null,
995
+ invoicepackingno: getQuantity(purchaseOrder.batchdetails),
996
+ insupacking: null,
997
+ intrpudetail: null,
998
+ freeproductquantity: null,
999
+ ddinsupacking: null,
1000
+ packingquantity: null,
1001
+ quantity: 0,
1002
+ totalquantity: null,
1003
+ orderquantity: getQuantity(purchaseOrder.batchdetails),
1004
+ imageurl: null,
1005
+ productnotes: null,
1006
+ productinstruction: null,
1007
+ dropdowndata: {
1008
+ datavalue: 1,
1009
+ displayvalue: '1 NOS',
1010
+ selected: 1,
1011
+ },
1012
+ productquantityentry: [
1013
+ {
1014
+ id: 0,
1015
+ insuproduct: 0,
1016
+ insuproductfree: 0,
1017
+ ddinsupacking: 'invget/invcommonget/rndddwdropdownselect 1,22401,8,3,5,0,1',
1018
+ ddinsuproduct: 'invget/invcommonget/rndddwdropdownselect 3,0,0,0,0,0,0',
1019
+ ismodified: 0,
1020
+ insuproductfreename: null,
1021
+ packing: null,
1022
+ customer: 0,
1023
+ spare: 0,
1024
+ quantitynumber: 0,
1025
+ batchname: null,
1026
+ },
1027
+ ],
1028
+ };
1029
+
1030
+ updatedData[sectionIndex].productdetail[productIndex].purchaseorderdetail[orderIndex].batchdetails = [
1031
+ ...purchaseOrder.batchdetails,
1032
+ newBatchDetail,
1033
+ ];
1034
+
1035
+ return updatedData;
1036
+ });
1037
+ };
1038
+
1039
+ // Quantity calculations - recalculated on every render
1040
+ const quantityData = (() => {
1041
+ if (!item || !item.purchaseorderdetail) {return { totalPacking: 0, totalFree: 0, totalQuantity: 0 };}
1042
+
1043
+ let totalPacking = 0;
1044
+ let totalFree = 0;
1045
+
1046
+ item.purchaseorderdetail.forEach(purchaseOrder => {
1047
+ purchaseOrder.batchdetails.forEach(batchdata => {
1048
+ // Add quantity
1049
+ if (batchdata.quantity != null && !isNaN(batchdata.quantity)) {
1050
+ totalPacking += Number(batchdata.quantity);
1051
+ }
1052
+
1053
+ // Add free quantity
1054
+ if (batchdata.freequantity) {
1055
+ totalFree += Number(batchdata.freequantity);
1056
+ }
1057
+
1058
+ // Add free products from productquantityentry
1059
+ batchdata?.productquantityentry?.forEach(freeProduct => {
1060
+ if (freeProduct.insuproductfree !== 0) {
1061
+ totalFree += 1;
1062
+ }
1063
+ });
1064
+ });
1065
+ });
1066
+
1067
+ const totalQuantity = totalPacking + totalFree;
1068
+
1069
+ return { totalPacking, totalFree, totalQuantity };
1070
+ })();
1071
+
1072
+ // Swipe actions
1073
+ const renderLeftActions = () => (
1074
+ <View
1075
+ style={{
1076
+ // justifyContent: 'flex-start',
1077
+ // alignItems: 'center',
1078
+ // borderTopLeftRadius: 10,
1079
+ // borderBottomLeftRadius: 10,
1080
+ flexDirection: 'row',
1081
+ marginTop: normalize(10),
1082
+ paddingHorizontal: normalize(10),
1083
+ // marginBottom: normalize(7),
1084
+ }}>
1085
+ <TouchableOpacity
1086
+ style={{ marginLeft: normalize(5) }}
1087
+ onPress={() => {
1088
+ navigation.navigate('CPurchaseDetails', {
1089
+ supplierCode: supplierdata?.insusupplier,
1090
+ productCode: item?.insuproduct,
1091
+ });
1092
+ }}>
1093
+ <View
1094
+ style={{
1095
+ backgroundColor: '#f4f5ae',
1096
+ justifyContent: 'center',
1097
+ alignItems: 'center',
1098
+ ...CButtonShadow(),
1099
+ borderRadius: normalize(5),
1100
+ paddingHorizontal: normalize(3),
1101
+ paddingVertical: normalize(5),
1102
+ height: normalize(30),
1103
+ width: normalize(30),
1104
+ }}>
1105
+ <HOCIcons.Entypo
1106
+ name={'info-with-circle'}
1107
+ size={normalize(20)}
1108
+ color={Global.AppTheme.primary_color}
1109
+ />
1110
+ <Text
1111
+ numberOfLines={1}
1112
+ style={{
1113
+ fontSize: normalize(8),
1114
+ fontWeight: 'bold',
1115
+ color: Global.AppTheme.primary_color,
1116
+ }}>
1117
+ Details
1118
+ </Text>
1119
+ </View>
1120
+ </TouchableOpacity>
1121
+
1122
+ <TouchableOpacity
1123
+ style={{ marginLeft: normalize(5) }}
1124
+ onPress={() => {
1125
+ navigation.navigate('CSupplierList', {
1126
+ productCode: item?.insuproduct,
1127
+ });
1128
+ }}>
1129
+ <View
1130
+ style={{
1131
+ backgroundColor: '#aef5b4',
1132
+ justifyContent: 'center',
1133
+ alignItems: 'center',
1134
+ ...CButtonShadow(),
1135
+ borderRadius: normalize(5),
1136
+ paddingHorizontal: normalize(3),
1137
+ paddingVertical: normalize(5),
1138
+ height: normalize(30),
1139
+ width: normalize(30),
1140
+ }}>
1141
+ <HOCIcons.MaterialCommunityIcons
1142
+ name={'human-dolly'}
1143
+ size={normalize(20)}
1144
+ color={Global.AppTheme.primary_color}
1145
+ />
1146
+ <Text
1147
+ numberOfLines={1}
1148
+ style={{
1149
+ fontSize: normalize(8),
1150
+ fontWeight: 'bold',
1151
+ color: Global.AppTheme.primary_color,
1152
+ }}>
1153
+ Supplier
1154
+ </Text>
1155
+ </View>
1156
+ </TouchableOpacity>
1157
+ </View>
1158
+ );
1159
+
1160
+ const renderRightActions = () => (
1161
+ <View
1162
+ style={{
1163
+ justifyContent: 'flex-start',
1164
+ alignItems: 'center',
1165
+ borderTopLeftRadius: 10,
1166
+ borderBottomLeftRadius: 10,
1167
+ flexDirection: 'row',
1168
+ paddingHorizontal: normalize(10),
1169
+ marginBottom: normalize(7),
1170
+ }}>
1171
+ {/* Add right actions if needed */}
1172
+ </View>
1173
+ );
1174
+
1175
+ if (!item) {return null;}
1176
+
1177
+ return (
1178
+ <View>
1179
+ {/* Item card section */}
1180
+ <SwipeRow
1181
+ disableLeftSwipe={false}
1182
+ disableRightSwipe={false}
1183
+ leftOpenValue={190}
1184
+ rightOpenValue={-190}
1185
+ swipeToClosePercent={10}
1186
+ swipeToOpenPercent={10}
1187
+ >
1188
+ {/* Hidden Row (Swipe Actions) */}
1189
+ <View style={{
1190
+ borderWidth: 0,
1191
+ flexDirection: 'row',
1192
+ justifyContent: 'space-between',
1193
+ minHeight: normalize(70),
1194
+ }}>
1195
+ <View style={{ flex: 1, alignItems: 'flex-start' }}>
1196
+ {renderLeftActions && renderLeftActions()}
1197
+ </View>
1198
+ <View style={{ flex: 1, alignItems: 'flex-end' }}>
1199
+ {renderRightActions && renderRightActions()}
1200
+ </View>
1201
+ </View>
1202
+
1203
+ {/* Main Content */}
1204
+ <TouchableOpacity
1205
+ onPress={() => groupExpand(sectionIndex, productIndex)}
1206
+ style={{
1207
+ padding: normalize(5),
1208
+ marginVertical: 5,
1209
+ borderLeftWidth: normalize(10),
1210
+ borderLeftColor: isNUQ(item?.color) ? item?.color : '#870808',
1211
+ backgroundColor: '#faeeeb',
1212
+ marginHorizontal: normalize(10),
1213
+ marginBottom: normalize(10),
1214
+ borderRadius: normalize(5),
1215
+ shadowColor: Global.AppTheme.primary_color,
1216
+ shadowOffset: { width: 4, height: 4 },
1217
+ shadowOpacity: 0.6,
1218
+ shadowRadius: 10,
1219
+ elevation: 8,
1220
+ ...CButtonShadow(),
1221
+ }}>
1222
+ <View>
1223
+ {/* Top section with hand icon, product name and delete icon and checkbox for verify screen */}
1224
+ <View
1225
+ style={{
1226
+ alignItems: 'center',
1227
+ flexDirection: 'row',
1228
+ justifyContent: 'space-between',
1229
+ padding: normalize(2),
1230
+ }}>
1231
+ <Icons.FontAwesome5
1232
+ name={'box-open'}
1233
+ size={normalize(19)}
1234
+ color={'#094485'}
1235
+ />
1236
+ <Text
1237
+ adjustsFontSizeToFit
1238
+ numberOfLines={2}
1239
+ style={{
1240
+ fontWeight: 'bold',
1241
+ marginLeft: normalize(5),
1242
+ fontSize: normalize(13),
1243
+ color: '#094485',
1244
+ marginHorizontal: normalize(5),
1245
+ width: '60%',
1246
+ }}>
1247
+ {item.productname}
1248
+ </Text>
1249
+ {verifyData === true ? (
1250
+ <SCheckBox
1251
+ data={{ value: item.productverify, size: 20 }}
1252
+ callBack={val => {
1253
+ handleProductVerify(sectionIndex, productIndex, val);
1254
+ }}
1255
+ />
1256
+ ) : item.flag === 3 ? (
1257
+ <Text style={{ color: 'red' }}>Deleted</Text>
1258
+ ) : (
1259
+ <TouchableOpacity
1260
+ onPress={() => {
1261
+ handleDeleteProduct(sectionIndex, productIndex);
1262
+ }}>
1263
+ <Icons.FontAwesome5
1264
+ name={'trash'}
1265
+ size={normalize(16)}
1266
+ color={'#094485'}
1267
+ />
1268
+ </TouchableOpacity>
1269
+ )}
1270
+ </View>
1271
+
1272
+ {/* Bottom section with quantity and total quantity */}
1273
+ <View style={{ justifyContent: 'space-between', flexDirection: 'row' }}>
1274
+ <Text
1275
+ adjustsFontSizeToFit
1276
+ numberOfLines={2}
1277
+ style={{
1278
+ color: '#094485',
1279
+ fontWeight: '500',
1280
+ fontSize: normalize(10),
1281
+ }}>
1282
+ QUANTITY : {quantityData.totalPacking}
1283
+ </Text>
1284
+ <Text
1285
+ style={{
1286
+ color: '#094485',
1287
+ fontWeight: '500',
1288
+ fontSize: normalize(10),
1289
+ }}>
1290
+ FREE QUANTITY : {quantityData.totalFree}
1291
+ </Text>
1292
+ <Text
1293
+ style={{
1294
+ color: '#094485',
1295
+ fontWeight: '500',
1296
+ fontSize: normalize(10),
1297
+ }}>
1298
+ TOTAL QUANTITY : {quantityData.totalQuantity}
1299
+ </Text>
1300
+ </View>
1301
+ </View>
1302
+ </TouchableOpacity>
1303
+ </SwipeRow>
1304
+
1305
+ {/* Item card expanded section */}
1306
+ {item.groupexpand && item.purchaseorderdetail && (
1307
+ <View>
1308
+ {item.purchaseorderdetail.map((productdata, i) => (
1309
+ <OrderSection
1310
+ key={`${sectionIndex}-${productIndex}-${i}-${productdata.intrpuorderdetail}`}
1311
+ productdata={productdata}
1312
+ i={i}
1313
+ sectionIndex={sectionIndex}
1314
+ productIndex={productIndex}
1315
+ verifyData={verifyData}
1316
+ updateData={updateData}
1317
+ supplierdata={supplierdata}
1318
+ item={item}
1319
+ onProductNoteUpdate={handleProductNoteUpdate}
1320
+ onOrderDelete={handleOrderDelete}
1321
+ onAddRow={addRow}
1322
+ onBatchUpdate={handleBatchUpdate}
1323
+ onBatchDelete={handleBatchDelete}
1324
+ onNavigation={navigationTo}
1325
+ onMediaUpdate={handleMediaUpdate}
1326
+ onBatchVerify={handleBatchVerify}
1327
+ onFreeQuantityUpdate={handleFreeQuantityUpdate}
1328
+ />
1329
+ ))}
1330
+ </View>
1331
+ )}
1332
+ </View>
1333
+ );
1334
+ };
1335
+
1336
+ export default ProductCard;