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

๐Ÿšจ Fix/common/directory #49

Merged
merged 4 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion src/components/UserText/UserId.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import styled from '@emotion/styled';

export const UserIdSpan = styled.span`
font-size: 16px;
color: ${({ theme }) => theme.greyLight};
color: ${({ theme }) => theme.color.greyLight};
`;
2 changes: 1 addition & 1 deletion src/components/UserText/UserName.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import styled from '@emotion/styled';
export const UserNameSpan = styled.span`
font-size: 16px;
font-weight: 700;
color: ${({ theme }) => theme.black};
color: ${({ theme }) => theme.color.black};
`;
File renamed without changes.
62 changes: 62 additions & 0 deletions src/pages/landing/Landing.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Link } from '@components/Link';
import { Button } from '@components/Button';
import { Icon } from '@components/Icon';
import {
LandingMain,
Heading,
PreviewLink,
PreviewSpan,
LinkContainer
} from './Landing.style';

const LandingPage = () => {
return (
<LandingMain>
<Heading />
<PreviewLink>
<PreviewSpan>๋‹ค๋ฅธ ์‚ฌ๋žŒ๋“ค์˜ ํ›„๊ธฐ๋ฅผ ๋จผ์ € ๋งŒ๋‚˜๋ณด์„ธ์š”.</PreviewSpan>
<Link
pageLink='/posts'
size={12}
color='white'>
๋ช…์ƒ ํ›„๊ธฐ ๋ณด๋Ÿฌ๊ฐ€๊ธฐ
<Icon
name='arrow_forward'
size={11}
color='white'
/>
</Link>
</PreviewLink>
<LinkContainer>
<Link
pageLink='/login'
size={16}
color='white'>
<Button
width={300}
height={50}
label='๋กœ๊ทธ์ธ'
handleClick={() => {}}
dark={false}
bold={false}
/>
</Link>
<Link
pageLink='/signup'
size={16}
color='white'>
<Button
width={300}
height={50}
label='ํšŒ์›๊ฐ€์ž…'
handleClick={() => {}}
dark={true}
bold={false}
/>
</Link>
</LinkContainer>
</LandingMain>
);
};

export default LandingPage;
60 changes: 1 addition & 59 deletions src/pages/landing/index.tsx
Original file line number Diff line number Diff line change
@@ -1,61 +1,3 @@
import { Link } from '@components/Link';
import { Button } from '@components/Button';
import { Icon } from '@components/Icon';
import {
LandingMain,
Heading,
PreviewLink,
PreviewSpan,
LinkContainer
} from './style';

const LandingPage = () => {
return (
<LandingMain>
<Heading />
<PreviewLink>
<PreviewSpan>๋‹ค๋ฅธ ์‚ฌ๋žŒ๋“ค์˜ ํ›„๊ธฐ๋ฅผ ๋จผ์ € ๋งŒ๋‚˜๋ณด์„ธ์š”.</PreviewSpan>
<Link
pageLink='/posts'
size={12}
color='white'>
๋ช…์ƒ ํ›„๊ธฐ ๋ณด๋Ÿฌ๊ฐ€๊ธฐ
<Icon
name='arrow_forward'
size={11}
color='white'></Icon>
</Link>
</PreviewLink>
<LinkContainer>
<Link
pageLink='/login'
size={16}
color='white'>
<Button
width={300}
height={50}
label='๋กœ๊ทธ์ธ'
handleClick={() => {}}
dark={false}
bold={false}
/>
</Link>
<Link
pageLink='/signup'
size={16}
color='white'>
<Button
width={300}
height={50}
label='ํšŒ์›๊ฐ€์ž…'
handleClick={() => {}}
dark={true}
bold={false}
/>
</Link>
</LinkContainer>
</LandingMain>
);
};
import LandingPage from './Landing';

export default LandingPage;
File renamed without changes.
18 changes: 18 additions & 0 deletions src/pages/layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Outlet } from 'react-router';
import { Header } from '@components/Header';
import { LayoutContainer } from './Layout.style';
import { Footer } from '@components/Footer';

const Layout = () => {
return (
<>
<Header />
<LayoutContainer>
<Outlet />
</LayoutContainer>
<Footer />
</>
);
};

export default Layout;
17 changes: 1 addition & 16 deletions src/pages/layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
import { Outlet } from 'react-router';
import { Header } from '@components/Header';
import { LayoutContainer } from './styles';
import { Footer } from '@components/Footer';

const Layout = () => {
return (
<>
<Header />
<LayoutContainer>
<Outlet />
</LayoutContainer>
<Footer />
</>
);
};
import Layout from './Layout';

export default Layout;
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import styled from '@emotion/styled';
import logo from '@assets/logo.svg';

