diff --git a/public/Profile_empty.svg b/public/Profile_empty.svg new file mode 100644 index 0000000..40aebab --- /dev/null +++ b/public/Profile_empty.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/Profile_emptybg.svg b/public/Profile_emptybg.svg new file mode 100644 index 0000000..ddb8741 --- /dev/null +++ b/public/Profile_emptybg.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/profile.svg b/public/profile.svg deleted file mode 100644 index a07614d..0000000 --- a/public/profile.svg +++ /dev/null @@ -1,20 +0,0 @@ -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 - - - - - - - - - - - - - - - - - - - diff --git a/src/app/(route)/login/page.tsx b/src/app/(route)/login/page.tsx index cd4be38..ff9d1b2 100644 --- a/src/app/(route)/login/page.tsx +++ b/src/app/(route)/login/page.tsx @@ -55,6 +55,33 @@ export default function Login() { console.error("에러가 발생했습니다:", error); } }; + + const googleLogin = async (event: React.FormEvent) => { + event.preventDefault(); + //토스트로직 만들기 + + try { + const response = await login({ + email, + password, + }); + console.log("response", response); + + if (response?.accessToken) { + localStorage.setItem("login-token", response.accessToken); + console.log(response.tokenType); + if (router) { + router.push("/"); + } + } else { + showToast("올바르지 않은 아이디 혹은 비밀번호입니다", 2000); + } + + //정보저장 + } catch (error) { + console.error("에러가 발생했습니다:", error); + } + }; return (
@@ -65,7 +92,8 @@ export default function Login() { alt="logo" width={404} height={145} - className="mb-[50px]" + className="mb-[50px] cursor-pointer" + onClick={() => router.push("/")} >
@@ -115,6 +143,7 @@ export default function Login() { width={80} height={45} className="mt-[50px] cursor-pointer z-10" + onClick={() => googleLogin} >
@@ -201,12 +230,12 @@ export default function Login() { event.preventDefault(); try { - const result: boolean | undefined = await findPW({ + const response = await findPW({ email, number, }); - if (result === true) { + if (response) { if (router) { // router.push("/"); } @@ -259,7 +288,7 @@ export default function Login() { text="비밀번호 찾기" type="submit" className="mt-[35px] " - onClick={() => setPage("returnPW")} + // onClick={() => setPage("returnPW")} //api작업시 onClick삭제 > diff --git a/src/app/(route)/login/resetPW/page/page.tsx b/src/app/(route)/login/resetPW/page/page.tsx new file mode 100644 index 0000000..ab6f2b2 --- /dev/null +++ b/src/app/(route)/login/resetPW/page/page.tsx @@ -0,0 +1,48 @@ +import { NextButton } from "@/app/components/components/buttons"; +import { Input } from "@/app/components/components/inputbox"; +import { useState } from "react"; + +export const resetPw = () => { + const [newPassword, setNewPassword] = useState(""); + const [reNewPassword, setReNewPassword] = useState(""); + const handleResetPW = () => {}; + return ( +
+
+
+
+ 비밀번호 재설정 하기 +
+
+ setNewPassword(e.target.value)} + label="새로운 비밀번호" + placeholder="새로운 비밀번호를 입력해주세요." + className="mt-[24px]" + /> + + setReNewPassword(e.target.value)} + label="새로운 비밀번호 확인" + placeholder="새로운 비밀번호를 재입력해주세요." + className="mt-[24px]" + /> + {/* + 매 입력시마다 reNewPassword에 저장 + -> 매 입력시 newPassword와 reNewPassword 대조 + -> 차이없을 때 오류메시지 안보이게 or nextButton 활성화 + */} + setPage("")} + //api작업시 onClick삭제 + > +
+
+
+ ); +}; diff --git a/src/app/(route)/regist/page.tsx b/src/app/(route)/regist/page.tsx index 1aa478a..4738590 100644 --- a/src/app/(route)/regist/page.tsx +++ b/src/app/(route)/regist/page.tsx @@ -27,11 +27,30 @@ export default function Regist() { const [selectedValue, setSelectedValue] = useState("직접입력"); - const [agreeMarketingSms, setAgreeMarketingSms] = useState(""); + const [agreeMarketingSms, setAgreeMarketingSms] = useState< + boolean | undefined + >(false); const [idRight, setIdRight] = useState(undefined); const [nickRight, setNickRight] = useState(undefined); + const inputStates = [ + email, + password, + phoneNumber, + name, + nickName, + checkPassword, + organization, + ]; + + const areAllInputsFilled = () => { + return ( + allIsChecked && + inputStates.every((inputState) => inputState.trim() !== "") + ); + }; + interface Option { value: string; name: string; @@ -57,6 +76,8 @@ export default function Regist() { { value: "BITAmin", name: "BITAmin" }, ]; + const { ToastComponent, showToast } = useToast(); + const selectHandle = (selectedValue: string) => { setSelectedValue(selectedValue); setOrganization(selectedValue); @@ -138,15 +159,23 @@ export default function Regist() { const onAllCheck = (e: ChangeEvent) => { setAllIsChecked((prev) => !prev); - if (e.target.checked) { - setSmallCheckBoxs( - smallCheckBoxs.map((item) => ({ ...item, checked: true })) - ); - } else { - setSmallCheckBoxs( - smallCheckBoxs.map((item) => ({ ...item, checked: false })) - ); - } + // 각 약관 체크박스의 상태를 업데이트 + setSmallCheckBoxs( + smallCheckBoxs.map((item) => ({ + ...item, + checked: e.target.checked, + })) + ); + + // "마케팅 수신 동의" 체크박스의 상태도 업데이트 + setAgreeMarketingSms(e.target.checked); + }; + + const handleAgreeMarketingSms = (e: ChangeEvent) => { + const checked = e.target.checked; + + setAgreeMarketingSms(checked); // agreeMarketingSms 상태 업데이트 + console.log("allIsChecked", allIsChecked); }; useEffect(() => { @@ -174,7 +203,7 @@ export default function Regist() { if (idRight == undefined) { return false; } else if (idRight == true) { - return false; + return true; } else { return true; } @@ -207,7 +236,7 @@ export default function Regist() { return true; } case "checkPassword": - if (password.localeCompare(checkPassword) >= 0) { + if (password.localeCompare(checkPassword) == 0) { return false; } else { return true; @@ -228,12 +257,14 @@ export default function Regist() { const handleIDCheck = async () => { try { - const result: boolean = await doubleCheck("email", email); + const response = await doubleCheck("email", email); - if (result === true) { + if (response === true) { setIdRight(true); + // showToast("사용 가능한 아이디입니다.", 2000); } else { setIdRight(false); + // showToast("중복된 아이디입니다.", 2000); } //정보저장 @@ -244,10 +275,11 @@ export default function Regist() { const handleNickCheck = async () => { try { - const result: boolean = await doubleCheck("", nickName); + const response = await doubleCheck("", nickName); - if (result === true) { + if (response === true) { setNickRight(true); + showToast("사용 가능한 닉네임입니다.", 2000); } else { setNickRight(false); } @@ -258,17 +290,11 @@ export default function Regist() { } }; - const handleAgreeMarketingSms = (e: ChangeEvent) => { - const checked = e.target.checked; - - setAgreeMarketingSms(checked === true ? "True" : "False"); // agreeMarketingSms 상태 업데이트 - console.log("sms상태:", agreeMarketingSms); - }; - return (
{/* */}
+
회원가입
@@ -292,7 +318,9 @@ export default function Regist() {
{ setOrganization(e.target.value), console.log("organization:", organization); @@ -427,6 +453,7 @@ export default function Regist() { text="회원가입" className="mt-[42px]" type="submit" + disabled={!areAllInputsFilled()} >
diff --git a/src/app/_api/Club/GetClub.ts b/src/app/_api/Club/GetClub.ts new file mode 100644 index 0000000..ea393b2 --- /dev/null +++ b/src/app/_api/Club/GetClub.ts @@ -0,0 +1,43 @@ +import { useEffect, useState } from "react"; + +interface Content { + title: string; + description: string; + createdAt: string; + nickname: string; + thumbnail: string; +} + +interface Information { + content: Content[]; +} + +interface ApiResponse { + check: true; + information: Information; + message: null; +} + +const GetClub = () => { + const [clubData, setClubData] = useState(null); + + useEffect(() => { + const fetchclubData = async () => { + try { + const response = await fetch( + "http://ec2-3-34-14-75.ap-northeast-2.compute.amazonaws.com:8080/api/club" + ); + const result: ApiResponse = await response.json(); + setClubData(result); + } catch (error) { + console.error("Error fetching clubData:", error); + } + }; + + fetchclubData(); + }, []); + + return clubData; +}; + +export default GetClub; diff --git a/src/app/_api/Club/GetClubDetail.ts b/src/app/_api/Club/GetClubDetail.ts new file mode 100644 index 0000000..8784dbd --- /dev/null +++ b/src/app/_api/Club/GetClubDetail.ts @@ -0,0 +1,44 @@ +"use client"; + +import { useEffect, useState } from "react"; + +interface Information { + title: string; + description: string; + createdAt: string; + url1: string; + url2: string | null; + nickname: string; + thumbnail: string | null; + otherImages: string[]; +} + +interface ApiResponse { + check: boolean; + information: Information; + message: null | string; +} + +const GetClubDetail = (id: string) => { + const [clubData, setClubData] = useState(null); + + useEffect(() => { + const fetchclubData = async () => { + try { + const response = await fetch( + `http://ec2-3-34-14-75.ap-northeast-2.compute.amazonaws.com:8080/api/club/${id}` + ); + const result: ApiResponse = await response.json(); + setClubData(result); + } catch (error) { + console.error("Error fetching clubData:", error); + } + }; + + fetchclubData(); + }, []); + + return clubData; +}; + +export default GetClubDetail; diff --git a/src/app/_api/Club/PostClub.ts b/src/app/_api/Club/PostClub.ts new file mode 100644 index 0000000..b3c4898 --- /dev/null +++ b/src/app/_api/Club/PostClub.ts @@ -0,0 +1,48 @@ +import { useEffect } from "react"; + +interface ClubPostRequest { + title: string; + description: string; + url1: string; + url2: string; +} + +interface ClubPostData { + clubPostReq: ClubPostRequest; + images: string[]; +} + +// const dataToSend = { +// postProjectReq: { +// // 프로젝트 게시 Request에 대한 데이터를 여기에 추가 +// }, +// images: [ +// // images 배열에 대한 데이터를 여기에 추가 +// ], +// }; + +const PostClub = async ( + clubData: ClubPostData | undefined, + images: { name: string; url: string; size: string }[] +) => { + try { + const response = await fetch( + "http://ec2-3-34-14-75.ap-northeast-2.compute.amazonaws.com:8080/api/club", + { + method: "POST", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${localStorage.getItem("login-token")}`, + }, + body: JSON.stringify({ + postclubReq: clubData?.clubPostReq, + images: clubData?.images, + }), + } + ); + } catch (error) { + console.error("Error fetching ideaData:", error); + } +}; + +export default PostClub; diff --git a/src/app/_api/Gallery/DeleteProject.ts b/src/app/_api/Gallery/DeleteProject.ts new file mode 100644 index 0000000..bf3e872 --- /dev/null +++ b/src/app/_api/Gallery/DeleteProject.ts @@ -0,0 +1,26 @@ +import { useEffect, useState } from "react"; + +interface ApiResponse { + message: string; +} + +const deleteProject = async (id: string) => { + try { + const response = await fetch( + `http://ec2-3-34-14-75.ap-northeast-2.compute.amazonaws.com:8080/api/project/${id}`, + { + method: "DELETE", + headers: { + "Content-Type": "application/json", + // You may need to add other necessary headers + Authorization: `Bearer ${localStorage.getItem("login-token")}`, + }, + } + ); + const result: ApiResponse = await response.json(); + } catch (error) { + console.error("Error fetching ideaData:", error); + } +}; + +export default deleteProject; diff --git a/src/app/_api/Gallery/FixProject.ts b/src/app/_api/Gallery/FixProject.ts new file mode 100644 index 0000000..9472fc4 --- /dev/null +++ b/src/app/_api/Gallery/FixProject.ts @@ -0,0 +1,47 @@ +import { useEffect } from "react"; + +interface ProjectFormData { + title: string; + booleanWeb: boolean; + booleanApp: boolean; + booleanAi: boolean; + simpleDescription: string; + detailedDescription: string; + team: string; + githubUrl: string; + webUrl: string; + googlePlayUrl: string; +} + +interface Images { + name: string; + url: string; + size: string; +} +[]; + +const fixProject = async ( + projectData: ProjectFormData | undefined, + id: string, + images: Array<{ name: string; url: string; size: string }> +) => { + try { + const response = await fetch( + `http://ec2-3-34-14-75.ap-northeast-2.compute.amazonaws.com:8080/api/project/${id}`, + { + method: "PUT", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${localStorage.getItem("login-token")}`, + }, + body: JSON.stringify({ + title: projectData?.title, + }), + } + ); + } catch (error) { + console.error("Error fetching ideaData:", error); + } +}; + +export default fixProject; diff --git a/src/app/_api/Gallery/GetProject.ts b/src/app/_api/Gallery/GetProject.ts new file mode 100644 index 0000000..35e0e90 --- /dev/null +++ b/src/app/_api/Gallery/GetProject.ts @@ -0,0 +1,47 @@ +import { useEffect, useState } from "react"; + +interface Project { + id: number; + booleanWeb: boolean; + booleanApp: boolean; + booleanAi: boolean; + team: string; + title: string; + simpleDescription: string; + thumbnail: string; + hits: number; + createdAt: string; +} + +interface Information { + content: Project[]; +} + +interface ApiResponse { + check: boolean; + information: Information; +} + +const GetProject = () => { + const [projectData, setProjectData] = useState(null); + + useEffect(() => { + const fetchProjectData = async () => { + try { + const response = await fetch( + "http://ec2-3-34-14-75.ap-northeast-2.compute.amazonaws.com:8080/api/project" + ); + const result: ApiResponse = await response.json(); + setProjectData(result); + } catch (error) { + console.error("Error fetching ProjectData:", error); + } + }; + + fetchProjectData(); + }, []); + + return projectData; +}; + +export default GetProject; diff --git a/src/app/_api/Gallery/GetProjectDetail.ts b/src/app/_api/Gallery/GetProjectDetail.ts new file mode 100644 index 0000000..52b9718 --- /dev/null +++ b/src/app/_api/Gallery/GetProjectDetail.ts @@ -0,0 +1,48 @@ +import { useEffect, useState } from "react"; + +interface ProjectInformation { + title: string; + simpleDescription: string; + detailedDescription: string; + teamInformation: string; + githubUrl: string; + webUrl: string; + googlePlayUrl: string; + hits: number; + booleanWeb: boolean; + booleanApp: boolean; + booleanAi: boolean; + thumbnail: string; + otherImages: string[]; + createdAt: string; +} + +interface ApiResponse { + check: boolean; + information: ProjectInformation; + message: null | string; +} + +const GetProjectDetail = (id: string) => { + const [projectData, setProjectData] = useState(null); + + useEffect(() => { + const fetchprojectData = async () => { + try { + const response = await fetch( + `http://ec2-3-34-14-75.ap-northeast-2.compute.amazonaws.com:8080/api/project/${id}` + ); + const result: ApiResponse = await response.json(); + setProjectData(result); + } catch (error) { + console.error("Error fetching projectData:", error); + } + }; + + fetchprojectData(); + }, []); + + return projectData; +}; + +export default GetProjectDetail; diff --git a/src/app/_api/Gallery/GetProjectKeyWord.ts b/src/app/_api/Gallery/GetProjectKeyWord.ts new file mode 100644 index 0000000..c43c176 --- /dev/null +++ b/src/app/_api/Gallery/GetProjectKeyWord.ts @@ -0,0 +1,54 @@ +import { useEffect, useState } from "react"; + +interface Project { + id: number; + booleanWeb: boolean; + booleanApp: boolean; + booleanAi: boolean; + team: string; + title: string; + simpleDescription: string; + thumbnail: string; + hits: number; + createdAt: string; +} + +interface Information { + content: Project[]; +} + +interface ApiResponse { + check: boolean; + information: Information; +} + +const GetProjectKeyWord = (buttonStates: { [key: string]: boolean }) => { + const [projectData, setProjectData] = useState(null); + + useEffect(() => { + const fetchProjectData = async () => { + try { + const response = await fetch( + "http://ec2-3-34-14-75.ap-northeast-2.compute.amazonaws.com:8080/api/project/keyword", + { + body: JSON.stringify({ + booleanApp: buttonStates[0], + booleanWeb: buttonStates[1], + booleanAi: buttonStates[2], + }), + } + ); + const result: ApiResponse = await response.json(); + setProjectData(result); + } catch (error) { + console.error("Error fetching ProjectData:", error); + } + }; + + fetchProjectData(); + }, []); + + return projectData; +}; + +export default GetProjectKeyWord; diff --git a/src/app/_api/Gallery/PostProject.ts b/src/app/_api/Gallery/PostProject.ts new file mode 100644 index 0000000..c2623f2 --- /dev/null +++ b/src/app/_api/Gallery/PostProject.ts @@ -0,0 +1,56 @@ +import { useEffect } from "react"; + +interface ProjectFormData { + title: string; + booleanWeb: boolean; + booleanApp: boolean; + booleanAi: boolean; + simpleDescription: string; + detailedDescription: string; + team: string; + githubUrl: string; + webUrl: string; + googlePlayUrl: string; +} + +interface Images { + name: string; + url: string; + size: string; +} +[]; + +// const dataToSend = { +// postProjectReq: { +// // 프로젝트 게시 Request에 대한 데이터를 여기에 추가 +// }, +// images: [ +// // images 배열에 대한 데이터를 여기에 추가 +// ], +// }; + +const postProject = async ( + ideaData: ProjectFormData | undefined, + images: { name: string; url: string; size: string }[] +) => { + try { + const response = await fetch( + "http://ec2-3-34-14-75.ap-northeast-2.compute.amazonaws.com:8080/api/project", + { + method: "POST", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${localStorage.getItem("login-token")}`, + }, + body: JSON.stringify({ + postProjectReq: ideaData, + images: images, + }), + } + ); + } catch (error) { + console.error("Error fetching ideaData:", error); + } +}; + +export default postProject; diff --git a/src/app/_api/IdeaZone/DeleteIdea.ts b/src/app/_api/IdeaZone/DeleteIdea.ts new file mode 100644 index 0000000..4d8d5e3 --- /dev/null +++ b/src/app/_api/IdeaZone/DeleteIdea.ts @@ -0,0 +1,26 @@ +import { useEffect, useState } from "react"; + +interface ApiResponse { + message: string; +} + +const deleteIdea = async (id: string) => { + try { + const response = await fetch( + `http://ec2-3-34-14-75.ap-northeast-2.compute.amazonaws.com:8080/api/idea/${id}`, + { + method: "DELETE", + headers: { + "Content-Type": "application/json", + // You may need to add other necessary headers + Authorization: `Bearer ${localStorage.getItem("login-token")}`, + }, + } + ); + const result: ApiResponse = await response.json(); + } catch (error) { + console.error("Error fetching ideaData:", error); + } +}; + +export default deleteIdea; diff --git a/src/app/_api/IdeaZone/FixIdea.ts b/src/app/_api/IdeaZone/FixIdea.ts new file mode 100644 index 0000000..013eb34 --- /dev/null +++ b/src/app/_api/IdeaZone/FixIdea.ts @@ -0,0 +1,37 @@ +import { useEffect } from "react"; + +interface Idea { + keyWord: any; + title: string; + simpleDescription: string; + detailedDescription: string; + url1: string; + url2: string; +} + +const fixIdea = async (ideaData: Idea | undefined, id: string) => { + try { + const response = await fetch( + `http://ec2-3-34-14-75.ap-northeast-2.compute.amazonaws.com:8080/api/idea/${id}`, + { + method: "PUT", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${localStorage.getItem("login-token")}`, + }, + body: JSON.stringify({ + title: ideaData?.title, + keyWord: ideaData?.keyWord, + simpleDescription: ideaData?.simpleDescription, + detailedDescription: ideaData?.detailedDescription, + url1: ideaData?.url1, + url2: ideaData?.url2, + }), + } + ); + } catch (error) { + console.error("Error fetching ideaData:", error); + } +}; + +export default fixIdea; diff --git a/src/app/_api/IdeaZone/GetIdea.ts b/src/app/_api/IdeaZone/GetIdea.ts new file mode 100644 index 0000000..6f5dd9d --- /dev/null +++ b/src/app/_api/IdeaZone/GetIdea.ts @@ -0,0 +1,44 @@ +import { useEffect, useState } from "react"; + +interface Idea { + keyword: string; + keyWord: string; + id: string; + hits: any; + title: string; + thumbnail: string; + nickName: string; + simpleDescription: string; + color: string; + createdAt: string; +} + +interface ApiResponse { + check: boolean; + information: Idea[]; + message: string | null; +} + +const GetIdea = () => { + const [ideaData, setideaData] = useState(null); + + useEffect(() => { + const fetchideaData = async () => { + try { + const response = await fetch( + "http://ec2-3-34-14-75.ap-northeast-2.compute.amazonaws.com:8080/api/idea" + ); + const result: ApiResponse = await response.json(); + setideaData(result); + } catch (error) { + console.error("Error fetching ideaData:", error); + } + }; + + fetchideaData(); + }, []); + + return ideaData; +}; + +export default GetIdea; diff --git a/src/app/_api/IdeaZone/GetIdeaDetail.ts b/src/app/_api/IdeaZone/GetIdeaDetail.ts new file mode 100644 index 0000000..0810c04 --- /dev/null +++ b/src/app/_api/IdeaZone/GetIdeaDetail.ts @@ -0,0 +1,46 @@ +import { useEffect, useState } from "react"; + +interface Idea { + id: string; + hits: any; + keyWord: any; + title: string; + thumbnail: string; + nickName: string; + simpleDescription: string; + detailedDescription: string; + color: string; + url1: string; + url2: string; + createdAt: string; +} + +interface ApiResponse { + check: boolean; + information: Idea; + message: string | null; +} + +const GetIdeaDeatil = (id: string) => { + const [ideaData, setideaData] = useState(null); + + useEffect(() => { + const fetchideaData = async () => { + try { + const response = await fetch( + `http://ec2-3-34-14-75.ap-northeast-2.compute.amazonaws.com:8080/api/idea/${id}` + ); + const result: ApiResponse = await response.json(); + setideaData(result); + } catch (error) { + console.error("Error fetching ideaData:", error); + } + }; + + fetchideaData(); + }, []); + + return ideaData; +}; + +export default GetIdeaDeatil; diff --git a/src/app/_api/IdeaZone/PostIdea.ts b/src/app/_api/IdeaZone/PostIdea.ts new file mode 100644 index 0000000..a18a60c --- /dev/null +++ b/src/app/_api/IdeaZone/PostIdea.ts @@ -0,0 +1,37 @@ +import { useEffect } from "react"; + +interface Idea { + keyWord: any; + title: string; + simpleDescription: string; + detailedDescription: string; + url1: string; + url2: string; +} + +const postIdea = async (ideaData: Idea | undefined) => { + try { + const response = await fetch( + "http://ec2-3-34-14-75.ap-northeast-2.compute.amazonaws.com:8080/api/idea", + { + method: "POST", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${localStorage.getItem("login-token")}`, + }, + body: JSON.stringify({ + title: ideaData?.title, + keyWord: ideaData?.keyWord, + simpleDescription: ideaData?.simpleDescription, + detailedDescription: ideaData?.detailedDescription, + url1: ideaData?.url1, + url2: ideaData?.url2, + }), + } + ); + } catch (error) { + console.error("Error fetching ideaData:", error); + } +}; + +export default postIdea; diff --git a/src/app/_api/IdeaZone/PutIdea.ts b/src/app/_api/IdeaZone/PutIdea.ts new file mode 100644 index 0000000..be4faca --- /dev/null +++ b/src/app/_api/IdeaZone/PutIdea.ts @@ -0,0 +1,53 @@ +import { useEffect, useState } from "react"; + +interface Idea { + id: string; + hits: any; + keyWord: any; + title: string; + thumbnail: string; + nickName: string; + simpleDescription: string; + detailedDescription: string; + color: string; + url1: string; + url2: string; + createdAt: string; +} + +interface ApiResponse { + message: string; +} + +const PutIdea = (ideaDate: Idea | undefined) => { + useEffect(() => { + const fetchIdeaData = async () => { + try { + const response = await fetch( + `http://ec2-3-34-14-75.ap-northeast-2.compute.amazonaws.com:8080/api/idea/${ideaDate?.id}`, + { + method: "DELETE", + headers: { + "Content-Type": "application/json", + // You may need to add other necessary headers + }, + body: JSON.stringify({ + title: ideaDate?.title, + keyWord: ideaDate?.keyWord, + simpleDescription: ideaDate?.simpleDescription, + detailedDescription: ideaDate?.detailedDescription, + url1: ideaDate?.url1, + url2: ideaDate?.url2, + }), + } + ); + const result: ApiResponse = await response.json(); + } catch (error) { + console.error("Error fetching ideaData:", error); + } + }; + fetchIdeaData(); + }, []); // Include props in the dependenZcy array +}; + +export default PutIdea; diff --git a/src/app/api/login.tsx b/src/app/api/login.tsx index d1fb0e3..23d9f49 100644 --- a/src/app/api/login.tsx +++ b/src/app/api/login.tsx @@ -51,7 +51,7 @@ export async function login({ } const data: ServerResponse = await resp.json(); - + console.log("data", data); return data; // if (data.check) { @@ -74,6 +74,20 @@ export async function findID({ number: string; }) { try { + const resp = await fetch( + "http://ec2-3-34-14-75.ap-northeast-2.compute.amazonaws.com:8080/auth/find-id", + { + method: "GET", // 여기를 POST로 변경 + headers: { + "Content-Type": "application/json", + // 여기에 필요한 다른 헤더 추가 + }, + body: JSON.stringify({ + name: name, + phoneNumber: number, + }), // 만약 POST 요청에 데이터를 보내려면 body에 데이터를 추가 + } + ); const resp = await fetch("https://ideacampus.site:8080/auth/find-id", { method: "Get", // 여기를 POST로 변경 headers: { @@ -94,14 +108,14 @@ export async function findID({ const data: ServerResponse = await resp.json(); console.log("data", data); - return data; - // if (data.check) { - // console.log("Data received:", data.information); - // return true; - // } else { - // console.error("Error occurred:", data.message || "Unknown error"); - // return false; - // } + + if (data.check) { + console.log("Data received:", data.information); + return data; + } else { + console.error("Error occurred:", data.message || "Unknown error"); + } + console.log("data", data); } catch (error) { // console.error("Error:", error.message || "Unknown error"); } @@ -135,12 +149,49 @@ export async function findPW({ if (data.check) { console.log("Data received:", data.information); - return true; + return data; + } else { + console.error("Error occurred:", data.message || "Unknown error"); + } + } catch (error) { + console.error("Error:", error || "Unknown error"); + } +} + +export async function onGoogle({ + email, + number, +}: { + email: string; + number: string; +}) { + try { + const resp = await fetch("https://ideacampus.site:8080/mail/send-email", { + method: "POST", // 여기를 POST로 변경 + headers: { + "Content-Type": "application/json", + // 여기에 필요한 다른 헤더 추가 + }, + body: JSON.stringify({ + email: email, + phoneNumber: number, + }), // 만약 POST 요청에 데이터를 보내려면 body에 데이터를 추가 + }); + + if (!resp.ok) { + throw new Error(`HTTP error! Status: ${resp.status}`); + } + + const data: ServerResponse = await resp.json(); + + if (data.check) { + console.log("Data received:", data.information); + return data; } else { console.error("Error occurred:", data.message || "Unknown error"); - return false; } } catch (error) { console.error("Error:", error || "Unknown error"); + console.error("Error:", error || "Unknown error"); } } diff --git a/src/app/api/naviBar.tsx b/src/app/api/naviBar.tsx index 182345b..51b4b44 100644 --- a/src/app/api/naviBar.tsx +++ b/src/app/api/naviBar.tsx @@ -15,7 +15,7 @@ interface ServerResponse { } ]; check?: boolean; - information?: { nickName?: string; color?: string }; + information?: { nickname?: string; color?: string }; } export async function LoginState() { diff --git a/src/app/api/regist.tsx b/src/app/api/regist.tsx index 228c46b..3fbffcf 100644 --- a/src/app/api/regist.tsx +++ b/src/app/api/regist.tsx @@ -20,7 +20,7 @@ interface ServerResponse { } ]; check: boolean; - information?: Idea[]; + information?: boolean; } export async function doubleCheck(type: string, checkData: string) { @@ -34,11 +34,10 @@ export async function doubleCheck(type: string, checkData: string) { if (data.check) { console.log("Data received:", data.information); - return true; } else { console.error("Error occurred:", data.message || "Unknown error"); - return false; } + return data.information; } export async function regist({ @@ -58,7 +57,7 @@ export async function regist({ checkPassword: string; phoneNumber: string; organization: string; - agreeMarketingSms: string; + agreeMarketingSms: boolean | undefined; }) { try { const resp = await fetch("https://ideacampus.site:8080/auth/sign-up", { diff --git a/src/app/components/components/buttons.tsx b/src/app/components/components/buttons.tsx index 786ad77..2cfc1ad 100644 --- a/src/app/components/components/buttons.tsx +++ b/src/app/components/components/buttons.tsx @@ -26,21 +26,28 @@ export const NextButton = ({ onClick, textColor, type, + disabled, }: { text: string; className?: string; onClick?: () => void; textColor?: string; type?: "button" | "submit" | "reset" | undefined; + disabled?: boolean; }) => { return ( diff --git a/src/app/myPage/profileChange/page.tsx b/src/app/myPage/profileChange/page.tsx index 669de06..ca32f0a 100644 --- a/src/app/myPage/profileChange/page.tsx +++ b/src/app/myPage/profileChange/page.tsx @@ -7,6 +7,7 @@ import { useState } from "react"; import GradientBackgroundmyPage from "@/assests/images/graidentBackgroundmyPage.png"; // import AlertModal from "@/app/myPage/_components/AlertModal"; import ColorChangeModal from "../_components/colorChangeModal"; +import { NavBar } from "@/app/components/components/naviBar"; const ProfileChange = () => { // Sample data for initial values @@ -55,7 +56,7 @@ const ProfileChange = () => { return (
-
+