@micha.bigler/ui-core-micha 4.3.0 → 4.5.0
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/CHANGELOG.md +25 -0
- package/dist/billing/AccessEndedBanner.js +11 -0
- package/dist/billing/PlanPicker.js +52 -0
- package/dist/billing/SubscriptionSection.js +101 -0
- package/dist/billing/TokenBalanceBadge.js +14 -0
- package/dist/billing/TokenCostPreview.js +18 -0
- package/dist/billing/WithdrawalDialog.js +95 -0
- package/dist/billing/WithdrawalSection.js +59 -0
- package/dist/billing/api.js +19 -0
- package/dist/billing/format.js +40 -0
- package/dist/billing/safeUrl.js +21 -0
- package/dist/billing/useBilling.js +37 -0
- package/dist/billing/wire.js +16 -0
- package/dist/i18n/billingTranslations.js +63 -0
- package/dist/i18n/uiCoreTranslations.js +2 -1
- package/dist/index.js +11 -0
- package/dist/theme/kitSxRegistry.js +24 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.5.0 - UCM-BILL-3
|
|
4
|
+
|
|
5
|
+
"Withdraw contract here" for EU/EEA consumers, against the `django-core-micha` 3.5.0 withdrawal API
|
|
6
|
+
(`withdrawal/`, `withdrawal/<id>/preview/`, `POST withdrawal/<id>/`). `WithdrawalSection` lists only the purchases the
|
|
7
|
+
server calls eligible, with the 14-day deadline (purchase date plus 14 days) and a button; `WithdrawalDialog` shows the
|
|
8
|
+
server's refund amount and a calculation composed from the server's numbers (`describeCalculation`), confirms exactly
|
|
9
|
+
once and shows the result. The kit never decides eligibility or the amount itself; a 409 shows "not possible". The
|
|
10
|
+
section is part of `SubscriptionSection` (prop `withdrawal`, default `true`, `false` hides it). `createBillingApi`
|
|
11
|
+
gets `listWithdrawals`, `previewWithdrawal`, `confirmWithdrawal`; `formatPrice` takes an optional currency and
|
|
12
|
+
`formatDateTime` is new. New keys `Billing.WITHDRAWAL_*` (de formal, de_informal, en, fr, sw).
|
|
13
|
+
|
|
14
|
+
## 4.4.0 - UCM-BILL-1
|
|
15
|
+
|
|
16
|
+
Subscription and token surfaces in the main entry, against the `django-core-micha` billing API (DCM-BILL-1, `me/`,
|
|
17
|
+
`checkout/`, `portal/`, `team/seats/`; base path `apiBase`, default `/api/billing/`). `PlanPicker` (monthly/yearly
|
|
18
|
+
switch when both exist, team packages with seats and term, token packages with `kinds`) continues to Stripe Checkout:
|
|
19
|
+
the checkout and portal links are followed only when the server returns an `https://` URL, through an injectable
|
|
20
|
+
`redirect`. `SubscriptionSection` is the account section "Abo": the state comes only from the server (active
|
|
21
|
+
subscription with end date and customer portal, team payer with seat management, team member, free access, ended
|
|
22
|
+
access with `AccessEndedBanner` and renewal, token balance and "buy a package"). Also `TokenBalanceBadge`,
|
|
23
|
+
`TokenCostPreview` (the cost, alternatives and balance the app passes in), `useBilling`, `createBillingApi` /
|
|
24
|
+
`defaultBillingApi` and `billingTranslations` (de/en/fr/sw, part of `uiCoreTranslations`). The operator overview and the
|
|
25
|
+
"free access" switch are not part of this release (UCM-BILL-2, no API yet). The server does not send the plan name,
|
|
26
|
+
token expiry or seat-holder names, so none are shown.
|
|
27
|
+
|
|
3
28
|
## 4.3.0 - UCM-CHAT-5
|
|
4
29
|
|
|
5
30
|
`ChatWorkspace` gets three optional props; without them it behaves as in 4.2.x. `getSendContext()` (synchronous, no
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Alert, Button, Stack } from '@mui/material';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { formatDate } from './format';
|
|
6
|
+
export const ACCESS_ENDED_BANNER_ALERT_SX = { alignItems: 'center' };
|
|
7
|
+
export function AccessEndedBanner({ endedAt, deletionDate, onRenew }) {
|
|
8
|
+
const { t, i18n } = useTranslation();
|
|
9
|
+
return _jsx(Alert, { severity: "warning", role: "status", sx: ACCESS_ENDED_BANNER_ALERT_SX, action: _jsx(Button, { color: "inherit", onClick: onRenew, children: t('Billing.RENEW') }), children: _jsxs(Stack, { spacing: 0.5, children: [_jsx("span", { children: t('Billing.ENDED_TITLE') }), formatDate(endedAt, i18n.language) && _jsx("span", { children: t('Billing.ENDED_ON', { date: formatDate(endedAt, i18n.language) }) }), formatDate(deletionDate, i18n.language) && _jsx("span", { children: t('Billing.DELETION_ON', { date: formatDate(deletionDate, i18n.language) }) })] }) });
|
|
10
|
+
}
|
|
11
|
+
export default AccessEndedBanner;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useMemo, useState } from 'react';
|
|
3
|
+
import { Alert, Button, Card, FormControlLabel, Radio, RadioGroup, Stack, ToggleButton, ToggleButtonGroup, Typography } from '@mui/material';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { formatPrice, formatTokens } from './format';
|
|
6
|
+
import { defaultBillingApi } from './api';
|
|
7
|
+
import { DEFAULT_PAYMENT_HOSTS, isTrustedPaymentUrl } from './safeUrl';
|
|
8
|
+
export const PLAN_PICKER_CARD_SX = { width: { xs: '100%', sm: 'calc(50% - 8px)' } };
|
|
9
|
+
export const PLAN_PICKER_SELECTED_CARD_SX = { outline: '2px solid', outlineColor: 'primary.main', outlineOffset: 1 };
|
|
10
|
+
export const PLAN_PICKER_ALERT_SX = { width: '100%' };
|
|
11
|
+
export const PLAN_PICKER_LABEL_SX = { m: 0, p: 2, width: '100%', height: '100%', alignItems: 'flex-start' };
|
|
12
|
+
export function PlanPicker({ plans = [], kinds = ['subscription', 'team_package'], api = defaultBillingApi, redirect = (url) => window.location.assign(url), allowedHosts = DEFAULT_PAYMENT_HOSTS, describePlan, onError }) {
|
|
13
|
+
const { t, i18n } = useTranslation();
|
|
14
|
+
const [selected, setSelected] = useState(null);
|
|
15
|
+
const [interval, setInterval] = useState('month');
|
|
16
|
+
const [busy, setBusy] = useState(false);
|
|
17
|
+
const [error, setError] = useState(false);
|
|
18
|
+
const subscriptionPlans = plans.filter((plan) => kinds.includes('subscription') && (plan === null || plan === void 0 ? void 0 : plan.kind) === 'subscription');
|
|
19
|
+
const intervals = [...new Set(subscriptionPlans.map((plan) => plan.interval).filter((value) => value === 'month' || value === 'year'))];
|
|
20
|
+
const filteredPlans = useMemo(() => plans.filter((plan) => kinds.includes(plan === null || plan === void 0 ? void 0 : plan.kind)
|
|
21
|
+
&& (plan.kind !== 'subscription' || intervals.length < 2 || plan.interval === interval)), [plans, kinds, intervals.length, interval]);
|
|
22
|
+
// A plan hidden by the interval switch is no longer selected, so a hidden plan can never be checked out.
|
|
23
|
+
const effectiveSelected = filteredPlans.some((plan) => plan.key === selected) ? selected : null;
|
|
24
|
+
const continueToPayment = async () => {
|
|
25
|
+
if (busy || effectiveSelected === null)
|
|
26
|
+
return;
|
|
27
|
+
setBusy(true);
|
|
28
|
+
setError(false);
|
|
29
|
+
try {
|
|
30
|
+
const result = await api.startCheckout(effectiveSelected);
|
|
31
|
+
if (!isTrustedPaymentUrl(result === null || result === void 0 ? void 0 : result.url, allowedHosts))
|
|
32
|
+
throw new Error('invalid_checkout_url');
|
|
33
|
+
redirect(result.url);
|
|
34
|
+
}
|
|
35
|
+
catch (cause) {
|
|
36
|
+
setError(true);
|
|
37
|
+
onError === null || onError === void 0 ? void 0 : onError(cause);
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
setBusy(false);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
return _jsxs(Stack, { spacing: 2, children: [intervals.length > 1 && _jsxs(ToggleButtonGroup, { exclusive: true, value: interval, onChange: (_, value) => { if (value) {
|
|
44
|
+
setInterval(value);
|
|
45
|
+
setSelected(null);
|
|
46
|
+
} }, "aria-label": t('Billing.PLAN_INTERVAL'), children: [_jsx(ToggleButton, { value: "month", children: t('Billing.MONTHLY') }), _jsx(ToggleButton, { value: "year", children: t('Billing.YEARLY') })] }), _jsx(RadioGroup, { row: true, value: effectiveSelected !== null && effectiveSelected !== void 0 ? effectiveSelected : '', onChange: (event) => setSelected(event.target.value), "aria-label": t('Billing.PLANS'), children: _jsx(Stack, { direction: "row", useFlexGap: true, flexWrap: "wrap", spacing: 2, children: filteredPlans.map((plan) => {
|
|
47
|
+
const active = effectiveSelected === plan.key;
|
|
48
|
+
const suffix = plan.kind === 'subscription' ? (plan.interval === 'year' ? t('Billing.PER_YEAR') : t('Billing.PER_MONTH')) : '';
|
|
49
|
+
return _jsx(Card, { variant: "outlined", sx: [PLAN_PICKER_CARD_SX, active && PLAN_PICKER_SELECTED_CARD_SX], children: _jsx(FormControlLabel, { value: plan.key, control: _jsx(Radio, {}), sx: PLAN_PICKER_LABEL_SX, label: _jsxs(Stack, { spacing: 1, children: [_jsx(Typography, { variant: "h6", children: plan.name }), _jsxs(Typography, { children: [formatPrice(plan.amount_cents, i18n.language), suffix] }), plan.kind === 'team_package' && _jsxs(Typography, { children: [t('Billing.SEATS', { count: plan.seats }), " \u00B7 ", t('Billing.TERM_MONTHS', { count: plan.term_months })] }), Number.isFinite(plan.token_allowance) && plan.token_allowance > 0 && _jsx(Typography, { children: t('Billing.TOKENS_INCLUDED', { tokens: formatTokens(plan.token_allowance, i18n.language) }) }), describePlan === null || describePlan === void 0 ? void 0 : describePlan(plan)] }) }) }, plan.key);
|
|
50
|
+
}) }) }), error && _jsx(Alert, { severity: "error", sx: PLAN_PICKER_ALERT_SX, children: t('Billing.ERROR_CHECKOUT') }), _jsx(Button, { variant: "contained", disabled: effectiveSelected === null || busy, onClick: continueToPayment, children: t('Billing.CONTINUE_TO_PAYMENT') })] });
|
|
51
|
+
}
|
|
52
|
+
export default PlanPicker;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Alert, Button, CircularProgress, Stack, TextField, Typography } from '@mui/material';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { defaultBillingApi } from './api';
|
|
6
|
+
import { DEFAULT_PAYMENT_HOSTS, isTrustedPaymentUrl } from './safeUrl';
|
|
7
|
+
import { useBilling } from './useBilling';
|
|
8
|
+
import { formatDate, formatPrice, formatTokens } from './format';
|
|
9
|
+
import { PlanPicker } from './PlanPicker';
|
|
10
|
+
import { TokenBalanceBadge } from './TokenBalanceBadge';
|
|
11
|
+
import { AccessEndedBanner } from './AccessEndedBanner';
|
|
12
|
+
import { WithdrawalSection } from './WithdrawalSection';
|
|
13
|
+
export const SUBSCRIPTION_SECTION_ALERT_SX = { width: '100%' };
|
|
14
|
+
function isStatus(error, status) { var _a; return ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === status; }
|
|
15
|
+
function activeUntil(access, t, language) {
|
|
16
|
+
const date = formatDate(access === null || access === void 0 ? void 0 : access.ends_at, language);
|
|
17
|
+
return date ? t('Billing.ACTIVE_UNTIL', { date }) : null;
|
|
18
|
+
}
|
|
19
|
+
export function SubscriptionSection({ api = defaultBillingApi, redirect = (url) => window.location.assign(url), allowedHosts = DEFAULT_PAYMENT_HOSTS, onRenew, describePlan, withdrawal = true, sx }) {
|
|
20
|
+
const { t, i18n } = useTranslation();
|
|
21
|
+
const { state, me, reload } = useBilling(api);
|
|
22
|
+
const [withdrawnPurchases, setWithdrawnPurchases] = useState({});
|
|
23
|
+
const [seats, setSeats] = useState(null);
|
|
24
|
+
const [seatError, setSeatError] = useState(null);
|
|
25
|
+
const [seatInput, setSeatInput] = useState('');
|
|
26
|
+
const [busy, setBusy] = useState(false);
|
|
27
|
+
const [actionError, setActionError] = useState(null);
|
|
28
|
+
const renewalPickerRef = useRef(null);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
var _a;
|
|
31
|
+
let live = true;
|
|
32
|
+
setSeats(null);
|
|
33
|
+
setSeatError(null);
|
|
34
|
+
if (state === 'ready' && ((_a = me === null || me === void 0 ? void 0 : me.access) === null || _a === void 0 ? void 0 : _a.status) === 'active' && me.access.source === 'team') {
|
|
35
|
+
api.listSeats().then((result) => { if (live)
|
|
36
|
+
setSeats(Array.isArray(result === null || result === void 0 ? void 0 : result.seats) ? result.seats : []); }).catch((error) => {
|
|
37
|
+
if (!live)
|
|
38
|
+
return;
|
|
39
|
+
if (isStatus(error, 404))
|
|
40
|
+
setSeats(false);
|
|
41
|
+
else
|
|
42
|
+
setSeatError(error);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return () => { live = false; };
|
|
46
|
+
}, [api, state, me]);
|
|
47
|
+
const safeRedirect = async (operation, errorKey) => {
|
|
48
|
+
setBusy(true);
|
|
49
|
+
setActionError(null);
|
|
50
|
+
try {
|
|
51
|
+
const result = await operation();
|
|
52
|
+
if (!isTrustedPaymentUrl(result === null || result === void 0 ? void 0 : result.url, allowedHosts))
|
|
53
|
+
throw new Error('invalid_billing_url');
|
|
54
|
+
redirect(result.url);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
setActionError(errorKey);
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
setBusy(false);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const updateSeat = async (operation) => {
|
|
64
|
+
setBusy(true);
|
|
65
|
+
setSeatError(null);
|
|
66
|
+
try {
|
|
67
|
+
await operation();
|
|
68
|
+
const result = await api.listSeats();
|
|
69
|
+
setSeats(Array.isArray(result === null || result === void 0 ? void 0 : result.seats) ? result.seats : []);
|
|
70
|
+
setSeatInput('');
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
setSeatError(isStatus(error, 409) ? 'Billing.ERROR_SEAT_LIMIT' : isStatus(error, 400) ? 'Billing.ERROR_SEAT_USER' : 'Billing.ERROR_LOAD');
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
setBusy(false);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
if (state === 'loading')
|
|
80
|
+
return _jsxs(Stack, { sx: sx, role: "status", direction: "row", spacing: 1, alignItems: "center", children: [_jsx(CircularProgress, { size: 20 }), _jsx(Typography, { children: t('Billing.LOADING') })] });
|
|
81
|
+
if (state === 'error' || !(me === null || me === void 0 ? void 0 : me.access))
|
|
82
|
+
return _jsxs(Stack, { sx: sx, spacing: 1, children: [_jsx(Alert, { severity: "error", sx: SUBSCRIPTION_SECTION_ALERT_SX, children: t('Billing.ERROR_LOAD') }), _jsx(Button, { onClick: reload, children: t('Billing.RETRY') })] });
|
|
83
|
+
const { access, tokens } = me;
|
|
84
|
+
if (!['active', 'read_only'].includes(access.status) || !Number.isFinite(tokens === null || tokens === void 0 ? void 0 : tokens.balance))
|
|
85
|
+
return _jsx(Alert, { severity: "error", sx: SUBSCRIPTION_SECTION_ALERT_SX, children: t('Billing.ERROR_LOAD') });
|
|
86
|
+
const dateLine = activeUntil(access, t, i18n.language);
|
|
87
|
+
const packagePlans = (Array.isArray(me.plans) ? me.plans : []).filter((plan) => (plan === null || plan === void 0 ? void 0 : plan.kind) === 'token_package');
|
|
88
|
+
const sourceLine = access.source === 'subscription' ? t('Billing.SOURCE_SUBSCRIPTION') : access.source === 'team' ? t('Billing.SOURCE_TEAM') : access.source === 'free' ? t('Billing.SOURCE_FREE') : null;
|
|
89
|
+
if (!sourceLine && access.status === 'active')
|
|
90
|
+
return _jsx(Alert, { severity: "error", sx: SUBSCRIPTION_SECTION_ALERT_SX, children: t('Billing.ERROR_LOAD') });
|
|
91
|
+
return _jsxs(Stack, { sx: sx, spacing: 2, children: [access.status === 'read_only' ? _jsxs(_Fragment, { children: [_jsx(AccessEndedBanner, { endedAt: access.ends_at, onRenew: onRenew || (() => {
|
|
92
|
+
var _a, _b, _c, _d;
|
|
93
|
+
(_b = (_a = renewalPickerRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a, { behavior: 'smooth', block: 'start' });
|
|
94
|
+
(_d = (_c = renewalPickerRef.current) === null || _c === void 0 ? void 0 : _c.querySelector('input[type="radio"]')) === null || _d === void 0 ? void 0 : _d.focus();
|
|
95
|
+
}) }), _jsx("div", { ref: renewalPickerRef, children: _jsx(PlanPicker, { plans: me.plans || [], api: api, redirect: redirect, allowedHosts: allowedHosts, describePlan: describePlan }) })] }) : _jsxs(_Fragment, { children: [_jsx(Typography, { variant: "h5", children: t('Billing.HEADING') }), _jsx(Typography, { children: sourceLine }), access.source !== 'free' && dateLine && _jsx(Typography, { children: dateLine }), access.source === 'subscription' && _jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsx(Button, { disabled: busy, onClick: () => safeRedirect(() => api.openPortal(), 'Billing.ERROR_PORTAL'), children: t('Billing.MANAGE') }), _jsx(Typography, { children: t('Billing.MANAGE_DETAILS') })] }), access.source === 'team' && seatError && !seats && _jsx(Alert, { severity: "error", sx: SUBSCRIPTION_SECTION_ALERT_SX, children: t('Billing.ERROR_LOAD') }), access.source === 'team' && seats && _jsxs(Stack, { spacing: 1, children: [_jsx(Typography, { children: t('Billing.TEAM_SEATS') }), seats.map((seat) => _jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsx(Typography, { children: String(seat.user_id) }), _jsx(Button, { disabled: busy, onClick: () => updateSeat(() => api.removeSeat({ userId: seat.user_id })), children: t('Billing.SEAT_REMOVE') })] }, seat.user_id)), _jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(TextField, { size: "small", label: t('Billing.SEAT_USER'), value: seatInput, onChange: (event) => setSeatInput(event.target.value) }), _jsx(Button, { disabled: busy || !seatInput.trim(), onClick: () => updateSeat(() => seatInput.includes('@') ? api.addSeat({ email: seatInput.trim() }) : api.addSeat({ userId: seatInput.trim() })), children: t('Billing.SEATS_ADD') })] }), seatError && _jsx(Alert, { severity: "error", sx: SUBSCRIPTION_SECTION_ALERT_SX, children: typeof seatError === 'string' ? t(seatError) : t('Billing.ERROR_LOAD') })] }), actionError && _jsx(Alert, { severity: "error", sx: SUBSCRIPTION_SECTION_ALERT_SX, children: t(actionError) })] }), _jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsx(Typography, { children: t('Billing.BALANCE_LABEL') }), _jsx(TokenBalanceBadge, { balance: tokens.balance })] }), _jsx(Typography, { children: t('Billing.BALANCE', { tokens: formatTokens(tokens.balance, i18n.language) }) }), packagePlans.length > 0 && _jsxs(Stack, { spacing: 1, children: [_jsx(Typography, { variant: "h6", children: t('Billing.BUY_PACKAGE') }), packagePlans.map((plan) => _jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsxs(Typography, { children: [formatPrice(plan.amount_cents, i18n.language), " \u00B7 ", t('Billing.PACKAGE_TOKENS', { tokens: formatTokens(plan.tokens, i18n.language) })] }), _jsx(Button, { disabled: busy, onClick: () => safeRedirect(() => api.startCheckout(plan.key), 'Billing.ERROR_CHECKOUT'), children: t('Billing.PACKAGE_BUY') })] }, plan.key))] }), withdrawal && _jsx(WithdrawalSection, { api: api, plans: me.plans, sessionWithdrawals: withdrawnPurchases, onWithdrawn: (result, purchase) => {
|
|
96
|
+
if ((purchase === null || purchase === void 0 ? void 0 : purchase.id) != null)
|
|
97
|
+
setWithdrawnPurchases((current) => (Object.assign(Object.assign({}, current), { [purchase.id]: { result, purchase } })));
|
|
98
|
+
reload();
|
|
99
|
+
} })] });
|
|
100
|
+
}
|
|
101
|
+
export default SubscriptionSection;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Chip } from '@mui/material';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { formatTokens } from './format';
|
|
6
|
+
export const TOKEN_BALANCE_BADGE_SX = { fontVariantNumeric: 'tabular-nums' };
|
|
7
|
+
export function TokenBalanceBadge({ balance, lowBelow, sx }) {
|
|
8
|
+
const { t, i18n } = useTranslation();
|
|
9
|
+
if (!Number.isInteger(balance) || balance < 0)
|
|
10
|
+
return null;
|
|
11
|
+
const label = t('Billing.BALANCE', { tokens: formatTokens(balance, i18n.language) });
|
|
12
|
+
return _jsx(Chip, { label: label, "aria-label": label, color: Number.isFinite(lowBelow) && balance < lowBelow ? 'warning' : 'default', sx: [TOKEN_BALANCE_BADGE_SX, ...(Array.isArray(sx) ? sx : sx ? [sx] : [])] });
|
|
13
|
+
}
|
|
14
|
+
export default TokenBalanceBadge;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Stack, Typography } from '@mui/material';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { formatTokens } from './format';
|
|
6
|
+
export function TokenCostPreview({ cost, alternatives = [], balance }) {
|
|
7
|
+
const { t, i18n } = useTranslation();
|
|
8
|
+
if (!Number.isInteger(cost) || cost < 0 || !Number.isInteger(balance) || balance < 0 || !Array.isArray(alternatives)
|
|
9
|
+
|| alternatives.some((item) => !item || typeof item.label !== 'string' || !Number.isInteger(item.cost) || item.cost < 0))
|
|
10
|
+
return null;
|
|
11
|
+
const insufficient = balance < cost;
|
|
12
|
+
// "47 Token, mit Übersetzung 71 · Guthaben 1'153": the cost and its alternatives, then the balance.
|
|
13
|
+
const costs = [t('Billing.COST', { tokens: formatTokens(cost, i18n.language) })];
|
|
14
|
+
alternatives.forEach(({ label, cost: alternativeCost }) => costs.push(`${label} ${formatTokens(alternativeCost, i18n.language)}`));
|
|
15
|
+
const parts = [costs.join(', '), t('Billing.BALANCE', { tokens: formatTokens(balance, i18n.language) })];
|
|
16
|
+
return _jsxs(Stack, { component: "span", direction: "row", spacing: 0.5, flexWrap: "wrap", "aria-live": "polite", children: [_jsx(Typography, { component: "span", color: insufficient ? 'error' : 'text.primary', children: parts.join(' · ') }), insufficient && _jsx(Typography, { component: "span", color: "error", children: t('Billing.NOT_ENOUGH') })] });
|
|
17
|
+
}
|
|
18
|
+
export default TokenCostPreview;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Alert, Button, CircularProgress, Dialog, DialogActions, DialogContent, DialogTitle, Stack, Typography } from '@mui/material';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { formatDateTime, formatPrice } from './format';
|
|
6
|
+
export const WITHDRAWAL_DIALOG_ALERT_SX = { width: '100%' };
|
|
7
|
+
export function describeCalculation(preview, t, language) {
|
|
8
|
+
const currency = (preview === null || preview === void 0 ? void 0 : preview.currency) || 'USD';
|
|
9
|
+
const price = (value) => formatPrice(value, language, currency);
|
|
10
|
+
const items = [t('Billing.WITHDRAWAL_PAID', { amount: price(preview === null || preview === void 0 ? void 0 : preview.amount_paid_cents) })];
|
|
11
|
+
const time = Number(preview === null || preview === void 0 ? void 0 : preview.time_share_cents) || 0;
|
|
12
|
+
const token = Number(preview === null || preview === void 0 ? void 0 : preview.token_share_cents) || 0;
|
|
13
|
+
if (time !== 0 || ((preview === null || preview === void 0 ? void 0 : preview.kind) !== 'token_package' && token === 0))
|
|
14
|
+
items.push(t('Billing.WITHDRAWAL_TIME_SHARE', { amount: price(time) }));
|
|
15
|
+
if (token !== 0 || (preview === null || preview === void 0 ? void 0 : preview.kind) === 'token_package')
|
|
16
|
+
items.push(t('Billing.WITHDRAWAL_TOKEN_SHARE', { amount: price(token) }));
|
|
17
|
+
const used = Number.isFinite(preview === null || preview === void 0 ? void 0 : preview.used_cents) ? preview.used_cents : Math.max(time, token);
|
|
18
|
+
items.push(t('Billing.WITHDRAWAL_USED', { amount: price(used) }));
|
|
19
|
+
items.push(t('Billing.WITHDRAWAL_REFUND', { amount: price(preview === null || preview === void 0 ? void 0 : preview.refund_cents) }));
|
|
20
|
+
return items.join(' · ');
|
|
21
|
+
}
|
|
22
|
+
export function WithdrawalDialog({ open, purchase, api, onClose, onWithdrawn }) {
|
|
23
|
+
const { t, i18n } = useTranslation();
|
|
24
|
+
const [state, setState] = useState('loading');
|
|
25
|
+
const [preview, setPreview] = useState(null);
|
|
26
|
+
const [result, setResult] = useState(null);
|
|
27
|
+
const [errorStatus, setErrorStatus] = useState(null);
|
|
28
|
+
const [attempt, setAttempt] = useState(0);
|
|
29
|
+
const confirmGuard = useRef(false);
|
|
30
|
+
const notified = useRef(false);
|
|
31
|
+
const previewRequest = useRef(null);
|
|
32
|
+
const titleId = `withdrawal-title-${purchase === null || purchase === void 0 ? void 0 : purchase.id}`;
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
var _a;
|
|
35
|
+
if (!open || !purchase || typeof (api === null || api === void 0 ? void 0 : api.previewWithdrawal) !== 'function') {
|
|
36
|
+
if (!open)
|
|
37
|
+
previewRequest.current = null;
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
const requestKey = String(purchase.id) + ':' + attempt;
|
|
41
|
+
let live = true;
|
|
42
|
+
setState('loading');
|
|
43
|
+
setPreview(null);
|
|
44
|
+
setResult(null);
|
|
45
|
+
setErrorStatus(null);
|
|
46
|
+
confirmGuard.current = false;
|
|
47
|
+
notified.current = false;
|
|
48
|
+
let request = ((_a = previewRequest.current) === null || _a === void 0 ? void 0 : _a.key) === requestKey ? previewRequest.current.promise : null;
|
|
49
|
+
if (!request) {
|
|
50
|
+
request = Promise.resolve().then(() => api.previewWithdrawal(purchase.id));
|
|
51
|
+
previewRequest.current = { key: requestKey, promise: request };
|
|
52
|
+
}
|
|
53
|
+
request.then((data) => {
|
|
54
|
+
if (!live)
|
|
55
|
+
return;
|
|
56
|
+
setPreview(data);
|
|
57
|
+
setState((data === null || data === void 0 ? void 0 : data.eligible) === true ? 'ready' : 'not_possible');
|
|
58
|
+
}).catch((error) => {
|
|
59
|
+
var _a;
|
|
60
|
+
if (!live)
|
|
61
|
+
return;
|
|
62
|
+
setErrorStatus((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status);
|
|
63
|
+
setState('preview_error');
|
|
64
|
+
});
|
|
65
|
+
return () => { live = false; };
|
|
66
|
+
}, [open, purchase === null || purchase === void 0 ? void 0 : purchase.id, api, attempt]);
|
|
67
|
+
const confirm = async () => {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
if (confirmGuard.current || !['ready', 'confirm_error'].includes(state) || typeof (api === null || api === void 0 ? void 0 : api.confirmWithdrawal) !== 'function')
|
|
70
|
+
return;
|
|
71
|
+
confirmGuard.current = true;
|
|
72
|
+
setState('submitting');
|
|
73
|
+
setErrorStatus(null);
|
|
74
|
+
try {
|
|
75
|
+
const value = await api.confirmWithdrawal(purchase.id);
|
|
76
|
+
setResult(value);
|
|
77
|
+
setState('success');
|
|
78
|
+
if (!notified.current) {
|
|
79
|
+
notified.current = true;
|
|
80
|
+
onWithdrawn === null || onWithdrawn === void 0 ? void 0 : onWithdrawn(value, purchase);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
setErrorStatus((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status);
|
|
85
|
+
setState(((_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.status) === 409 ? 'not_possible' : 'confirm_error');
|
|
86
|
+
confirmGuard.current = false;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const close = () => { if (state !== 'submitting')
|
|
90
|
+
onClose === null || onClose === void 0 ? void 0 : onClose(); };
|
|
91
|
+
const amount = formatPrice(preview === null || preview === void 0 ? void 0 : preview.refund_cents, i18n.language, preview === null || preview === void 0 ? void 0 : preview.currency);
|
|
92
|
+
const none = !(Number(preview === null || preview === void 0 ? void 0 : preview.refund_cents) > 0);
|
|
93
|
+
return _jsxs(Dialog, { open: open, onClose: close, disableEscapeKeyDown: state === 'submitting', fullWidth: true, maxWidth: "sm", "aria-labelledby": titleId, children: [_jsx(DialogTitle, { id: titleId, children: t(state === 'success' ? 'Billing.WITHDRAWAL_DONE' : 'Billing.WITHDRAWAL_TITLE') }), _jsxs(DialogContent, { children: [state === 'loading' && _jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", role: "status", children: [_jsx(CircularProgress, { size: 20 }), _jsx(Typography, { children: t('Billing.LOADING') })] }), state === 'preview_error' && _jsx(Alert, { severity: "error", sx: WITHDRAWAL_DIALOG_ALERT_SX, children: t('Billing.WITHDRAWAL_PREVIEW_ERROR') }), (state === 'not_possible') && _jsx(Alert, { severity: "info", children: t('Billing.WITHDRAWAL_NOT_POSSIBLE') }), (state === 'ready' || state === 'submitting' || state === 'confirm_error') && _jsxs(Stack, { spacing: 1, children: [_jsx(Typography, { children: t('Billing.WITHDRAWAL_EFFECT') }), _jsx(Typography, { children: none ? t('Billing.WITHDRAWAL_REFUND_NONE') : t('Billing.WITHDRAWAL_REFUND', { amount }) }), _jsx(Typography, { children: t('Billing.WITHDRAWAL_CALCULATION', { explanation: describeCalculation(Object.assign(Object.assign({}, preview), { kind: purchase === null || purchase === void 0 ? void 0 : purchase.kind }), t, i18n.language) }) }), state === 'confirm_error' && _jsx(Alert, { severity: "error", sx: WITHDRAWAL_DIALOG_ALERT_SX, children: t('Billing.WITHDRAWAL_ERROR') }), state === 'submitting' && _jsxs(Typography, { role: "status", children: [_jsx(CircularProgress, { size: 16 }), " ", t('Billing.LOADING')] })] }), state === 'success' && _jsx(Typography, { children: t('Billing.WITHDRAWAL_DONE_DETAIL', { date: formatDateTime(result === null || result === void 0 ? void 0 : result.withdrawn_at, i18n.language) }) })] }), _jsx(DialogActions, { children: state === 'ready' || state === 'confirm_error' ? _jsxs(_Fragment, { children: [_jsx(Button, { onClick: close, disabled: state === 'submitting', children: t('Billing.WITHDRAWAL_CANCEL') }), _jsx(Button, { variant: "contained", onClick: confirm, disabled: state === 'submitting', children: t('Billing.WITHDRAWAL_CONFIRM') })] }) : state === 'preview_error' ? _jsxs(_Fragment, { children: [_jsx(Button, { onClick: close, children: t('Billing.WITHDRAWAL_CLOSE') }), _jsx(Button, { onClick: () => setAttempt((n) => n + 1), children: t('Billing.RETRY') })] }) : (state === 'success' || state === 'not_possible') && _jsx(Button, { onClick: close, children: t('Billing.WITHDRAWAL_CLOSE') }) })] });
|
|
94
|
+
}
|
|
95
|
+
export default WithdrawalDialog;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import { Alert, Button, Stack, Typography } from '@mui/material';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { formatDate, formatDateTime } from './format';
|
|
6
|
+
import { WithdrawalDialog } from './WithdrawalDialog';
|
|
7
|
+
export const WITHDRAWAL_SECTION_ALERT_SX = { width: '100%' };
|
|
8
|
+
const is404 = (error) => { var _a; return ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === 404; };
|
|
9
|
+
const deadline = (purchase) => {
|
|
10
|
+
const date = new Date(purchase.purchased_at);
|
|
11
|
+
if (!Number.isFinite(date.getTime()))
|
|
12
|
+
return '';
|
|
13
|
+
date.setUTCDate(date.getUTCDate() + 14);
|
|
14
|
+
return date.toISOString();
|
|
15
|
+
};
|
|
16
|
+
export function WithdrawalSection({ api, plans = [], onWithdrawn, sessionWithdrawals = {}, sx }) {
|
|
17
|
+
const { t, i18n } = useTranslation();
|
|
18
|
+
const [purchases, setPurchases] = useState([]);
|
|
19
|
+
const [withdrawn, setWithdrawn] = useState({});
|
|
20
|
+
const [selected, setSelected] = useState(null);
|
|
21
|
+
const [loadError, setLoadError] = useState(false);
|
|
22
|
+
const [reload, setReload] = useState(0);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (typeof (api === null || api === void 0 ? void 0 : api.listWithdrawals) !== 'function')
|
|
25
|
+
return undefined;
|
|
26
|
+
let live = true;
|
|
27
|
+
Promise.resolve().then(() => api.listWithdrawals()).then((data) => {
|
|
28
|
+
if (live) {
|
|
29
|
+
setPurchases(Array.isArray(data === null || data === void 0 ? void 0 : data.purchases) ? data.purchases : []);
|
|
30
|
+
setLoadError(false);
|
|
31
|
+
}
|
|
32
|
+
}).catch((error) => {
|
|
33
|
+
if (!live)
|
|
34
|
+
return;
|
|
35
|
+
if (is404(error)) {
|
|
36
|
+
setPurchases([]);
|
|
37
|
+
setLoadError(false);
|
|
38
|
+
}
|
|
39
|
+
else
|
|
40
|
+
setLoadError(true);
|
|
41
|
+
});
|
|
42
|
+
return () => { live = false; };
|
|
43
|
+
}, [api, reload]);
|
|
44
|
+
const handleWithdrawn = (purchaseId, result) => {
|
|
45
|
+
setWithdrawn((current) => (Object.assign(Object.assign({}, current), { [purchaseId]: { purchase: purchases.find((item) => String(item.id) === String(purchaseId)), result } })));
|
|
46
|
+
setSelected(null);
|
|
47
|
+
onWithdrawn === null || onWithdrawn === void 0 ? void 0 : onWithdrawn(result, purchases.find((item) => String(item.id) === String(purchaseId)));
|
|
48
|
+
setReload((count) => count + 1);
|
|
49
|
+
};
|
|
50
|
+
const successful = Object.assign(Object.assign({}, sessionWithdrawals), withdrawn);
|
|
51
|
+
const eligible = purchases.filter((item) => (item === null || item === void 0 ? void 0 : item.eligible) === true && item.withdrawn_at == null && !successful[item.id]);
|
|
52
|
+
if (loadError)
|
|
53
|
+
return _jsxs(Stack, { sx: sx, spacing: 1, children: [_jsx(Alert, { severity: "error", sx: WITHDRAWAL_SECTION_ALERT_SX, children: t('Billing.WITHDRAWAL_LOAD_ERROR') }), _jsx(Button, { onClick: () => setReload((count) => count + 1), children: t('Billing.RETRY') }), Object.entries(successful).map(([id, entry]) => { var _a; return _jsxs(Stack, { spacing: 0.5, role: "status", children: [_jsx(Typography, { children: t('Billing.WITHDRAWAL_DONE') }), _jsx(Typography, { children: t('Billing.WITHDRAWAL_DONE_DETAIL', { date: formatDateTime((_a = ((entry === null || entry === void 0 ? void 0 : entry.result) || entry)) === null || _a === void 0 ? void 0 : _a.withdrawn_at, i18n.language) }) })] }, id); })] });
|
|
54
|
+
if (!eligible.length && !Object.keys(successful).length)
|
|
55
|
+
return null;
|
|
56
|
+
const findPlan = (key) => { var _a; return ((_a = plans.find((plan) => (plan === null || plan === void 0 ? void 0 : plan.key) === key)) === null || _a === void 0 ? void 0 : _a.name) || key; };
|
|
57
|
+
return _jsxs(Stack, { sx: sx, spacing: 1, children: [eligible.map((purchase) => _jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", flexWrap: "wrap", children: [_jsx(Typography, { children: findPlan(purchase.plan_key) }), _jsx(Typography, { children: formatDate(purchase.purchased_at, i18n.language) }), _jsx(Typography, { children: t('Billing.WITHDRAWAL_UNTIL', { date: formatDate(deadline(purchase), i18n.language) }) }), _jsx(Button, { onClick: () => setSelected(purchase), children: t('Billing.WITHDRAWAL_BUTTON') })] }, purchase.id)), Object.entries(successful).map(([id, entry]) => { var _a; return _jsxs(Stack, { spacing: 0.5, role: "status", children: [_jsx(Typography, { children: t('Billing.WITHDRAWAL_DONE') }), _jsx(Typography, { children: t('Billing.WITHDRAWAL_DONE_DETAIL', { date: formatDateTime((_a = ((entry === null || entry === void 0 ? void 0 : entry.result) || entry)) === null || _a === void 0 ? void 0 : _a.withdrawn_at, i18n.language) }) })] }, id); }), _jsx(WithdrawalDialog, { open: Boolean(selected), purchase: selected, api: api, onClose: () => setSelected(null), onWithdrawn: (result) => selected && handleWithdrawn(selected.id, result) })] });
|
|
58
|
+
}
|
|
59
|
+
export default WithdrawalSection;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import apiClient from '../auth/apiClient';
|
|
2
|
+
import { billingApiUrls } from './wire';
|
|
3
|
+
export function createBillingApi(overrides = {}, { apiBase = '/api/billing/' } = {}) {
|
|
4
|
+
const urls = billingApiUrls(apiBase);
|
|
5
|
+
const data = (request) => request.then((response) => response.data);
|
|
6
|
+
const defaults = {
|
|
7
|
+
getMe: () => data(apiClient.get(urls.me)),
|
|
8
|
+
startCheckout: (planKey) => data(apiClient.post(urls.checkout, { plan_key: planKey })),
|
|
9
|
+
openPortal: () => data(apiClient.post(urls.portal)),
|
|
10
|
+
listSeats: () => data(apiClient.get(urls.seats)),
|
|
11
|
+
addSeat: ({ userId, email } = {}) => data(apiClient.post(urls.seats, userId !== undefined ? { user_id: userId } : { email })),
|
|
12
|
+
removeSeat: ({ userId, email } = {}) => data(apiClient.delete(urls.seats, { data: userId !== undefined ? { user_id: userId } : { email } })),
|
|
13
|
+
listWithdrawals: () => data(apiClient.get(urls.withdrawals)),
|
|
14
|
+
previewWithdrawal: (id) => data(apiClient.get(urls.withdrawalPreview(id))),
|
|
15
|
+
confirmWithdrawal: (id) => data(apiClient.post(urls.withdrawalConfirm(id), { confirm: true })),
|
|
16
|
+
};
|
|
17
|
+
return Object.assign(Object.assign({}, defaults), overrides);
|
|
18
|
+
}
|
|
19
|
+
export const defaultBillingApi = createBillingApi();
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// The kit's own language codes (for example de_informal) are not valid Intl locales; use the base language.
|
|
2
|
+
export function intlLocale(language) {
|
|
3
|
+
return typeof language === 'string' && language ? language.split('_')[0] : undefined;
|
|
4
|
+
}
|
|
5
|
+
export function formatPrice(amountCents, language, currency = 'USD') {
|
|
6
|
+
if (!Number.isFinite(amountCents))
|
|
7
|
+
return '';
|
|
8
|
+
const candidate = typeof currency === 'string' ? currency.toUpperCase() : '';
|
|
9
|
+
let validCurrency = 'USD';
|
|
10
|
+
try {
|
|
11
|
+
const supported = typeof Intl.supportedValuesOf === 'function' ? Intl.supportedValuesOf('currency') : null;
|
|
12
|
+
if (/^[A-Z]{3}$/.test(candidate) && (!supported || supported.includes(candidate))) {
|
|
13
|
+
new Intl.NumberFormat(intlLocale(language), { style: 'currency', currency: candidate });
|
|
14
|
+
validCurrency = candidate;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
catch (_a) { /* use USD for unknown currency codes */ }
|
|
18
|
+
return new Intl.NumberFormat(intlLocale(language), { style: 'currency', currency: validCurrency }).format(amountCents / 100);
|
|
19
|
+
}
|
|
20
|
+
export function formatTokens(count, language) {
|
|
21
|
+
if (!Number.isFinite(count))
|
|
22
|
+
return '';
|
|
23
|
+
return new Intl.NumberFormat(intlLocale(language), { maximumFractionDigits: 0 }).format(count);
|
|
24
|
+
}
|
|
25
|
+
export function formatDate(iso, language) {
|
|
26
|
+
if (typeof iso !== 'string' || !iso)
|
|
27
|
+
return '';
|
|
28
|
+
const date = new Date(iso);
|
|
29
|
+
if (!Number.isFinite(date.getTime()))
|
|
30
|
+
return '';
|
|
31
|
+
return new Intl.DateTimeFormat(intlLocale(language), { year: 'numeric', month: 'long', day: 'numeric', timeZone: 'UTC' }).format(date);
|
|
32
|
+
}
|
|
33
|
+
export function formatDateTime(iso, language) {
|
|
34
|
+
if (typeof iso !== 'string' || !iso)
|
|
35
|
+
return '';
|
|
36
|
+
const date = new Date(iso);
|
|
37
|
+
if (!Number.isFinite(date.getTime()))
|
|
38
|
+
return '';
|
|
39
|
+
return new Intl.DateTimeFormat(intlLocale(language), { dateStyle: 'long', timeStyle: 'short' }).format(date);
|
|
40
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Hosts a checkout or portal link may point to. The server (Stripe) returns the link; the surface still checks it, so a
|
|
2
|
+
// malformed or tampered response can never send people to another site. An app can pass `allowedHosts` to add or replace.
|
|
3
|
+
export const DEFAULT_PAYMENT_HOSTS = ['*.stripe.com'];
|
|
4
|
+
const hostMatches = (hostname, pattern) => (pattern.startsWith('*.')
|
|
5
|
+
? hostname.endsWith(pattern.slice(1)) && hostname.length > pattern.length - 1
|
|
6
|
+
: hostname === pattern);
|
|
7
|
+
/** True only for an `https://` URL without credentials whose host is one of `allowedHosts` (exact or `*.suffix`). */
|
|
8
|
+
export function isTrustedPaymentUrl(value, allowedHosts = DEFAULT_PAYMENT_HOSTS) {
|
|
9
|
+
if (typeof value !== 'string')
|
|
10
|
+
return false;
|
|
11
|
+
let url;
|
|
12
|
+
try {
|
|
13
|
+
url = new URL(value);
|
|
14
|
+
}
|
|
15
|
+
catch (_a) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
if (url.protocol !== 'https:' || url.username || url.password)
|
|
19
|
+
return false;
|
|
20
|
+
return allowedHosts.some((pattern) => hostMatches(url.hostname.toLowerCase(), String(pattern).toLowerCase()));
|
|
21
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { BILLING_SOURCES, BILLING_STATUSES } from './wire';
|
|
3
|
+
const validMe = (me) => {
|
|
4
|
+
var _a;
|
|
5
|
+
const access = me === null || me === void 0 ? void 0 : me.access;
|
|
6
|
+
return Boolean(access && typeof access === 'object' && !Array.isArray(access)
|
|
7
|
+
&& [BILLING_STATUSES.ACTIVE, BILLING_STATUSES.READ_ONLY].includes(access.status)
|
|
8
|
+
&& [BILLING_SOURCES.SUBSCRIPTION, BILLING_SOURCES.TEAM, BILLING_SOURCES.FREE, BILLING_SOURCES.NONE].includes(access.source)
|
|
9
|
+
&& (access.ends_at === null || (typeof access.ends_at === 'string' && Number.isFinite(new Date(access.ends_at).getTime())))
|
|
10
|
+
&& Number.isInteger((_a = me.tokens) === null || _a === void 0 ? void 0 : _a.balance) && me.tokens.balance >= 0);
|
|
11
|
+
};
|
|
12
|
+
export function useBilling(api) {
|
|
13
|
+
const [state, setState] = useState('loading');
|
|
14
|
+
const [me, setMe] = useState(null);
|
|
15
|
+
const [reloadCount, setReloadCount] = useState(0);
|
|
16
|
+
const reload = useCallback(() => { setState('loading'); setReloadCount((count) => count + 1); }, []);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
let live = true;
|
|
19
|
+
setState('loading');
|
|
20
|
+
Promise.resolve().then(() => api.getMe()).then((result) => {
|
|
21
|
+
if (!live)
|
|
22
|
+
return;
|
|
23
|
+
if (!validMe(result)) {
|
|
24
|
+
setMe(null);
|
|
25
|
+
setState('error');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
setMe(result);
|
|
29
|
+
setState('ready');
|
|
30
|
+
}).catch(() => { if (live) {
|
|
31
|
+
setMe(null);
|
|
32
|
+
setState('error');
|
|
33
|
+
} });
|
|
34
|
+
return () => { live = false; };
|
|
35
|
+
}, [api, reloadCount]);
|
|
36
|
+
return { state, me, reload };
|
|
37
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const BILLING_STATUSES = { ACTIVE: 'active', READ_ONLY: 'read_only' };
|
|
2
|
+
export const BILLING_SOURCES = { SUBSCRIPTION: 'subscription', TEAM: 'team', FREE: 'free', NONE: null };
|
|
3
|
+
export const BILLING_KINDS = { SUBSCRIPTION: 'subscription', TEAM_PACKAGE: 'team_package', TOKEN_PACKAGE: 'token_package' };
|
|
4
|
+
export const BILLING_ERROR_CODES = ['unknown_plan', 'checkout_unavailable', 'no_customer', 'portal_unavailable', 'no_active_team', 'invalid_user', 'seat_limit'];
|
|
5
|
+
export const billingApiUrls = (base = '/api/billing/') => {
|
|
6
|
+
const root = base.replace(/\/$/, '') + '/';
|
|
7
|
+
return {
|
|
8
|
+
me: root + 'me/',
|
|
9
|
+
checkout: root + 'checkout/',
|
|
10
|
+
portal: root + 'portal/',
|
|
11
|
+
seats: root + 'team/seats/',
|
|
12
|
+
withdrawals: root + 'withdrawal/',
|
|
13
|
+
withdrawalPreview: (id) => root + `withdrawal/${encodeURIComponent(id)}/preview/`,
|
|
14
|
+
withdrawalConfirm: (id) => root + `withdrawal/${encodeURIComponent(id)}/`,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export const billingTranslations = {
|
|
2
|
+
'Billing.BALANCE': { de: 'Guthaben {{tokens}} Token', en: 'Balance {{tokens}} tokens', fr: 'Solde {{tokens}} jetons', sw: 'Salio {{tokens}} tokeni' },
|
|
3
|
+
'Billing.COST': { de: '{{tokens}} Token', en: '{{tokens}} tokens', fr: '{{tokens}} jetons', sw: 'Tokeni {{tokens}}' },
|
|
4
|
+
'Billing.NOT_ENOUGH': { de: 'Guthaben reicht nicht aus', en: 'Insufficient balance', fr: 'Solde insuffisant', sw: 'Salio halitoshi' },
|
|
5
|
+
'Billing.ENDED_TITLE': { de: 'Abo beendet – Projekte sind schreibgeschützt. Export bleibt möglich.', en: 'Subscription ended — projects are read-only. You can still export.', fr: 'Abonnement terminé — les projets sont en lecture seule. L’export reste possible.', sw: 'Usajili umeisha — miradi inaweza kusomwa tu. Bado unaweza kuhamisha data.' },
|
|
6
|
+
'Billing.ENDED_ON': { de: 'Beendet am {{date}}', en: 'Ended on {{date}}', fr: 'Terminé le {{date}}', sw: 'Uliisha tarehe {{date}}' },
|
|
7
|
+
'Billing.DELETION_ON': { de: 'Löschung am {{date}}', en: 'Deletion on {{date}}', fr: 'Suppression le {{date}}', sw: 'Kufutwa tarehe {{date}}' },
|
|
8
|
+
'Billing.RENEW': { de: 'Abo erneuern', en: 'Renew subscription', fr: 'Renouveler l’abonnement', sw: 'Fanya upya usajili' },
|
|
9
|
+
'Billing.MONTHLY': { de: 'Monatlich', en: 'Monthly', fr: 'Mensuel', sw: 'Kila mwezi' },
|
|
10
|
+
'Billing.YEARLY': { de: 'Jährlich', en: 'Yearly', fr: 'Annuel', sw: 'Kila mwaka' },
|
|
11
|
+
'Billing.PER_MONTH': { de: '/ Monat', en: '/ month', fr: '/ mois', sw: '/ mwezi' },
|
|
12
|
+
'Billing.PER_YEAR': { de: '/ Jahr', en: '/ year', fr: '/ an', sw: '/ mwaka' },
|
|
13
|
+
'Billing.TOKENS_INCLUDED': { de: '{{tokens}} Token inklusive', en: '{{tokens}} tokens included', fr: '{{tokens}} jetons inclus', sw: 'Tokeni {{tokens}} zimejumuishwa' },
|
|
14
|
+
'Billing.CONTINUE_TO_PAYMENT': { de: 'Weiter zur Bezahlung', en: 'Continue to payment', fr: 'Continuer vers le paiement', sw: 'Endelea kulipa' },
|
|
15
|
+
'Billing.ERROR_CHECKOUT': { de: 'Die Bezahlung konnte nicht gestartet werden. Bitte versuchen Sie es erneut.', en: 'Checkout could not be started. Please try again.', fr: 'Le paiement n’a pas pu démarrer. Veuillez réessayer.', sw: 'Malipo hayakuweza kuanzishwa. Tafadhali jaribu tena.' },
|
|
16
|
+
'Billing.ERROR_LOAD': { de: 'Abodaten konnten nicht geladen werden.', en: 'Subscription details could not be loaded.', fr: 'Impossible de charger les informations de l’abonnement.', sw: 'Maelezo ya usajili hayakuweza kupakiwa.' },
|
|
17
|
+
'Billing.RETRY': { de: 'Erneut versuchen', en: 'Try again', fr: 'Réessayer', sw: 'Jaribu tena' },
|
|
18
|
+
'Billing.SOURCE_SUBSCRIPTION': { de: 'Persönliches Abo', en: 'Personal subscription', fr: 'Abonnement personnel', sw: 'Usajili binafsi' },
|
|
19
|
+
'Billing.SOURCE_TEAM': { de: 'Platz in einem Team-Paket', en: 'Seat in a team package', fr: 'Place dans un forfait d’équipe', sw: 'Nafasi katika kifurushi cha timu' },
|
|
20
|
+
'Billing.SOURCE_FREE': { de: 'Ohne Abo freigeschaltet', en: 'Access enabled without a subscription', fr: 'Accès activé sans abonnement', sw: 'Ufikiaji umewezeshwa bila usajili' },
|
|
21
|
+
'Billing.ACTIVE_UNTIL': { de: 'Aktiv bis {{date}}', en: 'Active until {{date}}', fr: 'Actif jusqu’au {{date}}', sw: 'Inatumika hadi {{date}}' },
|
|
22
|
+
'Billing.MANAGE': { de: 'Abo verwalten', en: 'Manage subscription', fr: 'Gérer l’abonnement', sw: 'Dhibiti usajili' },
|
|
23
|
+
'Billing.MANAGE_DETAILS': { de: 'Kündigung, Zahlungsmethode und Belege', en: 'Cancellation, payment method, and receipts', fr: 'Résiliation, moyen de paiement et reçus', sw: 'Kughairi, njia ya malipo na risiti' },
|
|
24
|
+
'Billing.ERROR_PORTAL': { de: 'Das Abo-Portal ist derzeit nicht verfügbar.', en: 'The subscription portal is unavailable right now.', fr: 'Le portail d’abonnement est indisponible pour le moment.', sw: 'Tovuti ya usajili haipatikani kwa sasa.' },
|
|
25
|
+
'Billing.BALANCE_LABEL': { de: 'Token-Guthaben', en: 'Token balance', fr: 'Solde de jetons', sw: 'Salio la tokeni' },
|
|
26
|
+
'Billing.BUY_PACKAGE': { de: 'Token-Paket kaufen', en: 'Buy a token package', fr: 'Acheter un forfait de jetons', sw: 'Nunua kifurushi cha tokeni' },
|
|
27
|
+
'Billing.PACKAGE_BUY': { de: 'Paket kaufen', en: 'Buy package', fr: 'Acheter le forfait', sw: 'Nunua kifurushi' },
|
|
28
|
+
'Billing.SEATS_one': { de: '{{count}} Sitzplatz', en: '{{count}} seat', fr: '{{count}} place', sw: 'Nafasi {{count}}' },
|
|
29
|
+
'Billing.SEATS_other': { de: '{{count}} Sitzplätze', en: '{{count}} seats', fr: '{{count}} places', sw: 'Nafasi {{count}}' },
|
|
30
|
+
'Billing.TERM_MONTHS_one': { de: '{{count}} Monat', en: '{{count}} month', fr: '{{count}} mois', sw: 'Mwezi {{count}}' },
|
|
31
|
+
'Billing.TERM_MONTHS_other': { de: '{{count}} Monate', en: '{{count}} months', fr: '{{count}} mois', sw: 'Miezi {{count}}' },
|
|
32
|
+
'Billing.SEATS_ADD': { de: 'Sitzplatz hinzufügen', en: 'Add seat', fr: 'Ajouter une place', sw: 'Ongeza nafasi' },
|
|
33
|
+
'Billing.SEAT_USER': { de: 'E-Mail-Adresse oder Benutzer-ID', en: 'Email address or user ID', fr: 'Adresse e-mail ou identifiant utilisateur', sw: 'Barua pepe au kitambulisho cha mtumiaji' },
|
|
34
|
+
'Billing.SEAT_REMOVE': { de: 'Entfernen', en: 'Remove', fr: 'Retirer', sw: 'Ondoa' },
|
|
35
|
+
'Billing.ERROR_SEAT_LIMIT': { de: 'Alle Sitzplätze sind belegt.', en: 'All seats are occupied.', fr: 'Toutes les places sont occupées.', sw: 'Nafasi zote zimejazwa.' },
|
|
36
|
+
'Billing.ERROR_SEAT_USER': { de: 'Diese Person kann nicht hinzugefügt werden.', en: 'This person could not be added.', fr: 'Cette personne ne peut pas être ajoutée.', sw: 'Mtu huyu hakuweza kuongezwa.' },
|
|
37
|
+
'Billing.PLAN_INTERVAL': { de: 'Abrechnungszeitraum', en: 'Billing interval', fr: 'Période de facturation', sw: 'Kipindi cha malipo' },
|
|
38
|
+
'Billing.LOADING': { de: 'Abodaten werden geladen …', en: 'Loading subscription details …', fr: 'Chargement de l’abonnement …', sw: 'Inapakia maelezo ya usajili …' },
|
|
39
|
+
'Billing.HEADING': { de: 'Abo', en: 'Subscription', fr: 'Abonnement', sw: 'Usajili' },
|
|
40
|
+
'Billing.TEAM_SEATS': { de: 'Sitzplätze im Team-Paket', en: 'Seats in the team package', fr: 'Places dans le forfait d’équipe', sw: 'Nafasi katika kifurushi cha timu' },
|
|
41
|
+
'Billing.PACKAGE_TOKENS': { de: '{{tokens}} Token', en: '{{tokens}} tokens', fr: '{{tokens}} jetons', sw: 'Tokeni {{tokens}}' },
|
|
42
|
+
'Billing.PLANS': { de: 'Pläne', en: 'Plans', fr: 'Offres', sw: 'Mipango' },
|
|
43
|
+
'Billing.WITHDRAWAL_BUTTON': { de: 'Vertrag hier widerrufen', de_informal: 'Vertrag hier widerrufen', en: 'Withdraw this contract', fr: 'Révoquer ce contrat ici', sw: 'Ondoa mkataba huu hapa' },
|
|
44
|
+
'Billing.WITHDRAWAL_UNTIL': { de: 'bis {{date}}', de_informal: 'bis {{date}}', en: 'until {{date}}', fr: 'jusqu’au {{date}}', sw: 'hadi {{date}}' },
|
|
45
|
+
'Billing.WITHDRAWAL_TITLE': { de: 'Vertrag widerrufen?', de_informal: 'Vertrag widerrufen?', en: 'Withdraw this contract?', fr: 'Révoquer ce contrat ?', sw: 'Uondoe mkataba huu?' },
|
|
46
|
+
'Billing.WITHDRAWAL_EFFECT': { de: 'Mit dem Widerruf endet der Zugang aus diesem Kauf sofort, und das Abo verlängert sich nicht.', de_informal: 'Mit dem Widerruf endet der Zugang aus diesem Kauf sofort, und das Abo verlängert sich nicht.', en: 'With the withdrawal, access from this purchase ends immediately and the subscription will not renew.', fr: 'La révocation met immédiatement fin à l’accès lié à cet achat et l’abonnement ne sera pas renouvelé.', sw: 'Ukiondoa, ufikiaji wa ununuzi huu utaisha mara moja na usajili hautasasishwa.' },
|
|
47
|
+
'Billing.WITHDRAWAL_REFUND': { de: 'Sie erhalten {{amount}} zurück.', de_informal: 'Du erhältst {{amount}} zurück.', en: 'You will receive {{amount}} back.', fr: 'Vous recevrez {{amount}} en remboursement.', sw: 'Utarejeshewa {{amount}}.' },
|
|
48
|
+
'Billing.WITHDRAWAL_REFUND_NONE': { de: 'Sie erhalten keine Rückzahlung.', de_informal: 'Du erhältst keine Rückzahlung.', en: 'You will receive no refund.', fr: 'Vous ne recevrez aucun remboursement.', sw: 'Hutapokea marejesho ya pesa.' },
|
|
49
|
+
'Billing.WITHDRAWAL_CALCULATION': { de: 'Berechnung: {{explanation}}', de_informal: 'Berechnung: {{explanation}}', en: 'Calculation: {{explanation}}', fr: 'Calcul : {{explanation}}', sw: 'Hesabu: {{explanation}}' },
|
|
50
|
+
'Billing.WITHDRAWAL_CONFIRM': { de: 'Widerruf bestätigen', de_informal: 'Widerruf bestätigen', en: 'Confirm withdrawal', fr: 'Confirmer la révocation', sw: 'Thibitisha uondoaji' },
|
|
51
|
+
'Billing.WITHDRAWAL_CANCEL': { de: 'Abbrechen', de_informal: 'Abbrechen', en: 'Cancel', fr: 'Annuler', sw: 'Ghairi' },
|
|
52
|
+
'Billing.WITHDRAWAL_DONE': { de: 'Widerruf eingegangen', de_informal: 'Widerruf eingegangen', en: 'Withdrawal received', fr: 'Révocation reçue', sw: 'Uondoaji umepokelewa' },
|
|
53
|
+
'Billing.WITHDRAWAL_DONE_DETAIL': { de: 'Eingegangen am {{date}}. Eine Bestätigung ist per E-Mail unterwegs; die Rückzahlung folgt innerhalb von 14 Tagen.', de_informal: 'Eingegangen am {{date}}. Eine Bestätigung ist per E-Mail unterwegs; die Rückzahlung folgt innert 14 Tagen.', en: 'Received on {{date}}. A confirmation email is on its way; the refund will follow within 14 days.', fr: 'Reçu le {{date}}. Un e-mail de confirmation est en route ; le remboursement suivra sous 14 jours.', sw: 'Imepokelewa {{date}}. Barua pepe ya uthibitisho inatumwa; marejesho yatafuata ndani ya siku 14.' },
|
|
54
|
+
'Billing.WITHDRAWAL_PREVIEW_ERROR': { de: 'Die Vorschau konnte nicht geladen werden.', de_informal: 'Die Vorschau konnte nicht geladen werden.', en: 'The preview could not be loaded.', fr: 'Impossible de charger l’aperçu.', sw: 'Muhtasari haukuweza kupakiwa.' },
|
|
55
|
+
'Billing.WITHDRAWAL_NOT_POSSIBLE': { de: 'Dieser Vertrag kann derzeit nicht widerrufen werden.', de_informal: 'Dieser Vertrag kann derzeit nicht widerrufen werden.', en: 'This contract cannot be withdrawn right now.', fr: 'Ce contrat ne peut pas être révoqué pour le moment.', sw: 'Mkataba huu hauwezi kuondolewa kwa sasa.' },
|
|
56
|
+
'Billing.WITHDRAWAL_ERROR': { de: 'Der Widerruf konnte nicht übermittelt werden. Bitte versuchen Sie es erneut.', de_informal: 'Der Widerruf konnte nicht übermittelt werden. Bitte versuche es erneut.', en: 'The withdrawal could not be submitted. Please try again.', fr: 'La révocation n’a pas pu être envoyée. Veuillez réessayer.', sw: 'Uondoaji haukuweza kutumwa. Tafadhali jaribu tena.' },
|
|
57
|
+
'Billing.WITHDRAWAL_LOAD_ERROR': { de: 'Widerrufsmöglichkeiten konnten nicht geladen werden.', de_informal: 'Widerrufsmöglichkeiten konnten nicht geladen werden.', en: 'Withdrawal options could not be loaded.', fr: 'Impossible de charger les possibilités de révocation.', sw: 'Chaguo za uondoaji hazikuweza kupakiwa.' },
|
|
58
|
+
'Billing.WITHDRAWAL_PAID': { de: 'Gezahlt: {{amount}}', de_informal: 'Gezahlt: {{amount}}', en: 'Paid: {{amount}}', fr: 'Payé : {{amount}}', sw: 'Imelipwa: {{amount}}' },
|
|
59
|
+
'Billing.WITHDRAWAL_TIME_SHARE': { de: 'Zeitanteil: {{amount}}', de_informal: 'Zeitanteil: {{amount}}', en: 'Time share: {{amount}}', fr: 'Part temporelle : {{amount}}', sw: 'Sehemu ya muda: {{amount}}' },
|
|
60
|
+
'Billing.WITHDRAWAL_TOKEN_SHARE': { de: 'Tokenanteil: {{amount}}', de_informal: 'Tokenanteil: {{amount}}', en: 'Token share: {{amount}}', fr: 'Part des jetons : {{amount}}', sw: 'Sehemu ya tokeni: {{amount}}' },
|
|
61
|
+
'Billing.WITHDRAWAL_USED': { de: 'Genutzt: {{amount}}', de_informal: 'Genutzt: {{amount}}', en: 'Used: {{amount}}', fr: 'Utilisé : {{amount}}', sw: 'Imetumika: {{amount}}' },
|
|
62
|
+
'Billing.WITHDRAWAL_CLOSE': { de: 'Schließen', de_informal: 'Schließen', en: 'Close', fr: 'Fermer', sw: 'Funga' },
|
|
63
|
+
};
|
|
@@ -10,6 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { authTranslations } from './authTranslations';
|
|
13
|
+
import { billingTranslations } from './billingTranslations';
|
|
13
14
|
import { chartsTranslations } from './chartsTranslations';
|
|
14
15
|
import { chatTranslations } from './chatTranslations';
|
|
15
16
|
import { messagingTranslations } from './messagingTranslations';
|
|
@@ -17,7 +18,7 @@ import { notificationsTranslations } from './notificationsTranslations';
|
|
|
17
18
|
import { onboardingTranslations } from './onboardingTranslations';
|
|
18
19
|
import { sectionNavTranslations } from './sectionNavTranslations';
|
|
19
20
|
import { userMenuTranslations } from './userMenuTranslations';
|
|
20
|
-
export const uiCoreTranslations = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, authTranslations), chartsTranslations), chatTranslations), messagingTranslations), notificationsTranslations), onboardingTranslations), sectionNavTranslations), userMenuTranslations);
|
|
21
|
+
export const uiCoreTranslations = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, authTranslations), billingTranslations), chartsTranslations), chatTranslations), messagingTranslations), notificationsTranslations), onboardingTranslations), sectionNavTranslations), userMenuTranslations);
|
|
21
22
|
export function createUiCoreTranslations({ germanVariant = 'formal' } = {}) {
|
|
22
23
|
return Object.fromEntries(Object.entries(uiCoreTranslations).map(([key, value]) => {
|
|
23
24
|
const { de_informal } = value, rest = __rest(value, ["de_informal"]);
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,16 @@ export { MobileBottomNav } from './components/MobileBottomNav';
|
|
|
42
42
|
export { default as StatTile } from './components/StatTile';
|
|
43
43
|
export { default as SoftChip } from './components/SoftChip';
|
|
44
44
|
export { default as EmptyState } from './components/EmptyState';
|
|
45
|
+
// --- 5.1 Billing ---
|
|
46
|
+
export { TokenBalanceBadge } from './billing/TokenBalanceBadge';
|
|
47
|
+
export { TokenCostPreview } from './billing/TokenCostPreview';
|
|
48
|
+
export { AccessEndedBanner } from './billing/AccessEndedBanner';
|
|
49
|
+
export { PlanPicker } from './billing/PlanPicker';
|
|
50
|
+
export { SubscriptionSection } from './billing/SubscriptionSection';
|
|
51
|
+
export { WithdrawalSection } from './billing/WithdrawalSection';
|
|
52
|
+
export { WithdrawalDialog } from './billing/WithdrawalDialog';
|
|
53
|
+
export { useBilling } from './billing/useBilling';
|
|
54
|
+
export { createBillingApi, defaultBillingApi } from './billing/api';
|
|
45
55
|
// --- 6. Charts ---
|
|
46
56
|
export { getNeutralChartPalette, useNeutralChartPalette } from './components/charts/palette';
|
|
47
57
|
export { formatShortTime, formatShortDate, formatShortMonth, formatShortYear, } from './components/charts/chartLabels';
|
|
@@ -88,4 +98,5 @@ export { onboardingTranslations } from './i18n/onboardingTranslations';
|
|
|
88
98
|
export { chartsTranslations } from './i18n/chartsTranslations';
|
|
89
99
|
export { messagingTranslations } from './i18n/messagingTranslations';
|
|
90
100
|
export { chatTranslations } from './i18n/chatTranslations';
|
|
101
|
+
export { billingTranslations } from './i18n/billingTranslations';
|
|
91
102
|
export { createUiCoreTranslations, uiCoreTranslations } from './i18n/uiCoreTranslations';
|
|
@@ -33,8 +33,15 @@ import { SIGN_UP_PAGE_ALERT_SX } from '../pages/SignUpPage';
|
|
|
33
33
|
import { SIGNUP_CONFIRM_PAGE_ALERT_SX } from '../pages/SignupConfirmPage';
|
|
34
34
|
import { REAUTH_MODAL_ALERT_SX, REAUTH_MODAL_TEXT_FIELD_SX } from '../auth/ReauthModal';
|
|
35
35
|
import { createKitSxEntry } from './kitSxEntry';
|
|
36
|
+
import { ACCESS_ENDED_BANNER_ALERT_SX } from '../billing/AccessEndedBanner';
|
|
37
|
+
import { TOKEN_BALANCE_BADGE_SX } from '../billing/TokenBalanceBadge';
|
|
38
|
+
import { PLAN_PICKER_ALERT_SX, PLAN_PICKER_CARD_SX, PLAN_PICKER_LABEL_SX, PLAN_PICKER_SELECTED_CARD_SX } from '../billing/PlanPicker';
|
|
39
|
+
import { SUBSCRIPTION_SECTION_ALERT_SX } from '../billing/SubscriptionSection';
|
|
40
|
+
import { WITHDRAWAL_DIALOG_ALERT_SX } from '../billing/WithdrawalDialog';
|
|
41
|
+
import { WITHDRAWAL_SECTION_ALERT_SX } from '../billing/WithdrawalSection';
|
|
36
42
|
const SX_EXPORTS = {
|
|
37
43
|
ACCESS_CODE_ACTION_SX,
|
|
44
|
+
ACCESS_ENDED_BANNER_ALERT_SX,
|
|
38
45
|
ACCESS_CODE_ALERT_SX,
|
|
39
46
|
ACCESS_CODE_PRIMARY_ACTION_SX,
|
|
40
47
|
ACCESS_CODE_SINGLE_USE_ALERT_SX,
|
|
@@ -101,6 +108,14 @@ const SX_EXPORTS = {
|
|
|
101
108
|
SUPPORT_RECOVERY_AGENT_PAPER_SX,
|
|
102
109
|
SUPPORT_RECOVERY_ALERT_SX,
|
|
103
110
|
THREAD_DAY_SEPARATOR_SX,
|
|
111
|
+
TOKEN_BALANCE_BADGE_SX,
|
|
112
|
+
PLAN_PICKER_ALERT_SX,
|
|
113
|
+
PLAN_PICKER_CARD_SX,
|
|
114
|
+
PLAN_PICKER_LABEL_SX,
|
|
115
|
+
PLAN_PICKER_SELECTED_CARD_SX,
|
|
116
|
+
SUBSCRIPTION_SECTION_ALERT_SX,
|
|
117
|
+
WITHDRAWAL_DIALOG_ALERT_SX,
|
|
118
|
+
WITHDRAWAL_SECTION_ALERT_SX,
|
|
104
119
|
USER_INVITE_ACTION_SX,
|
|
105
120
|
USER_INVITE_ALERT_SX,
|
|
106
121
|
USER_LIST_ACTION_SX,
|
|
@@ -199,4 +214,13 @@ export const KIT_COMPONENT_SX_REGISTRY = [
|
|
|
199
214
|
entry('SignupConfirmPage.alert', 'MuiAlert', SIGNUP_CONFIRM_PAGE_ALERT_SX),
|
|
200
215
|
entry('ReauthModal.alert', 'MuiAlert', REAUTH_MODAL_ALERT_SX),
|
|
201
216
|
entry('ReauthModal.field', 'MuiTextField', REAUTH_MODAL_TEXT_FIELD_SX),
|
|
217
|
+
entry('AccessEndedBanner.alert', 'MuiAlert', ACCESS_ENDED_BANNER_ALERT_SX),
|
|
218
|
+
entry('TokenBalanceBadge.root', 'MuiChip', TOKEN_BALANCE_BADGE_SX),
|
|
219
|
+
entry('PlanPicker.card', 'MuiCard', PLAN_PICKER_CARD_SX),
|
|
220
|
+
entry('PlanPicker.selectedCard', 'MuiCard', PLAN_PICKER_SELECTED_CARD_SX),
|
|
221
|
+
entry('PlanPicker.label', 'MuiFormControlLabel', PLAN_PICKER_LABEL_SX),
|
|
222
|
+
entry('PlanPicker.alert', 'MuiAlert', PLAN_PICKER_ALERT_SX),
|
|
223
|
+
entry('SubscriptionSection.alert', 'MuiAlert', SUBSCRIPTION_SECTION_ALERT_SX),
|
|
224
|
+
entry('WithdrawalDialog.alert', 'MuiAlert', WITHDRAWAL_DIALOG_ALERT_SX),
|
|
225
|
+
entry('WithdrawalSection.alert', 'MuiAlert', WITHDRAWAL_SECTION_ALERT_SX),
|
|
202
226
|
];
|