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

A사이드 토픽 생성 API 연동 #175

Merged
merged 43 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
c695b7d
Merge remote-tracking branch 'origin/dev' into feat/topic-create-page
chaeyoung103 Jan 23, 2024
855ff93
fix: lineheight 1.4 기본값 적용
chaeyoung103 Jan 23, 2024
82cf6ea
Merge remote-tracking branch 'origin/dev' into feat/topic-create-page
chaeyoung103 Jan 23, 2024
c73a3fc
feat: text, image icon 추가
chaeyoung103 Jan 26, 2024
4343393
fix: padding 값 수정
chaeyoung103 Jan 26, 2024
994921a
fix: 수정된 input theme으로 변경
chaeyoung103 Jan 26, 2024
8393de3
feat: 카테고리 input form 추가
chaeyoung103 Jan 26, 2024
b113a7a
fix: 파일 로직 변경
chaeyoung103 Jan 26, 2024
05fd4a6
feat: 토픽생성 image input 컴포넌트 추가
chaeyoung103 Jan 26, 2024
f54f375
fix: textinput props 변경
chaeyoung103 Jan 26, 2024
d44f5c8
feat: 뒤로가기 로직을 위한 코드수정
chaeyoung103 Jan 26, 2024
cf420e0
feat: B topic step2 추가
chaeyoung103 Jan 26, 2024
566a0d3
feat: B topic step1 추가
chaeyoung103 Jan 26, 2024
c2194ae
feat: B topic 페이지 추가
chaeyoung103 Jan 26, 2024
4d8ff82
Merge remote-tracking branch 'origin/dev' into feat/topic-create-page
chaeyoung103 Jan 26, 2024
9635ad1
feat: add delete icon
chaeyoung103 Feb 2, 2024
a6f5120
feat: add maxlength
chaeyoung103 Feb 2, 2024
e553957
fix: constant fix
chaeyoung103 Feb 2, 2024
0172e74
fix: constant fix
chaeyoung103 Feb 2, 2024
ed145fc
fix: form fix
chaeyoung103 Feb 2, 2024
2e67b54
feat: add BTopicCreate Step2 page
chaeyoung103 Feb 2, 2024
9bf1611
feat: separate imageinput component
chaeyoung103 Feb 2, 2024
38d7165
feat: add imgurl dto
chaeyoung103 Feb 2, 2024
1885fe4
feat: add topic deadline constant
chaeyoung103 Feb 2, 2024
1841bcc
fix: modal close button width, height fix
chaeyoung103 Feb 2, 2024
9252b80
feat: 토픽생성 api 구축
chaeyoung103 Feb 7, 2024
ce8ed01
feat: 토픽생성 form 유효성 검사 추가
chaeyoung103 Feb 7, 2024
84e2c29
chore: update gitignore
Jinho1011 Feb 7, 2024
2b43074
fix: update value by useWatch
Jinho1011 Feb 7, 2024
3c50d17
Merge branch 'dev' into feat/topic-create-page
Jinho1011 Feb 7, 2024
e7aaad0
fix: lint error
Jinho1011 Feb 7, 2024
f892164
fix: 로고색상 변경 #169
chaeyoung103 Feb 8, 2024
5ed4022
feat: 토픽생성 유효성 검사 및 api 연동
chaeyoung103 Feb 8, 2024
ebb1e21
feat: 토픽생성 api dto 수정
chaeyoung103 Feb 8, 2024
2268ba5
fix: 슬라이더 , 투표완료 컴포넌트 내 로고위치 수정
chaeyoung103 Feb 8, 2024
b058bfa
fix: topic content 글자수에 따른 size 조정
chaeyoung103 Feb 8, 2024
5a9a7f5
fix: 로그인 화면 로고 B 색상 수정
chaeyoung103 Feb 8, 2024
5b73c90
fix: 슬라이더 topic content text z index 수정
chaeyoung103 Feb 8, 2024
5f43c70
fix: api 변경에 따라 topic content 받아오도록 수정
chaeyoung103 Feb 8, 2024
c0db0a5
fix: topiccreate dto interface 위치 조정
chaeyoung103 Feb 8, 2024
fc8d96f
feat: Aside topiccreate api 연동
chaeyoung103 Feb 8, 2024
0098a76
Merge remote-tracking branch 'origin/dev' into feat/topic-create-page
chaeyoung103 Feb 8, 2024
d6f57b1
fix: 절대경로로 수정
chaeyoung103 Feb 8, 2024
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
7 changes: 1 addition & 6 deletions src/apis/topic/useTopics.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { useMutation, useQuery } from '@tanstack/react-query';

import {
CHOICE_OPTIONS,
ChoiceContent,
TopicCreateRequestDTO,
TopicResponse,
} from '@interfaces/api/topic';
import { TopicCreateRequestDTO, TopicResponse } from '@interfaces/api/topic';

