ui-soxo-bootstrap-core 2.5.4 → 2.5.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.
|
@@ -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
|
|
@@ -279,10 +279,7 @@ const StaffAdd = ({ visible, onCancel, staffId, staffData, onSuccess }) => {
|
|
|
279
279
|
name="id"
|
|
280
280
|
validateTrigger="onChange"
|
|
281
281
|
hasFeedback={!editMode}
|
|
282
|
-
rules={[
|
|
283
|
-
{ required: true, message: 'Code is required' },
|
|
284
|
-
{ validator: validateInput },
|
|
285
|
-
]}
|
|
282
|
+
rules={[{ required: true, message: 'Code is required' }, { validator: validateInput }]}
|
|
286
283
|
>
|
|
287
284
|
<Input placeholder="Enter Code" autoComplete="off" maxLength={10} ref={nameInputRef} onKeyDown={handleEnterKey} disabled={editMode} />
|
|
288
285
|
</Form.Item>
|
|
@@ -383,7 +380,7 @@ const StaffAdd = ({ visible, onCancel, staffId, staffData, onSuccess }) => {
|
|
|
383
380
|
name="slno"
|
|
384
381
|
rules={[{ message: 'only numbers are allowed', pattern: /^\d*$/ }, { validator: validateSerial }]}
|
|
385
382
|
>
|
|
386
|
-
<Input autoComplete="off" maxLength={5} placeholder="Enter Serial Number" onKeyDown={handleEnterKey}
|
|
383
|
+
<Input autoComplete="off" maxLength={5} placeholder="Enter Serial Number" onKeyDown={handleEnterKey} />
|
|
387
384
|
</Form.Item>
|
|
388
385
|
</Col>
|
|
389
386
|
|