1 import { numToSI } from "@utils/helpers";
2 import { Link } from "inferno-router";
7 } from "lemmy-js-client";
8 import { I18NextService } from "../../services";
10 interface BadgesProps {
11 counts: CommunityAggregates | SiteAggregates;
12 communityId?: CommunityId;
15 const isCommunityAggregates = (
16 counts: CommunityAggregates | SiteAggregates,
17 ): counts is CommunityAggregates => {
18 return "subscribers" in counts;
21 const isSiteAggregates = (
22 counts: CommunityAggregates | SiteAggregates,
23 ): counts is SiteAggregates => {
24 return "communities" in counts;
27 export const Badges = ({ counts, communityId }: BadgesProps) => {
29 <ul className="badges my-1 list-inline">
31 className="list-inline-item badge text-bg-secondary pointer"
32 data-tippy-content={I18NextService.i18n.t(
33 "active_users_in_the_last_day",
35 count: Number(counts.users_active_day),
36 formattedCount: numToSI(counts.users_active_day),
40 {I18NextService.i18n.t("number_of_users", {
41 count: Number(counts.users_active_day),
42 formattedCount: numToSI(counts.users_active_day),
44 / {I18NextService.i18n.t("day")}
47 className="list-inline-item badge text-bg-secondary pointer"
48 data-tippy-content={I18NextService.i18n.t(
49 "active_users_in_the_last_week",
51 count: Number(counts.users_active_week),
52 formattedCount: numToSI(counts.users_active_week),
56 {I18NextService.i18n.t("number_of_users", {
57 count: Number(counts.users_active_week),
58 formattedCount: numToSI(counts.users_active_week),
60 / {I18NextService.i18n.t("week")}
63 className="list-inline-item badge text-bg-secondary pointer"
64 data-tippy-content={I18NextService.i18n.t(
65 "active_users_in_the_last_month",
67 count: Number(counts.users_active_month),
68 formattedCount: numToSI(counts.users_active_month),
72 {I18NextService.i18n.t("number_of_users", {
73 count: Number(counts.users_active_month),
74 formattedCount: numToSI(counts.users_active_month),
76 / {I18NextService.i18n.t("month")}
79 className="list-inline-item badge text-bg-secondary pointer"
80 data-tippy-content={I18NextService.i18n.t(
81 "active_users_in_the_last_six_months",
83 count: Number(counts.users_active_half_year),
84 formattedCount: numToSI(counts.users_active_half_year),
88 {I18NextService.i18n.t("number_of_users", {
89 count: Number(counts.users_active_half_year),
90 formattedCount: numToSI(counts.users_active_half_year),
93 {I18NextService.i18n.t("number_of_months", {
98 {isSiteAggregates(counts) && (
100 <li className="list-inline-item badge text-bg-secondary">
101 {I18NextService.i18n.t("number_of_users", {
102 count: Number(counts.users),
103 formattedCount: numToSI(counts.users),
106 <li className="list-inline-item badge text-bg-secondary">
107 {I18NextService.i18n.t("number_of_communities", {
108 count: Number(counts.communities),
109 formattedCount: numToSI(counts.communities),
114 {isCommunityAggregates(counts) && (
115 <li className="list-inline-item badge text-bg-secondary">
116 {I18NextService.i18n.t("number_of_subscribers", {
117 count: Number(counts.subscribers),
118 formattedCount: numToSI(counts.subscribers),
122 <li className="list-inline-item badge text-bg-secondary">
123 {I18NextService.i18n.t("number_of_posts", {
124 count: Number(counts.posts),
125 formattedCount: numToSI(counts.posts),
128 <li className="list-inline-item badge text-bg-secondary">
129 {I18NextService.i18n.t("number_of_comments", {
130 count: Number(counts.comments),
131 formattedCount: numToSI(counts.comments),
134 <li className="list-inline-item">
136 className="badge text-bg-primary"
137 to={`/modlog${communityId ? `/${communityId}` : ""}`}
139 {I18NextService.i18n.t("modlog")}