Skip to content

Commit

Permalink
Merge branch 'main' into feat/#9
Browse files Browse the repository at this point in the history
  • Loading branch information
frombozztoang committed Aug 22, 2023
2 parents 7ca6b42 + 97757dc commit 9913257
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 43 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"react-native-screens": "~3.22.0",
"react-native-svg": "13.9.0",
"react-native-web": "~0.19.6",
"react-native-webview": "13.2.2",
"react-native-webview": "^13.2.2",
"styled-components": "^6.0.7"
},
"devDependencies": {
Expand Down
64 changes: 27 additions & 37 deletions pages/Diary/DiaryAnswer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,44 @@ import MolButton from "../../components/atom/Button/MolButton";
import axios from "axios";
import AfterAnswerWidget from "@/components/organisms/widget/AfterAnswerWidget";
import EvolvingWidget from "@/components/organisms/widget/EvolvingWidget";
import { useAuth } from "@/context/AuthContext";

type ownProps = {
navigation: any;
route: any;
};

const DiaryAnswer = (props: ownProps) => {
const { token } = useAuth();
const { navigation, route } = props;
const { emotionId, myCrystalCount, inputContent, answerType } = route.params;
const [chatResponse, setChatResponse] = useState<string>("");
const [isModalShown, setIsModalShown] = useState(false);
const [isAfterAnswer, setIsAfterAnswer] = useState(false);
const [isWaterChange, setIsWaterChange] = useState(false);
const [isWaterEvolving, setIsWaterEvolving] = useState(false);

const headers = {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
};
useEffect(() => {
// const apiUrl = `http://3.36.4.36:8080/comment/${answerType}`;
// const requestBody = {
// diary: inputContent,
// };

// // API 요청 헤더 설정
// const headers = {
// Authorization:
// "Bearer mA5GsYhjZhxhsoHn2R4rzEY-kYgbRQniiCBLtNntCiolUAAAAYoTwGNw",
// "Content-Type": "application/json",
// };

// // POST 요청 보내기
// axios
// .post(apiUrl, requestBody, { headers })
// .then((response) => {
// console.log("API 요청 성공:", response.data);
// setChatResponse(response.data.data);
// })
// .catch((error) => {
// console.error("API 요청 실패:", error);
// });
setChatResponse("sival");
const apiUrl = `http://3.36.4.36:8080/comment/${answerType}`;
const requestBody = {
diary: inputContent,
};

// API 요청 헤더 설정

// POST 요청 보내기
axios
.post(apiUrl, requestBody, { headers })
.then((response) => {
console.log("API 요청 성공:", response.data);
setChatResponse(response.data.data);
})
.catch((error) => {
console.error("API 요청 실패:", error);
});
}, []);

const CloseButtonHandler = () => {
Expand All @@ -57,11 +56,6 @@ const DiaryAnswer = (props: ownProps) => {
};

// API 요청 헤더 설정
const headers = {
Authorization:
"Bearer mA5GsYhjZhxhsoHn2R4rzEY-kYgbRQniiCBLtNntCiolUAAAAYoTwGNw",
"Content-Type": "application/json",
};

// POST 요청 보내기
axios
Expand All @@ -80,13 +74,6 @@ const DiaryAnswer = (props: ownProps) => {
setIsAfterAnswer(false);
const apiUrl = `http://3.36.4.36:8080/crystal/comments`;

// API 요청 헤더 설정
const headers = {
Authorization:
"Bearer mA5GsYhjZhxhsoHn2R4rzEY-kYgbRQniiCBLtNntCiolUAAAAYoTwGNw",
"Content-Type": "application/json",
};

// POST 요청 보내기
axios
.get(apiUrl, { headers })
Expand All @@ -103,6 +90,8 @@ const DiaryAnswer = (props: ownProps) => {
) {
console.log("분기점이다!");
setIsWaterChange(true);
} else {
navigation.navigate("Home");
}
})
.catch((error) => {
Expand Down Expand Up @@ -153,9 +142,10 @@ const DiaryAnswer = (props: ownProps) => {
<MolText
label={chatResponse}
size="17"
weight="regular"
weight="bold"
align="left"
color="black"
mt="-40"
/>
</ScrollViewContainer>
</DiaryWritingBox>
Expand Down
5 changes: 3 additions & 2 deletions pages/Diary/DiaryWriting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import MolText from "../../components/atom/Text/Text";
import MolButton from "../../components/atom/Button/MolButton";
import Widget from "../../components/organisms/widget/Widget";
import axios from "axios";
import { useAuth } from "@/context/AuthContext";

export const DiaryWriting = ({ navigation }: { navigation: any }) => {
const { token } = useAuth();
const [onWidget, setOnWidget] = useState<boolean>(false);

const [inputContent, setInputContent] = useState("");
Expand All @@ -33,8 +35,7 @@ export const DiaryWriting = ({ navigation }: { navigation: any }) => {

// API 요청 헤더 설정
const headers = {
Authorization:
"Bearer KvOxVva9xKjsl2mZ44aLt8Wa_bJCvhWaBDQcqEVfCiolTgAAAYoSco7Z",
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
};

Expand Down
5 changes: 3 additions & 2 deletions pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import styled from "styled-components/native";
import { LinearGradient } from "expo-linear-gradient";
import { useIsFocused } from "@react-navigation/native";
import axios from "axios";
import { useAuth } from "@/context/AuthContext";

const Home = ({ navigation }: { navigation: any }) => {
const isFocused = useIsFocused();
const [answerCount, setAnswerCount] = useState(0);
const { token } = useAuth();

const waters = {
first: require("@/assets/png/water01.png"),
Expand All @@ -24,8 +26,7 @@ const Home = ({ navigation }: { navigation: any }) => {
const apiUrl = `http://3.36.4.36:8080/crystal/comments`;
// API 요청 헤더 설정
const headers = {
Authorization:
"Bearer mA5GsYhjZhxhsoHn2R4rzEY-kYgbRQniiCBLtNntCiolUAAAAYoTwGNw",
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
};
// POST 요청 보내기
Expand Down

0 comments on commit 9913257

Please sign in to comment.