Skip to content

Commit

Permalink
feat: 로드맵 답변 전체 글 보기 필터 구현
Browse files Browse the repository at this point in the history
Co-authored-by: WaiNaat <[email protected]>
Co-authored-by: gc-park <[email protected]>
  • Loading branch information
3 people committed Nov 17, 2023
1 parent 07f89b5 commit ca72aff
Show file tree
Hide file tree
Showing 32 changed files with 500 additions and 458 deletions.
7 changes: 7 additions & 0 deletions frontend/src/apis/essayanswers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,10 @@ export const requestGetQuizAsync = async (quizId: number) => {

export const requestGetQuiz = (quizId: Number): AxiosPromise<AxiosResponse<Quiz>> =>
client.get<AxiosResponse<Quiz>>(`/quizzes/${quizId}`);

export const requestGetQuizzes = async (curriculumId: number) => {
const { data } = await client.get<{ id: number; question: string }[]>(
`/curriculums/${curriculumId}/quizzes`
);
return data;
};
11 changes: 11 additions & 0 deletions frontend/src/apis/filter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { client } from '.';
import { FilterResponse } from '../models/filter';
import { Author } from '../models/Studylogs';

export const getMembersForFilter = async (): Promise<Author[]> => {
const {
data: { members },
} = await client.get<FilterResponse>(`/filters`);

return members;
};
11 changes: 7 additions & 4 deletions frontend/src/components/DropdownMenu/DropdownMenu.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import DropdownMenu from './DropdownMenu';
/** @jsxImportSource @emotion/react */

import DropdownMenu, { DropdownMenuProps } from './DropdownMenu';
import { Story, Meta } from '@storybook/react';
import { css } from '@emotion/react';

export default {
title: 'Component/DropdownMenu',
component: DropdownMenu,
argTypes: { children: { control: 'text' } },
} as Meta;
} as Meta<typeof DropdownMenu>;

const Template: Story<typeof DropdownMenu> = (args) => <DropdownMenu {...args} />;
const Template: Story<React.PropsWithChildren<DropdownMenuProps>> = (args) => <DropdownMenu {...args} />;

export const Basic = Template.bind({});

Expand All @@ -25,5 +28,5 @@ Basic.args = {
</li>
</ul>
),
onLogoClick: () => {},
css: css``,
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { InterpolationWithTheme } from '@emotion/core';
import { Theme } from '@emotion/react';
import styled from '@emotion/styled';
import COLOR from '../../constants/color';
import { css } from '@emotion/react';

