Skip to content

Commit

Permalink
feat(sdk): show message in tooltip for negative balance (#762)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsbh authored Sep 3, 2024
1 parent 396ca73 commit bfa5cf7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useFrontier } from '~/react/contexts/FrontierContext';
import { V1Beta1Invoice, V1Beta1Plan } from '~/src';
import { toast } from 'sonner';
import Skeleton from 'react-loading-skeleton';
import { Flex, Text, Image, Button } from '@raystack/apsara';
import { Flex, Text, Image, Button, Tooltip } from '@raystack/apsara';
import billingStyles from './billing.module.css';
import line from '~/react/assets/line.svg';
import Amount from '../../helpers/Amount';
Expand All @@ -15,6 +15,7 @@ import {
getPlanNameWithInterval,
makePlanSlug
} from '~/react/utils';
import { NEGATIVE_BALANCE_TOOLTIP_MESSAGE } from '~/react/utils/constants';

function LabeledBillingData({
label,
Expand Down Expand Up @@ -258,10 +259,20 @@ export const UpcomingBillingCycle = ({
<LabeledBillingData
label="Amount"
value={
<Amount
currency={upcomingInvoice?.currency}
value={Number(upcomingInvoice?.amount)}
/>
<Flex gap={'medium'}>
<Amount
currency={upcomingInvoice?.currency}
value={Number(upcomingInvoice?.amount)}
/>
{Number(upcomingInvoice?.amount) < 0 ? (
<Tooltip
message={NEGATIVE_BALANCE_TOOLTIP_MESSAGE}
side="bottom"
>
<InfoCircledIcon />
</Tooltip>
) : null}
</Flex>
}
/>
</Flex>
Expand Down
3 changes: 3 additions & 0 deletions sdks/js/packages/core/react/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export const DEFAULT_TOKEN_PRODUCT_NAME = 'token';
export const DEFAULT_PLAN_UPGRADE_MESSAGE =
'Any remaining balance from your current plan will be prorated and credited to your account in future billing cycles.';

export const NEGATIVE_BALANCE_TOOLTIP_MESSAGE =
'This negative amount shows a credit balance for prorated seats, which will be applied to future invoices.';

export const SUBSCRIPTION_STATES = {
ACTIVE: 'active',
PAST_DUE: 'past_due',
Expand Down

0 comments on commit bfa5cf7

Please sign in to comment.