diff --git a/apps/marketing/src/app/(marketing)/open/gh-metrics.tsx b/apps/marketing/src/app/(marketing)/open/bar-metrics.tsx similarity index 79% rename from apps/marketing/src/app/(marketing)/open/gh-metrics.tsx rename to apps/marketing/src/app/(marketing)/open/bar-metrics.tsx index 357c110c2..ec677ec83 100644 --- a/apps/marketing/src/app/(marketing)/open/gh-metrics.tsx +++ b/apps/marketing/src/app/(marketing)/open/bar-metrics.tsx @@ -7,18 +7,15 @@ import { Bar, BarChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recha import { formatMonth } from '@documenso/lib/client-only/format-month'; import { cn } from '@documenso/ui/lib/utils'; -import { StargazersType } from './page'; - -export type MetricsDataKey = keyof StargazersType[string]; -export type GithubMetricProps = HTMLAttributes & { - data: StargazersType; - metricKey: MetricsDataKey; +export type BarMetricProps> = HTMLAttributes & { + data: T; + metricKey: keyof T[string]; title: string; label: string; chartHeight?: number; }; -export const GithubMetric = ({ +export const BarMetric = >>({ className, data, metricKey, @@ -26,7 +23,7 @@ export const GithubMetric = ({ label, chartHeight = 400, ...props -}: GithubMetricProps) => { +}: BarMetricProps) => { const formattedData = Object.keys(data) .map((key) => ({ month: formatMonth(key), @@ -50,7 +47,7 @@ export const GithubMetric = ({ formatter={(value) => [Number(value), label]} cursor={{ fill: 'hsl(var(--primary) / 10%)' }} /> - + {' '} diff --git a/apps/marketing/src/app/(marketing)/open/early-adopter-metrics.tsx b/apps/marketing/src/app/(marketing)/open/early-adopter-metrics.tsx deleted file mode 100644 index b84deea37..000000000 --- a/apps/marketing/src/app/(marketing)/open/early-adopter-metrics.tsx +++ /dev/null @@ -1,59 +0,0 @@ -'use client'; - -import { HTMLAttributes } from 'react'; - -import { Bar, BarChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'; - -import { formatMonth } from '@documenso/lib/client-only/format-month'; -import { cn } from '@documenso/ui/lib/utils'; - -import { EarlyAdoptersType } from './page'; - -export type MetricsDataKey = keyof Omit; -export type EarlyAdopterMetricsProps = HTMLAttributes & { - data: EarlyAdoptersType; - metricKey: MetricsDataKey; - title: string; - label: string; - chartHeight?: number; -}; - -export const EarlyAdopterMetrics = ({ - className, - data, - metricKey, - title, - label, - chartHeight = 400, - ...props -}: EarlyAdopterMetricsProps) => { - const formattedData = Object.keys(data) - .map((key) => ({ - month: formatMonth(key), - [metricKey]: data[key][metricKey], - })) - .reverse(); - - return ( -
-

{title}

- -
- - - - - [Number(value), label]} - cursor={{ fill: 'hsl(var(--primary) / 10%)' }} - /> - - - -
-
- ); -}; diff --git a/apps/marketing/src/app/(marketing)/open/funding-raised.tsx b/apps/marketing/src/app/(marketing)/open/funding-raised.tsx index c6601f547..51857bb06 100644 --- a/apps/marketing/src/app/(marketing)/open/funding-raised.tsx +++ b/apps/marketing/src/app/(marketing)/open/funding-raised.tsx @@ -7,14 +7,14 @@ import { Bar, BarChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recha import { formatMonth } from '@documenso/lib/client-only/format-month'; import { cn } from '@documenso/ui/lib/utils'; -import { FUNDING_RAISED } from '~/app/(marketing)/open/data'; +export type FundingRaisedProps = HTMLAttributes & { + data: Record[]; +}; -export type FundingRaisedProps = HTMLAttributes; - -export const FundingRaised = ({ className, ...props }: FundingRaisedProps) => { - const formattedData = FUNDING_RAISED.map((item) => ({ +export const FundingRaised = ({ className, data, ...props }: FundingRaisedProps) => { + const formattedData = data.map((item) => ({ amount: Number(item.amount), - date: formatMonth(item.date), + date: formatMonth(item.date as string), })); return ( diff --git a/apps/marketing/src/app/(marketing)/open/page.tsx b/apps/marketing/src/app/(marketing)/open/page.tsx index 1740a65ad..8a8281d53 100644 --- a/apps/marketing/src/app/(marketing)/open/page.tsx +++ b/apps/marketing/src/app/(marketing)/open/page.tsx @@ -1,12 +1,12 @@ import { z } from 'zod'; +import { FUNDING_RAISED } from '~/app/(marketing)/open/data'; import { MetricCard } from '~/app/(marketing)/open/metric-card'; import { SalaryBands } from '~/app/(marketing)/open/salary-bands'; +import { BarMetric } from './bar-metrics'; import { CapTable } from './cap-table'; -import { EarlyAdopterMetrics } from './early-adopter-metrics'; import { FundingRaised } from './funding-raised'; -import { GithubMetric } from './gh-metrics'; import { TeamMembers } from './team-members'; export const revalidate = 3600; @@ -41,8 +41,6 @@ const ZEarlyAdoptersResponse = z.record( export type StargazersType = z.infer; export type EarlyAdoptersType = z.infer; -// const ZOpenPullRequestsResponse = ZMergedPullRequestsResponse; - export default async function OpenPage() { const { forks_count: forksCount, @@ -125,11 +123,11 @@ export default async function OpenPage() { - + - data={EARLY_ADOPTERS_DATA} metricKey="earlyAdopters" title="Early Adopters" @@ -137,7 +135,7 @@ export default async function OpenPage() { className="col-span-12 lg:col-span-6" /> - data={STARGAZERS_DATA} metricKey="stars" title="Github: Total Stars" @@ -145,7 +143,7 @@ export default async function OpenPage() { className="col-span-12 lg:col-span-6" /> - data={STARGAZERS_DATA} metricKey="mergedPRs" title="Github: Total Merged PRs" @@ -153,7 +151,8 @@ export default async function OpenPage() { chartHeight={300} className="col-span-12 lg:col-span-6" /> - data={STARGAZERS_DATA} metricKey="forks" title="Github: Total Forks" @@ -161,7 +160,8 @@ export default async function OpenPage() { chartHeight={300} className="col-span-12 lg:col-span-6" /> - data={STARGAZERS_DATA} metricKey="openIssues" title="Github: Total Open Issues"