const Container = styled.div<{ css?: InterpolationWithTheme<Theme> }>`
height: fit-content;
Expand Down
42 changes: 0 additions & 42 deletions frontend/src/components/DropdownMenu/DropdownMenu.styles.tsx

This file was deleted.

15 changes: 9 additions & 6 deletions frontend/src/components/DropdownMenu/DropdownMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import PropTypes from 'prop-types';
/** @jsxImportSource @emotion/react */

// import PropTypes from 'prop-types';
import { Container } from './DropdownMenu.styles';
import { css } from '@emotion/react';

const DropdownMenu = ({ children, css }) => {
return <Container css={css}>{children}</Container>;
};
export interface DropdownMenuProps {
css: ReturnType<typeof css>;
}

DropdownMenu.propTypes = {
children: PropTypes.node,
const DropdownMenu = ({ children, css }: React.PropsWithChildren<DropdownMenuProps>) => {
return <Container css={css}>{children}</Container>;
};

export default DropdownMenu;
4 changes: 2 additions & 2 deletions frontend/src/components/Items/EssayAnswerItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {
import { AlignItemsEndStyle, FlexColumnStyle, FlexStyle } from '../../styles/flex.styles';
import Card from '../Card/Card';
import ProfileChip from '../ProfileChip/ProfileChip';
import { EssayAnswerResponse } from '../../models/EssayAnswers';
import { EssayAnswer } from '../../models/EssayAnswers';

type EssayAnswerItemProps = (
Pick<EssayAnswerResponse, "author" | "answer">
Pick<EssayAnswer, "author" | "answer">
& { title?: string; showTitle?: boolean }
);

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Lists/QuizAnswerList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import {css} from '@emotion/react';
import EssayAnswerItem from "../Items/EssayAnswerItem";
import { NoDefaultHoverLink } from '../Items/EssayAnswerItem.styles';
import { EssayAnswerResponse } from '../../models/EssayAnswers';
import { EssayAnswer } from '../../models/EssayAnswers';

interface QuizAnswerListProps {
essayAnswers: EssayAnswerResponse[];
essayAnswers: EssayAnswer[];
showQuizTitle?: boolean;
}

Expand Down
121 changes: 0 additions & 121 deletions frontend/src/components/RoadmapFilter/RoadmapFilter.tsx

This file was deleted.

18 changes: 0 additions & 18 deletions frontend/src/components/RoadmapFilter/RoadmapSelectedFilter.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion frontend/src/components/SearchBar/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ChangeEventHandler, FormEventHandler } from 'react';
interface SearchBarProps {
onSubmit?: FormEventHandler;
onChange: ChangeEventHandler<HTMLInputElement>;
css: ReturnType<typeof css>;
css?: ReturnType<typeof css>;
value: string;
}

Expand Down
2 changes: 2 additions & 0 deletions frontend/src/constants/reactQueryKey.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const REACT_QUERY_KEY = {
STUDYLOG: 'STUDYLOG',
QUIZ: 'QUIZ',
QUIZZES: 'QUIZZES',
ESSAY_ANSWER: 'ESSAY_ANSWER',
QUIZ_ANSWERS: 'QUIZ_ANSWERS',
ESSAY_ANSWER_FILTER_LIST: 'ESSAY_ANSWER_FILTER_LIST',
};

export default REACT_QUERY_KEY;
11 changes: 0 additions & 11 deletions frontend/src/hooks/EssayAnswer/useEssayAnswerList.ts

This file was deleted.

22 changes: 15 additions & 7 deletions frontend/src/hooks/queries/essayanswer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import {
requestGetEssayAnswers,
requestGetQuizAnswers,
requestGetQuizAsync,
requestGetQuizzes,
} from '../../apis/essayanswers';
import { ResponseError } from '../../apis/studylogs';
import { ALERT_MESSAGE, PATH } from '../../constants';
import ERROR_CODE from '../../constants/errorCode';
import { ERROR_MESSAGE, SUCCESS_MESSAGE } from '../../constants/message';
import REACT_QUERY_KEY from '../../constants/reactQueryKey';
import {
EssayAnswer,
EssayAnswerFilterRequest,
EssayAnswerRequest,
EssayAnswerResponse,
Expand Down Expand Up @@ -53,15 +55,15 @@ export const useEditEssayAnswer = ({ essayAnswerId }: { essayAnswerId: number })

export const useGetEssayAnswer = (
{ essayAnswerId },
{ onSuccess = (essayAnswer: EssayAnswerResponse) => {}, onError = () => {} } = {}
{ onSuccess = (essayAnswer: EssayAnswer) => {}, onError = () => {} } = {}
) => {
const history = useHistory();
const { openSnackBar } = useSnackBar();
return useQuery<EssayAnswerResponse>(
return useQuery<EssayAnswer>(
[REACT_QUERY_KEY.ESSAY_ANSWER, essayAnswerId],
() => requestGetEssayAnswer(essayAnswerId),
{
onSuccess: (essayAnswer: EssayAnswerResponse) => {
onSuccess: (essayAnswer: EssayAnswer) => {
onSuccess?.(essayAnswer);
},
onError: (error) => {
Expand Down Expand Up @@ -93,13 +95,13 @@ export const useDeleteEssayAnswerMutation = ({

export const useGetQuizAnswerList = (
{ quizId },
{ onSuccess = (essayAnswer: EssayAnswerResponse[]) => {}, onError = () => {} } = {}
{ onSuccess = (essayAnswer: EssayAnswer[]) => {}, onError = () => {} } = {}
) => {
return useQuery<EssayAnswerResponse[]>(
return useQuery<EssayAnswer[]>(
[REACT_QUERY_KEY.QUIZ_ANSWERS, quizId],
() => requestGetQuizAnswers(quizId),
{
onSuccess: (essayAnswer: EssayAnswerResponse[]) => {
onSuccess: (essayAnswer: EssayAnswer[]) => {
onSuccess?.(essayAnswer);
},
onError: (error) => {},
Expand All @@ -110,7 +112,7 @@ export const useGetQuizAnswerList = (
};

export const useGetEssayAnswers = (filter: EssayAnswerFilterRequest) => {
return useQuery<EssayAnswerResponse[]>([REACT_QUERY_KEY.ESSAY_ANSWER_FILTER_LIST, filter], () =>
return useQuery<EssayAnswerResponse>([REACT_QUERY_KEY.ESSAY_ANSWER_FILTER_LIST, filter], () =>
requestGetEssayAnswers(filter)
);
};
Expand All @@ -127,3 +129,9 @@ export const useGetQuiz = (
retry: false,
});
};

export const useGetQuizzes = ({ curriculumId }: { curriculumId: number }) => {
return useQuery<Array<{ id: number; question: string }>>([REACT_QUERY_KEY.QUIZZES], () =>
requestGetQuizzes(curriculumId)
);
};
Loading

0 comments on commit ca72aff

Please sign in to comment.