diff --git a/app/components/ui/carousel.tsx b/app/components/ui/carousel.tsx deleted file mode 100644 index 6fe2f3b..0000000 --- a/app/components/ui/carousel.tsx +++ /dev/null @@ -1,171 +0,0 @@ -import { useState } from 'react' -import { Link, useLocation } from 'react-router' -import { twMerge } from 'tailwind-merge' - -import { CarouselNextIcon } from '~/components/icons/carousel-next' -import { CarouselPreviousIcon } from '~/components/icons/carousel-previous' -import { useNewsContext } from '~/contexts/news' -import type { TNews } from '~/types/news' - -import { Button } from './button' - -export const Carousel = (properties: TNews) => { - const { setIsSuccessOpen } = useNewsContext() - const [currentIndex, setCurrentIndex] = useState(0) - const { pathname } = useLocation() - const hasCategory = pathname.includes('/category/') - - const { title, description, items, type } = properties - const itemsPerPage = type === 'hero' ? 1 : 3 - const totalPages = Math.ceil(items.length / itemsPerPage) - - const nextSlide = () => { - setCurrentIndex((previousIndex) => (previousIndex + 1) % totalPages) - } - - const previousSlide = () => { - setCurrentIndex( - (previousIndex) => (previousIndex - 1 + totalPages) % totalPages, - ) - } - return ( -
-
-
-

- {title} -

-

- {description} -

-
- {!hasCategory && ( -
- - -
- )} -
- -
- {items - .slice(currentIndex * itemsPerPage, (currentIndex + 1) * itemsPerPage) - .map(({ featured, title, content, tags, slug, isPremium }, index) => ( -
- {title} -
-
- {tags?.map((item) => ( - - {item} - - ))} - {isPremium && ( - - Premium Content - - )} -
- -
-

- {title} -

-

- {content} -

-
- -
-
- ))} -
- - {hasCategory && ( -
-
- - -
-
- )} -
- ) -} diff --git a/app/components/ui/table.tsx b/app/components/ui/table.tsx deleted file mode 100644 index 12a9334..0000000 --- a/app/components/ui/table.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import DT from 'datatables.net-dt' -import DataTable from 'datatables.net-react' - -export const TableComponent = () => { - DataTable.use(DT) - return ( - <> -

test

- - - ) -} diff --git a/app/data/contents.ts b/app/data/contents.ts index cb2233b..b849bfa 100644 --- a/app/data/contents.ts +++ b/app/data/contents.ts @@ -1,9 +1,10 @@ import type { TNews } from '~/types/news' +export const DUMMY_DESCRIPTION = 'Berita Terhangat hari ini' + export const SPOTLIGHT: TNews = { title: 'SPOTLIGHT', - description: 'Berita Terhangat hari ini', - type: 'hero', + description: DUMMY_DESCRIPTION, items: [ { title: '01 Hotman Paris Membuka Perpustakaan di tengah Diskotik', @@ -31,8 +32,7 @@ export const SPOTLIGHT: TNews = { export const BERITA: TNews = { title: 'BERITA', - description: 'Berita Terhangat hari ini', - type: 'grid', + description: DUMMY_DESCRIPTION, items: [ { title: '01 Travelling as a way of self-discovery and progress ', @@ -89,8 +89,7 @@ export const BERITA: TNews = { export const KAJIAN: TNews = { title: 'KAJIAN', - description: 'Berita Terhangat hari ini ', - type: 'grid', + description: DUMMY_DESCRIPTION, items: [ { title: 'Travelling as a way of self-discovery and progress ', diff --git a/app/layouts/news/form-register.tsx b/app/layouts/news/form-register.tsx index e7f6dde..5f1c01c 100644 --- a/app/layouts/news/form-register.tsx +++ b/app/layouts/news/form-register.tsx @@ -31,6 +31,7 @@ export const FormRegister = () => { const [disabled, setDisabled] = useState(false) const fetcher = useFetcher() const loaderData = useRouteLoaderData('routes/_layout') + const subscriptions = loaderData?.subscriptionsData const formMethods = useRemixForm({ mode: 'onSubmit', @@ -98,7 +99,7 @@ export const FormRegister = () => { name="subscribe_plan" label="Subscription" placeholder="Pilih Subscription" - options={loaderData?.subscriptionsData} + options={subscriptions} /> {error && ( diff --git a/app/layouts/news/header-top.tsx b/app/layouts/news/header-top.tsx index aac8b4e..a1ba0d2 100644 --- a/app/layouts/news/header-top.tsx +++ b/app/layouts/news/header-top.tsx @@ -3,11 +3,12 @@ import { Link, useFetcher, useRouteLoaderData } from 'react-router' import { Button } from '~/components/ui/button' import { APP } from '~/configs/meta' import { useNewsContext } from '~/contexts/news' -import type { loader } from '~/routes/_layout' +import { loader } from '~/routes/_layout' export const HeaderTop = () => { const { setIsLoginOpen } = useNewsContext() const loaderData = useRouteLoaderData('routes/_layout') + const userToken = loaderData?.userToken const fetcher = useFetcher() return ( @@ -29,7 +30,7 @@ export const HeaderTop = () => { - {loaderData?.userToken ? ( + {userToken ? ( { + const { pathname } = useLocation() + const code = pathname.split('/')[2] + const loaderData = useRouteLoaderData('routes/_layout') + const { name } = + loaderData?.categoriesData.find((item) => item.code === code) || {} + const { items } = BERITA + return (
- +
) diff --git a/app/pages/news-detail/data.ts b/app/pages/news-detail/data.ts index cb61d9b..92f69b4 100644 --- a/app/pages/news-detail/data.ts +++ b/app/pages/news-detail/data.ts @@ -1,3 +1,4 @@ +import { DUMMY_DESCRIPTION } from '~/data/contents' import type { TNews, TNewsDetail } from '~/types/news' export const CONTENT: TNewsDetail = { @@ -40,8 +41,7 @@ export const CONTENT: TNewsDetail = { export const BERITA: TNews = { title: 'BERITA', - description: 'Berita Terhangat hari ini', - type: 'grid', + description: DUMMY_DESCRIPTION, items: [ { title: 'Travelling as a way of self-discovery and progress', diff --git a/app/types/news.ts b/app/types/news.ts index bb9ff12..d04e998 100644 --- a/app/types/news.ts +++ b/app/types/news.ts @@ -1,7 +1,6 @@ export type TNews = { title: string description: string - type: 'hero' | 'grid' items: Pick< TNewsDetail, 'title' | 'content' | 'featured' | 'slug' | 'tags' | 'isPremium'