+
+
{
+ // //allow selecting only if the equipment id field is not empty
+ // if (form.getFieldValue('equipmentId') === undefined) {
+ // return Promise.reject(new Error('Please enter Equipment ID first!'))
+ // }
+ // if (value === undefined) {
+ // return Promise.reject(new Error('Please select Equipment Type!'))
+ // }
+ // return Promise.resolve()
+ // },
+ // },
+ ]}
+ >
+ {/**/}
+
+
+
+
{
{
required: true,
pattern: new RegExp(/^[a-zA-Z0-9]+$/),
- message: 'Equipment ID must be alphanumeric',
+ message: 'Alphanumeric Equipment ID Required!',
+ },
+ {
+ validator: async (_, value) => {
+ //check if the equipment id first characters match with the model class code
+ if (value === undefined) {
+ return Promise.reject(new Error())
+ }
+
+ if (!form.getFieldValue('modelClass')) {
+ return Promise.reject(new Error('Please Select Equipment Type First!'))
+ }
+ const modelClassSelected = listOfModelClass?.data?.find((modelClass: any) => {
+ return modelClass?.modelClassId === form.getFieldValue('modelClass')[0]
+ })
+ if (listOfModelClass?.data) {
+ if (
+ !value
+ ?.trim()
+ ?.toLowerCase()
+ ?.startsWith(modelClassSelected?.code?.trim()?.toLowerCase())
+ ) {
+ return Promise.reject(
+ new Error(`Equipment ID should start with ${modelClassSelected?.code}!`)
+ )
+ }
+ }
+ },
},
]}
+ className='form-control form-control-solid'
>
-
-
-
-
-
@@ -112,19 +182,38 @@ const AddEquipRegister = () => {
/>
+ {/*
*/}
+ {/*
*/}
+ {/* */}
+ {/* */}
+ {/**/}
-
-
+
+
@@ -191,6 +280,7 @@ const AddEquipRegister = () => {