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 | import { css } from '@emotion/react'; import { IconCircleFilled } from '@tabler/icons-react'; import { isNil } from 'lodash-es'; import { memo } from 'react'; import { canViewHiddenPlans } from '@amalia/kernel/auth/shared'; import { useAbilityContext } from '@amalia/kernel/auth/state'; import { type Plan } from '@amalia/payout-definition/plans/types'; export type PlanVisibilityIconProps = { readonly isPlanHidden?: Plan['isHidden'] | null; }; export const IconPlanVisibility = memo(function PlanVisibilityIcon({ isPlanHidden }: PlanVisibilityIconProps) { const ability = useAbilityContext(); // Non-admin user cannot see hidden plans, so there is no need to show the dot // since everything they'll see on the app are live plans. if (!canViewHiddenPlans(ability)) { return null; } // In case the plan visibility is not defined, we don't show the dot. if (isNil(isPlanHidden)) { return null; } return ( <IconCircleFilled size={6} css={(theme) => css` color: ${isPlanHidden ? theme.ds.hues.orange[500] : theme.ds.hues.green[500]}; [data-color-scheme='dark'] & { color: ${isPlanHidden ? theme.ds.hues.orange[700] : theme.ds.hues.green[700]}; } `} /> ); }); |