contactBillingMembers.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {Fragment} from 'react';
  2. import EmptyMessage from 'sentry/components/emptyMessage';
  3. import Panel from 'sentry/components/panels/panel';
  4. import {IconWarning} from 'sentry/icons';
  5. import {t, tct} from 'sentry/locale';
  6. import type {Member} from 'sentry/types/organization';
  7. import {useApiQuery} from 'sentry/utils/queryClient';
  8. import useOrganization from 'sentry/utils/useOrganization';
  9. function HelpfulMembers() {
  10. const organization = useOrganization();
  11. const {data: billingMembers} = useApiQuery<Member[]>(
  12. [
  13. `/organizations/${organization.slug}/members/`,
  14. {query: {query: 'scope:"org:billing"'}},
  15. ],
  16. {staleTime: 0}
  17. );
  18. if (!billingMembers || billingMembers.length === 0) {
  19. return null;
  20. }
  21. return (
  22. <p>
  23. {tct('Maybe a billing admin ([members]) could help?', {
  24. members: billingMembers.slice(0, 3).map((member, i, list) => (
  25. <Fragment key={member.id}>
  26. <a href={`mailto: ${member.email}`}>{member.email}</a>
  27. {i + 1 < Math.min(list.length, 3) && ', '}
  28. </Fragment>
  29. )),
  30. })}
  31. </p>
  32. );
  33. }
  34. function ContactBillingMembers() {
  35. return (
  36. <Panel data-test-id="permission-denied">
  37. <EmptyMessage
  38. title={t('Insufficient Access')}
  39. icon={<IconWarning size="xl" />}
  40. description={
  41. <Fragment>
  42. <p>
  43. {t("You don't have access to manage billing and subscription details.")}
  44. </p>
  45. <HelpfulMembers />
  46. </Fragment>
  47. }
  48. />
  49. </Panel>
  50. );
  51. }
  52. export default ContactBillingMembers;