import { PagingDataResponse } from '@interfaces/api';

Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/api/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ interface TopicResponse {

export interface TopicCreateRequestDTO {
side: string;
keywordName: string;
keywordName: string | null;
title: string;
choices: ChoiceRequest[];
deadline: number;
deadline: number | null;
}

interface ChoiceRequest {
Expand Down
58 changes: 45 additions & 13 deletions src/routes/Topic/Create/ASide/ATopicCreate.tsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,79 @@
import React, { useState, useEffect } from 'react';
import { FormProvider, useForm } from 'react-hook-form';

import { useCreateTopics } from '@apis/topic/useTopics';
import DefaultButton from '@components/commons/Button/DefaultButton';
import { Col } from '@components/commons/Flex/Flex';
import Text from '@components/commons/Text/Text';
import TextInput from '@components/commons/TextInput/TextInput';
import { theme3 } from '@components/commons/TextInput/theme';
import TopicCreateTextInput from '@components/TopicCreate/TopicCreateTextInput';
import { CHOICE_OPTIONS } from '@interfaces/api/topic';
import { TopicCreateDTO } from '@routes/Topic/Create/TopicCreate';

import { INPUT_TYPE, CONFIG } from '@constants/form';

import { colors } from '@styles/theme';

import { Container, SubmitButton } from './ATopicCreate.styles';

interface TopicCreateDTO {
topicTitle: string;
ATopic: string;
BTopic: string;
}

const ATopicCreate = () => {
const methods = useForm<TopicCreateDTO>({ mode: 'onChange' });

const titleProgress = methods.watch(INPUT_TYPE.TOPIC_TITLE)
? `${methods.watch(INPUT_TYPE.TOPIC_TITLE)?.length}/20`
: '0/20';
const [isFormFilled, setIsFormFilled] = useState(false);
const handleSubmitButtonClick = () => {
console.log('submit');

const createTopicMutation = useCreateTopics();

const handleSubmitForm = async () => {
const data = methods.getValues();
try {
const res = await createTopicMutation.mutateAsync({
side: 'TOPIC_A',
title: data.topicTitle,
keywordName: null,
deadline: null,
choices: [
{
choiceContentRequest: {
text: data.ATopic,
type: 'IMAGE_TEXT',
imageUrl: null,
},
choiceOption: CHOICE_OPTIONS.CHOICE_A,
},
{
choiceContentRequest: {
text: data.BTopic,
type: 'IMAGE_TEXT',
imageUrl: null,
},
choiceOption: CHOICE_OPTIONS.CHOICE_B,
},
],
});
console.log('success :', res);
} catch (error) {
console.error(error);
}
};

useEffect(() => {
const ATopicCondition = methods.getFieldState(INPUT_TYPE.A_TOPIC, methods.formState);
const BTopicCondition = methods.getFieldState(INPUT_TYPE.B_TOPIC, methods.formState);
if (
methods.getValues(INPUT_TYPE.TOPIC_TITLE) &&
methods.getValues(INPUT_TYPE.A_TOPIC) &&
methods.getValues(INPUT_TYPE.B_TOPIC)
!ATopicCondition.invalid &&
!BTopicCondition.invalid &&
ATopicCondition.isDirty &&
BTopicCondition.isDirty
) {
setIsFormFilled(true);
} else {
setIsFormFilled(false);
}
}, [methods]);
}, [methods.formState, methods]);

return (
<FormProvider {...methods}>
Expand Down Expand Up @@ -69,7 +101,7 @@ const ATopicCreate = () => {
<SubmitButton>
<DefaultButton
title={'토픽 던지기'}
onClick={handleSubmitButtonClick}
onClick={handleSubmitForm}
disabled={!isFormFilled}
></DefaultButton>
</SubmitButton>
Expand Down
12 changes: 1 addition & 11 deletions src/routes/Topic/Create/BSide/BTopicCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useSearchParams } from 'react-router-dom';
import { useCreateTopics } from '@apis/topic/useTopics';
import DefaultButton from '@components/commons/Button/DefaultButton';
import { CHOICE_OPTIONS, TopicCreateRequestDTO } from '@interfaces/api/topic';
import { TopicCreateDTO } from '@routes/Topic/Create/TopicCreate';

import { INPUT_TYPE } from '@constants/form';

Expand All @@ -18,17 +19,6 @@ import {
import BTopicCreateStep1 from './BTopicCreateStep1';
import BTopicCreateStep2 from './BTopicCreateStep2';

interface TopicCreateDTO {
topicTitle: string;
ATopic: string;
BTopic: string;
topicCategory: string;
ATopicImageURL: string;
BTopicImageURL: string;
topicDeadline: number;
topicType: string;
}

const BTopicCreate = () => {
const methods = useForm<TopicCreateDTO>({ mode: 'onChange' });
const contentType = useWatch({
Expand Down
11 changes: 11 additions & 0 deletions src/routes/Topic/Create/TopicCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ import {
SideChangeButton,
} from './TopicCreate.sytles';

export interface TopicCreateDTO {
topicTitle: string;
ATopic: string;
BTopic: string;
topicCategory: string;
ATopicImageURL: string;
BTopicImageURL: string;
topicDeadline: number;
topicType: string;
}

const TopicCreate = () => {
const navigate = useNavigate();
const [searchParams] = useSearchParams();
Expand Down
Loading