Commit 1aefd0c4 authored by Phạm Quang Bảo's avatar Phạm Quang Bảo

update/fix search feature

parent 4badb076
......@@ -41,7 +41,6 @@ const Page = () => {
}
);
console.log(newsData);
const { data: newsAll, isLoading: isLoadingNewsAll } = useGetNews<GetNewsResponseType>(
{
pageSize: '10',
......
......@@ -7,7 +7,7 @@ import { Pagination } from "@/components/base/pagination";
import { ListFilter } from "@/components/base/list-filter";
import EventCalendar from "@/components/base/event-calendar";
import ListCategory from "@/components/base/list-category";
import NewsContent from "@/components/base/card-news";
import CardNews from "@/components/base/card-news";
import Image from "next/image";
import parse from "html-react-parser";
import dayjs from "dayjs";
......@@ -108,7 +108,7 @@ export default function DynamicPage() {
) : (
<>
{news?.responseData.rows.map((item) => (
<NewsContent
<CardNews
key={item.id}
news={item}
link={`/${url}/${item.id}`}
......
"use client";
import React, { useState, Suspense } from "react";
import ListCategory from "@app/dai-dien-gioi-chu/components/list-category";
import { OWNER_REPRESENTATIVES_CATEGORIES } from "@constants/categories";
import ListFilter from "@app/dai-dien-gioi-chu/components/list-filter";
import NewsContent from "@app/dai-dien-gioi-chu/components/card-news";
import ListCategory from "@/components/base/list-category";
import ListFilter from "@/components/base/list-filter";
import CardNews from "@/components/base/card-news";
import { Pagination } from "@components/base/pagination";
import Image from "next/image";
import { useGetNews } from "@api/endpoints/news";
import { GetNewsResponseType } from "@api/types/NewsPage.type";
import { Spinner } from "@components/ui/spinner";
import { PATHS } from "@constants/paths";
import { useSearchParams } from 'next/navigation'
function SearchContent() {
......@@ -22,7 +20,7 @@ function SearchContent() {
currentPage: String(page),
filters: query ? `title @=${query}` : undefined,
});
return (
<div className="min-h-screen container mx-auto p-4">
<div className="w-full flex flex-col gap-5">
......@@ -49,10 +47,10 @@ function SearchContent() {
) : (
<>
{allData?.responseData.rows.map((news) => (
<NewsContent
<CardNews
key={news.id}
news={news}
link={`${PATHS.mediaInformation}/tin-vcci/${news.id}`}
link={`${news.category}/${news.id}`}
/>
))}
......
export interface NewsDetailItem {
id: string
title: string
thumbnail: string
external_link: string
description: string
release_at: string
is_active: boolean
created_at: string
created_by: string | null
updated_at: string
updated_by: string | null
mode: 'NOW' | string
category: string
}
export interface NewsDetailResponseData {
count: number
rows: NewsDetailItem[]
totalPages: number
currentPage: number
}
export interface GetNewsDetailResponseType {
message: string
message_en: string
responseData: NewsDetailItem
status: 'success' | 'error'
timeStamp: string
violations: any | null
}
\ No newline at end of file
import { NewsItem } from '@app/dai-dien-gioi-chu/lib/types/NewsPage.type';
import { NewsDetailItem } from './CardNews.type';
import Links from '@links/index'
import dayjs from 'dayjs';
......@@ -19,8 +19,8 @@ const stripImagesAndHtml = (html?: string) => {
}
return withoutImgs.replace(/<[^>]*>/g, '')
}
function NewsContent({ news ,link}: { news: NewsItem ,link:string}) {
const CardNews = ({ news, link }: { news: NewsDetailItem, link: string }) => {
return (
<a
href={`${link}`}
......@@ -30,14 +30,14 @@ function NewsContent({ news ,link}: { news: NewsItem ,link:string}) {
src={`${Links.imageEndpoint}${news.thumbnail}`}
alt={news.title}
className="w-full sm:w-56 md:w-64 h-40 md:h-36 object-cover shrink-0"
onError={(e) => {
e.currentTarget.src = "/img-error.png"
}}
onError={(e) => {
e.currentTarget.src = "/img-error.png"
}}
/>
<div className="flex-1 min-w-0 pl-0 sm:pl-4">
<p className="text-primary font-semibold text-base md:text-lg hover:underline line-clamp-2 wrap-break-word">
<p className="text-primary font-semibold text-base md:text-lg hover:underline line-clamp-2 wrap-break-word">
{news.title}
</p>
......@@ -51,4 +51,4 @@ function NewsContent({ news ,link}: { news: NewsItem ,link:string}) {
)
}
export default NewsContent;
\ No newline at end of file
export default CardNews;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment