@@ -11,26 +11,27 @@ shopping cart experience, so most likely to feel familiar to users and easy
11
11
to use.
12
12
*/
13
13
14
+ import { Alert , Button , Checkbox , Popconfirm , Table } from "antd" ;
15
+ import { useRouter } from "next/router" ;
16
+ import { useEffect , useMemo , useState , type JSX } from "react" ;
17
+
14
18
import { Icon } from "@cocalc/frontend/components/icon" ;
19
+ import type {
20
+ ProductDescription ,
21
+ ProductType ,
22
+ } from "@cocalc/util/db-schema/shopping-cart-items" ;
15
23
import { describeQuotaFromInfo } from "@cocalc/util/licenses/describe-quota" ;
16
24
import { CostInputPeriod } from "@cocalc/util/licenses/purchase/types" ;
25
+ import { computeCost } from "@cocalc/util/licenses/store/compute-cost" ;
17
26
import { capitalize , isValidUUID } from "@cocalc/util/misc" ;
18
- import { Alert , Button , Checkbox , Popconfirm , Table } from "antd" ;
19
27
import A from "components/misc/A" ;
20
28
import Loading from "components/share/loading" ;
21
29
import SiteName from "components/share/site-name" ;
22
30
import apiPost from "lib/api/post" ;
23
31
import useAPI from "lib/hooks/api" ;
24
32
import useIsMounted from "lib/hooks/mounted" ;
25
- import { useRouter } from "next/router" ;
26
- import { useEffect , useMemo , useState , type JSX } from "react" ;
27
- import { computeCost } from "@cocalc/util/licenses/store/compute-cost" ;
28
33
import OtherItems from "./other-items" ;
29
34
import { describeItem , describePeriod , DisplayCost } from "./site-license-cost" ;
30
- import type {
31
- ProductDescription ,
32
- ProductType ,
33
- } from "@cocalc/util/db-schema/shopping-cart-items" ;
34
35
35
36
export default function ShoppingCart ( ) {
36
37
const isMounted = useIsMounted ( ) ;
@@ -353,9 +354,9 @@ export function DescriptionColumn(props: DCProps) {
353
354
const router = useRouter ( ) ;
354
355
const { id, description, style, readOnly } = props ;
355
356
if (
356
- description . type == "disk" ||
357
- description . type == "vm" ||
358
- description . type == "quota"
357
+ description . type === "disk" ||
358
+ description . type === "vm" ||
359
+ description . type === "quota"
359
360
) {
360
361
return < DescriptionColumnSiteLicense { ...props } /> ;
361
362
} else if ( description . type == "cash-voucher" ) {
@@ -390,9 +391,9 @@ function DescriptionColumnSiteLicense(props: DCProps) {
390
391
const { id, cost, description, compact, project_id, readOnly } = props ;
391
392
if (
392
393
! (
393
- description . type == "disk" ||
394
- description . type == "vm" ||
395
- description . type == "quota"
394
+ description . type === "disk" ||
395
+ description . type === "vm" ||
396
+ description . type === "quota"
396
397
)
397
398
) {
398
399
throw Error ( "BUG -- incorrect typing" ) ;
@@ -403,7 +404,7 @@ function DescriptionColumnSiteLicense(props: DCProps) {
403
404
return < pre > { JSON . stringify ( description , undefined , 2 ) } </ pre > ;
404
405
}
405
406
const { input } = cost ;
406
- if ( input . type == "cash-voucher" ) {
407
+ if ( input . type === "cash-voucher" ) {
407
408
throw Error ( "incorrect typing" ) ;
408
409
}
409
410
@@ -423,7 +424,7 @@ function DescriptionColumnSiteLicense(props: DCProps) {
423
424
}
424
425
425
426
function editableQuota ( ) {
426
- if ( input . type == "cash-voucher" ) return null ;
427
+ if ( input . type === "cash-voucher" ) return null ;
427
428
return (
428
429
< div >
429
430
< div > { describeQuotaFromInfo ( input ) } </ div >
@@ -433,9 +434,14 @@ function DescriptionColumnSiteLicense(props: DCProps) {
433
434
}
434
435
435
436
// this could rely an the "type" field, but we rather check the data directly
436
- function editPage ( ) : "site-license" | "vouchers" {
437
- if ( input . type == "cash-voucher" ) {
437
+ function editPage ( ) : "site-license" | "vouchers" | "course" {
438
+ if ( input . type === "cash-voucher" ) {
438
439
return "vouchers" ;
440
+ } else if (
441
+ description . type === "quota" &&
442
+ description . source === "course"
443
+ ) {
444
+ return "course" ;
439
445
}
440
446
return "site-license" ;
441
447
}
@@ -451,7 +457,7 @@ function DescriptionColumnSiteLicense(props: DCProps) {
451
457
< div style = { DESCRIPTION_STYLE } >
452
458
< div style = { { marginBottom : "8px" } } >
453
459
< b >
454
- { input . subscription == "no"
460
+ { input . subscription === "no"
455
461
? describePeriod ( { quota : input } )
456
462
: capitalize ( input . subscription ) + " subscription" }
457
463
</ b >
0 commit comments