ui-soxo-bootstrap-core 2.4.25-dev.13 → 2.4.25-dev.14

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.
@@ -10,7 +10,7 @@ const DoctorAdd = ({ visible, onCancel, attributes, doctorId, doctorData, onSucc
10
10
  const [form] = Form.useForm();
11
11
  const { t } = useTranslation();
12
12
 
13
- // Signature states
13
+ // Signature states..
14
14
  const [fileUrl, setFileUrl] = useState(null);
15
15
  const [editingSignature, setEditingSignature] = useState(false);
16
16
  const [previousSignature, setPreviousSignature] = useState(null);
@@ -57,6 +57,18 @@ const StaffAdd = ({ visible, onCancel, staffId, staffData, onSuccess }) => {
57
57
  }
58
58
  }, [visible]);
59
59
 
60
+ const phoneValidator = (_, value) => {
61
+ if (!value) {
62
+ return Promise.resolve(); // not required
63
+ }
64
+
65
+ if (!/^\d{10}$/.test(value)) {
66
+ return Promise.reject('Phone number must be 10 digits');
67
+ }
68
+
69
+ return Promise.resolve();
70
+ };
71
+
60
72
  /** -------------------------------
61
73
  * API CALL – Designations
62
74
  * ------------------------------- */
@@ -92,11 +104,31 @@ const StaffAdd = ({ visible, onCancel, staffId, staffData, onSuccess }) => {
92
104
  return Promise.resolve();
93
105
  }
94
106
 
