managed-group-subscriptions.tsx 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import GroupSettingsButton from '@/features/subscription/components/dashboard/group-settings-button'
  2. import getMeta from '@/utils/meta'
  3. import { Trans, useTranslation } from 'react-i18next'
  4. import { useSubscriptionDashboardContext } from '../../context/subscription-dashboard-context'
  5. import { RowLink } from './row-link'
  6. export default function ManagedGroupSubscriptions() {
  7. const { t } = useTranslation()
  8. const { managedGroupSubscriptions } = useSubscriptionDashboardContext()
  9. if (!managedGroupSubscriptions) {
  10. return null
  11. }
  12. const groupSettingsEnabledFor = getMeta(
  13. 'ol-groupSettingsEnabledFor',
  14. []
  15. ) as string[]
  16. return (
  17. <>
  18. {managedGroupSubscriptions.map(subscription => {
  19. return (
  20. <div key={`managed-group-${subscription._id}`}>
  21. <p>
  22. {subscription.userIsGroupMember ? (
  23. <Trans
  24. i18nKey="you_are_a_manager_and_member_of_x_plan_as_member_of_group_subscription_y_administered_by_z"
  25. components={[
  26. // eslint-disable-next-line react/jsx-key, jsx-a11y/anchor-has-content
  27. <a href="/user/subscription/plans" />,
  28. // eslint-disable-next-line react/jsx-key
  29. <strong />,
  30. ]}
  31. values={{
  32. planName: subscription.planLevelName,
  33. groupName: subscription.teamName || '',
  34. adminEmail: subscription.admin_id.email,
  35. }}
  36. shouldUnescape
  37. tOptions={{ interpolation: { escapeValue: true } }}
  38. />
  39. ) : (
  40. <Trans
  41. i18nKey="you_are_a_manager_of_x_plan_as_member_of_group_subscription_y_administered_by_z"
  42. components={[
  43. // eslint-disable-next-line react/jsx-key, jsx-a11y/anchor-has-content
  44. <a href="/user/subscription/plans" />,
  45. // eslint-disable-next-line react/jsx-key
  46. <strong />,
  47. ]}
  48. values={{
  49. planName: subscription.planLevelName,
  50. groupName: subscription.teamName || '',
  51. adminEmail: subscription.admin_id.email,
  52. }}
  53. shouldUnescape
  54. tOptions={{ interpolation: { escapeValue: true } }}
  55. />
  56. )}
  57. </p>
  58. <RowLink
  59. href={`/manage/groups/${subscription._id}/members`}
  60. heading={t('manage_members')}
  61. subtext={t('manage_group_members_subtext')}
  62. icon="groups"
  63. />
  64. <RowLink
  65. href={`/manage/groups/${subscription._id}/managers`}
  66. heading={t('manage_group_managers')}
  67. subtext={t('manage_managers_subtext')}
  68. icon="manage_accounts"
  69. />
  70. {groupSettingsEnabledFor?.includes(subscription._id) && (
  71. <GroupSettingsButton subscription={subscription} />
  72. )}
  73. <RowLink
  74. href={`/metrics/groups/${subscription._id}`}
  75. heading={t('view_metrics')}
  76. subtext={t('view_metrics_group_subtext')}
  77. icon="insights"
  78. />
  79. <hr />
  80. </div>
  81. )
  82. })}
  83. </>
  84. )
  85. }