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

자잘한 오류 수정 #27

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 25 additions & 0 deletions public/Profile_empty.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions public/Profile_emptybg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 0 additions & 20 deletions public/profile.svg

This file was deleted.

37 changes: 33 additions & 4 deletions src/app/(route)/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,33 @@ export default function Login() {
console.error("에러가 발생했습니다:", error);
}
};

const googleLogin = async (event: React.FormEvent<HTMLFormElement>) => {
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 (
<div className="h-screen text-black bg-white flex justify-center items-center relative z-[10]">
<div className="w-full h-[230px] bg-[url('/wave.svg')] fixed bottom-0 z-[-1]"></div>
Expand All @@ -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("/")}
></Image>

<form onSubmit={handleLogin} className="flex flex-col items-center">
Expand Down Expand Up @@ -115,6 +143,7 @@ export default function Login() {
width={80}
height={45}
className="mt-[50px] cursor-pointer z-10"
onClick={() => googleLogin}
></Image>
</div>
</div>
Expand Down Expand Up @@ -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("/");
}
Expand Down Expand Up @@ -259,7 +288,7 @@ export default function Login() {
text="비밀번호 찾기"
type="submit"
className="mt-[35px] "
onClick={() => setPage("returnPW")}
// onClick={() => setPage("returnPW")}
//api작업시 onClick삭제
></NextButton>
</form>
Expand Down
48 changes: 48 additions & 0 deletions src/app/(route)/login/resetPW/page/page.tsx
Original file line number Diff line number Diff line change
@@ -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<string>("");
const [reNewPassword, setReNewPassword] = useState<string>("");
const handleResetPW = () => {};
return (
<div className="h-screen text-black bg-white flex justify-center items-center relative z-[10]">
<div className="w-full h-[230px] bg-[url('/wave.svg')] fixed bottom-0 z-[-1]"></div>
<div className="items-center flex flex-col justify-center box-border z-10">
<div className="text-center text-[36px] font-bold">
비밀번호 재설정 하기
</div>
<form onSubmit={handleResetPW} className="flex flex-col items-center">
<Input
value={newPassword}
onChange={(e) => setNewPassword(e.target.value)}
label="새로운 비밀번호"
placeholder="새로운 비밀번호를 입력해주세요."
className="mt-[24px]"
/>

<Input
value={reNewPassword}
onChange={(e) => setReNewPassword(e.target.value)}
label="새로운 비밀번호 확인"
placeholder="새로운 비밀번호를 재입력해주세요."
className="mt-[24px]"
/>
{/*
매 입력시마다 reNewPassword에 저장
-> 매 입력시 newPassword와 reNewPassword 대조
-> 차이없을 때 오류메시지 안보이게 or nextButton 활성화
*/}
<NextButton
text="비밀번호 재설정"
type="submit"
className="mt-[35px] "
// onClick={() => setPage("")}
//api작업시 onClick삭제
></NextButton>
</form>
</div>
</div>
);
};
83 changes: 55 additions & 28 deletions src/app/(route)/regist/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,30 @@ export default function Regist() {

const [selectedValue, setSelectedValue] = useState("직접입력");

const [agreeMarketingSms, setAgreeMarketingSms] = useState<string>("");
const [agreeMarketingSms, setAgreeMarketingSms] = useState<
boolean | undefined
>(false);

const [idRight, setIdRight] = useState<boolean | undefined>(undefined);
const [nickRight, setNickRight] = useState<boolean | undefined>(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;
Expand All @@ -57,6 +76,8 @@ export default function Regist() {
{ value: "BITAmin", name: "BITAmin" },
];

const { ToastComponent, showToast } = useToast();

const selectHandle = (selectedValue: string) => {
setSelectedValue(selectedValue);
setOrganization(selectedValue);
Expand Down Expand Up @@ -138,15 +159,23 @@ export default function Regist() {

const onAllCheck = (e: ChangeEvent<HTMLInputElement>) => {
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<HTMLInputElement>) => {
const checked = e.target.checked;

setAgreeMarketingSms(checked); // agreeMarketingSms 상태 업데이트
console.log("allIsChecked", allIsChecked);
};

useEffect(() => {
Expand Down Expand Up @@ -174,7 +203,7 @@ export default function Regist() {
if (idRight == undefined) {
return false;
} else if (idRight == true) {
return false;
return true;
} else {
return true;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}

//정보저장
Expand All @@ -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);
}
Expand All @@ -258,17 +290,11 @@ export default function Regist() {
}
};

const handleAgreeMarketingSms = (e: ChangeEvent<HTMLInputElement>) => {
const checked = e.target.checked;

setAgreeMarketingSms(checked === true ? "True" : "False"); // agreeMarketingSms 상태 업데이트
console.log("sms상태:", agreeMarketingSms);
};

return (
<div className="h-fit-content text-black bg-white flex flex-col justify-center items-center relative z-[10]">
{/* <NavBar /> */}
<div className="items-center flex flex-col justify-evenly box-border z-10">
<ToastComponent />
<div className="text-center text-[36px] font-bold mt-[183px]">
회원가입
</div>
Expand All @@ -292,7 +318,9 @@ export default function Regist() {
</div>
</div>
<WrongMessage
text="이메일 형식을 확인해주세요"
text={
idRight ? "사용 가능한 아이디입니다." : "중복된 아이디입니다."
}
visible={handleError("idEmail")}
/>
<Input
Expand All @@ -317,7 +345,7 @@ export default function Regist() {
placeholder="닉네임을 입력해주세요."
className="mt-[31px]"
w="1"
disabled={handleError("nickName")}
disabled={nickRight}
/>
<div
className="w-[130px] h-[50px] box-border ml-[8px] px-[8px] py-[4px] rounded bottom-0 right-0 border flex justify-center items-center bg-[#f5f5f5] cursor-pointer"
Expand Down Expand Up @@ -370,9 +398,7 @@ export default function Regist() {
<div className="flex relative w-full items-end">
<Input
type="text"
value={
selectedValue === "직접입력" ? organization : selectedValue
}
value={selectedValue === "직접입력" ? undefined : selectedValue}
onChange={(e) => {
setOrganization(e.target.value),
console.log("organization:", organization);
Expand Down Expand Up @@ -427,6 +453,7 @@ export default function Regist() {
text="회원가입"
className="mt-[42px]"
type="submit"
disabled={!areAllInputsFilled()}
></NextButton>
</div>
</form>
Expand Down
43 changes: 43 additions & 0 deletions src/app/_api/Club/GetClub.ts
Original file line number Diff line number Diff line change
@@ -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<ApiResponse | null>(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;
44 changes: 44 additions & 0 deletions src/app/_api/Club/GetClubDetail.ts
Original file line number Diff line number Diff line change
@@ -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<ApiResponse | null>(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;
Loading