Skip to content

Commit

Permalink
Merge pull request #265 from TeamBookTez/develop
Browse files Browse the repository at this point in the history
[Release] ๋ฒ„๊ทธ ์ˆ˜์ • ๋ฐ ์ฝ”๋“œ ๊ฐœ์„ ๋œ v1.1.0 ๋ฐฐํฌํ•ฉ๋‹ˆ๋‹ค.
  • Loading branch information
soryeongk authored Apr 18, 2022
2 parents 78692a8 + 14e9df8 commit 6ab3f6e
Show file tree
Hide file tree
Showing 53 changed files with 369 additions and 413 deletions.
131 changes: 8 additions & 123 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,133 +121,18 @@

## ๐Ÿ›  ๊ธฐ์ˆ  ์Šคํƒ

<img src="https://img.shields.io/badge/-ReactJs-61DAFB?logo=react&logoColor=white&style=flat" height=40>&nbsp;&nbsp;<img src="https://img.shields.io/badge/-Typescript-3074BF?logo=Typescript&logoColor=white&style=flat" height=40>&nbsp;&nbsp;

```json
"axios": "^0.24.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^6.2.1",
"framer-motion": "^6.2.3",
"react-hook-form": "^7.28.1",
"react-responsive": "^9.0.0-beta.6",
"react-textarea-autosize": "^8.3.3",
"recoil": "^0.6.1",
"recoil-persist": "^4.0.0",
"styled-components": "^5.3.3",
"styled-reset": "^4.3.4",
"typescript": "^4.5.4",
```

<br/>

## ๐Ÿ—‚ ํ”„๋กœ์ ํŠธ ํด๋” ๊ตฌ์กฐ

```
.
โ”œโ”€โ”€ components
โ”‚ โ”œโ”€โ”€ addBook
โ”‚ โ”‚ โ”œโ”€โ”€ AddBookDefault.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ BookEmpty.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ BookInfoWrapper.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ BookList.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ ModalWrapper.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ SearchBar.tsx
โ”‚ โ”‚ โ””โ”€โ”€ ShowModal.tsx
โ”‚ โ”œโ”€โ”€ bookcase
โ”‚ โ”‚ โ”œโ”€โ”€ cardSection
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ AddBookCard.tsx
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ BookCard.tsx
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ Empty.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ Card.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ Navigation.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ NoCards.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ PeriRead.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ PostRead.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ PreRead.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ Total.tsx
โ”‚ โ”‚ โ””โ”€โ”€ index.ts
โ”‚ โ”œโ”€โ”€ common
โ”‚ โ”‚ โ”œโ”€โ”€ styled
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Button.tsx
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ Input.tsx
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ LabelHidden.tsx
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ LabelQuestion.tsx
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ NoteModalWrapper.tsx
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ Popup.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ AlertLabel.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ CommonLayout.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ NavHeader.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ InputEmail.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ InputPwd.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ MainHeader.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ MainLayout.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ NavHeader.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ NavWrapper.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ PopUpDelete.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ PopUpExit.tsx
โ”‚ โ”‚ โ””โ”€โ”€ index.ts
โ”‚ โ”œโ”€โ”€ detail
โ”‚ โ”‚ โ”œโ”€โ”€ DetailArticleWrapper.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ DetailArticleWrapperLabeling.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ ExamplePeriNote.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ ExamplePreNote.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ ExamplePreNoteLabeling.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ StepUpOnExample.tsx
โ”‚ โ”‚ โ””โ”€โ”€ index.ts
โ”‚ โ”œโ”€โ”€ landing
โ”‚ โ”‚ โ”œโ”€โ”€ LandingCard.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ LandingOne.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ LandingTwo.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ LandingThree.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ LandingFour.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ LandingFive.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ LandingHeader.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ LandingFooter.tsx
โ”‚ โ”‚ โ””โ”€โ”€ index.ts
โ”‚ โ”œโ”€โ”€ login
โ”‚ โ”‚ โ”œโ”€โ”€ LoginForm.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ LoginNavSection.tsx
โ”‚ โ”‚ โ””โ”€โ”€ index.ts
โ”‚ โ”œโ”€โ”€ main
โ”‚ โ”‚ โ”œโ”€โ”€ Banner.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ Recent.tsx
โ”‚ โ”‚ โ””โ”€โ”€ index.ts
โ”‚ โ”œโ”€โ”€ myPage
โ”‚ โ”‚ โ”œโ”€โ”€ BookComment.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ BottomContent.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ TopBanner.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ TopContent.tsx
โ”‚ โ”‚ โ””โ”€โ”€ index.ts
โ”‚ โ”œโ”€โ”€ signup
โ”‚ โ”‚ โ”œโ”€โ”€ FirstStep.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ SecondStep.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ ThirdStep.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ LastStep.tsx
โ”‚ โ”‚ โ””โ”€โ”€ index.ts
โ”‚ โ””โ”€โ”€ Router.tsx
โ”œโ”€โ”€ pages
โ”‚ โ”œโ”€โ”€ AddBook.tsx
โ”‚ โ”œโ”€โ”€ Bookcase.tsx
โ”‚ โ”œโ”€โ”€ BookNote.tsx
โ”‚ โ”œโ”€โ”€ DetailBookNote.tsx
โ”‚ โ”œโ”€โ”€ DetailExample.tsx
โ”‚ โ”œโ”€โ”€ Landing.tsx
โ”‚ โ”œโ”€โ”€ Login.tsx
โ”‚ โ”œโ”€โ”€ Main.tsx
โ”‚ โ”œโ”€โ”€ MyPage.tsx
โ”‚ โ”œโ”€โ”€ Signup.tsx
โ”‚ โ”œโ”€โ”€ Test.tsx
โ”‚ โ”œโ”€โ”€ ToBe.tsx
โ”‚ โ””โ”€โ”€ index.ts
โ”œโ”€โ”€ styles
โ”‚ โ”œโ”€โ”€ globalStyle.ts
โ”‚ โ”œโ”€โ”€ styled.d.ts
โ”‚ โ””โ”€โ”€ theme.ts
โ”œโ”€โ”€ utils
โ”‚ โ”œโ”€โ”€ lib
โ”‚ โ”‚ โ”œโ”€โ”€ api.ts
โ”‚ โ”‚ โ””โ”€โ”€ index.ts
โ”‚ โ”œโ”€โ”€ check.ts
โ”‚ โ”œโ”€โ”€ dataType.ts
โ”‚ โ””โ”€โ”€ mockData.ts
โ”œโ”€โ”€ App.tsx
โ”œโ”€โ”€ index.tsx
โ””โ”€โ”€ tsconfig.json
"swr": "^1.2.1",
"typescript": "^4.5.4"
```

