Merge pull request 'Contact Number Field Accepts More Than 10 Digits in Create/Update Contact' (#378) from Kartik_Bug#1090 into Issues_Sep_1W
Reviewed-on: #378 Merged
This commit is contained in:
commit
d87defbf9a
@ -40,7 +40,7 @@ const ManageDirectory = ({ submitContact, onCLosed }) => {
|
|||||||
const { designationList, loading: designloading } = useDesignation();
|
const { designationList, loading: designloading } = useDesignation();
|
||||||
const { contactTags, loading: Tagloading } = useContactTags();
|
const { contactTags, loading: Tagloading } = useContactTags();
|
||||||
const [IsSubmitting, setSubmitting] = useState(false);
|
const [IsSubmitting, setSubmitting] = useState(false);
|
||||||
const [showSuggestions,setShowSuggestions] = useState(false);
|
const [showSuggestions, setShowSuggestions] = useState(false);
|
||||||
const [filteredDesignationList, setFilteredDesignationList] = useState([]);
|
const [filteredDesignationList, setFilteredDesignationList] = useState([]);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
@ -132,6 +132,12 @@ const ManageDirectory = ({ submitContact, onCLosed }) => {
|
|||||||
setValue("designation", val);
|
setValue("designation", val);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle phone number input to only allow numbers and max length of 10
|
||||||
|
const handlePhoneInput = (e) => {
|
||||||
|
const value = e.target.value.replace(/[^0-9]/g, "");
|
||||||
|
e.target.value = value.slice(0, 10);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const toggleBucketId = (id) => {
|
const toggleBucketId = (id) => {
|
||||||
const updated = watchBucketIds?.includes(id)
|
const updated = watchBucketIds?.includes(id)
|
||||||
@ -277,23 +283,11 @@ const ManageDirectory = ({ submitContact, onCLosed }) => {
|
|||||||
placeholder="email@example.com"
|
placeholder="email@example.com"
|
||||||
/>
|
/>
|
||||||
{index === emailFields.length - 1 ? (
|
{index === emailFields.length - 1 ? (
|
||||||
// <button
|
|
||||||
// type="button"
|
|
||||||
// className="btn btn-xs btn-primary ms-1"
|
|
||||||
// onClick={handleAddEmail}
|
|
||||||
// style={{ width: "24px", height: "24px" }}
|
|
||||||
// >
|
|
||||||
<i
|
<i
|
||||||
className="bx bx-plus-circle bx-xs ms-1 cursor-pointer text-primary"
|
className="bx bx-plus-circle bx-xs ms-1 cursor-pointer text-primary"
|
||||||
onClick={handleAddEmail}
|
onClick={handleAddEmail}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
// <button
|
|
||||||
// type="button"
|
|
||||||
// className="btn btn-xs btn-danger ms-1 p-0"
|
|
||||||
// onClick={() => removeEmail(index)}
|
|
||||||
// style={{ width: "24px", height: "24px" }}
|
|
||||||
// >
|
|
||||||
<i
|
<i
|
||||||
className="bx bx-minus-circle bx-xs ms-1 cursor-pointer text-primary"
|
className="bx bx-minus-circle bx-xs ms-1 cursor-pointer text-primary"
|
||||||
onClick={() => removeEmail(index)}
|
onClick={() => removeEmail(index)}
|
||||||
@ -335,29 +329,19 @@ const ManageDirectory = ({ submitContact, onCLosed }) => {
|
|||||||
<label className="form-label">Phone</label>
|
<label className="form-label">Phone</label>
|
||||||
<div className="d-flex align-items-center">
|
<div className="d-flex align-items-center">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="tel"
|
||||||
className="form-control form-control-sm"
|
className="form-control form-control-sm"
|
||||||
{...register(`contactPhones.${index}.phoneNumber`)}
|
{...register(`contactPhones.${index}.phoneNumber`)}
|
||||||
placeholder="9876543210"
|
placeholder="9876543210"
|
||||||
|
onInput={handlePhoneInput}
|
||||||
|
maxLength={10}
|
||||||
/>
|
/>
|
||||||
{index === phoneFields.length - 1 ? (
|
{index === phoneFields.length - 1 ? (
|
||||||
// <button
|
|
||||||
// type="button"
|
|
||||||
// className="btn btn-xs btn-primary ms-1"
|
|
||||||
// onClick={handleAddPhone}
|
|
||||||
// style={{ width: "24px", height: "24px" }}
|
|
||||||
// >
|
|
||||||
<i
|
<i
|
||||||
className="bx bx-plus-circle bx-xs ms-1 cursor-pointer text-primary"
|
className="bx bx-plus-circle bx-xs ms-1 cursor-pointer text-primary"
|
||||||
onClick={handleAddPhone}
|
onClick={handleAddPhone}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
// <button
|
|
||||||
// type="button"
|
|
||||||
// className="btn btn-xs btn-danger ms-1"
|
|
||||||
// onClick={() => removePhone(index)}
|
|
||||||
// style={{ width: "24px", height: "24px" }}
|
|
||||||
// >
|
|
||||||
<i
|
<i
|
||||||
className="bx bx-minus-circle bx-xs ms-1 cursor-pointer text-danager"
|
className="bx bx-minus-circle bx-xs ms-1 cursor-pointer text-danager"
|
||||||
onClick={() => removePhone(index)}
|
onClick={() => removePhone(index)}
|
||||||
@ -504,4 +488,4 @@ const ManageDirectory = ({ submitContact, onCLosed }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ManageDirectory;
|
export default ManageDirectory;
|
@ -121,6 +121,11 @@ const UpdateContact = ({ submitContact, existingContact, onCLosed }) => {
|
|||||||
setValue("designation", val);
|
setValue("designation", val);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handlePhoneInput = (e) => {
|
||||||
|
const value = e.target.value.replace(/[^0-9]/g, "");
|
||||||
|
e.target.value = value.slice(0, 10);
|
||||||
|
};
|
||||||
|
|
||||||
const watchBucketIds = watch("bucketIds");
|
const watchBucketIds = watch("bucketIds");
|
||||||
|
|
||||||
const toggleBucketId = (id) => {
|
const toggleBucketId = (id) => {
|
||||||
@ -377,10 +382,12 @@ const UpdateContact = ({ submitContact, existingContact, onCLosed }) => {
|
|||||||
<label className="form-label">Phone</label>
|
<label className="form-label">Phone</label>
|
||||||
<div className="d-flex align-items-center">
|
<div className="d-flex align-items-center">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="tel"
|
||||||
className="form-control form-control-sm"
|
className="form-control form-control-sm"
|
||||||
{...register(`contactPhones.${index}.phoneNumber`)}
|
{...register(`contactPhones.${index}.phoneNumber`)}
|
||||||
placeholder="9876543210"
|
placeholder="9876543210"
|
||||||
|
onInput={handlePhoneInput}
|
||||||
|
maxLength={10}
|
||||||
/>
|
/>
|
||||||
{index === phoneFields.length - 1 ? (
|
{index === phoneFields.length - 1 ? (
|
||||||
// <button
|
// <button
|
||||||
|
Loading…
x
Reference in New Issue
Block a user