@@ -4,7 +4,7 @@ import { formatDate } from '@/lib/helper';
44import { useArticlesQuery } from '@/services/queries/article.query' ;
55import type { Article } from '@/types/article' ;
66
7- export type Filter = { page : number ; pageSize : number ; search ?: string } ;
7+ export type Filter = { page : number ; search ?: string } ;
88
99export interface ArticleListProps {
1010 articles : Article [ ] ;
@@ -19,31 +19,48 @@ const ArticleList: React.FC<ArticleListProps> = ({ articles }) => {
1919 < >
2020 { articles . map ( ( article ) => (
2121 < div
22- key = { article . url }
22+ key = { article . link }
2323 className = "my-1 px-1 w-full md:w-1/2 lg:my-4 lg:px-4 lg:w-1/3"
2424 >
2525 < article className = "overflow-hidden rounded-lg shadow-lg" >
26- < a href = { article . url } target = "_blank" rel = "noreferrer" >
27- < img
28- alt = "Placeholder"
29- className = "block h-auto w-full"
30- src = { article . urlToImage }
31- />
26+ < a href = { article . link } target = "_blank" rel = "noreferrer" >
27+ { article . image_url ? (
28+ < img
29+ alt = "Placeholder"
30+ className = "block h-auto w-full"
31+ src = { article . image_url }
32+ />
33+ ) : (
34+ < svg
35+ xmlns = "http://www.w3.org/2000/svg"
36+ className = "h-[215px] w-[370px] bg-gray-100"
37+ fill = "none"
38+ viewBox = "0 0 24 24"
39+ stroke = "currentColor"
40+ strokeWidth = { 2 }
41+ >
42+ < path
43+ strokeLinecap = "round"
44+ strokeLinejoin = "round"
45+ d = "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"
46+ />
47+ </ svg >
48+ ) }
3249 </ a >
3350
3451 < header className = "flex items-center justify-between leading-tight p-2 md:p-4" >
3552 < h1 className = "text-lg" >
3653 < a
3754 className = "no-underline hover:underline text-black"
38- href = { article . url }
55+ href = { article . link }
3956 target = "_blank"
4057 rel = "noreferrer"
4158 >
4259 { article . title }
4360 </ a >
4461 </ h1 >
4562 < p className = "text-grey-darker text-sm" >
46- { formatDate ( article . publishedAt ) }
63+ { formatDate ( article . pubDate ) }
4764 </ p >
4865 </ header >
4966
@@ -107,7 +124,7 @@ const Articles = () => {
107124 { isLoading ? (
108125 < div > Loading...</ div >
109126 ) : (
110- < ArticleList articles = { data ?. articles ?? [ ] } />
127+ < ArticleList articles = { data ?. results ?? [ ] } />
111128 ) }
112129 </ div >
113130 </ div >
0 commit comments