From 0b6327e2fb256c55a49681fb46724e7552c7cfcf Mon Sep 17 00:00:00 2001 From: "fredy.siswanto" Date: Sat, 8 Mar 2025 21:29:39 +0700 Subject: [PATCH] feat: create NewsAuthor component and update news detail page --- app/apis/admin/get-news.ts | 1 + app/components/icons/link-icon.tsx | 22 ------------------- app/components/ui/news-author.tsx | 34 ++++++++++++++++++++++++++++++ app/pages/news-detail/index.tsx | 32 ++++++---------------------- 4 files changed, 42 insertions(+), 47 deletions(-) delete mode 100644 app/components/icons/link-icon.tsx create mode 100644 app/components/ui/news-author.tsx diff --git a/app/apis/admin/get-news.ts b/app/apis/admin/get-news.ts index 0b540f2..a6f5896 100644 --- a/app/apis/admin/get-news.ts +++ b/app/apis/admin/get-news.ts @@ -29,6 +29,7 @@ const dataResponseSchema = z.object({ }) export type TNewsResponse = z.infer +export type TAuthor = z.infer export const getNews = async (parameters: THttpServer) => { try { diff --git a/app/components/icons/link-icon.tsx b/app/components/icons/link-icon.tsx deleted file mode 100644 index db5f618..0000000 --- a/app/components/icons/link-icon.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import type { JSX, SVGProps } from 'react' - -export const LinkIcon = ( - properties: JSX.IntrinsicAttributes & SVGProps, -) => { - return ( - - - - ) -} diff --git a/app/components/ui/news-author.tsx b/app/components/ui/news-author.tsx new file mode 100644 index 0000000..c6df263 --- /dev/null +++ b/app/components/ui/news-author.tsx @@ -0,0 +1,34 @@ +import type { TAuthor } from '~/apis/admin/get-news' +import { ProfileIcon } from '~/components/icons/profile' +import { formatDate } from '~/utils/formatter' + +type TDetailNewsAuthor = { + author?: TAuthor + live_at?: string + text?: string +} + +export const NewsAuthor = ({ author, live_at, text }: TDetailNewsAuthor) => { + return ( +
+ {author?.profile_picture ? ( + {author?.name} + ) : ( + + )} + +
+

{author?.name}

+

+ {live_at && `${formatDate(live_at)}`} + · + {text} +

+
+
+ ) +} diff --git a/app/pages/news-detail/index.tsx b/app/pages/news-detail/index.tsx index 36b3ac6..a31168d 100644 --- a/app/pages/news-detail/index.tsx +++ b/app/pages/news-detail/index.tsx @@ -3,13 +3,12 @@ import { useReadingTime } from 'react-hook-reading-time' import { useRouteLoaderData } from 'react-router' import type { TTagResponse } from '~/apis/common/get-tags' -import { ProfileIcon } from '~/components/icons/profile' import { Card } from '~/components/ui/card' import { CarouselSection } from '~/components/ui/carousel-section' +import { NewsAuthor } from '~/components/ui/news-author' import { SocialShareButtons } from '~/components/ui/social-share' import { BERITA } from '~/data/contents' import type { loader } from '~/routes/_news.detail.$slug' -import { formatDate } from '~/utils/formatter' export const NewsDetailPage = () => { const loaderData = useRouteLoaderData( @@ -30,35 +29,18 @@ export const NewsDetailPage = () => { {title} - {/* START TODO: create component for this section */}
-
- {author?.profile_picture ? ( - {author?.name} - ) : ( - - )} - -
-

{author?.name}

-

- {live_at && `${formatDate(live_at)}`} - · - {text} -

-
-
- +
- {/* END TODO: create component for this section */} +