Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions app/[locale]/roadmap/_components/ReleaseCarousel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use client"

// TODO: Extract intl strings
// TODO: Fix RTL compatibility; currently forced to LTR flow
import { useCallback, useEffect, useMemo, useState } from "react"
import { useLocale } from "next-intl"
Expand All @@ -19,10 +18,15 @@ import {
import { cn } from "@/lib/utils/cn"
import { formatDate } from "@/lib/utils/date"

import { Release, releasesData } from "@/data/roadmap/releases"
import { getReleasesData, Release } from "@/data/roadmap/releases"

import { useTranslation } from "@/hooks/useTranslation"

const ReleaseCarousel = () => {
const locale = useLocale()
const { t } = useTranslation("page-roadmap")

const releasesData = useMemo(() => getReleasesData(t), [t])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially out-of-scope for these changes, but our "data" file seems more like a hook... we could consider refactoring getReleasesData to a hook, with the other hooks embedded

ie create app/[locale]/roadmap/hooks/useReleases.tsx, which could contain everything in src/data/roadmap/releases.tsx, as well as the other client-side hooks here, returning everything we need:

const {
  releasesData,
  startIndex,
  setApi1,
  setApi2,
  getStatus,
  getDisplayDate,
  currentIndex,
  t
} = useReleases()


const [api1, setApi1] = useState<CarouselApi>()
const [api2, setApi2] = useState<CarouselApi>()
Expand All @@ -49,7 +53,7 @@ const ReleaseCarousel = () => {

// If no upcoming releases, start at the last production release
return productionReleases.length - 1
}, [])
}, [releasesData])

const [currentIndex, setCurrentIndex] = useState(startIndex)

Expand Down Expand Up @@ -125,7 +129,9 @@ const ReleaseCarousel = () => {
currentIndex !== index && "hidden"
)}
>
<p className="text-sm font-bold">In production</p>
<p className="text-sm font-bold">
{t("page-roadmap-release-status-prod")}
</p>
</div>
)}
{status === "soon" && (
Expand All @@ -136,7 +142,7 @@ const ReleaseCarousel = () => {
)}
>
<p className="text-sm font-bold text-black">
Coming soon
{t("page-roadmap-release-status-soon")}
</p>
</div>
)}
Expand All @@ -148,7 +154,7 @@ const ReleaseCarousel = () => {
)}
>
<p className="text-sm font-bold">
In development
{t("page-roadmap-release-status-dev")}
</p>
</div>
)}
Expand Down Expand Up @@ -243,17 +249,19 @@ const ReleaseCarousel = () => {

<div>
<p className="mb-3 text-xl font-bold">
Main features
{t("page-roadmap-release-main-features")}
</p>
<div className="flex flex-col gap-4">
{release.content}
{typeof release.content === "function"
? release.content(t)
: release.content}
</div>
</div>
<ButtonLink
href={release.href}
className="w-full lg:w-fit"
>
Learn more
{t("page-roadmap-release-learn-more")}
</ButtonLink>
</div>
</div>
Expand Down
Loading