Skip to content

Commit 2ddcb88

Browse files
committed
fix(article): change sort criteria to take into account publishedAt
1 parent f1f9d86 commit 2ddcb88

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

backend/src/main/java/wooteco/prolog/article/application/dto/ArticleResponse.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ public class ArticleResponse {
1919
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
2020
private final LocalDateTime createdAt;
2121

22+
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
23+
private final LocalDateTime publishedAt;
24+
2225
private ArticleResponse() {
23-
this(null, null, null, null, null, false, false, null);
26+
this(null, null, null, null, null, false, false, null, null);
2427
}
2528

2629
public static ArticleResponse of(final Article article, final Long memberId) {
@@ -32,8 +35,9 @@ public static ArticleResponse of(final Article article, final Long memberId) {
3235
final boolean isBookmarked = article.getArticleBookmarks().containBookmark(memberId);
3336
final boolean isLiked = article.getArticleLikes().isAlreadyLike(memberId);
3437
final LocalDateTime createdAt = article.getCreatedAt();
38+
final LocalDateTime publishedAt = article.getPublishedAt();
3539
return new ArticleResponse(id, nickName, title, url, imageUrl, isBookmarked, isLiked,
36-
createdAt);
40+
createdAt, publishedAt);
3741
}
3842

3943
public Long getId() {
@@ -67,4 +71,8 @@ public boolean getIsLiked() {
6771
public LocalDateTime getCreatedAt() {
6872
return createdAt;
6973
}
74+
75+
public LocalDateTime getPublishedAt() {
76+
return publishedAt;
77+
}
7078
}

frontend/src/components/Article/Article.style.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const ArticleBookmarkButtonStyle = css`
9090
}
9191
`;
9292

93-
export const CreatedAt = styled.span`
93+
export const PublishedAt = styled.span`
9494
width: 100%;
9595
color: ${COLOR.DARK_GRAY_400};
9696
text-align: right;

frontend/src/components/Article/Article.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const Article = ({
1717
userName,
1818
url,
1919
createdAt,
20+
publishedAt,
2021
imageUrl,
2122
isBookmarked,
2223
isLiked,
@@ -75,7 +76,7 @@ const Article = ({
7576
<Styled.ArticleInfoContainer>
7677
<Styled.ArticleInfoWrapper>
7778
<Styled.UserName>{userName}</Styled.UserName>
78-
<Styled.CreatedAt>{createdAt.split(' ')[0]}</Styled.CreatedAt>
79+
<Styled.PublishedAt>{(publishedAt ? publishedAt : createdAt).split(' ')[0]}</Styled.PublishedAt>
7980
</Styled.ArticleInfoWrapper>
8081
<Styled.Title>{title}</Styled.Title>
8182
<Styled.ButtonContainer>

frontend/src/mocks/handlers/articles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const articlesHandler = [
2323
title: '직렬화, 역직렬화는 무엇일까?',
2424
url: 'https://think0wise.tistory.com/107',
2525
createdAt: '2023-07-08 16:48',
26+
publishedAt: '2023-07-08 16:48',
2627
isBookmarked: false,
2728
isLiked: false,
2829
imageUrl:

frontend/src/models/Article.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface ArticleType {
1313
isLiked: boolean;
1414
url: string;
1515
createdAt: string;
16+
publishedAt: string;
1617
imageUrl: string;
1718
}
1819

0 commit comments

Comments
 (0)