All files / modules/75-ce/components/RecommendationDetailsSummaryCards RecommendationDetailsSummaryCards.tsx

100% Statements 16/16
100% Branches 0/0
100% Functions 2/2
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121              2x 2x 2x 2x 2x 2x                 2x 4x 4x   4x                                                                         2x 4x 4x   4x                                                                                                            
/*
 * Copyright 2021 Harness Inc. All rights reserved.
 * Use of this source code is governed by the PolyForm Shield 1.0.0 license
 * that can be found in the licenses directory at the root of this repository, also available at
 * https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt.
 */
 
import { Card, Layout, Text, Icon, Container } from '@wings-software/uicore'
import { Color, FontVariation } from '@harness/design-system'
import React from 'react'
import cx from 'classnames'
import { useStrings } from 'framework/strings'
import css from './RecommendationDetailsSummaryCards.module.scss'
 
interface RecommendationDetailsSavingsCardProps {
  title: string
  amount: string
  amountSubTitle: string
  subTitle: string
}
 
export const RecommendationDetailsSavingsCard: React.FC<RecommendationDetailsSavingsCardProps> = props => {
  const { title, amount, amountSubTitle, subTitle } = props
  const { getString } = useStrings()
 
  return (
    <Card className={cx(css.savingsCard)} style={{ backgroundColor: Color.PRIMARY_1 }} elevation={1}>
      <Layout.Vertical spacing="small">
        <Text
          font={{ variation: FontVariation.H6 }}
          color={Color.GREY_500}
          tooltipProps={{ dataTooltipId: 'recommendationDetailsSavingsCardTitle' }}
        >
          {title}
        </Text>
        <Layout.Horizontal style={{ alignItems: 'baseline' }} spacing="xsmall">
          <Icon name="money-icon" size={28} color={Color.GREEN_700} />
          <Text color={Color.GREEN_700} font={{ variation: FontVariation.SMALL_SEMI }}>
            {getString('ce.recommendation.listPage.uptoText')}
          </Text>
          <Text className={css.amount} color={Color.GREEN_600} font={{ variation: FontVariation.H3 }}>
            {amount}
          </Text>
          <Text color={Color.GREEN_700} font={{ variation: FontVariation.BODY2 }}>
            {amountSubTitle}
          </Text>
        </Layout.Horizontal>
        <Text color={Color.GREY_500} font={{ variation: FontVariation.TINY }}>
          {subTitle}
        </Text>
      </Layout.Vertical>
    </Card>
  )
}
 
interface RecommendationDetailsSpendCardProps {
  title: string
  spentBy: string
  withRecommendationAmount: string
  withoutRecommendationAmount: string
}
 
export const RecommendationDetailsSpendCard: React.FC<RecommendationDetailsSpendCardProps> = props => {
  const { title, spentBy, withRecommendationAmount, withoutRecommendationAmount } = props
  const { getString } = useStrings()
 
  return (
    <Card className={cx(css.potentialSpendCard)} elevation={1}>
      <Layout.Vertical spacing="small">
        <Layout.Horizontal style={{ alignItems: 'baseline' }} padding={{ bottom: 'small' }} spacing="xsmall">
          <Text
            font={{ variation: FontVariation.H6 }}
            color={Color.GREY_500}
            tooltipProps={{ dataTooltipId: 'recommendationDetailsSpendCardTitle' }}
          >
            {title}
          </Text>
          <Text color={Color.GREY_500}>{`(${getString('ce.recommendation.detailsPage.monthlySpendByDate', {
            date: spentBy
          })})`}</Text>
        </Layout.Horizontal>
        <Layout.Horizontal padding={{ left: 'small', right: 'small' }}>
          <Layout.Vertical
            padding={{ right: 'medium' }}
            flex={{ justifyContent: 'space-between', alignItems: 'start' }}
          >
            <Text className={css.amount} font={{ variation: FontVariation.H3 }}>
              {withRecommendationAmount}
            </Text>
            <Layout.Horizontal spacing="xsmall">
              <Text color={Color.GREEN_700} font={{ variation: FontVariation.TINY }}>
                {getString('common.with')}
              </Text>
              <Text color={Color.GREY_500} font={{ variation: FontVariation.TINY }}>
                {getString('ce.recommendation.sideNavText').toLowerCase()}
              </Text>
            </Layout.Horizontal>
          </Layout.Vertical>
          <Container
            margin={{ left: 'medium', right: 'medium' }}
            style={{ borderLeft: '1px solid var(--grey-300)', height: 52 }}
          />
          <Layout.Vertical flex={{ justifyContent: 'space-between', alignItems: 'start' }}>
            <Text className={css.amount} font={{ variation: FontVariation.H6 }} padding={{ top: 'xsmall' }}>
              {withoutRecommendationAmount}
            </Text>
            <Layout.Horizontal spacing="xsmall">
              <Text color={Color.RED_700} font={{ variation: FontVariation.TINY }}>
                {getString('common.without')}
              </Text>
              <Text color={Color.GREY_500} font={{ variation: FontVariation.TINY }}>
                {getString('ce.recommendation.sideNavText').toLowerCase()}
              </Text>
            </Layout.Horizontal>
          </Layout.Vertical>
        </Layout.Horizontal>
      </Layout.Vertical>
    </Card>
  )
}