Fixed vendor form issues IO-444

This commit is contained in:
Patrick Fic
2020-12-08 11:28:36 -08:00
parent bb8343f966
commit 83a90779a8
3 changed files with 27 additions and 12 deletions

View File

@@ -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"));