Fixed vendor form issues IO-444
This commit is contained in:
@@ -2,12 +2,11 @@ import i18n from "i18next";
|
||||
import phone from "phone";
|
||||
import React, { forwardRef } from "react";
|
||||
import PhoneInput from "react-phone-input-2";
|
||||
import "./phone-form-item.styles.scss";
|
||||
import "react-phone-input-2/lib/high-res.css";
|
||||
import "./phone-form-item.styles.scss";
|
||||
function FormItemPhone(props, ref) {
|
||||
return (
|
||||
<PhoneInput
|
||||
country={"ca"}
|
||||
onlyCountries={["ca", "us"]}
|
||||
ref={ref}
|
||||
className="ant-input"
|
||||
@@ -30,10 +29,9 @@ export default forwardRef(FormItemPhone);
|
||||
|
||||
export const PhoneItemFormatterValidation = (getFieldValue, name) => ({
|
||||
async validator(rule, value) {
|
||||
console.log("getFieldValue(name)", getFieldValue(name));
|
||||
|
||||
const p = phone(getFieldValue(name), "ca");
|
||||
if (p.length > 0) {
|
||||
const p = phone(getFieldValue(name), "us");
|
||||
const p2 = phone(getFieldValue(name), "ca");
|
||||
if (p.length > 0 || p2.length > 0) {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
return Promise.reject(i18n.t("general.validation.invalidphone"));
|
||||
|
||||
Reference in New Issue
Block a user