Skip to content

Commit

Permalink
Merge pull request #173 from kdt-8-4/148-social_login
Browse files Browse the repository at this point in the history
[Fix] 피드페이지 카테고리 수정, 소셜로그인 완료 (#10)
  • Loading branch information
nebulaBdj authored Dec 7, 2023
2 parents dae5d0d + 436cfce commit cf5526d
Show file tree
Hide file tree
Showing 16 changed files with 125 additions and 77 deletions.
8 changes: 6 additions & 2 deletions src/app/detail/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import CommentIcon from "@/component/CommentIcon";
import CategoryDetail from "@/component/CategoryDetail";
import { useRouter } from "next/navigation";
import { editBoardIdState } from "@/recoilAtom/EditDetail";
import { ProfileTemperature } from "@/recoilAtom/ProfileTemperature";
import Link from "next/link";

interface boardCommentType {
Expand All @@ -42,15 +43,16 @@ export default function Detail(): JSX.Element {
const [editBoardId, setEditBoardId] = useRecoilState(editBoardIdState);
const [comment, setComment] = useState<boardCommentType[]>([]);
const [refreshComments, setRefreshComments] = useState(false);
const [likelist, setLikelist] = useState<LIKE[]>([]); //리코일로 만드는게 나을듯 일단은 이대로 ㄱㄱ
const [likelist, setLikelist] = useState<LIKE[]>([]);
const [profile_temperature, setProfileTemperature] = useRecoilState(ProfileTemperature);
// const [likeCount, setLikeCount] = useState<number>();
const [likeCount, setLikeCount] = useState(0);

// 좋아요 개수 업데이트 함수
const updateLikeCount = (boardId: number, newCount: number) => {
setLikeCount((prevCount) => prevCount + newCount);
};


const router = useRouter();
const accessToken = Cookies.get("accessToken");

Expand All @@ -72,10 +74,12 @@ export default function Detail(): JSX.Element {
const response = await axios.get(
`https://www.jerneithe.site/board/detail/${localBoardId}`,
);
// console.log("디테일 응답", response);
setLikelist(response.data.likelist);
setLikeCount(response.data.likeCount);
setBoardDetail(response.data);
setComment(response.data.comments);
setProfileTemperature(response.data.temperature);
} catch (error) {
console.error("Error fetching data:", error);
}
Expand Down
67 changes: 35 additions & 32 deletions src/app/feed/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,40 @@ import "../../style/feed.scss";
import { FeedDecodeNickname } from "@/recoilAtom/FeedNickname";
import { FeedLoginToken } from "@/recoilAtom/FeedLoginToken";

export default function Feed() {
const [decodeNick, setNick] = useRecoilState(FeedDecodeNickname);
const [loginToken_feed, setFeedToken] = useRecoilState(FeedLoginToken);

useEffect(() => {
const accessToken = Cookies.get("accessToken");
// console.log("accessToken 값: ", accessToken);
const decodedToken = accessToken
? (jwt.decode(accessToken) as { [key: string]: any })
: null;
const decoded_nickName = decodedToken?.sub;
// console.log("디코딩", decodedToken);
// console.log("디코딩 닉네임", decoded_nickName);

setFeedToken(accessToken);
setNick(decoded_nickName);
}, []);

return (
<>
{/* <RecoilRoot> */}
<div className="container_dj">
<br />
<FeedSearch />
<WeatherBar />
<FeedCategory />
<FeedSort />
<FeedContenets />

export default function Feed(){
const [decodeNick, setNick] = useRecoilState(FeedDecodeNickname);
const [loginToken_feed, setFeedToken] = useRecoilState(FeedLoginToken);

useEffect(()=>{
const accessToken = Cookies.get("accessToken");
// console.log("accessToken 값: ", accessToken);
const decodedToken = accessToken
? (jwt.decode(accessToken) as { [key: string]: any })
: null;
const decoded_nickName = decodedToken?.sub;
// console.log("디코딩", decodedToken);
// console.log("디코딩 닉네임", decoded_nickName);

setFeedToken(accessToken);
setNick(decoded_nickName);

},[])

return(<>
{/* <RecoilRoot> */}

<div className="container_dj">
<br />
<FeedSearch />
<hr />
<WeatherBar />
<FeedCategory />
<FeedSort />
<FeedContenets />
</div>
<Menubar />
</div>
{/* </RecoilRoot> */}
</>
);
{/* </RecoilRoot> */}
</>)

}
2 changes: 1 addition & 1 deletion src/app/mypage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function Mypage() {
const [fromSocial, setFromSocial] = useState<boolean>(false);

// 로그인 확인 후 페이지 로드
const [logincheck, setCheck] = useState<boolean>(false);
const [logincheck, setCheck] = useState<boolean>(true);
// 토큰 값
const [logintoken, setToken] = useState<string | undefined>("");

Expand Down
11 changes: 10 additions & 1 deletion src/app/socialregister/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default function CompleteProfile() {
const [nickname, setNickname] = useState<string>("");
const [name, setName] = useState<string>("");
const [resEmail, setResEmail] = useState<string>("");
const [token, setToken] = useState<string>("");

const [google_signup_check, setSignUpCheck] = useState<boolean>();

Expand Down Expand Up @@ -70,11 +71,18 @@ export default function CompleteProfile() {
} else {
setSignUpCheck(true);
}
setToken(resGoogle.data.token);

}
googlesenddata();
}
},[sendGoogle_data])
},[sendGoogle_data]);

useEffect(()=>{
if(token){
document.cookie = `accessToken=${token}; path=/`;
}
},[token]);

