Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/1443 자바스크립트를 타입스크립트로 마이그레이션한다 #1448

Closed
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
2510d61
Merge pull request #1278 from woowacourse/bug/1271-github-actions-bui…
solo5star May 10, 2023
a269e8a
Merge pull request #1241 from woowacourse/refactor/1239-popular-secti…
D0Dam May 15, 2023
be89039
Merge pull request #1290 from woowacourse/feature/1232-bebe-hoy
wonyongChoi05 May 15, 2023
905f1f1
Merge pull request #1291 from woowacourse/feature/1280-bebe-hoy
wonyongChoi05 May 17, 2023
7b61272
Merge pull request #1283 from woowacourse/refactor/1270-modify-header…
GC-Park May 18, 2023
a4c30fd
Merge pull request #1307 from woowacourse/feature/1280-pooh-salmon-ur…
BGuga May 23, 2023
3ea9dcc
Merge pull request #1318 from woowacourse/feature/1280-hongSile_amaranth
amaran-th May 24, 2023
c8afab8
Merge pull request #1306 from woowacourse/feature/1280-split-journey
splitCoding May 24, 2023
9435e8d
Merge branch 'develop' into feature/1309-hongsile-amaranth
hong-sile May 24, 2023
7f9063d
Merge pull request #1319 from woowacourse/feature/1309-hongsile-amaranth
hong-sile May 24, 2023
f1ce6cd
Merge pull request #1323 from woowacourse/refactor/1315-modify-roadmap
GC-Park May 26, 2023
dd30c20
Merge pull request #1299 from woowacourse/refactor/1269-responsive-st…
WaiNaat May 31, 2023
3cabdc9
Merge pull request #1301 from woowacourse/feature/1280-ocean-raon
e-astsea May 31, 2023
6a4b8c7
Merge pull request #1308 from woowacourse/refactor/1273-my-profile-la…
D0Dam Jun 5, 2023
6a66b80
refactor: assets 폴더의 js 파일 ts 파일로 마이그레이션
D0Dam Jun 14, 2023
ac19b6f
refactor: @shared 폴더의 js 파일 ts 파일로 마이그레이션
D0Dam Jun 14, 2023
a3db016
refactor: Button 폴더의 js 파일 ts 파일로 마이그레이션
D0Dam Jun 14, 2023
6f4bf4d
refactor: CancelIcon props interface 타입 정의
D0Dam Jun 16, 2023
3288b30
refactor: SnackBar props 타입 정의
D0Dam Jun 16, 2023
0895e41
refactor: PageButton props 타입 정의
D0Dam Jun 16, 2023
e5fc304
Merge branch 'develop' into feature/1333-break-points
solo5star Jun 16, 2023
0e3a2a7
refactor: Calendar 컴포넌트 ts 파일로 마이그레이션
D0Dam Jun 16, 2023
8e69732
refactor: `constants` 컨벤션에 맞게 SNAKE_CASE로 수정
solo5star Jun 16, 2023
46cd845
refactor: 기존 코드에 `MEDIA_QUERY` 및 `useScreenMediaQuery` 훅 적용
solo5star Jun 16, 2023
d8bc614
fix: 잘못된 media query 문 수정
solo5star Jun 16, 2023
4f84f83
refactor: 기존 코드에 `MEDIA_QUERY` 적용
solo5star Jun 16, 2023
8b8b3a1
refactor: ts로 마이그레이션
feb-dain Jul 5, 2023
8cb546a
refactor: Dropdown 컴포넌트 ts 파일로 마이그레이션
D0Dam Jul 7, 2023
49933fe
refactor: 필요없는 코드 제거
feb-dain Jul 10, 2023
7b16e72
Merge branch 'develop' into refactor/1366
feb-dain Jul 17, 2023
dd48899
refactor: Constant 파일 ts 파일로 변경
D0Dam Jul 17, 2023
19955db
refactor: App, index, GlobalStyles 파일 ts 파일로 변경
D0Dam Jul 17, 2023
87bc31a
Merge commit '6a4b8c7864c2eb39c5752c5c1a305e4a0e60e7ff' into refactor…
D0Dam Jul 17, 2023
d33862a
Merge branch 'main' into refactor/1344-js-ts-migration
D0Dam Jul 17, 2023
bfcd887
Merge pull request #1416 from woowacourse/refactor/1365-커스텀-예외-수정
This2sho Jul 17, 2023
ba9312b
refactor: prettierrc 설정
D0Dam Jul 17, 2023
e9f1111
Merge commit '1e4f126e636b0d829a79a75a921ee9edcfa04276' into refactor…
D0Dam Jul 17, 2023
a9123c2
refactor: js 파일 삭제
D0Dam Jul 17, 2023
66ae3ce
Merge pull request #1417 from woowacourse/refactor/1366
feb-dain Jul 17, 2023
7b58149
Merge pull request #1420 from woowacourse/refactor/1344-js-ts-migration
D0Dam Jul 17, 2023
9aa9a84
Merge branch 'feature/1371-create-article-main-page' of https://githu…
Creative-Lee Jul 19, 2023
c0adfdc
Merge branch 'feature/1368-article-register-page' of https://github.c…
Creative-Lee Jul 19, 2023
9311017
fix: api 명세와 맞지않았던 type 변경
Creative-Lee Jul 19, 2023
f3ea20a
Merge pull request #1432 from woowacourse/main
This2sho Jul 19, 2023
6545260
Merge branch 'develop' into refactor/#1429-article-front-merge-featur…
Creative-Lee Jul 20, 2023
eeeb299
Merge pull request #1434 from woowacourse/refactor/#1429-article-fron…
Creative-Lee Jul 20, 2023
22cdf89
feat: EssayAnswer 의 로직 예외 상황 커스텀
BGuga Jul 23, 2023
5e25314
feat: MemberGroup 의 로직 예외 상황 커스텀
BGuga Jul 23, 2023
4637296
test: 변경된 내용을 테스트 코드에 반영
BGuga Jul 23, 2023
50b97f8
Merge pull request #1442 from woowacourse/feat/1441-change-to-custom-…
BGuga Jul 23, 2023
ce0e891
chore: article 테이블 생성 sql 이름 변경
splitCoding Jul 24, 2023
be0c613
refactor: GithubLogin js → tsx로 마이그레이션
feb-dain Jul 24, 2023
6108397
refactor: Modal js → tsx로 마이그레이션
feb-dain Jul 24, 2023
9b24f8b
refactor: Modal style js → ts로 마이그레이션
feb-dain Jul 24, 2023
27bdbcd
refactor: Introduction 폴더 ts로 마이그레이션
D0Dam Jul 24, 2023
5794f59
Merge pull request #1444 from woowacourse/feature/article-sql-rename
splitCoding Jul 24, 2023
f15fae5
Merge branch 'develop' into refactor/1445-introduction-folder-ts-migr…
D0Dam Jul 24, 2023
ee9194f
Merge pull request #1446 from woowacourse/refactor/1445-introduction-…
D0Dam Jul 24, 2023
1a345b8
refactor: NavBar js → ts/tsx로 변경
feb-dain Jul 24, 2023
a77dd1f
Merge branch 'develop' into refactor/1443
feb-dain Jul 24, 2023
f65f006
Merge pull request #1447 from woowacourse/refactor/1443
feb-dain Jul 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public enum BadRequestCode {
SCRAP_NOT_EXIST(3008, "스크랩이 존재하지 않습니다."),
SCRAP_NOT_VALID_USER(3009, "본인의 스크랩만 추가할 수 있습니다."),
NOT_EXISTS_MEMBER_TAG(3010, "멤버 태그가 존재하지 않습니다."),
CANT_FIND_GROUP_TYPE(3011, "해당 그룹의 타입을 결정할 수 없습니다."),

INVALID_LIKE_REQUEST_EXCEPTION(5001, "스터디로그를 좋아요 할 수 없습니다."),
INVALID_UNLIKE_REQUEST_EXCEPTION(5002, "스터디로그를 좋아요 취소 할 수 없습니다."),
Expand All @@ -65,6 +66,10 @@ public enum BadRequestCode {
CURRICULUM_NOT_FOUND_EXCEPTION(8010, "해당하는 커리큘럼을 찾을 수 없습니다"),
CURRICULUM_INVALID_EXCEPTION(8011, "커리큘럼이 유효하지 않습니다."),

ESSAY_ANSWER_NOT_FOUND_EXCEPTION(8012, "해당 답변을 찾을 수 없습니다."),
NOT_EMPTY_ESSAY_ANSWER_EXCEPTION(8013, "답변은 공백일 수 없습니다."),
ESSAY_ANSWER_NOT_VALID_USER(8014, "본인이 작성한 답변만 수정할 수 있습니다."),

FILE_NAME_EMPTY_EXCEPTION(9001, "파일 이름이 존재하지 않습니다."),
UNSUPPORTED_FILE_EXTENSION_EXCEPTION(9002, "지원하지 않는 파일 확장자입니다."),
FILE_UPLOAD_FAIL_EXCEPTION(9003, "파일 업로드에 실패했습니다."),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package wooteco.prolog.member.domain;

import static wooteco.prolog.common.exception.BadRequestCode.CANT_FIND_GROUP_TYPE;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import wooteco.prolog.common.exception.BadRequestCode;
import wooteco.prolog.common.exception.BadRequestException;

@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand All @@ -31,13 +35,13 @@ public MemberGroup(Long id, String name, String description) {
this.description = description;
}

public MemberGroupType getGroupType() {
public MemberGroupType groupType() {
for (MemberGroupType groupType : MemberGroupType.values()) {
if (groupType.isContainedBy(this.name)) {
return groupType;
}
}
throw new IllegalArgumentException("그룹이 포함되는 타입이 없습니다. id=" + this.id);
throw new BadRequestException(CANT_FIND_GROUP_TYPE);
}

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package wooteco.prolog.roadmap.application;

import static wooteco.prolog.common.exception.BadRequestCode.ESSAY_ANSWER_NOT_FOUND_EXCEPTION;
import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_QUIZ_NOT_FOUND_EXCEPTION;

import org.hibernate.Hibernate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import wooteco.prolog.common.exception.BadRequestException;
import wooteco.prolog.member.application.MemberService;
import wooteco.prolog.member.domain.Member;
import wooteco.prolog.roadmap.application.dto.EssayAnswerRequest;
Expand Down Expand Up @@ -36,7 +40,7 @@ public EssayAnswerService(EssayAnswerRepository essayAnswerRepository,
public Long createEssayAnswer(EssayAnswerRequest essayAnswerRequest, Long memberId) {
Long quizId = essayAnswerRequest.getQuizId();
Quiz quiz = quizRepository.findById(quizId)
.orElseThrow(() -> new IllegalArgumentException("퀴즈가 존재하지 않습니다. quizId=" + quizId));
.orElseThrow(() -> new BadRequestException(ROADMAP_QUIZ_NOT_FOUND_EXCEPTION));

Member member = memberService.findById(memberId);
EssayAnswer essayAnswer = new EssayAnswer(quiz, essayAnswerRequest.getAnswer(), member);
Expand All @@ -56,16 +60,15 @@ public void updateEssayAnswer(Long answerId, EssayAnswerUpdateRequest request, L

@Transactional
public void deleteEssayAnswer(Long answerId, Long memberId) {
if (!essayAnswerRepository.findByIdAndMemberId(answerId, memberId).isPresent()) {
throw new IllegalArgumentException("답변이 존재하지 않습니다. answerId=" + answerId);
}
essayAnswerRepository.deleteById(answerId);
EssayAnswer essayAnswer = essayAnswerRepository.findByIdAndMemberId(answerId, memberId)
.orElseThrow(() -> new BadRequestException(ESSAY_ANSWER_NOT_FOUND_EXCEPTION));
essayAnswerRepository.deleteById(essayAnswer.getId());
}

@Transactional(readOnly = true)
public EssayAnswer getById(Long answerId) {
EssayAnswer essayAnswer = essayAnswerRepository.findById(answerId)
.orElseThrow(() -> new IllegalArgumentException("답변이 존재하지 않습니다. answerId=" + answerId));
.orElseThrow(() -> new BadRequestException(ESSAY_ANSWER_NOT_FOUND_EXCEPTION));
Hibernate.initialize(essayAnswer.getQuiz());
Hibernate.initialize(essayAnswer.getMember());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package wooteco.prolog.roadmap.domain;

import static wooteco.prolog.common.exception.BadRequestCode.ESSAY_ANSWER_NOT_VALID_USER;
import static wooteco.prolog.common.exception.BadRequestCode.NOT_EMPTY_ESSAY_ANSWER_EXCEPTION;

import javax.persistence.Column;
import javax.persistence.ConstraintMode;
import javax.persistence.Entity;
Expand All @@ -16,6 +19,7 @@
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import wooteco.prolog.common.AuditingEntity;
import wooteco.prolog.common.exception.BadRequestException;
import wooteco.prolog.member.domain.Member;

@Table(name = "essay_answer")
Expand Down Expand Up @@ -52,10 +56,10 @@ public EssayAnswer(final Quiz quiz, final String answer, Member member) {

public void update(String answer, Member member) {
if (StringUtils.isBlank(answer)) {
throw new IllegalArgumentException("답변 내용은 공백일 수 없습니다.");
throw new BadRequestException(NOT_EMPTY_ESSAY_ANSWER_EXCEPTION);
}
if (!this.member.equals(member)) {
throw new IllegalArgumentException("본인이 작성한 답변만 수정할 수 있습니다.");
throw new BadRequestException(ESSAY_ANSWER_NOT_VALID_USER);
}

this.answer = answer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package wooteco.prolog.roadmap.domain;


import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_KEYWORD_AND_KEYWORD_PARENT_SAME_EXCEPTION;
import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_KEYWORD_SEQUENCE_EXCEPTION;

Expand Down Expand Up @@ -35,6 +36,12 @@
import java.util.Objects;
import java.util.Set;

import javax.persistence.*;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void updatePopularStudylogs(Pageable pageable) {
List<GroupMember> groupMembers = groupMemberRepository.findAll();
Map<MemberGroupType, List<MemberGroup>> memberGroupsBygroupType = memberGroupRepository.findAll()
.stream()
.collect(Collectors.groupingBy(MemberGroup::getGroupType));
.collect(Collectors.groupingBy(MemberGroup::groupType));

final List<Studylog> recentStudylogs = findRecentStudylogs(LocalDateTime.now(),
pageable.getPageSize());
Expand Down Expand Up @@ -92,6 +92,7 @@ private List<Studylog> findRecentStudylogs(final LocalDateTime dateTime,
private List<Studylog> filterStudylogsByMemberGroups(final List<Studylog> studylogs,
final MemberGroups memberGroups,
final List<GroupMember> groupMembers) {

return studylogs.stream()
.filter(
studylog -> checkMemberAssignedInMemberGroups(memberGroups, studylog.getMember(),
Expand All @@ -111,7 +112,7 @@ public PopularStudylogsResponse findPopularStudylogs(Pageable pageable, Long mem
List<Studylog> allPopularStudylogs = getSortedPopularStudyLogs(pageable);
List<GroupMember> groupedMembers = groupMemberRepository.findAll();
Map<MemberGroupType, List<MemberGroup>> memberGroupsBygroupType = memberGroupRepository.findAll()
.stream().collect(Collectors.groupingBy(MemberGroup::getGroupType));
.stream().collect(Collectors.groupingBy(MemberGroup::groupType));

return PopularStudylogsResponse.of(
studylogsResponse(allPopularStudylogs, pageable, memberId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;

import org.junit.jupiter.api.Test;
import wooteco.prolog.common.exception.BadRequestCode;
import wooteco.prolog.common.exception.BadRequestException;

class MemberGroupTest {

Expand All @@ -13,18 +15,18 @@ class MemberGroupTest {

@Test
void getGroupType_이름이_그룹명을_포함하면_그룹을_반환한다() {
assertThat(ANDROID_GROUP.getGroupType()).isEqualTo(MemberGroupType.ANDROID);
assertThat(BACKEND_GROUP.getGroupType()).isEqualTo(MemberGroupType.BACKEND);
assertThat(FRONTEND_GROUP.getGroupType()).isEqualTo(MemberGroupType.FRONTEND);
assertThat(ANDROID_GROUP.groupType()).isEqualTo(MemberGroupType.ANDROID);
assertThat(BACKEND_GROUP.groupType()).isEqualTo(MemberGroupType.BACKEND);
assertThat(FRONTEND_GROUP.groupType()).isEqualTo(MemberGroupType.FRONTEND);
}

@Test
void getGroupType_이름이_포함하는_그룹명이_없으면_예외가_발생한다() {
MemberGroup memberGroup = new MemberGroup(null, "테스트", "test");

assertThatThrownBy(memberGroup::getGroupType)
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("그룹이 포함되는 타입이 없습니다. id=null");
assertThatThrownBy(memberGroup::groupType)
.isInstanceOf(BadRequestException.class)
.hasMessage("해당 그룹의 타입을 결정할 수 없습니다.");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import wooteco.prolog.common.exception.BadRequestCode;
import wooteco.prolog.common.exception.BadRequestException;
import wooteco.prolog.member.application.MemberService;
import wooteco.prolog.member.domain.Member;
Expand Down Expand Up @@ -109,7 +110,7 @@ void deleteEssayAnswer_fail() {

//when,then
assertThatThrownBy(() -> essayAnswerService.deleteEssayAnswer(1L, 1L))
.isInstanceOf(IllegalArgumentException.class);
.isInstanceOf(BadRequestException.class);
}

@DisplayName("deleteEssayAnswer 에서 answerId memberId 에 매핑되는 EssayAnswer 가 있다면 삭제한다")
Expand All @@ -135,7 +136,7 @@ void getById_fail() {

//when,then
assertThatThrownBy(() -> essayAnswerService.getById(1L))
.isInstanceOf(IllegalArgumentException.class);
.isInstanceOf(BadRequestException.class);
}

@DisplayName("getById 에서 answerId 에 해당하는 EssayAnswer 가있다면 반환해준다")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import wooteco.prolog.common.exception.BadRequestCode;
import wooteco.prolog.common.exception.BadRequestException;
import wooteco.prolog.member.domain.Member;

public class EssayAnswerTest {
class EssayAnswerTest {

@ValueSource(strings = {"", " "})
@ParameterizedTest
Expand All @@ -19,8 +21,8 @@ public class EssayAnswerTest {

//expect
assertThatThrownBy(() -> essayAnswer.update(answer, member))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("답변 내용은 공백일 수 없습니다.");
.isInstanceOf(BadRequestException.class)
.hasMessage("답변은 공백일 수 없습니다.");
}

@Test
Expand All @@ -32,7 +34,7 @@ public class EssayAnswerTest {

//expect
assertThatThrownBy(() -> essayAnswer.update("answer", another))
.isInstanceOf(IllegalArgumentException.class)
.isInstanceOf(BadRequestException.class)
.hasMessage("본인이 작성한 답변만 수정할 수 있습니다.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
@ExtendWith(MockitoExtension.class)
class StudylogSessionServiceTest {


@Mock
private StudylogRepository studylogRepository;
@InjectMocks
Expand Down
8 changes: 5 additions & 3 deletions frontend/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"printWidth": 100,
"singleQuote": true,
"endOfLine": "auto"
"printWidth": 100,
"singleQuote": true,
"endOfLine": "auto",
"tabWidth": 2,
"useTabs": false
}
File renamed without changes.
Loading
Loading