Skip to content

Commit 022163d

Browse files
committed
store/course: record "source"
1 parent 8eed770 commit 022163d

File tree

10 files changed

+48
-30
lines changed

10 files changed

+48
-30
lines changed

src/packages/next/components/store/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export default function StoreLayout({ page }: Props) {
123123

124124
switch (main) {
125125
case "site-license":
126-
return <SiteLicense noAccount={noAccount} source="license" />;
126+
return <SiteLicense noAccount={noAccount} source="site-license" />;
127127
case "course":
128128
return <SiteLicense noAccount={noAccount} source="course" />;
129129
case "cart":

src/packages/next/components/store/quota-config.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const QuotaConfig: React.FC<Props> = (props: Props) => {
115115
return "Booster";
116116
} else {
117117
switch (source) {
118-
case "license":
118+
case "site-license":
119119
return "Quota Upgrades";
120120
case "course":
121121
return "Project Upgrades";
@@ -651,7 +651,7 @@ export const QuotaConfig: React.FC<Props> = (props: Props) => {
651651
);
652652
} else {
653653
switch (source) {
654-
case "license":
654+
case "site-license":
655655
return (
656656
<Tabs
657657
activeKey={configMode}

src/packages/next/components/store/run-limit.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function RunLimit({
3434
if (!showExplanations) return;
3535

3636
switch (source) {
37-
case "license":
37+
case "site-license":
3838
return (
3939
<div style={{ marginTop: "5px" }}>
4040
{boost ? (
@@ -76,7 +76,7 @@ export function RunLimit({
7676
}
7777

7878
switch (source) {
79-
case "license":
79+
case "site-license":
8080
return (
8181
<>
8282
<Divider plain>Simultaneous Project Upgrades</Divider>
@@ -87,7 +87,7 @@ export function RunLimit({
8787
extra={extra()}
8888
>
8989
<EditRunLimit
90-
type={source}
90+
source={source}
9191
disabled={disabled}
9292
onChange={(run_limit) => {
9393
form.setFieldsValue({ run_limit });
@@ -109,7 +109,7 @@ export function RunLimit({
109109
extra={extra()}
110110
>
111111
<EditRunLimit
112-
type={source}
112+
source={source}
113113
disabled={disabled}
114114
onChange={(run_limit) => {
115115
form.setFieldsValue({ run_limit });
@@ -129,12 +129,12 @@ function EditRunLimit({
129129
value,
130130
onChange,
131131
disabled,
132-
type,
132+
source,
133133
}: {
134134
value?: number;
135135
onChange: (run_limit: number) => void;
136136
disabled?: boolean;
137-
type: LicenseSource;
137+
source: LicenseSource;
138138
}) {
139139
return (
140140
<IntegerSlider
@@ -144,9 +144,9 @@ function EditRunLimit({
144144
max={300}
145145
maxText={MAX_ALLOWED_RUN_LIMIT}
146146
onChange={onChange}
147-
units={type === "course" ? "students" : "projects"}
147+
units={source === "course" ? "students" : "projects"}
148148
presets={
149-
type === "course"
149+
source === "course"
150150
? [10, 25, 50, 75, 100, 125, 150, 200]
151151
: [1, 2, 10, 50, 100, 250, 500]
152152
}

src/packages/next/components/store/site-license.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export default function SiteLicense({ noAccount, source }: Props) {
8383
</Title>
8484
{router.query.id == null && (
8585
<>
86-
{source === "license" && (
86+
{source === "site-license" && (
8787
<div>
8888
<Paragraph style={{ fontSize: "12pt" }}>
8989
<A href="https://doc.cocalc.com/licenses.html">

src/packages/next/components/store/usage-and-duration.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export function UsageAndDuration(props: Props) {
6464
<>Academic users receive a 40% discount off the standard price.</>
6565
);
6666
switch (source) {
67-
case "license":
67+
case "site-license":
6868
return (
6969
<>
7070
Will this license be used for academic or commercial purposes?
@@ -80,7 +80,7 @@ export function UsageAndDuration(props: Props) {
8080

8181
function renderUsageItem() {
8282
switch (source) {
83-
case "license":
83+
case "site-license":
8484
return (
8585
<Radio.Group disabled={disabled}>
8686
<Space direction="vertical" style={{ margin: "5px 0" }}>
@@ -118,7 +118,7 @@ export function UsageAndDuration(props: Props) {
118118
Academic
119119
</Form.Item>
120120
);
121-
case "license":
121+
case "site-license":
122122
return (
123123
<Form.Item
124124
name="user"
@@ -256,7 +256,7 @@ export function UsageAndDuration(props: Props) {
256256
case "course":
257257
return <>{tz}</>;
258258

259-
case "license":
259+
case "site-license":
260260
return (
261261
<>
262262
You can buy a license either via a subscription or a single purchase
@@ -290,7 +290,7 @@ export function UsageAndDuration(props: Props) {
290290
</Form.Item>
291291
);
292292

293-
case "license":
293+
case "site-license":
294294
return (
295295
<Form.Item
296296
name="period"

src/packages/next/lib/api/schema/licenses/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const SiteLicenseQuotaSchema = z.object({
6969
),
7070
user: z.enum(["academic", "business"]).describe("User type."),
7171
source: z
72-
.enum(["license", "course"])
72+
.enum(["site-license", "course"])
7373
.optional()
7474
.describe(
7575
"Indicates which page (license or course) was used to create this license.",

src/packages/next/tsconfig.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,16 @@
3333
"locales/*/*.json",
3434
"locales/en/common.ts"
3535
],
36-
"exclude": ["node_modules", "public", "styles", "dist"],
36+
"exclude": [
37+
"node_modules",
38+
"public",
39+
"styles",
40+
"dist",
41+
".next",
42+
"target",
43+
"locales",
44+
"software-inventory"
45+
],
3746
"references": [
3847
{ "path": "../backend" },
3948
{ "path": "../database" },

src/packages/util/licenses/purchase/purchase-info.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export default function getPurchaseInfo(
2727
disk,
2828
member,
2929
uptime,
30+
source,
3031
boost = false,
3132
} = conf;
3233
return {
@@ -47,6 +48,7 @@ export default function getPurchaseInfo(
4748
boost,
4849
title,
4950
description,
51+
source,
5052
};
5153

5254
case "vm":

src/packages/util/licenses/purchase/types.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
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 type { Uptime } from "@cocalc/util/consts/site-license";
7+
import type { DedicatedDisk, DedicatedVM } from "@cocalc/util/types/dedicated";
8+
import type {
9+
CustomDescription,
10+
LicenseSource,
11+
Period,
12+
} from "@cocalc/util/upgrades/shopping";
13+
114
export type User = "academic" | "business";
215
export type Upgrade = "basic" | "standard" | "max" | "custom";
316
export type Subscription = "no" | "monthly" | "yearly";
@@ -45,15 +58,6 @@ export interface StartEndDatesWithStrings {
4558
end: Date | string;
4659
}
4760

48-
/*
49-
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
50-
* License: MS-RSL – see LICENSE.md for details
51-
*/
52-
53-
import type { Uptime } from "@cocalc/util/consts/site-license";
54-
import type { DedicatedDisk, DedicatedVM } from "@cocalc/util/types/dedicated";
55-
import type { CustomDescription, Period } from "../../upgrades/shopping";
56-
5761
interface Version {
5862
version: string; // it's just a string with no special interpretation.
5963
}
@@ -81,9 +85,12 @@ interface PurchaseInfoQuota0 {
8185
run_limit?: number;
8286
}
8387

88+
type PurchseInfoSource = { source?: LicenseSource };
89+
8490
export type PurchaseInfoQuota = PurchaseInfoQuota0 &
8591
CustomDescription &
86-
StartEndDates;
92+
StartEndDates &
93+
PurchseInfoSource;
8794

8895
export type PurchaseInfoVoucher = {
8996
type: "vouchers";

src/packages/util/upgrades/shopping.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export type VMCostProps = {
2727
};
2828

2929
// the store's source page from where a site-license has been created
30-
export type LicenseSource = "license" | "course";
30+
export type LicenseSource = "site-license" | "course";
3131

3232
export type QuotaCostProps = {
3333
type: "quota";

0 commit comments

Comments
 (0)