Skip to content

Commit

Permalink
[Release] 리뷰미 v2.0.3 배포
Browse files Browse the repository at this point in the history
[Release] 리뷰미 v2.0.3 배포
  • Loading branch information
donghoony authored Oct 25, 2024
2 parents 726955d + 64359f5 commit 4960ca0
Show file tree
Hide file tree
Showing 10 changed files with 269 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import reviewme.review.service.dto.request.ReviewAnswerRequest;
import reviewme.review.service.dto.request.ReviewRegisterRequest;
import reviewme.review.service.exception.ReviewGroupNotFoundByReviewRequestCodeException;
import reviewme.review.service.exception.SubmittedQuestionNotFoundException;
import reviewme.reviewgroup.domain.ReviewGroup;
import reviewme.reviewgroup.repository.ReviewGroupRepository;
import reviewme.template.domain.Template;
Expand Down Expand Up @@ -62,6 +63,10 @@ private List<Answer> getAnswersByQuestionType(ReviewRegisterRequest request) {
private Answer mapRequestToAnswer(Map<Long, Question> questions, ReviewAnswerRequest answerRequest) {
Question question = questions.get(answerRequest.questionId());

if (question == null) {
throw new SubmittedQuestionNotFoundException(answerRequest.questionId());
}

// TODO: 아래 코드를 삭제해야 한다
if (question.isSelectable() && answerRequest.selectedOptionIds() != null && answerRequest.selectedOptionIds().isEmpty()) {
return null;
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/apis/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,17 @@ export const REVIEW_GROUP_DATA_API_PARAMS = {
},
};

export const REVIEW_GROUP_API_PARAMS = {
queryString: {
sectionId: 'sectionId',
},
};

export const REVIEW_WRITING_API_URL = `${serverUrl}/${VERSION2}/${REVIEW_WRITING_API_PARAMS.resource}`;
export const REVIEW_LIST_API_URL = `${serverUrl}/${VERSION2}/${REVIEW_LIST_API_PARAMS.resource}`;
export const DETAILED_REVIEW_API_URL = `${serverUrl}/${VERSION2}/${DETAILED_REVIEW_API_PARAMS.resource}`;
export const REVIEW_GROUP_DATA_API_URL = `${serverUrl}/${VERSION2}/${REVIEW_GROUP_DATA_API_PARAMS.resource}`;
export const REVIEW_GROUP_API_URL = `${serverUrl}/${VERSION2}/reviews/gather`;

const endPoint = {
postingReview: `${serverUrl}/${VERSION2}/reviews`,
Expand All @@ -70,7 +77,8 @@ const endPoint = {
gettingReviewGroupData: (reviewRequestCode: string) =>
`${REVIEW_GROUP_DATA_API_URL}?${REVIEW_GROUP_DATA_API_PARAMS.queryString.reviewRequestCode}=${reviewRequestCode}`,
gettingSectionList: `${serverUrl}/${VERSION2}/sections`,
gettingGroupedReviews: (sectionId: number) => `${serverUrl}/${VERSION2}/reviews/gather?sectionId=${sectionId}`,
gettingGroupedReviews: (sectionId: number) =>
`${REVIEW_GROUP_API_URL}?${REVIEW_GROUP_API_PARAMS.queryString.sectionId}=${sectionId}`,
postingHighlight: `${serverUrl}/${VERSION2}/highlight`,
};

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/common/Accordion/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const AccordionContainer = styled.div<AccordionStyleProps>`

export const AccordionHeader = styled.div<AccordionStyleProps>`
display: flex;
padding: 1rem;
border-bottom: ${({ $isOpened, theme }) => $isOpened && `0.1rem solid ${theme.colors.placeholder}`};
`;

Expand All @@ -36,7 +35,8 @@ export const AccordionButton = styled.button`
width: 100%;
height: fit-content;
min-height: 3rem;
min-height: 5rem;
padding: 1rem;
`;

export const AccordionTitle = styled.p`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { useState } from 'react';
import { useEffect, useState } from 'react';

import { EDITOR_ANSWER_CLASS_NAME, HIGHLIGHT_EVENT_NAME, HIGHLIGHT_SPAN_CLASS_NAME } from '@/constants';
import {
EDITOR_ANSWER_CLASS_NAME,
HIGHLIGHT_EVENT_NAME,
HIGHLIGHT_SPAN_CLASS_NAME,
SESSION_STORAGE_KEY,
} from '@/constants';
import { EditorAnswerMap, EditorLine, HighlightResponseData, ReviewAnswerResponseData } from '@/types';
import {
getEndLineOffset,
Expand Down Expand Up @@ -71,13 +76,25 @@ const useHighlight = ({
handleModalMessage,
}: UseHighlightProps) => {
const [editorAnswerMap, setEditorAnswerMap] = useState<EditorAnswerMap>(makeInitialEditorAnswerMap(answerList));
const storageKey = `${SESSION_STORAGE_KEY.editorAnswerMap}-${questionId}`;

useEffect(() => {
const item = localStorage.getItem(storageKey);
if (item) {
setEditorAnswerMap(new Map(JSON.parse(item)) as EditorAnswerMap);
}
}, []);

// span 클릭 시, 제공되는 형광펜 삭제 기능 타겟
const [longPressRemovalTarget, setLongPressRemovalTarget] = useState<RemovalTarget | null>(null);

const resetLongPressRemovalTarget = () => setLongPressRemovalTarget(null);

const updateEditorAnswerMap = (newEditorAnswerMap: EditorAnswerMap) => setEditorAnswerMap(newEditorAnswerMap);
const updateEditorAnswerMap = (newEditorAnswerMap: EditorAnswerMap) => {
setEditorAnswerMap(newEditorAnswerMap);
// editorAnswerMap이 변경될 때 새로운 값을 로컬 스토리지에 저장
localStorage.setItem(storageKey, JSON.stringify(Array.from(newEditorAnswerMap)));
};

const resetHighlightMenu = () => {
removeSelection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { ErrorBoundary } from '../../../error';
import ErrorFallback from '../../../error/ErrorFallback';
import HighlightEditor, { HighlightEditorProps } from '../HighlightEditor';

const HighlightEditorContainer = (props: Omit<HighlightEditorProps, 'handleErrorModal'>) => {
interface HighlightEditorContainerProps extends Omit<HighlightEditorProps, 'handleErrorModal' | 'handleModalMessage'> {}

const HighlightEditorContainer = (props: HighlightEditorContainerProps) => {
const [isOpenErrorModal, setIsOpenErrorModal] = useState(false);
const [modalMessage, setModalMessage] = useState('');

Expand Down
4 changes: 4 additions & 0 deletions frontend/src/constants/storageKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ export const LOCAL_STORAGE_KEY = {
isHighlightEditable: 'isHighlightEditable',
isHighlightError: 'isHighlightError',
};

export const SESSION_STORAGE_KEY = {
editorAnswerMap: 'editorAnswerMap-question',
};
16 changes: 12 additions & 4 deletions frontend/src/mocks/handlers/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { http, HttpResponse } from 'msw';
import endPoint, {
DETAILED_REVIEW_API_PARAMS,
DETAILED_REVIEW_API_URL,
REVIEW_GROUP_API_PARAMS,
REVIEW_GROUP_API_URL,
REVIEW_WRITING_API_PARAMS,
REVIEW_WRITING_API_URL,
VERSION2,
Expand Down Expand Up @@ -104,17 +106,23 @@ const getSectionList = () =>
return authorizeWithCookie(cookies, () => HttpResponse.json(GROUPED_SECTION_MOCK_DATA));
});

const getGroupedReviews = (sectionId: number) =>
http.get(endPoint.gettingGroupedReviews(sectionId), ({ cookies }) => {
return authorizeWithCookie(cookies, () => HttpResponse.json(GROUPED_REVIEWS_MOCK_DATA));
const getGroupedReviews = () => {
return http.get(new RegExp(`^${REVIEW_GROUP_API_URL}`), ({ request, cookies }) => {
const url = new URL(request.url);
const sectionId = url.searchParams.get(REVIEW_GROUP_API_PARAMS.queryString.sectionId);
const { length } = GROUPED_REVIEWS_MOCK_DATA;
const index = (Number(sectionId) + length) % length;

return authorizeWithCookie(cookies, () => HttpResponse.json(GROUPED_REVIEWS_MOCK_DATA[index]));
});
};

const reviewHandler = [
getDetailedReview(),
getReviewList(null, 10),
getDataToWriteReview(),
getSectionList(),
getGroupedReviews(1),
getGroupedReviews(),
getReviewInfoData(),
postReview(),
];
Expand Down
Loading

0 comments on commit 4960ca0

Please sign in to comment.