Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
Newspaper Frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lap nguyen
Newspaper Frontend
Commits
fccb3a3d
Commit
fccb3a3d
authored
Dec 09, 2022
by
Ken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sorted news by date
parent
82cb0104
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
4 deletions
+30
-4
Newspaper.scss
src/components/Newspaper/Newspaper.scss
+1
-1
index.tsx
src/pages/NewsDetail/index.tsx
+3
-1
HomePage.scss
src/pages/home/HomePage.scss
+6
-0
homePageSlice.ts
src/pages/home/homePageSlice.ts
+7
-1
index.tsx
src/pages/home/index.tsx
+7
-0
interface.ts
src/pages/interface.ts
+6
-1
No files found.
src/components/Newspaper/Newspaper.scss
View file @
fccb3a3d
...
@@ -56,7 +56,7 @@
...
@@ -56,7 +56,7 @@
&
-content
{
&
-content
{
padding
:
20px
;
padding
:
20px
;
min-height
:
1
6
0px
;
min-height
:
1
8
0px
;
display
:
flex
;
display
:
flex
;
flex-direction
:
column
;
flex-direction
:
column
;
justify-content
:
space-between
;
justify-content
:
space-between
;
...
...
src/pages/NewsDetail/index.tsx
View file @
fccb3a3d
...
@@ -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
>
...
...
src/pages/home/HomePage.scss
View file @
fccb3a3d
...
@@ -35,4 +35,10 @@
...
@@ -35,4 +35,10 @@
&
-list
{
&
-list
{
margin-top
:
40px
;
margin-top
:
40px
;
}
}
&
-load
{
button
{
width
:
32%
;
}
}
}
}
src/pages/home/homePageSlice.ts
View file @
fccb3a3d
...
@@ -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
;
});
});
},
},
});
});
...
...
src/pages/home/index.tsx
View file @
fccb3a3d
...
@@ -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
>
);
);
...
...
src/pages/interface.ts
View file @
fccb3a3d
...
@@ -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
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment