@skhemata/skhemata-crowdfunding-campaign
Version:
Skhemata Crowdfunding Campaign Web Component. This web component provides crowdfunding campaign functionality (reward/donation based) for a website.
136 lines (134 loc) • 4.93 kB
JavaScript
import { __decorate } from "tslib";
/* eslint-disable import/no-extraneous-dependencies */
import '@power-elements/stripe-elements';
import { html, css, LitElement } from 'lit';
import { property } from 'lit/decorators.js';
import { Bulma } from '@skhemata/skhemata-css';
import { loginRequest } from '../utils/requests';
import { GlobalStyles } from '../styles/global';
export class CreateAccountContribution extends LitElement {
constructor() {
super(...arguments);
this.submitDisabled = false;
this.authState = false;
// firstUpdated() {
// }
this.handleCreateAccount = async () => {
var _a, _b, _c, _d, _e;
if (this.shadowRoot) {
const firstName = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById('firstName');
const lastName = (_b = this.shadowRoot) === null || _b === void 0 ? void 0 : _b.getElementById('lastName');
const email = (_c = this.shadowRoot) === null || _c === void 0 ? void 0 : _c.getElementById('email');
const password = (_d = this.shadowRoot) === null || _d === void 0 ? void 0 : _d.getElementById('password');
const confirmPassword = (_e = this.shadowRoot) === null || _e === void 0 ? void 0 : _e.getElementById('confirmPassword');
if (email.value &&
password.value &&
firstName.value &&
lastName.value &&
password.value === confirmPassword.value) {
const info = {
email: email.value,
first_name: firstName.value,
inline_registration: true,
last_name: lastName.value,
password: password.value,
password_confirm: confirmPassword.value,
};
const res = await loginRequest('/register', 'POST', info);
const data = await res.json();
if (data.auth_token !== undefined) {
window.localStorage.setItem('skhemataToken', data.auth_token);
}
this.handleAuthStateChange();
this.requestUpdate();
}
else if (password.value !== confirmPassword.value) {
console.log('Passwords do not match');
}
else {
console.log('Please fill out all fields');
}
}
};
}
render() {
return html `
<div class="field formWrapper">
<div class="is-flex is-flex-gap-4 control double-box-wrapper">
<div class="is-flex is-flex-direction-column is-flex-gap-4">
<input
class="input is-size-5"
type="text"
id="firstName"
placeholder="First Name"
/>
<input
class="input is-size-5"
type="text"
id="lastName"
placeholder="Last Name"
/>
<input
class="input is-size-5"
type="email"
id="email"
placeholder="Email"
/>
</div>
<div class=" is-flex is-flex-direction-column is-flex-gap-4">
<input
class="input is-size-5"
type="password"
id="password"
placeholder="Password"
/>
<input
class="input is-size-5"
type="password"
id="confirmPassword"
placeholder="Confirm Password"
/>
<div class="is-flex is-justify-content-flex-end">
<button
class="button btnRadius has-background-success has-text-white is-size-5 py-0 px-6 "
="${this.handleCreateAccount}"
>
Create Account
</button>
</div>
</div>
</div>
</div>
`;
}
}
CreateAccountContribution.styles = [
Bulma,
GlobalStyles,
css `
/* .formWrapper {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 1rem;
}
.double-box-wrapper {
display: flex;
flex-direction: row;
gap: 1rem;
} */
.formWrapper div {
width: 100%;
}
`,
];
__decorate([
property({ type: Boolean })
], CreateAccountContribution.prototype, "submitDisabled", void 0);
__decorate([
property({ type: Boolean })
], CreateAccountContribution.prototype, "authState", void 0);
__decorate([
property({ type: Function })
], CreateAccountContribution.prototype, "handleAuthStateChange", void 0);
//# sourceMappingURL=CreateAccountContribution.js.map