107
+ // Starting space not allowed
108
+ if (value.startsWith(' ')) {
109
+ setCodeStatus({
110
+ status: 'error',
111
+ message: 'Code cannot start with a space',
112
+ });
113
+ return Promise.reject(new Error('Code cannot start with a space'));
114
+ }
115
+
116
+ // Any space not allowed
117
+ if (/\s/.test(value)) {
118
+ setCodeStatus({
119
+ status: 'error',
120
+ message: 'Spaces are not allowed in the code',
121
+ });
122
+ return Promise.reject(new Error('Spaces are not allowed in the code'));
123
+ }
124
+
95
125
  try {
96
126
  const res = await UsersAPI.getStaffCode(value);
127
+ console.log(res.message, ' inside validateDoctorCode');
97
128
 
98
129
  if (res?.status === 409 || res?.success === false) {
99
130
  setCodeStatus({ status: 'error', message: res.message || 'Code already exists' });
131
+ console.log('here');
100
132
  return Promise.reject(new Error(res.message || 'Code already exists'));
101
133
  }
102
134
 
@@ -108,8 +140,8 @@ const StaffAdd = ({ visible, onCancel, staffId, staffData, onSuccess }) => {
108
140
  return Promise.resolve();
109
141
  }
110
142
 
111
- setCodeStatus({ status: 'error', message: 'Unexpected response' });
112
- return Promise.reject(new Error('Unexpected response'));
143
+ setCodeStatus({ status: 'error', message: 'Please enter a valid code' });
144
+ return Promise.reject(new Error('Please enter a valid code'));
113
145
  } catch {
114
146
  setCodeStatus({ status: 'error', message: 'Validation failed' });
115
147
  return Promise.reject(new Error('Validation failed'));
@@ -163,19 +195,19 @@ const StaffAdd = ({ visible, onCancel, staffId, staffData, onSuccess }) => {
163
195
  id: values.id,
164
196
  shortName: values.shortName,
165
197
  description: values.description,
166
- designationPtr: values.designation,
167
- phone: values.phone1,
168
- mobile: values.phone2,
169
- alternateMobile: values.phone2,
170
- email: values.email1,
171
- alternateEmail: values.email2,
172
- remarks: values.remarks,
198
+ designationPtr: values.designation || null,
199
+ phone: values.phone1 || null,
200
+ mobile: values.phone1 || null,
201
+ alternateMobile: values.phone2 || null,
202
+ email: values.email1 || null,
203
+ alternateEmail: values.email2 || null,
204
+ remarks: values.remarks || null,
173
205
  slNo: values.slno ? Number(values.slno) : null,
174
206
  active: values.active === 'Y' ? 'Y' : 'N',
175
- address1: values.address1,
176
- address2: values.address2,
177
- place: values.place,
178
- zip: values.zip,
207
+ address1: values.address1 || null,
208
+ address2: values.address2 || null,
209
+ place: values.place || null,
210
+ zip: values.zip || null,
179
211
  };
180
212
 
181
213
  try {
@@ -217,21 +249,20 @@ const StaffAdd = ({ visible, onCancel, staffId, staffData, onSuccess }) => {
217
249
  name="id"
218
250
  validateTrigger="onChange"
219
251
  hasFeedback={!editMode}
220
- rules={[{ required: true }, { validator: validateDoctorCode }]}
252
+ rules={[{ required: true, message: 'Code is required' }, { validator: validateDoctorCode }]}
221
253
  >
222
- <Input placeholder="Enter Code" ref={nameInputRef} onKeyDown={handleEnterKey} disabled={editMode} />
254
+ <Input placeholder="Enter Code" autoComplete="off" maxLength={10} ref={nameInputRef} onKeyDown={handleEnterKey} disabled={editMode} />
223
255
  </Form.Item>
224
256
  </Col>
225
257
 
226
- <Col span={6}>
227
- <Form.Item label="Name" name="shortName" rules={[{ required: true }]}>
228
- <Input placeholder="Enter Name" onKeyDown={handleEnterKey} />
258
+ <Col span={12}>
259
+ <Form.Item label="Name" name="description" rules={[{ required: true }]}>
260
+ <Input placeholder="Enter Description" autoComplete="off" onKeyDown={handleEnterKey} />
229
261
  </Form.Item>
230
262
  </Col>
231
-
232
- <Col span={12}>
233
- <Form.Item label="Description" name="description" rules={[{ required: true }]}>
234
- <Input placeholder="Enter Description" onKeyDown={handleEnterKey} />
263
+ <Col span={6}>
264
+ <Form.Item label="Short Name" name="shortName" rules={[{ required: true }]}>
265
+ <Input placeholder="Enter Short Name" autoComplete="off" onKeyDown={handleEnterKey} maxLength={10} />
235
266
  </Form.Item>
236
267
  </Col>
237
268
  </Row>
@@ -240,7 +271,7 @@ const StaffAdd = ({ visible, onCancel, staffId, staffData, onSuccess }) => {
240
271
  {/* GENERAL TAB */}
241
272
  <Tabs.TabPane tab="GENERAL" key="1">
242
273
  <Row gutter={16}>
243
- <Col span={6}>
274
+ {/* <Col span={6}>
244
275
  <Form.Item label="Phone Number 1" name="phone1">
245
276
  <Input maxLength={10} placeholder="Enter Phone Number" onKeyDown={handleEnterKey} />
246
277
  </Form.Item>
@@ -250,17 +281,42 @@ const StaffAdd = ({ visible, onCancel, staffId, staffData, onSuccess }) => {
250
281
  <Form.Item label="Phone Number 2" name="phone2">
251
282
  <Input maxLength={10} placeholder="Enter Phone Number" onKeyDown={handleEnterKey} />
252
283
  </Form.Item>
284
+ </Col> */}
285
+ <Col span={6}>
286
+ <Form.Item label="Phone Number" name="phone1" rules={[{ validator: phoneValidator }]}>
287
+ <Input
288
+ maxLength={10}
289
+ autoComplete="off"
290
+ placeholder="Enter Phone Number"
291
+ inputMode="numeric"
292
+ onChange={(e) => (e.target.value = e.target.value.replace(/\D/g, ''))}
293
+ onKeyDown={handleEnterKey}
294
+ />
295
+ </Form.Item>
296
+ </Col>
297
+
298
+ <Col span={6}>
299
+ <Form.Item label="Alternate Phone Number" name="phone2" rules={[{ validator: phoneValidator }]}>
300
+ <Input
301
+ maxLength={10}
302
+ placeholder="Enter Phone Number"
303
+ autoComplete="off"
304
+ inputMode="numeric"
305
+ onChange={(e) => (e.target.value = e.target.value.replace(/\D/g, ''))}
306
+ onKeyDown={handleEnterKey}
307
+ />
308
+ </Form.Item>
253
309
  </Col>
254
310
 
255
311
  <Col span={6}>
256
- <Form.Item label="Email ID 1" name="email1">
257
- <Input placeholder="Enter Email" onKeyDown={handleEnterKey} />
312
+ <Form.Item label="Email ID" name="email1">
313
+ <Input autoComplete="off" placeholder="Enter Email" onKeyDown={handleEnterKey} />
258
314
  </Form.Item>
259
315
  </Col>
260
316
 
261
317
  <Col span={6}>
262
- <Form.Item label="Email ID 2" name="email2">
263
- <Input placeholder="Enter Email" onKeyDown={handleEnterKey} />
318
+ <Form.Item label="Alternate Email" name="email2">
319
+ <Input autoComplete="off" placeholder="Enter Email" onKeyDown={handleEnterKey} />
264
320
  </Form.Item>
265
321
  </Col>
266
322
  </Row>
@@ -273,8 +329,8 @@ const StaffAdd = ({ visible, onCancel, staffId, staffData, onSuccess }) => {
273
329
  </Col>
274
330
 
275
331
  <Col span={8}>
276
- <Form.Item label="Serial Number" name="slno">
277
- <Input placeholder="Enter Serial Number" onKeyDown={handleEnterKey} />
332
+ <Form.Item label="Serial Number" name="slno" rules={[{ message: 'only numbers are allowed', pattern: /^\d*$/ }]}>
333
+ <Input autoComplete="off" maxLength={5} placeholder="Enter Serial Number" onKeyDown={handleEnterKey} />
278
334
  </Form.Item>
279
335
  </Col>
280
336
 
@@ -297,7 +353,7 @@ const StaffAdd = ({ visible, onCancel, staffId, staffData, onSuccess }) => {
297
353
  <Row>
298
354
  <Col span={24}>
299
355
  <Form.Item label="Remarks" name="remarks">
300
- <Input placeholder="Enter Remarks" onKeyDown={handleEnterKey} />
356
+ <Input autoComplete="off" placeholder="Enter Remarks" onKeyDown={handleEnterKey} />
301
357
  </Form.Item>
302
358
  </Col>
303
359
  </Row>
@@ -308,13 +364,13 @@ const StaffAdd = ({ visible, onCancel, staffId, staffData, onSuccess }) => {
308
364
  <Row gutter={16}>
309
365
  <Col span={12}>
310
366
  <Form.Item label="Address Line 1" name="address1">
311
- <Input placeholder="Enter Address" onKeyDown={handleEnterKey} />
367
+ <Input autoComplete="off" placeholder="Enter Address" onKeyDown={handleEnterKey} />
312
368
  </Form.Item>
313
369
  </Col>
314
370
 
315
371
  <Col span={12}>
316
372
  <Form.Item label="Address Line 2" name="address2">
317
- <Input placeholder="Enter Address" onKeyDown={handleEnterKey} />
373
+ <Input autoComplete="off" placeholder="Enter Address" onKeyDown={handleEnterKey} />
318
374
  </Form.Item>
319
375
  </Col>
320
376
  </Row>
@@ -322,13 +378,13 @@ const StaffAdd = ({ visible, onCancel, staffId, staffData, onSuccess }) => {
322
378
  <Row gutter={16}>
323
379
  <Col span={12}>
324
380
  <Form.Item label="Place" name="place">
325
- <Input placeholder="Enter Place" onKeyDown={handleEnterKey} />
381
+ <Input autoComplete="off" placeholder="Enter Place" onKeyDown={handleEnterKey} />
326
382
  </Form.Item>
327
383
  </Col>
328
384
 
329
385
  <Col span={12}>
330
386
  <Form.Item label="Zip Code" name="zip">
331
- <Input placeholder="Enter Zip Code" maxLength={7} onKeyDown={handleEnterKey} />
387
+ <Input autoComplete="off" placeholder="Enter Zip Code" maxLength={7} onKeyDown={handleEnterKey} />
332
388
  </Form.Item>
333
389
  </Col>
334
390
  </Row>
@@ -506,12 +506,20 @@ const UserAdd = ({ model, callback, edit, history, formContent, match, additiona
506
506
  {' '}
507
507
  {/* Show extra dropdown only if user type is Doctor */}
508
508
  {userType === 'RAD' && (
509
- <Form.Item name="default_code" label="Default Code" rules={[{ required: true, message: 'Please select a default code' }]}>
509
+ <Form.Item
510
+ name="default_code"
511
+ preserve={false}
512
+ label="Default Code"
513
+ rules={[{ required: true, message: 'Please select a default code' }]}
514
+ >
510
515
  <Select
511
516
  placeholder="Select Code"
512
517
  options={doctorList}
513
518
  showSearch
514
519
  optionFilterProp="label"
520
+ onChange={(value) => {
521
+ form.setFieldsValue({ default_code: value });
522
+ }}
515
523
  dropdownRender={(menu) => (
516
524
  <>
517
525
  {menu}
@@ -541,12 +549,20 @@ const UserAdd = ({ model, callback, edit, history, formContent, match, additiona
541
549
  </Form.Item>
542
550
  )}
543
551
  {userType === 'STAFF' && (
544
- <Form.Item name="staff_code" label="Staff Code" rules={[{ required: true, message: 'Please select a staff code' }]}>
552
+ <Form.Item
553
+ name="staff_code"
554
+ preserve={false} // THIS FIXES IT
555
+ label="Staff Code"
556
+ rules={[{ required: true, message: 'Please select a staff code' }]}
557
+ >
545
558
  <Select
546
559
  placeholder="Select Code"
547
560
  options={staffList}
548
561
  showSearch
549
562
  optionFilterProp="label"
563
+ onChange={(value) => {
564
+ form.setFieldsValue({ staff_code: value });
565
+ }}
550
566
  dropdownRender={(menu) => (
551
567
  <>
552
568
  {menu}
@@ -584,7 +600,7 @@ const UserAdd = ({ model, callback, edit, history, formContent, match, additiona
584
600
  <Col span={8}>
585
601
  {/* Mobile */}
586
602
  <Form.Item name="mobile" label="Mobile" rules={[{ required: true, message: 'Please enter your mobile number' }]}>
587
- <Input placeholder="Enter Mobile" />
603
+ <Input placeholder="Enter Mobile" maxLength={10} />
588
604
  </Form.Item>
589
605
  </Col>
590
606
  <Col span={8}>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ui-soxo-bootstrap-core",
3
- "version": "2.4.25-dev.13",
3
+ "version": "2.4.25-dev.14",
4
4
  "description": "All the Core Components for you to start",
5
5
  "keywords": [
6
6
  "all in one"