// console.log("받아온 토큰:", googleToken);
// console.log("보내려고 하는 데이터", sendGoogle_data);
Expand Down Expand Up @@ -135,6 +143,7 @@ export default function CompleteProfile() {

console.log("회원가입 여부", google_signup_check);
// console.log("받은 이메일", resEmail);


return (
<>
Expand Down
8 changes: 6 additions & 2 deletions src/app/upload/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function Upload(): JSX.Element {
const [usetemp, setTemp] = useRecoilState(TemNowControl);

// 로그인 확인 후 페이지 로드
const [logincheck, setCheck] = useState<boolean>(false);
const [logincheck, setCheck] = useState<boolean>(true);
// 토큰 값
const [logintoken, setLoginToken] = useState<string | undefined>("");

Expand All @@ -47,8 +47,12 @@ export default function Upload(): JSX.Element {
setLoginToken(accessToken);
};

useEffect(() => {
useEffect(()=> {
cookie();
}, []);

useEffect(() => {
// cookie();
if (logintoken === undefined) {
setCheck(false);
} else {
Expand Down
24 changes: 12 additions & 12 deletions src/component/FeedCateDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,17 @@ export default function FeedcateDetail( { categorytitle, setControl } : PROPS) {

return(<>
<div className="tab_detail">
<div className="high_var">
{/* <div className="high_var">
<p id="cate_name">{categorytitle}</p>
<button id="cateclose_btn" onClick={close_cate}>X</button>
</div>
<hr />
<hr /> */}
{/* 카테고리 목록 */}
<div className="tab_flex_table">
<div className="tab_menu_box">
{view_arr && view_arr.map((myarr, index)=>{
return(<>
<button key={index} className="cate_btn_dj" onClick={()=>cate_btn(myarr)}>{myarr}</button>
<br />
</>)
}
)}
Expand All @@ -213,15 +212,16 @@ export default function FeedcateDetail( { categorytitle, setControl } : PROPS) {
오류 예방
*/}
<p style={{"fontWeight" : "bold"}}>선택한 카테고리</p>
{chooseCa && chooseCa.map((myarr, index)=>{
return(<>
<div key={index} style={{"display":"flex"}} className="choose_small_box">
<p className="chooseCa">{myarr} </p>
<button className="catecancle_btn" onClick={() => del_choose(myarr)}> x</button>
</div>
<hr />
</>)
})}
<div id="choose_flex_box">
{chooseCa && chooseCa.map((myarr, index)=>{
return(<>
<div key={index} style={{"display":"flex"}} className="choose_small_box">
<p className="chooseCa">{myarr} </p>
<button className="catecancle_btn" onClick={() => del_choose(myarr)}> x</button>
</div>
</>)
})}
</div>
<button onClick={startSearch} id="chooseDone">완료</button>
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/component/FeedContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface LIKE {
interface FEEDATA {
boardId: number;
images: IMAGE;
createDate: string;
likeCount: number;
likelist: LIKE[];
nickName: string;
Expand Down Expand Up @@ -157,7 +158,7 @@ export default function FeedContents() {
return likelist.some((like) => like.nickName === userNickname);
};

// console.log("리코일스테이트로 잘 들어왔는지 확인", feedata);
console.log("리코일스테이트로 잘 들어왔는지 확인", feedata);

return (
<>
Expand Down Expand Up @@ -204,7 +205,7 @@ export default function FeedContents() {
width={100}
height={100}
/> */}
<img src={arr.weatherIcon} alt="날씨 아이콘">
<img src={arr.weatherIcon} alt="날씨 아이콘" id="weather_icon_dj">
</img>
</div>
<div>
Expand Down
2 changes: 1 addition & 1 deletion src/component/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default function LoginForm() {
<br />
<div className="login_linkbox">
<a className="link_pw">비밀번호 찾기</a> |
<a className="link_signup">회원가입</a>
<a className="link_signup" href="/register">회원가입</a>
</div>
<br />
<br />
Expand Down
7 changes: 6 additions & 1 deletion src/component/Profile.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
"use client";
import Image from "next/image";
import { ProfileTemperature } from "@/recoilAtom/ProfileTemperature";
import { useRecoilState } from "recoil";

interface ProfileProps {
nickName: string;
}

const Profile = ({ nickName }: ProfileProps): JSX.Element => {

const [profile_temperature, setProfileTemperature] = useRecoilState(ProfileTemperature);

return (
<div className="profile w-full h-20 flex items-center p-3">
<div className="img relative rounded-full overflow-hidden w-12 h-12 md:w-18 md:h-18 lg:w-18 lg:h-18">
Expand All @@ -19,7 +24,7 @@ const Profile = ({ nickName }: ProfileProps): JSX.Element => {
</div>
<div className="text flex flex-col ml-2">
<span>{nickName}</span>
<span>-5 ℃</span>
<span> {profile_temperature} </span>
</div>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions src/recoilAtom/FeedContents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface LIKE {
interface FEEDATA {
boardId: number;
images: IMAGE;
createDate?: string;
likeCount: number;
likelist: LIKE[];
nickName: string;
Expand Down
6 changes: 6 additions & 0 deletions src/recoilAtom/ProfileTemperature.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { atom } from "recoil";

export const ProfileTemperature = atom<string>({
key: "tem_key_profile", //전역적으로 유일한 값
default: "",
});
2 changes: 1 addition & 1 deletion src/style/GotoLogin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
border-radius: 4px;

height: 30px;
width: 20%;
width: 200px;

text-align: center;

Expand Down
2 changes: 1 addition & 1 deletion src/style/feed.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.container_dj{
width: 70%;
width: 90%;
}
Loading

0 comments on commit cf5526d

Please sign in to comment.