mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-08 09:56:36 +00:00
Use human readable description if possible (#1688)
* Use human readable description if possible * lint
This commit is contained in:
parent
03525c010f
commit
e1407a7d73
@ -196,41 +196,11 @@ class HaConfigCloudAccount extends EventsMixin(PolymerElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_formatSubscription(subInfo) {
|
_formatSubscription(subInfo) {
|
||||||
if (subInfo === null) {
|
return subInfo === null
|
||||||
return 'Fetching subscription…';
|
? 'Fetching subscription…'
|
||||||
}
|
: subInfo.human_description.replace(
|
||||||
/* eslint-disable camelcase */
|
'{periodEnd}', formatDateTime(new Date(subInfo.subscription.current_period_end * 1000))
|
||||||
const { subscription, source, customer_exists } = subInfo;
|
);
|
||||||
|
|
||||||
// Check if we're before Oct 17.
|
|
||||||
const beforeOct17 = Date.now() < 1539734400000;
|
|
||||||
|
|
||||||
if (!customer_exists) {
|
|
||||||
return `Legacy user. Subscription expire${beforeOct17 ? 's' : 'd'} Oct 17, 2018.`;
|
|
||||||
}
|
|
||||||
if (!subscription || subscription.status === 'canceled') {
|
|
||||||
return 'No subscription';
|
|
||||||
}
|
|
||||||
|
|
||||||
const periodExpires = formatDateTime(new Date(subscription.current_period_end * 1000));
|
|
||||||
|
|
||||||
if (subscription.status === 'trialing' && !source) {
|
|
||||||
return `Trial user. Trial expires ${periodExpires}.`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (subscription.status === 'trialing') {
|
|
||||||
return `Active user. You will be charged on ${periodExpires}.`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (subscription.status === 'active' && subscription.cancel_at_period_end) {
|
|
||||||
return `Active user. Scheduled to cancel on ${periodExpires}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (subscription.status === 'active') {
|
|
||||||
return `Active user. You will be charged on ${periodExpires}.`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'Unable to determine subscription status.';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_alexaChanged(ev) {
|
_alexaChanged(ev) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user