@wulperstudio/cms
Version:
Wulper Studio Library Components CMS
42 lines • 2.03 kB
JavaScript
/* eslint-disable max-len */
import React from 'react';
import { CONTINENTS } from '../constants';
import { log, getFirstIntersection } from '../helpers';
export function useMismatchProps(props) {
var defaultCountry = props.defaultCountry,
onlyCountries = props.onlyCountries,
excludedCountries = props.excludedCountries,
continents = props.continents;
React.useEffect(function () {
if (onlyCountries && excludedCountries) {
var intersection = getFirstIntersection(onlyCountries, excludedCountries);
if (intersection) {
log("[phone-input] Not expected to have the country ".concat(intersection, " to be included in the 'onlyCountries' AND 'excludedCountries' props"));
}
}
}, [onlyCountries, excludedCountries]);
React.useEffect(function () {
if (defaultCountry) {
if (excludedCountries && excludedCountries.includes(defaultCountry)) {
log("[phone-input] Not expected to have the 'defaultCountry' (".concat(defaultCountry, ") prop excluded by the 'excludedCountries' prop"));
}
}
}, [defaultCountry, excludedCountries]);
React.useEffect(function () {
if (defaultCountry) {
if (onlyCountries && !onlyCountries.includes(defaultCountry)) {
log("[phone-input] Not expected to have a 'defaultCountry' prop (".concat(defaultCountry, ") and a 'onlyCountries' prop but without included the 'defaultCountry' (").concat(defaultCountry, ")"));
}
}
}, [defaultCountry, onlyCountries]);
React.useEffect(function () {
if (defaultCountry && continents && continents.length > 0) {
var continentOfDefaultCountry = continents.some(function (continentCode) {
return CONTINENTS[continentCode].includes(defaultCountry);
});
if (!continentOfDefaultCountry) {
log("[phone-input] Not expected to have a 'defaultCountry' prop (".concat(defaultCountry, ") and a 'continents' prop that are not contain the country (").concat(defaultCountry, ")"));
}
}
}, [defaultCountry, continents]);
}