CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/billing/store.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { List, Map, Set } from "immutable";
7
8
import { redux, Store, TypedMap } from "@cocalc/frontend/app-framework";
9
import { SiteLicense } from "@cocalc/util/types/site-licenses";
10
import { AppliedCoupons, CoursePay, CustomerMap, InvoicesMap } from "./types";
11
12
export interface BillingStoreState {
13
stripe_publishable_key?: string;
14
applied_coupons: AppliedCoupons;
15
coupon_error?: string;
16
error?: string;
17
action?: string;
18
no_stripe?: boolean;
19
customer?: CustomerMap;
20
invoices?: InvoicesMap;
21
loaded?: boolean;
22
continue_first_purchase?: boolean;
23
selected_plan?: string;
24
course_pay: CoursePay;
25
managed_license_ids?: List<string>; // array of active (or recently expired) id's of license you manage. Not a changefeed -- you must explicitly call update_managed_licenses action.
26
all_managed_license_ids?: List<string>; // same as managed_license_ids, but also includes all expired licenses.
27
managed_licenses?: TypedMap<{ [id: string]: SiteLicense }>; // actual data of the licenses.
28
subscription_list_state?: "view" | "buy_upgrades" | "buy_license";
29
pay_as_you_go?: TypedMap<{
30
showModal?: boolean;
31
service?: string;
32
cost?: number;
33
reason?: string;
34
allowed?: boolean;
35
}>;
36
}
37
38
export class BillingStore extends Store<BillingStoreState> {}
39
40
export const store = redux.createStore("billing", BillingStore, {
41
applied_coupons: Map<string, any>(),
42
course_pay: Set<string>(),
43
});
44
45