const LogoContainer = styled.div`
export const LogoContainer = styled.div`
margin-bottom: 80px;
`;

const Logo = () => {
export const Logo = () => {
return (
<svg
width='223'
Expand All @@ -21,7 +21,7 @@ const Logo = () => {
);
};

const LoginContainer = styled.div`
export const LoginContainer = styled.div`
${({ theme }) => theme.style.flexCenter};
flex-direction: column;
width: 100vw;
Expand All @@ -30,7 +30,7 @@ const LoginContainer = styled.div`
background: ${({ theme }) => theme.color.linearGradientPurple};
`;

const LoginForm = styled.form`
export const LoginForm = styled.form`
background-color: ${({ theme }) => theme.color.white};
${({ theme }) => theme.style.flexCenter};
flex-direction: column;
Expand All @@ -42,10 +42,8 @@ const LoginForm = styled.form`
border-radius: 10px;
`;

const ButtonContainer = styled.div`
export const ButtonContainer = styled.div`
${({ theme }) => theme.style.flexJustifyCenter};
width: 300px;
margin-top: 15px;
`;

export { LoginForm, ButtonContainer, LoginContainer, LogoContainer, Logo };
110 changes: 110 additions & 0 deletions src/pages/login/Login.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import postLogInUser from '@apis/login';
import { Button } from '@components/Button';
import { UserInput } from '@components/UserInput';
import { USER_INPUT } from './constants';
import { GoToSignUp } from './components';
import {
LoginForm,
ButtonContainer,
LoginContainer,
LogoContainer,
Logo
} from './Login.style';
import useSessionStorage from '@hooks/useSessionStorage';
import { User } from '@/types';

const Login = () => {
const [email, setEmail] = useState<string>('');
const [password, setPassword] = useState<string>('');
const [errorCatched, setErrorCatched] = useState<boolean>(false);
const navigate = useNavigate();
let timer = 0;

const [userSessionData, setUserSessionData] = useSessionStorage<
Pick<User, '_id' | 'token'>
>('userData', {
_id: '',
token: ''
});

useEffect(() => {
if (userSessionData.token) {
navigate('/meditation');
}
}, [userSessionData, navigate]);

const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
event.preventDefault();
const { name, value } = event.target;

if (timer) {
clearTimeout(timer);
}
timer = setTimeout(() => {
switch (name) {
case 'email':
setEmail(value);
break;
case 'password':
setPassword(value);
break;
default:
break;
}
}, 200);
};

const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
postLogInUser({ email, password })
.then((res) => {
const { user, token } = res.data;
setUserSessionData({ _id: user._id, token });
})
.catch((err) => {
console.log(err);
setErrorCatched(true);
});
};

return (
<LoginContainer>
<LogoContainer>
<Logo />
</LogoContainer>

<LoginForm onSubmit={handleSubmit}>
<UserInput
name={USER_INPUT.EMAIL.NAME}
placeholder={USER_INPUT.EMAIL.PLACE_HOLDER}
title={USER_INPUT.EMAIL.TITLE}
handleChange={handleInputChange}
show={errorCatched}
errorMessage={USER_INPUT.ERROR_MESSAGE}
/>
<UserInput
name={USER_INPUT.PASSWORD.NAME}
placeholder={USER_INPUT.PASSWORD.PLACE_HOLDER}
title={USER_INPUT.PASSWORD.TITLE}
handleChange={handleInputChange}
type={USER_INPUT.PASSWORD.TYPE}
/>
<ButtonContainer>
<Button
label='๋กœ๊ทธ์ธ'
width={300}
height={45}
bold={false}
dark={true}
handleClick={() => handleSubmit}
/>
</ButtonContainer>
<GoToSignUp />
</LoginForm>
</LoginContainer>
);
};

export default Login;
17 changes: 17 additions & 0 deletions src/pages/login/components/GoToSignUp.style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import styled from '@emotion/styled';

export const GoToSignUpContainer = styled.div`
margin-top: 30px;
${({ theme }) => theme.style.flexAlignCenter};
flex-direction: column;
`;

export const Message = styled.span`
color: ${({ theme }) => theme.color.greyLight};
font-size: 14px;
margin-bottom: 10px;
`;

export const LinkContainer = styled.div`
${({ theme }) => theme.style.flexCenter};
`;
22 changes: 5 additions & 17 deletions src/pages/login/components/GoToSignUp.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
import styled from '@emotion/styled';
import { Link } from '@components/Link';
import { Icon } from '@components/Icon';
import { MESSAGE, LABEL } from '../constants';

const GoToSignUpContainer = styled.div`
margin-top: 30px;
${({ theme }) => theme.style.flexAlignCenter};
flex-direction: column;
`;

const Message = styled.span`
color: ${({ theme }) => theme.color.greyLight};
font-size: 14px;
margin-bottom: 10px;
`;

const LinkContainer = styled.div`
${({ theme }) => theme.style.flexCenter};
`;
import {
GoToSignUpContainer,
Message,
LinkContainer
} from './GoToSignUp.style';

const GoToSignUp = () => {
return (
Expand Down
Loading