Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 24x 3x 21x 24x 19x 5x 24x 1x 23x 1x 22x 24x 24x 24x 24x 24x 24x | import { FieldValues } from "react-hook-form";
function getCountryKeysStatus(settingsData: FieldValues) {
if (settingsData?.blacklist_country_keys) {
return "exclude";
}
return "include";
}
function getTerritoryDistributionStatus(data: FieldValues) {
if (
data?.whitelist_countries.length > 0 ||
data?.blacklist_countries.length > 0
) {
return "custom";
} else {
return "all";
}
}
function getVisibilityStatus(data: FieldValues) {
if (data?.unlisted) {
return "unlisted";
}
if (data?.private) {
return "private";
}
return "public";
}
function getSettingsData(settingsData: FieldValues) {
settingsData.visibility = getVisibilityStatus(settingsData);
settingsData.territory_distribution_status =
getTerritoryDistributionStatus(settingsData);
settingsData.whitelist_country_keys = settingsData?.whitelist_countries
.sort()
.join(" ");
settingsData.blacklist_country_keys = settingsData?.blacklist_countries
.sort()
.join(" ");
settingsData.country_keys_status = getCountryKeysStatus(settingsData);
return settingsData;
}
export default getSettingsData;
|