Skip to content

Commit

Permalink
Revert "[Feat] 구글 로그인 기능 구현 및 웨더바 현재 온도 표시 변경 #34, #10"
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeiis authored Nov 25, 2023
1 parent 948df01 commit b849e85
Show file tree
Hide file tree
Showing 10 changed files with 271 additions and 49 deletions.
124 changes: 121 additions & 3 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@mui/material": "^5.14.18",
"axios": "^1.6.2",
"next": "14.0.3",
"next-auth": "^4.24.5",
"react": "^18",
"react-dom": "^18",
"recoil": "^0.7.7",
Expand Down
17 changes: 17 additions & 0 deletions src/app/detail/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"use client";

import WeatherBar from "@/component/WeatherBar";
import Image from "next/image";

export default function Detail(): JSX.Element {
return (
<div className="container">
<div className="w-full h-12 flex items-center ">
<Image src="/images/back.svg" width={15} height={15} alt="back" />
</div>
<hr className="w-full h-px" />
<WeatherBar />
<hr className="w-full h-px" />
</div>
);
}
32 changes: 28 additions & 4 deletions src/app/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"use client";
import { Link } from "@mui/icons-material";
import "../../style/login.scss";
import CloseIcon from "@mui/icons-material/Close";
import Menubar from "../../component/MenuBar";
Expand All @@ -8,10 +7,29 @@ import axios from "axios";
import { useRouter } from "next/navigation";

export default function Login() {
const router = useRouter();
const [email, setEmail] = useState<string>("");
const [pw, setPw] = useState<string>("");

useEffect(() => {
// 페이지 로드 시 URL에서 access_token 파싱
const urlParams = new URLSearchParams(window.location.hash.substring(1));
const accessToken = urlParams.get("access_token");

// accessToken을 로컬 스토리지에 저장 또는 백엔드로 전송
if (accessToken) {
localStorage.setItem("accessToken", accessToken);
// 백엔드로 전송하려면 이곳에서 API 호출을 수행할 수 있습니다.
// axios.post('/api/authenticate', { accessToken });
}
}, []);

const onGoogleSocialLogin = async () => {
window.location.href =
"https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.metadata.readonly&include_granted_scopes=true&response_type=token&redirect_uri=https%3A%2F%2Fwww.jerneithe.site%2Fuser%2Flogin%2Foauth2%2Fcode%2Fgoogle&client_id=453423602833-7db2b1dbicre47rkcrpfgn20nd16l9rs.apps.googleusercontent.com&service=lso&o2v=2&theme=glif&flowName=GeneralOAuthFlow";
};

// 일반 로그인

const handleLogin = async (e: FormEvent) => {
e.preventDefault();

Expand All @@ -32,8 +50,9 @@ export default function Login() {

const handleInputChange =
(setState: React.Dispatch<React.SetStateAction<string>>) =>
(e: ChangeEvent<HTMLInputElement>) =>
(e: ChangeEvent<HTMLInputElement>) => {
setState(e.target.value);
};

return (
<div className="container">
Expand Down Expand Up @@ -75,7 +94,12 @@ export default function Login() {
<br />
<br />
<div className="login_easy">
<hr /> 간편 로그인 <hr />
<div>
<hr /> 간편 로그인 <hr />
</div>
<button className="" onClick={onGoogleSocialLogin}>
구글 소셜 로그인
</button>
</div>
<Menubar />
</div>
Expand Down
56 changes: 56 additions & 0 deletions src/app/socialregister/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"use client";
import { useState } from "react";
import { useRouter } from "next/router";
import { useSession } from "next-auth/react";
import axios from "axios";

export default function CompleteProfile() {
const [name, setName] = useState<string>("");
const [nickname, setNickname] = useState<string>("");
const router = useRouter();
const { data: session } = useSession();

// 닉네임 설정 완료 후 다음 단계로 이동
const handleNicknameSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
try {
const response = await axios({
method: "POST",
url: "",
data: {
name,
nickname,
},
});
router.push("/");
} catch (error) {
console.error("닉네임 저장 오류:", error);
}
};

if (!session) {
router.push("/login");
return null;
}

return (
<div>
<h1>닉네임 설정</h1>
<form onSubmit={handleNicknameSubmit}>
<input
type="text"
placeholder="이름을 입력하세요"
value={name}
onChange={(e) => setName(e.target.value)}
/>
<input
type="text"
placeholder="닉네임을 입력하세요"
value={nickname}
onChange={(e) => setNickname(e.target.value)}
/>
<button type="submit">저장</button>
</form>
</div>
);
}
2 changes: 0 additions & 2 deletions src/app/upload/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ export default function Upload(): JSX.Element {
>({});

const handleImagesSelected = useCallback((files: File[] | null) => {
// if (files) {
setSelectedImages(files ? Array.from(files) : []);
// }
}, []);

const handleContent = (text: string) => {
Expand Down
1 change: 1 addition & 0 deletions src/component/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const TextArea: React.FC<TextAreaProps> = ({
}
return [];
};

// 엔터키 인식해서 줄바꿈 가능하게
const handleKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (event.key === "Enter") {
Expand Down
Loading

0 comments on commit b849e85

Please sign in to comment.