<br />
Expand Down
22 changes: 3 additions & 19 deletions src/components/addBook/ModalWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
import React from "react";
import styled from "styled-components";

import { StBookModalWrapper } from "../common/styled/BookModalWrapper";

interface ModalWrapperProps {
children: React.ReactNode;
}
export default function ModalWrapper(props: ModalWrapperProps) {
const { children } = props;

return <StModalWrapper>{children}</StModalWrapper>;
return <StBookModalWrapper>{children}</StBookModalWrapper>;
}

export const StModalWrapper = styled.div`
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
position: fixed;
z-index: 10;
left: 0;
top: 0;
background-color: ${({ theme }) => theme.colors.white};
`;
2 changes: 1 addition & 1 deletion src/components/addBook/ShowModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const StWriteBtn = styled(Button)`
${({ theme }) => theme.fonts.button};
`;

export const StIcCancel = styled(IcCancelBlack)`
const StIcCancel = styled(IcCancelBlack)`
position: absolute;
top: 3.2rem;
left: 2.4rem;
Expand Down
7 changes: 7 additions & 0 deletions src/components/addBook/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export { default as AddBookDefault } from "./AddBookDefault";
export { default as BookEmpty } from "./BookEmpty";
export { default as BookInfoWrapper } from "./BookInfoWrapper";
export { default as BookList } from "./BookList";
export { default as ModalWrapper } from "./ModalWrapper";
export { default as SearchBar } from "./SearchBar";
export { default as ShowModal } from "./ShowModal";
2 changes: 1 addition & 1 deletion src/components/bookNote/PeriNoteExample.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from "styled-components";

import theme from "../../styles/theme";
import LabelQuestion from "../common/styled/LabelQuestion";
import LabelQuestion from "../common/LabelQuestion";

export default function PeriNoteExample() {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/bookNote/periNote/Complete.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useNavigate } from "react-router-dom";
import styled, { keyframes } from "styled-components";

import { StModalWrapper } from "../../addBook/ModalWrapper";
import { StBookModalWrapper } from "../../common/styled/BookModalWrapper";
import { Button } from "../../common/styled/Button";
import { BookData } from "./PeriNote";

Expand Down Expand Up @@ -56,7 +56,7 @@ const fadein = keyframes`
}
`;

