Commit fccb3a3d authored by Ken's avatar Ken

sorted news by date

parent 82cb0104
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
&-content { &-content {
padding: 20px; padding: 20px;
min-height: 160px; min-height: 180px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-between; justify-content: space-between;
......
...@@ -36,7 +36,9 @@ const NewsDetail = () => { ...@@ -36,7 +36,9 @@ const NewsDetail = () => {
<> <>
{newsDetail ? ( {newsDetail ? (
<div <div
dangerouslySetInnerHTML={{ __html: purifyHTML(newsDetail?.content) }} dangerouslySetInnerHTML={{
__html: purifyHTML(newsDetail.newspaperContent.content),
}}
></div> ></div>
) : ( ) : (
<div></div> <div></div>
......
...@@ -35,4 +35,10 @@ ...@@ -35,4 +35,10 @@
&-list { &-list {
margin-top: 40px; margin-top: 40px;
} }
&-load {
button {
width: 32%;
}
}
} }
...@@ -17,7 +17,13 @@ const home = createSlice({ ...@@ -17,7 +17,13 @@ const home = createSlice({
reducers: {}, reducers: {},
extraReducers: (builder) => { extraReducers: (builder) => {
builder.addCase(getNews.fulfilled, (state, action: PayloadAction<any>) => { builder.addCase(getNews.fulfilled, (state, action: PayloadAction<any>) => {
state.newsData = action.payload.data; const { data } = action.payload;
const sortedDataByDate = data.sort((a: INewspaper, b: INewspaper) => {
return (
new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
);
});
state.newsData = sortedDataByDate;
}); });
}, },
}); });
......
...@@ -5,6 +5,7 @@ import WrapperContainer from "components/WrapperContainer"; ...@@ -5,6 +5,7 @@ import WrapperContainer from "components/WrapperContainer";
import React, { useEffect } from "react"; import React, { useEffect } from "react";
import Newspaper from "../../components/Newspaper"; import Newspaper from "../../components/Newspaper";
import { getNews } from "./homePageSlice"; import { getNews } from "./homePageSlice";
import { Button } from "@mui/material";
const HomePage = () => { const HomePage = () => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
...@@ -39,6 +40,12 @@ const HomePage = () => { ...@@ -39,6 +40,12 @@ const HomePage = () => {
</div> </div>
))} ))}
</div> </div>
<div className="homePage-load d-flex justify-content-center">
<Button variant="outlined" color="primary">
Xem Thêm
</Button>
</div>
</WrapperContainer> </WrapperContainer>
</main> </main>
); );
......
...@@ -7,7 +7,12 @@ export interface INewspaper { ...@@ -7,7 +7,12 @@ export interface INewspaper {
description: string; description: string;
image: string; image: string;
createdAt: string; createdAt: string;
content: string;
categorylink: string; categorylink: string;
categorylinkNavigation: ICategory; categorylinkNavigation: ICategory;
newspaperContent: INewspaperContent;
}
export interface INewspaperContent {
id: string;
content: string;
} }
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