@rocket.chat/onboarding-ui
Version:
Set of components and functions for the onboarding experience on Rocket.Chat
79 lines • 2.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.countryOptions = exports.organizationSizeOptions = exports.organizationIndustryOptions = exports.validatePassword = exports.validateEmail = exports.validateUsername = exports.logSubmit = void 0;
const countries_list_1 = require("countries-list");
const actions_1 = require("storybook/actions");
const logSubmit = (onSubmit) => (...args) => {
(0, actions_1.action)('submit')(...args);
return onSubmit(...args);
};
exports.logSubmit = logSubmit;
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const simulateNetworkDelay = () => delay(3000 * Math.random());
const fetchMock = (endpoint, handler) => async (...args) => {
(0, actions_1.action)(`fetch(${endpoint})`)(...args);
await simulateNetworkDelay();
return handler(...args);
};
exports.validateUsername = fetchMock('/username/validate', (username) => {
if (username === 'admin') {
return `Username "${username}" is not available`;
}
return true;
});
exports.validateEmail = fetchMock('/email/validate', (email) => {
if (email === 'admin@rocket.chat') {
return `Email "${email}" is already in use`;
}
return true;
});
const validatePassword = (password) => {
if (password.length < 6) {
return `Password is too short`;
}
return true;
};
exports.validatePassword = validatePassword;
exports.organizationIndustryOptions = [
['aerospaceDefense', 'Aerospace and Defense'],
['blockchain', 'Blockchain'],
['consulting', 'Consulting'],
['consumerGoods', 'Consumer Packaged Goods'],
['contactCenter', 'Contact Center'],
['education', 'Education'],
['entertainment', 'Entertainment'],
['financialServices', 'Financial Services'],
['gaming', 'Gaming'],
['healthcare', 'Healthcare'],
['hospitalityBusinness', 'Hospitality Businness'],
['insurance', 'Insurance'],
['itSecurity', 'IT Security'],
['logistics', 'Logistics'],
['manufacturing', 'Manufacturing'],
['media', 'Media'],
['pharmaceutical', 'Pharmaceutical'],
['realEstate', 'Real Estate'],
['religious', 'Religious'],
['retail', 'Retail'],
['socialNetwork', 'Social Network'],
['technologyProvider', 'Technology Provider'],
['technologyServices', 'Technology Services'],
['telecom', 'Telecom'],
['utilities', 'Utilities'],
['other', 'Other'],
];
exports.organizationSizeOptions = [
['0', '1-250 people'],
['1', '251-500 people'],
['2', '501-1000 people'],
['3', '1001-4000 people'],
['4', '4001 or more people'],
];
exports.countryOptions = [
...Object.entries(countries_list_1.countries).map(([code, { name }]) => [
code,
name,
]),
['worldwide', 'Worldwide'],
];
//# sourceMappingURL=mocks.js.map