Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export default class UsageSummary extends React.Component {
  2.   /**
  3.    * @return {{}}
  4.    */
  5.   static get propTypes () {
  6.     return {
  7.       storage: PropTypes.instanceOf(Storage).isRequired
  8.     };
  9.   }
  10.  
  11.   /**
  12.    * @return {Usage}
  13.    */
  14.   get #usage () {
  15.     return this.props.storage.usage;
  16.   }
  17.  
  18.   /**
  19.    * @return {*}
  20.    */
  21.   render () {
  22.     if (!this.props.storage.shop.hasUsageBasedPlan) {
  23.       return null;
  24.     }
  25.     return (
  26.       <Layout.Section>
  27.         <Card sectioned>
  28.           <Stack alignment="center">
  29.             <Stack.Item fill>
  30.               <TextStyle variation="strong">Current plan: {this.#currentPlanTitle}</TextStyle>
  31.               <br/>
  32.               Discounts applied to: {this.#countLine} unique products.
  33.             </Stack.Item>
  34.             <Stack.Item>
  35.               <Button onClick={() => navigateTo(route.PLANS)}>
  36.                 Learn more
  37.               </Button>
  38.             </Stack.Item>
  39.           </Stack>
  40.         </Card>
  41.       </Layout.Section>
  42.     );
  43.   }
  44.  
  45.   /**
  46.    * @return {string}
  47.    */
  48.   get #currentPlanTitle () {
  49.     let currentPlan = this.#usage.currentPlan;
  50.     if (!currentPlan) {
  51.       return 'Free';
  52.     }
  53.     return `${currentPlan.name}, ${currentPlan.priceFormatted}`;
  54.   }
  55.  
  56.   /**
  57.    * @return {string}
  58.    */
  59.   get #countLine () {
  60.     let currentPlan = this.#usage.currentPlan;
  61.     let topLimit = this.#usage.planTopLimit(currentPlan);
  62.     if (topLimit) {
  63.       return `${this.#usage.count}/${topLimit}`;
  64.     } else {
  65.       return `${currentPlan.usage_min} or more`;
  66.     }
  67.   }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement