From 08c9a14b6eb73997087806d4ae85d2bfde43a4ea Mon Sep 17 00:00:00 2001 From: Satont Date: Tue, 5 Sep 2023 01:32:06 +0300 Subject: [PATCH] chore(landing): use client rendered stats --- .../src/components/index/StatsList.astro | 56 ----------------- .../src/components/index/StatsList.vue | 61 +++++++++++++++++++ frontend/landing/src/pages/index.astro | 4 +- 3 files changed, 63 insertions(+), 58 deletions(-) delete mode 100644 frontend/landing/src/components/index/StatsList.astro create mode 100644 frontend/landing/src/components/index/StatsList.vue diff --git a/frontend/landing/src/components/index/StatsList.astro b/frontend/landing/src/components/index/StatsList.astro deleted file mode 100644 index d4a728d29..000000000 --- a/frontend/landing/src/components/index/StatsList.astro +++ /dev/null @@ -1,56 +0,0 @@ ---- -import { type Response } from '@twir/grpc/generated/api/api/stats'; - -import { unProtectedClient } from '../../api/twirp.js'; - -let res: Response | undefined; - -try { - const { response } = await unProtectedClient.getStats({}, { timeout: 1000 }); - res = response; -} catch (e) { - console.error(e) -} - -const formatter = Intl.NumberFormat('en-US', { - notation: 'compact', - maximumFractionDigits: 1, -}); - -const stats = [ - { - key: 'Users', - value: formatter.format(res?.users ?? 0), - }, - { - key: 'Channels', - value: formatter.format(res?.channels ?? 0), - }, - { - key: 'Commands', - value: formatter.format(res?.commands ?? 0), - }, - { - key: 'Messages', - value: formatter.format(res?.messages ?? 0), - }, - { - key: 'Used emotes', - value: formatter.format(res?.usedEmotes ?? 0), - }, -]; ---- - - -
- {stats.map((item) => -
- - {item.value} - - - {item.key} - -
)} -
- diff --git a/frontend/landing/src/components/index/StatsList.vue b/frontend/landing/src/components/index/StatsList.vue new file mode 100644 index 000000000..c283df4ed --- /dev/null +++ b/frontend/landing/src/components/index/StatsList.vue @@ -0,0 +1,61 @@ + + + + diff --git a/frontend/landing/src/pages/index.astro b/frontend/landing/src/pages/index.astro index 575a78af9..541535b2b 100644 --- a/frontend/landing/src/pages/index.astro +++ b/frontend/landing/src/pages/index.astro @@ -6,7 +6,7 @@ import Integrations from '../components/index/Integrations.astro'; import Reviews from '../components/index/Reviews.vue'; import Team from '../components/index/Team.astro'; import Footer from '../components/index/Footer.astro'; -import StatsList from '../components/index/StatsList.astro'; +import StatsList from '../components/index/StatsList.vue'; --- @@ -14,7 +14,7 @@ import StatsList from '../components/index/StatsList.astro';
- +