@@ -1,7 +1,23 @@
|
||||
//import NumberFormat from "react-number-format";
|
||||
import { Typography } from "antd";
|
||||
import parsePhoneNumber from "libphonenumber-js";
|
||||
|
||||
export default function PhoneNumberFormatter(props) {
|
||||
const p = parsePhoneNumber(props.children || "", "CA");
|
||||
return p ? <span>{p.formatNational()}</span> : null;
|
||||
const { Text } = Typography;
|
||||
|
||||
export default function PhoneNumberFormatter({ children, type }) {
|
||||
const p = parsePhoneNumber(children || "", "CA");
|
||||
if (!p) return null;
|
||||
|
||||
const phone = p.formatNational();
|
||||
|
||||
return (
|
||||
<span>
|
||||
<Text>{phone}</Text>
|
||||
{type ? (
|
||||
<>
|
||||
{" "}
|
||||
<Text type="secondary">({type})</Text>
|
||||
</>
|
||||
) : null}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user