Skip to content

Commit

Permalink
fix(logic) : 소셜로그인 => 체험형
Browse files Browse the repository at this point in the history
  • Loading branch information
chhw130 committed Dec 16, 2023
1 parent 6691efe commit 62166cb
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 70 deletions.
15 changes: 5 additions & 10 deletions component/Funnel/LoginFunnel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,9 @@ import VerticalLogoIcon from "../icon/VerticalLogoIcon";
const LoginFunnel = () => {
const router = useRouter();

const Rest_api_key = "536cb646ce60d71102dc92d2b7845c8d"; //REST API KEY
const redirect_uri = "http://localhost:3000/signup"; //Redirect URI
// oauth 요청 URL
const kakaoURL = `https://kauth.kakao.com/oauth/authorize?client_id=${Rest_api_key}&redirect_uri=${redirect_uri}&response_type=code`;

const signUpKakaoHandler = () => {
window.location.href = kakaoURL;
};
// const signUpKakaoHandler = () => {
// window.location.href = kakaoURL;
// };

return (
<VStack w={"100%"} h={"100%"} justifyContent={"center"}>
Expand All @@ -32,9 +27,9 @@ const LoginFunnel = () => {
flexDir={"column"}
gap={"20px"}
>
<Box onClick={() => signUpKakaoHandler()} cursor={"pointer"}>
{/* <Box onClick={() => signUpKakaoHandler()} cursor={"pointer"}>
<KaKaoButtonIcon />
</Box>
</Box> */}

<Text
as={"u"}
Expand Down
73 changes: 40 additions & 33 deletions component/Funnel/MainFunnel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ const MainFunnel = ({ setFunnel }: MainFunnelPropsType) => {

return (
<>
<VStack spacing={"16px"} as="section" marginTop={"71px"}>
<VStack
w={"#100%"}
h={"100%"}
spacing={"16px"}
as="section"
marginTop={"71px"}
>
<Heading
as={"h1"}
color={"#FFFFFF"}
Expand All @@ -44,40 +50,41 @@ const MainFunnel = ({ setFunnel }: MainFunnelPropsType) => {
</Text>
을 추천 받자!
</Heading>
</VStack>

<Card bgColor={"#FFFFFF20"} marginTop={"71px"}>
<CardBody textAlign={"center"} color={"#D2D2D2"}>
나.. 오늘 얼마나 먹었더라?
<br />안 찌려면 얼마만큼 운동해야하지?
</CardBody>
</Card>
<Image
src={MainPageDiet}
alt="식선생"
placeholder="blur"
style={{ width: "100%", height: "auto" }}
quality={100}
/>

<ButtonGroup
width={"100%"}
pos={"absolute"}
bottom={"100px"}
padding={"0 22px"}
justifyContent={"center"}
>
<MainButton
w={"100%"}
h={"52px"}
bgColor={"#40E98E"}
onClick={() => {
setFunnel("login");
}}
<VStack spacing={"1px"} marginTop={"10%"}>
<Card bgColor={"#FFFFFF20"}>
<CardBody textAlign={"center"} color={"#D2D2D2"}>
나.. 오늘 얼마나 먹었더라?
<br />안 찌려면 얼마만큼 운동해야하지?
</CardBody>
</Card>
<Image
src={MainPageDiet}
alt="식선생"
placeholder="blur"
style={{ width: "100%", height: "auto" }}
quality={100}
/>
</VStack>
<ButtonGroup
width={"100%"}
pos={"absolute"}
bottom={"100px"}
padding={"0 22px"}
justifyContent={"center"}
>
<Text color={"#2B2C2C"}>다음으로</Text>
</MainButton>
</ButtonGroup>
<MainButton
w={"100%"}
h={"52px"}
bgColor={"#40E98E"}
onClick={() => {
setFunnel("login");
}}
>
<Text color={"#2B2C2C"}>다음으로</Text>
</MainButton>
</ButtonGroup>
</VStack>
</>
);
};
Expand Down
10 changes: 1 addition & 9 deletions component/template/MyPageTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ const MyPageTemplate = () => {
const router = useRouter();
const [userData, setUserData] = useState<UserInfoType>();

useEffect(() => {
let userInfo = localStorage.getItem("userInfo");
if (userInfo !== null) {
const userParsing: UserInfoType = JSON.parse(userInfo);
console.log(userParsing);
setUserData(userParsing);
}
}, [setUserData]);

return (
<>
<Flex
Expand All @@ -29,6 +20,7 @@ const MyPageTemplate = () => {
h={"100vh"}
pos={"relative"}
maxW={"390px"}
minH={"844px"}
padding={"60px 22px 0px 22px"}
margin={"0 auto"}
alignItems={"center"}
Expand Down
8 changes: 1 addition & 7 deletions component/template/SignupTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface UserInfoType {
targetweight: number;
}

const SignupTemplate = ({ jwtToken }: { jwtToken: JwtToken }) => {
const SignupTemplate = ({ jwtToken }: { jwtToken?: JwtToken }) => {
const [progress, setProgress] = useState<number>(33.3);
const [userInfo, setUserInfo] = useState<UserInfoType>({
name: "",
Expand All @@ -29,12 +29,6 @@ const SignupTemplate = ({ jwtToken }: { jwtToken: JwtToken }) => {
});
const { funnel, setFunnel } = useFunnel("userAgreement");

useEffect(() => {
if (jwtToken) {
localStorage.setItem("jwt", jwtToken.jwt);
}
}, [jwtToken]);

return (
<>
<Progress
Expand Down
1 change: 1 addition & 0 deletions src/app/detail/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const Page = () => {
h={"100vh"}
pos={"relative"}
maxW={"390px"}
minH={"844px"}
padding={"60px 22px 0px 22px"}
margin={"0 auto"}
alignItems={"center"}
Expand Down
7 changes: 1 addition & 6 deletions src/app/main/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ const Page = () => {
reset,
} = useForm<DietMsgType>();

useEffect(() => {
const jwt = localStorage.getItem("jwt");
const userInfo = localStorage.getItem("userInfo");
if (!jwt && !userInfo) return redirect("/");
}, []);

const onSubmit: SubmitHandler<DietMsgType> = async (data) => {
reset();
await postUserDietMutation(data.msg);
Expand All @@ -53,6 +47,7 @@ const Page = () => {
margin={"0 auto"}
bgColor={"#2B2C2C"}
alignItems={"center"}
minH={"844px"}
>
<TheHeader>
<TextLogoIcon />
Expand Down
10 changes: 5 additions & 5 deletions src/app/signup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ const Page = async ({
}: {
searchParams: { code: string; error: string };
}) => {
const kakaoCode = searchParams.code;
// const kakaoCode = searchParams.code;

const errorCode = searchParams.error;
if (errorCode) return redirect("/");
// const errorCode = searchParams.error;
// if (errorCode) return redirect("/");

const jwtToken: JwtToken = await postKakaoCode(kakaoCode);
// const jwtToken: JwtToken = await postKakaoCode(kakaoCode);

return <SignupTemplate jwtToken={jwtToken} />;
return <SignupTemplate />;
};

export default Page;

0 comments on commit 62166cb

Please sign in to comment.