docbrown/app/javascript/packs/Onboarding.jsx
Ben Halpern 4eb2f05387
[deploy] Add generalized community name and description to onboarding slides (#7725)
* Comment out redirect

* Back to where we were

* Add basic generalization to onboarding

* Update app/javascript/onboarding/Onboarding.jsx

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>

* Update app/javascript/onboarding/components/IntroSlide.jsx

* Update app/javascript/onboarding/components/ProfileForm.jsx

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
2020-05-08 14:45:24 -04:00

45 lines
1.3 KiB
JavaScript

import { h, render } from 'preact';
import { getUserDataAndCsrfToken } from '../chat/util';
import getUnopenedChannels from '../src/utils/getUnopenedChannels';
HTMLDocument.prototype.ready = new Promise((resolve) => {
if (document.readyState !== 'loading') {
return resolve();
}
document.addEventListener('DOMContentLoaded', () => resolve());
return null;
});
function renderPage() {
const dataElement = document.getElementById('onboarding-container');
const communityConfig = {
communityName: dataElement.dataset.communityName,
communityDescription: dataElement.dataset.communityDescription,
};
import('../onboarding/Onboarding')
.then(({ default: Onboarding }) => {
render(
<Onboarding communityConfig={communityConfig} />,
document.getElementById('onboarding-container'),
);
})
.catch((error) => {
// eslint-disable-next-line no-console
console.error('Unable to load onboarding', error);
});
}
document.ready.then(
getUserDataAndCsrfToken()
.then(({ currentUser, csrfToken }) => {
window.currentUser = currentUser;
window.csrfToken = csrfToken;
getUnopenedChannels();
renderPage();
})
.catch((error) => {
// eslint-disable-next-line no-console
console.error('Error getting user and CSRF Token', error);
}),
);