@composable-os/pack-courses 0.1.0-beta.10 → 0.1.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/automations.js +1 -2
- package/dist/blocks/courses-builder/course-builder.js +15 -21
- package/dist/blocks/courses-catalogue/catalogue.js +2 -3
- package/dist/blocks/courses-course/course-page.d.ts +6 -1
- package/dist/blocks/courses-course/course-page.js +73 -9
- package/dist/blocks/courses-my-courses/my-courses.d.ts +14 -1
- package/dist/blocks/courses-my-courses/my-courses.js +9 -1
- package/dist/blocks/courses-native-catalogue/catalogue-screen.js +3 -6
- package/dist/blocks/courses-native-course/course-screen.js +2 -2
- package/dist/blocks/courses-native-my-courses/my-courses-screen.d.ts +14 -1
- package/dist/blocks/courses-native-my-courses/my-courses-screen.js +16 -3
- package/dist/blocks/courses-native-player/lesson-screen.d.ts +1 -0
- package/dist/blocks/courses-native-player/lesson-screen.js +2 -2
- package/dist/blocks/courses-native-subscription/subscription-screen.js +2 -2
- package/dist/blocks/courses-player/player.d.ts +1 -1
- package/dist/blocks/courses-subscribe/subscribe.d.ts +6 -1
- package/dist/blocks/courses-subscribe/subscribe.js +80 -9
- package/dist/blocks/courses-subscription/my-subscription.d.ts +6 -4
- package/dist/blocks/courses-subscription/my-subscription.js +14 -49
- package/dist/client/index.d.ts +382 -10
- package/dist/client/index.js +24 -36
- package/dist/dashboards.d.ts +2 -0
- package/dist/dashboards.js +3 -3
- package/dist/index.d.ts +82 -3
- package/dist/index.js +68 -3
- package/dist/outline.d.ts +1 -3
- package/dist/outline.js +25 -16
- package/dist/tools.d.ts +7 -1
- package/dist/tools.js +130 -103
- package/package.json +3 -3
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { CoursesHooks } from "@composable-os/pack-courses/client";
|
|
2
|
-
export declare function MySubscription({ courses,
|
|
3
|
-
courses: Pick<CoursesHooks, "useMySubscriptions" | "useCancelSubscription" | "useResumeSubscription"
|
|
4
|
-
/**
|
|
5
|
-
returnUrl
|
|
2
|
+
export declare function MySubscription({ courses, empty, }: {
|
|
3
|
+
courses: Pick<CoursesHooks, "useMySubscriptions" | "useCancelSubscription" | "useResumeSubscription">;
|
|
4
|
+
/** Kept for a page that still passes it: the card is My account's Payment method section. */
|
|
5
|
+
returnUrl?: string;
|
|
6
|
+
/** What to say when there is none; null says nothing (as a part of the Courses section). */
|
|
7
|
+
empty?: string | null;
|
|
6
8
|
}): import("react").JSX.Element;
|
|
@@ -1,50 +1,15 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import { formatMinor,
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (error || !data)
|
|
16
|
-
return _jsx("p", { role: "alert", children: "We could not load your subscription." });
|
|
17
|
-
const live = data.items.filter(isLive);
|
|
18
|
-
if (!live.length)
|
|
19
|
-
return _jsx("p", { children: "You have no course subscription." });
|
|
20
|
-
async function act(run, done) {
|
|
21
|
-
setProblem(null);
|
|
22
|
-
setSaid(null);
|
|
23
|
-
try {
|
|
24
|
-
await run();
|
|
25
|
-
setSaid(done);
|
|
26
|
-
}
|
|
27
|
-
catch (e) {
|
|
28
|
-
setProblem(e instanceof Error ? e.message : "That did not work");
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
async function onPortal() {
|
|
32
|
-
setProblem(null);
|
|
33
|
-
try {
|
|
34
|
-
// The provider's portal opens in its own page: it cannot be put in a frame.
|
|
35
|
-
const opened = await portal.mutateAsync({ returnUrl });
|
|
36
|
-
window.location.assign(opened.url);
|
|
37
|
-
}
|
|
38
|
-
catch (e) {
|
|
39
|
-
setProblem(e instanceof Error ? e.message : "We could not open your billing");
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const ending = (sub) => sub.cancelAtPeriodEnd || sub.cancelAt !== null;
|
|
43
|
-
const busy = cancel.isPending || resume.isPending || portal.isPending;
|
|
44
|
-
return (_jsxs("section", { className: "grid gap-4", "aria-label": "My subscription", children: [live.map((sub) => (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { children: sub.planTitle }), _jsx(CardDescription, { children: `${formatMinor(sub.amount, sub.currency)} a ${sub.interval} · every course` })] }), _jsxs(CardContent, { className: "grid gap-3", children: [_jsx("p", { "data-testid": "subscription-status", children: subscriptionStatus(sub) }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [sub.actionUrl ? (_jsx(Button, { onClick: () => window.location.assign(sub.actionUrl ?? ""), children: "Confirm your payment" })) : null, sub.cancelAtPeriodEnd ? (_jsx(Button, { disabled: busy, onClick: () => void act(() => resume.mutateAsync({ id: sub.id }), "Asked to keep it going. It shows here once the payment provider confirms."), children: "Keep my subscription" })) : ending(sub) ? null : (_jsx(Button, { variant: "outline", disabled: busy, onClick: () => {
|
|
45
|
-
if (!window.confirm("Cancel? You keep every course until the period ends.")) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
void act(() => cancel.mutateAsync({ id: sub.id, reason: "Cancelled by the member" }), "Asked to cancel. It ends when the period does; it shows here once the payment provider confirms.");
|
|
49
|
-
}, children: "Cancel subscription" })), _jsx(Button, { variant: "outline", disabled: busy, onClick: () => void onPortal(), children: "Card and invoices" })] })] })] }, sub.id))), said ? _jsx("p", { role: "status", children: said }) : null, problem ? _jsx("p", { role: "alert", children: problem }) : null] }));
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { formatMinor, subscriptionStatus } from "@composable-os/pack-courses/client";
|
|
3
|
+
import { MySubscriptions } from "../web-account-subscriptions/subscriptions.js";
|
|
4
|
+
export function MySubscription({ courses, empty = "You have no course subscription.", }) {
|
|
5
|
+
return (_jsx("section", { className: "grid gap-4", "aria-label": "My subscription", children: _jsx(MySubscriptions, { account: {
|
|
6
|
+
useSubscriptions: courses.useMySubscriptions,
|
|
7
|
+
useCancelSubscription: courses.useCancelSubscription,
|
|
8
|
+
useResumeSubscription: courses.useResumeSubscription,
|
|
9
|
+
}, label: "Your course subscription", empty: empty, status: subscriptionStatus, words: {
|
|
10
|
+
cancel: "Cancel subscription",
|
|
11
|
+
resume: "Keep my subscription",
|
|
12
|
+
confirmCancel: "Cancel? You keep every course until the period ends.",
|
|
13
|
+
description: (sub) => `${formatMinor(sub.amount, sub.currency)} a ${sub.interval} · every course`,
|
|
14
|
+
} }) }));
|
|
50
15
|
}
|