Skip to content

Commit

Permalink
Merge branch 'develop' into feat/#101
Browse files Browse the repository at this point in the history
  • Loading branch information
hyo-4 committed May 20, 2024
2 parents 2e581b0 + d0ad046 commit d802713
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 11 deletions.
Binary file added public/assets/profile1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/profile2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/profile3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/profile4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/profile5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/components/common/MainButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const MainButton = ({ children, ...props }: MainButtonProps) => {
const Button = styled.button`
flex-shrink: 0;
border-radius: 67.408px;
background: var(--main-500, #7d82ff);
background: ${(props) => props.theme.colors.main500};
padding: 22px 44px;
color: white;
border: none;
Expand All @@ -20,6 +20,9 @@ const Button = styled.button`
justify-content: center;
${(props) => props.theme.fonts.title4};
gap: 5px;
&:disabled {
background: ${(props) => props.theme.colors.neutral500};
}
`;

export default MainButton;
27 changes: 23 additions & 4 deletions src/components/common/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const Navbar = () => {
const location = useLocation();
const user = getCookie("user");

const handleImgError = (e: React.SyntheticEvent<HTMLImageElement, Event>) => {
e.currentTarget.src = `${process.env.PUBLIC_URL}/assets/profile1.png`;
};

return (
<NavContainer>
<ItemContainer>
Expand All @@ -32,9 +36,24 @@ const Navbar = () => {
</ItemContainer>
<ItemContainer>
{user?.token ? (
<UserInfo onClick={() => navigate(`/profile`)}>
{user?.nickName}
</UserInfo>
<>
<img
src={
user?.profileImgUrl ||
`${process.env.PUBLIC_URL}/assets/profile1.png`
}
alt="profile"
style={{
width: "32px",
height: "32px",
borderRadius: "50%",
}}
onError={handleImgError}
/>
<UserInfo onClick={() => navigate(`/profile`)}>
{user?.nickName}
</UserInfo>
</>
) : (
<LoginButton onClick={() => navigate(`/sign-in`)}>로그인</LoginButton>
)}
Expand Down Expand Up @@ -62,7 +81,7 @@ const ItemContainer = styled.div`
display: flex;
flex-direction: row;
align-items: center;
gap: 2.5rem;
gap: 0.5rem;
`;

const MenuList = styled.div`
Expand Down
8 changes: 8 additions & 0 deletions src/pages/SignInPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ const SignInPage = () => {
// 기존 계정 (로그인)
else {
const token = res.data.accessToken;
const refreshToken = res.data.refreshToken;
getUserInfo(token)
.then((res) =>
setCookie("user", {
nickName: res.data.nickName,
profileImgUrl: res.data.profileImgUrl,
provider: "KAKAO",
email: res.data.email,
token: token,
refreshToken: refreshToken,
})
)
.then(() => navigate("/experience"));
Expand Down Expand Up @@ -83,12 +87,16 @@ const SignInPage = () => {
// 기존 계정 (로그인)
else {
const token = res.data.accessToken;
const refreshToken = res.data.refreshToken;
getUserInfo(token)
.then((res) =>
setCookie("user", {
nickName: res.data.nickName,
profileImgUrl: res.data.profileImgUrl,
provider: "GOOGLE",
email: res.data.email,
token: token,
refreshToken: refreshToken,
})
)
.then(() => navigate("/experience"));
Expand Down
22 changes: 16 additions & 6 deletions src/pages/SignupPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import { RegisterDataType } from "../types/user";
import { getCookie, setCookie } from "../services/cookie";

const profileImgUrl = [
"../assets/images/profile1.png",
"../assets/images/profile2.png",
"../assets/images/profile3.png",
"../assets/images/profile4.png",
"../assets/images/profile5.png",
"/assets/profile1.png",
"/assets/profile2.png",
"/assets/profile3.png",
"/assets/profile4.png",
"/assets/profile5.png",
];

const SignupPage = () => {
Expand All @@ -40,6 +40,7 @@ const SignupPage = () => {
goal: "",
dream: "",
});
const [isLoading, setIsLoading] = React.useState(false);

const [isModalOpen, setIsModalOpen] = React.useState(false); // 저장 모달

Expand Down Expand Up @@ -68,18 +69,24 @@ const SignupPage = () => {

const handleRegister = () => {
register(registerData).then((res) => {
setIsLoading(true);
const token = res.data.accessToken;
const refreshToken = res.data.refreshToken;
getUserInfo(token)
.then((res) => {
setCookie("user", {
...user,
nickName: res.data.nickName,
profileImgUrl: res.data.profileImgUrl,
provider: res.data.provider,
email: res.data.email,
token: token,
refreshToken: refreshToken,
});
})
.then(() => openModal());
});
setIsLoading(false);
};

return (
Expand Down Expand Up @@ -254,9 +261,12 @@ const SignupPage = () => {
style={{ background: theme.colors.neutral100 }}
/>
<MainButton
disabled={
isLoading ||
!(registerData.profileImgUrl && registerData.nickName)
}
style={{
borderRadius: "8px",
background: theme.colors.neutral500,
}}
onClick={handleRegister}
>
Expand Down
5 changes: 5 additions & 0 deletions src/services/user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ export const login = async (loginType: string, accessToken: string) => {
});
};

// 로그아웃
export const logout = async (refreshToken: string) => {
return await client.delete(`/api/auth/logout`);
};

// 회원가입
export const register = async ({
registrationToken,
Expand Down

0 comments on commit d802713

Please sign in to comment.