ui-soxo-bootstrap-core 2.5.4 → 2.5.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { Modal, Tabs, Input, Form, Row, Col, message, Checkbox, Select } from 'antd';
|
|
4
4
|
import { useTranslation, Button } from './../../../../lib/';
|
|
5
5
|
import { UsersAPI } from '../../..';
|
|
@@ -163,20 +163,20 @@ const StaffAdd = ({ visible, onCancel, staffId, staffData, onSuccess }) => {
|
|
|
163
163
|
return Promise.resolve();
|
|
164
164
|
};
|
|
165
165
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
const validateSerial = (_, value) => {
|
|
167
|
+
if (!value) {
|
|
168
|
+
return Promise.resolve();
|
|
169
|
+
}
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
// Allow same serial number for the same staff in edit mode
|
|
172
|
+
if (editMode && String(value) === String(staffData?.slNo)) {
|
|
173
|
+
return Promise.resolve();
|
|
174
|
+
}
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
const exists = staffList.some((staff) => String(staff.slNo) === String(value));
|
|
177
177
|
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
return exists ? Promise.reject('Serial Number already exists') : Promise.resolve();
|
|
179
|
+
};
|
|
180
180
|
|
|
181
181
|
/** -------------------------------
|
|
182
182
|
* UTIL – Enter Key Navigation
|
|
@@ -215,6 +215,8 @@ const StaffAdd = ({ visible, onCancel, staffId, staffData, onSuccess }) => {
|
|
|
215
215
|
});
|
|
216
216
|
};
|
|
217
217
|
|
|
218
|
+
const existing = staffData || {};
|
|
219
|
+
|
|
218
220
|
/** -------------------------------
|
|
219
221
|
* SUBMIT HANDLER
|
|
220
222
|
* ------------------------------- */
|
|
@@ -225,19 +227,19 @@ const StaffAdd = ({ visible, onCancel, staffId, staffData, onSuccess }) => {
|
|
|
225
227
|
id: values.id,
|
|
226
228
|
shortName: values.shortName,
|
|
227
229
|
description: values.description,
|
|
228
|
-
designationPtr: values.designation
|
|
229
|
-
phone: values.phone1
|
|
230
|
-
mobile: values.phone1
|
|
231
|
-
alternateMobile: values.phone2
|
|
232
|
-
email: values.email1
|
|
233
|
-
alternateEmail: values.email2
|
|
234
|
-
remarks: values.remarks
|
|
235
|
-
slNo: values.slno
|
|
230
|
+
designationPtr: values.designation ?? existing.designationPtr ?? null,
|
|
231
|
+
phone: values.phone1 ?? existing.phone ?? null,
|
|
232
|
+
mobile: values.phone1 ?? existing.mobile ?? null,
|
|
233
|
+
alternateMobile: values.phone2 ?? existing.alternateMobile ?? null,
|
|
234
|
+
email: values.email1 ?? existing.email ?? null,
|
|
235
|
+
alternateEmail: values.email2 ?? existing.alternateEmail ?? null,
|
|
236
|
+
remarks: values.remarks ?? existing.remarks ?? null,
|
|
237
|
+
slNo: values.slno ?? existing.slNo ?? null,
|
|
236
238
|
active: values.active === 'Y' ? 'Y' : 'N',
|
|
237
|
-
address1: values.address1
|
|
238
|
-
address2: values.address2
|
|
239
|
-
place: values.place
|
|
240
|
-
zip: values.zip
|
|
239
|
+
address1: values.address1 ?? existing.address1 ?? null,
|
|
240
|
+
address2: values.address2 ?? existing.address2 ?? null,
|
|
241
|
+
place: values.place ?? existing.place ?? null,
|
|
242
|
+
zip: values.zip ?? existing.zip ?? null,
|
|
241
243
|
};
|
|
242
244
|
|
|
243
245
|
try {
|
|
@@ -279,10 +281,7 @@ const StaffAdd = ({ visible, onCancel, staffId, staffData, onSuccess }) => {
|
|
|
279
281
|
name="id"
|
|
280
282
|
validateTrigger="onChange"
|
|
281
283
|
hasFeedback={!editMode}
|
|
282
|
-
rules={[
|
|
283
|
-
{ required: true, message: 'Code is required' },
|
|
284
|
-
{ validator: validateInput },
|
|
285
|
-
]}
|
|
284
|
+
rules={[{ required: true, message: 'Code is required' }, { validator: validateInput }]}
|
|
286
285
|
>
|
|
287
286
|
<Input placeholder="Enter Code" autoComplete="off" maxLength={10} ref={nameInputRef} onKeyDown={handleEnterKey} disabled={editMode} />
|
|
288
287
|
</Form.Item>
|
|
@@ -383,7 +382,7 @@ const StaffAdd = ({ visible, onCancel, staffId, staffData, onSuccess }) => {
|
|
|
383
382
|
name="slno"
|
|
384
383
|
rules={[{ message: 'only numbers are allowed', pattern: /^\d*$/ }, { validator: validateSerial }]}
|
|
385
384
|
>
|
|
386
|
-
<Input autoComplete="off" maxLength={5} placeholder="Enter Serial Number" onKeyDown={handleEnterKey}
|
|
385
|
+
<Input autoComplete="off" maxLength={5} placeholder="Enter Serial Number" onKeyDown={handleEnterKey} />
|
|
387
386
|
</Form.Item>
|
|
388
387
|
</Col>
|
|
389
388
|
|