Appearance
Self sign-up to approval
A trader signs up on the website; the application appears live in the CRM for review.
Trader side
ts
/** Trader web: what may be opened, then a demo account at once. */
export async function signUpDemo(email: string, password: string) {
const options = await trader.register.retrieve();
if (!options.demo) throw new Error("demo sign-up is off");
const opened = await trader.register.create({ type: "demo", name: "Ann Smith", email, password, country: "GB" });
return opened.login; // sign in with it: trader.auth.login(...)
}type: "real" files an application instead and answers only that it was received. When register.retrieve() says a kind needs a confirmation code, call trader.register.code(...) first and send code.
Staff side
ts
/** CRM: new applications arrive live; approve after review. */
export async function watchApplications(review: (clientId: number) => Promise<boolean>) {
const socket = staff.socket();
socket.on("client_created", async (frame) => {
const id = frame.data.id;
if (await review(id)) await staff.clients.approve(id, { comment: "Approved from the queue" });
});
await socket.connect();
// What came in while nobody watched:
return staff.clients.list({ status: "registered", limit: 100 });
}