import Bind from "@web-atoms/core/dist/core/Bind.js"; import XNode from "@web-atoms/core/dist/core/XNode.js"; import Form from "@web-atoms/web-controls/dist/basic/Form.js"; import FormField from "@web-atoms/web-controls/dist/basic/FormField.js"; import { CountrySelect, formatForCountry, isdForCountry } from "../../../controls/countries/CountrySelect.js"; import MaskedInput from "@web-atoms/web-controls/dist/basic/MaskedInput.js"; import FetchBuilder from "@web-atoms/core/dist/services/FetchBuilder.js"; import Action from "@web-atoms/core/dist/view-model/Action.js"; import Pack from "@web-atoms/core/dist/Pack.js"; import { ContentPage } from "@web-atoms/web-controls/dist/mobile-app/MobileApp.js"; import PageNavigator from "@web-atoms/web-controls/dist/PageNavigator.js"; import TermsPage from "../../terms/TermsPage.js"; import "./SignupPage.local.css"; const css = "social-mail-site-sign-up-page"; interface IVerification { id?: string; code?: string; verified?: string; } @Pack export default class SignupPage extends ContentPage { termsAgreed = false; model: { username: string; password: string; passwordAgain: string; phoneNumber: string; country: string; phoneNumberText: string; name: string; captcha: IVerification; phone: IVerification; } = { name: "", username: "", password: "", passwordAgain: "", phoneNumber: "", country: "US", phoneNumberText: "", captcha: { code: "" }, phone: { code: "" } } async init() { this.hideToolbar = true; this.element.className = css; this.title = "Social Mail Signup"; const { id } = await FetchBuilder.put("/api/users/captcha").asJson<{ id }>(); this.model.captcha.id = id; this.renderer =
this.model.name)}/>
this.model.username)} />
Username Policy Please choose username that resembles your real legal name. Any other name will be banned and blocked permanently. And you will not be able to create new username with same phone number as well.
this.model.password)} /> this.model.passwordAgain)} />
this.model.country)} /> formatForCountry(this.model.country))} value={Bind.twoWaysImmediate(() => this.model.phoneNumberText)} />
We require phone number verification to prevent misuse and fraud over the email. And it will also help you in setting up two factor authentication to prevent hackers from accessing your private emails.


this.model.captcha.code)}/>
; } @Action({ onEvent: "signup"}) async signup() { const { model } = this; if (!model.password) { throw new Error("Password is required"); } if (model.password.length < 7) { throw new Error("Password is cannot be less than 7 characters"); } if (/\s/i.test(model.password)) { throw new Error("Password must not any whitespace characters"); } if (!this.termsAgreed) { await PageNavigator.pushPageForResult(TermsPage); this.termsAgreed = true; } const isdCode = await isdForCountry(model.country); const phoneNumber = model.phoneNumberText.replace(/[^0-9]/g,""); model.phoneNumber = isdCode.startsWith("+") ? isdCode + phoneNumber: `+${isdCode}${phoneNumber}`; const { userID, phone = {} as IVerification, captcha = {} as IVerification } = await FetchBuilder.post("/api/users/signup") .jsonBody(model) .asJson(); if (userID) { location.href = "/"; return; } if (captcha) { model.captcha.verified = captcha.verified; } if (phone?.verified) { model.phone.verified = phone.verified; } if (phone?.id) { model.phone.id = phone.id; await this.askPhoneCode(); } } async askPhoneCode() { this.renderer =

Phone Verification Code

We have send text verification code on your phone number, please enter the code below to verify.

this.model.phone.code)}/>
; } }