Path: blob/master/src/packages/frontend/account/table.ts
5537 views
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Table } from "@cocalc/frontend/app-framework/Table";67// Create and register account table, which gets automatically8// synchronized with the server.9export class AccountTable extends Table {10private first_set: boolean = true;1112constructor(name, redux) {13super(name, redux);14this.query = this.query.bind(this);15this._change = this._change.bind(this);16}1718options() {19return [];20}2122query() {23return {24accounts: [25{26account_id: null,27balance: null,28min_balance: null,29balance_alert: null,30auto_balance: null,31email_address: null,32email_address_verified: null,33email_address_problem: null,34editor_settings: null,35other_settings: null,36name: null,37first_name: null,38last_name: null,39terminal: null,40autosave: null,41evaluate_key: null,42font_size: null,43passports: null,44groups: null,45last_active: null,46ssh_keys: null,47created: null,48ephemeral: null,49customize: null,50unlisted: null,51tags: null,52tours: null,53purchase_closing_day: null,54email_daily_statements: null,55stripe_checkout_session: null,56stripe_usage_subscription: null,57stripe_customer: null, // used for legacy upgrades ONLY.58unread_message_count: null,59},60],61};62}6364_change(table: { get_one: () => { toJS: () => any } }) {65const changes = table.get_one();66if (!changes) return;67const actions = this.redux.getActions("account");68const obj = changes.toJS();69actions.setState(obj);70if (this.first_set) {71this.first_set = false;72actions.setState({ is_ready: true });73this.redux.getStore("account").emit("is_ready");74if (obj.stripe_customer?.subscriptions?.data != null) {75// exclude legacy customers from commercialization requirements.76(77this.redux.getActions("customize") as any78).disableCommercializationParameters();79}80}81}82}838485