export const StCompleteWrapper = styled(StModalWrapper)`
const StCompleteWrapper = styled(StBookModalWrapper)`
z-index: 20;
`;

Expand Down
80 changes: 48 additions & 32 deletions src/components/bookNote/periNote/PeriNote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { deepCopyTree, getNodeByPath } from "../../../utils/tree";
import { useFetchNote } from "../../../utils/useHooks";
import { Loading } from "../../common";
import { Button } from "../../common/styled/Button";
import { StStepModalWrapper } from "../../common/styled/StepModalWrapper";
import { Complete, ExButton, PriorQuestion, StepUp, StepUpLayout } from "..";
import { StStepModalWrapper } from "../preNote/PreNoteForm";

export interface BookData {
author: string[];
Expand Down Expand Up @@ -147,12 +147,37 @@ export default function PeriNote() {
miniMenu.classList.remove("open");
}
}
const getFormData = () => {
const obj = getValues();

const submitPeriNote = async () => {
patchBookNote(userToken, `/review/${reviewId}/peri`, { answerThree: data.answerThree, reviewSt: 4 }).then((res) =>
setBookData(res.bookData),
);
setOpenSubmitModal(true);
const keys = Object.keys(obj);
const newRoot = deepCopyTree(data.answerThree);

keys.map((key) => {
const value = obj[key];
const pathKey = key.split(",").map((k) => parseInt(k));

const current = getNodeByPath(newRoot, pathKey);

current.content = value;
});

// data state์—๋„ ์ €์žฅ
setData((current) => ({ ...current, answerThree: newRoot }));

return newRoot;
};

const submitPeriNote = () => {
const dataToPatch = getFormData();

patchBookNote(userToken, `/review/${reviewId}/peri`, {
answerThree: dataToPatch,
reviewSt: 4,
}).then((res) => {
setBookData(res.bookData);
setOpenSubmitModal(true);
});
};

useEffect(() => {
Expand All @@ -165,41 +190,32 @@ export default function PeriNote() {
};
}, []);

// ์ด๊ฑฐ ๋งˆ์Ÿˆ..?
useEffect(() => {
// ์งˆ๋ฌธ์ด ๋ชจ๋‘ ์ฑ„์›Œ์ ธ ์žˆ์œผ๋ฉด addQuestion์˜ isPrevented๋ฅผ false
if (data.answerThree.children.every((nodeList) => nodeList.content !== "")) {
// ์งˆ๋ฌธ์ด ๋ชจ๋‘ ์ฑ„์›Œ์ง„ ์ƒํƒœ์—์„œ ๋‹ต๋ณ€์ด ์ฑ„์›Œ์ง€๋ฉด ๋ชจ๋‘ false
if (data.answerThree.children.every((nodeList) => nodeList.children.every((node) => node.content !== ""))) {
setIsPrevented({ addQuestion: false, isCompleted: false });
// ๋ชจ๋“  ์งˆ๋ฌธ ๋ฆฌ์ŠคํŠธ๊ฐ€ ์ง€์›Œ์กŒ์„ ๊ฒฝ์šฐ์—๋Š” ์งˆ๋ฌธ ๋ฆฌ์ŠคํŠธ ์ถ”๊ฐ€๋งŒ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•˜๊ณ , ์ž‘์„ฑ์™„๋ฃŒ๋Š” ๋ถˆ๊ฐ€ํ•˜๊ฒŒ ํ•จ
if (!data.answerThree.children.length) {
setIsPrevented({ addQuestion: false, isCompleted: true });
} else {
// ์งˆ๋ฌธ์ด ๋ชจ๋‘ ์ฑ„์›Œ์ ธ ์žˆ์œผ๋ฉด addQuestion์˜ isPrevented๋ฅผ false
if (data.answerThree.children.every((nodeList) => nodeList.content !== "")) {
// ์งˆ๋ฌธ์ด ๋ชจ๋‘ ์ฑ„์›Œ์ง„ ์ƒํƒœ์—์„œ ๋‹ต๋ณ€์ด ์ฑ„์›Œ์ง€๋ฉด ๋ชจ๋‘ false
if (data.answerThree.children.every((nodeList) => nodeList.children.every((node) => node.content !== ""))) {
setIsPrevented({ addQuestion: false, isCompleted: false });
} else {
// ๋‹ต๋ณ€๋งŒ ๋น„์›Œ์žˆ์œผ๋ฉด isCompleted๋งŒ true
setIsPrevented({ addQuestion: false, isCompleted: true });
}
} else {
// ๋‹ต๋ณ€๋งŒ ๋น„์›Œ์žˆ์œผ๋ฉด isCompleted๋งŒ true
setIsPrevented({ addQuestion: false, isCompleted: true });
// ์งˆ๋ฌธ์ด ๋น„์›Œ์ ธ์žˆ์œผ๋ฉด ๋‘˜ ๋‹ค true;
setIsPrevented({ addQuestion: true, isCompleted: true });
}
} else {
// ์งˆ๋ฌธ์ด ๋น„์›Œ์ ธ์žˆ์œผ๋ฉด ๋‘˜ ๋‹ค true;
setIsPrevented({ addQuestion: true, isCompleted: true });
}
}, [data.answerThree]);

useEffect(() => {
if (navIndex && isSave) {
const obj = getValues();
const keys = Object.keys(obj);
const newRoot = deepCopyTree(data.answerThree);

keys.map((key) => {
const value = obj[key];
const pathKey = key.split(",").map((k) => parseInt(k));

const current = getNodeByPath(newRoot, pathKey);

current.content = value;
});
const dataToPatch = getFormData();

setTimeout(() => {
saveReview({ ...data, answerThree: newRoot });
}, 0);
saveReview({ ...data, answerThree: dataToPatch });
}
}, [isSave, navIndex]);

Expand Down
8 changes: 5 additions & 3 deletions src/components/bookNote/periNote/PeriNoteInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import styled, { css } from "styled-components";

import theme from "../../../styles/theme";
import { PeriNoteTreeNode } from "../../../utils/dataType";
import { StAddAnswerButton, StMenuBtn } from "../../common/styled/Button";
import { StMoreIcon } from "../../common/styled/Icon";
import { StMenuWrapper } from "../../common/styled/MenuWrapper";
import { FormController } from "./PeriNote";
import { StAddAnswerButton, StMenu, StMenuBtn, StMoreIcon } from "./PriorQuestion";

interface PeriNoteInputProps {
path: number[];
Expand Down Expand Up @@ -78,7 +80,7 @@ export default function PeriNoteInput(props: PeriNoteInputProps) {
</StAddAnswerButton>
)}
<StMore className="icn_more" />
<StMenu>
<StMenuWrapper>
{!isQuestion && (
<StMenuBtn type="button" onClick={() => onAddChild(path, index, !isQuestion)}>
๊ผฌ๋ฆฌ์งˆ๋ฌธ ์ถ”๊ฐ€
Expand All @@ -87,7 +89,7 @@ export default function PeriNoteInput(props: PeriNoteInputProps) {
<StMenuBtn type="button" onClick={() => onDeleteChild(path)}>
์‚ญ์ œ
</StMenuBtn>
</StMenu>
</StMenuWrapper>
</StInputWrapper>
</StFieldset>
<StFieldWrapper isanswer={!isQuestion}>
Expand Down
8 changes: 5 additions & 3 deletions src/components/bookNote/periNote/PriorAnswer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import styled, { css } from "styled-components";

import { IcPeriAnswer } from "../../../assets/icons";
import { PeriNoteTreeNode } from "../../../utils/dataType";
import { StMenuBtn } from "../../common/styled/Button";
import { StMoreIcon } from "../../common/styled/Icon";
import { StMenuWrapper } from "../../common/styled/MenuWrapper";
import { PeriNoteInput } from "..";
import { FormController } from "./PeriNote";
import { StMenu, StMenuBtn, StMoreIcon } from "./PriorQuestion";

interface PriorAnswerProps {
path: number[];
Expand Down Expand Up @@ -73,14 +75,14 @@ export default function PriorAnswer(props: PriorAnswerProps) {
onKeyPress={(e) => handleKeyPress(e, path, index, isQuestion)}
/>
<StMore className="icn_more" />
<StMenu menuposition={"isPriQ"}>
<StMenuWrapper menuposition={"isPriQ"}>
<StMenuBtn type="button" onClick={() => handleClickAddChild(path, index, !isQuestion)}>
๊ผฌ๋ฆฌ์งˆ๋ฌธ ์ถ”๊ฐ€
</StMenuBtn>
<StMenuBtn type="button" onClick={() => handleClickDeleteChild(path)}>
์‚ญ์ œ
</StMenuBtn>
</StMenu>
</StMenuWrapper>
</StAnswerWrapper>
{node.children &&
node.children.map((node, i) => (
Expand Down
Loading

0 comments on commit 6ab3f6e

Please sign in to comment.