Skip to content

Commit e11a600

Browse files
authored
Merge pull request #14 from AIVLE-School-Third-Big-Project/mergeTemp
✨ Feat : 추가 마이페이지 기능
2 parents e8709d7 + f98a544 commit e11a600

File tree

14 files changed

+366
-85
lines changed

14 files changed

+366
-85
lines changed

style/src/components/MainPage/Content.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ import sizeListIcon1 from '../../images/sizeListIcon1.png'
88
import sizeListIcon2 from '../../images/sizeListIcon2.png'
99
import GrayButton from './GrayButton'
1010
import { Link } from 'react-router-dom'
11-
import { useSelector } from 'react-redux'
1211

1312
function Content() {
14-
const isAuthenticated = useSelector((state) => state.auth.isAuthenticated)
15-
console.log(`auth1 : ${isAuthenticated}`)
1613
return (
1714
<div className="mainPageContent">
1815
<section className="homeMainSection">

style/src/components/MainPage/MainPage.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import Navigation from '../Navigationbar/Nav.js'
22
import Footer from '../Footer.js'
33
import Content from './Content.js'
4-
import { useSelector } from 'react-redux'
54

65
function MainPage() {
7-
const user = useSelector((state) => state.auth.user)
8-
console.log('aa')
9-
console.log(user)
106
return (
117
<div className="mainPage">
128
<Navigation></Navigation>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import Alert from 'react-bootstrap/Alert'
2+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
3+
import { solid } from '@fortawesome/fontawesome-svg-core/import.macro'
4+
import styles from './MyPage.module.css'
5+
6+
function AlertMessage({ variant, message, show, setShow }) {
7+
return (
8+
<Alert
9+
className={styles.alertMessageBox}
10+
variant={variant}
11+
show={show}
12+
onClose={() => setShow(false)}
13+
dismissible
14+
style={{ position: 'absolute' }}
15+
>
16+
{variant === 'success' && (
17+
<FontAwesomeIcon icon={solid('circle-check')} />
18+
)}
19+
{variant === 'danger' && (
20+
<FontAwesomeIcon icon={solid('circle-exclamation')} />
21+
)}
22+
{' '}
23+
{message}
24+
</Alert>
25+
)
26+
}
27+
28+
export default AlertMessage
Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ClassMerger from '../tools/ClassNameGenerater'
2-
import Proptypes from 'prop-types'
2+
// import Proptypes from 'prop-types'
33
import { Form } from 'react-bootstrap'
44
import styles from './MyPage.module.css'
55

@@ -11,8 +11,9 @@ function FormBox({
1111
max,
1212
pattern,
1313
setState,
14-
inputHandler,
1514
value,
15+
isInvalid,
16+
invalidTest,
1617
disabled = false,
1718
}) {
1819
return (
@@ -28,29 +29,30 @@ function FormBox({
2829
max={max}
2930
pattern={pattern}
3031
disabled={disabled}
31-
isInvalid={true}
32+
isInvalid={isInvalid}
3233
value={value}
34+
formNoValidate
3335
onChange={(event) => {
34-
console.log(event)
35-
inputHandler(event, setState)
36+
const input = event.target.value
37+
setState(input)
3638
}}
3739
/>
38-
<Form.Control.Feedback type="invalid" isInvalid={true}>
39-
패턴에 맞지 않는 값입니다.
40+
<Form.Control.Feedback type="invalid">
41+
{invalidTest}
4042
</Form.Control.Feedback>
4143
</Form.Group>
4244
)
4345
}
4446

45-
FormBox.propTypes = {
46-
id: Proptypes.string.isRequired,
47-
label: Proptypes.string.isRequired,
48-
type: Proptypes.string.isRequired,
49-
data: Proptypes.string.isRequired,
50-
min: Proptypes.string,
51-
max: Proptypes.string,
52-
pattern: Proptypes.string,
53-
disabled: Proptypes.bool,
54-
}
47+
// FormBox.propTypes = {
48+
// id: Proptypes.string.isRequired,
49+
// label: Proptypes.string.isRequired,
50+
// type: Proptypes.string.isRequired,
51+
// min: Proptypes.string,
52+
// max: Proptypes.string,
53+
// pattern: Proptypes.string,
54+
// setState: Proptypes.func,
55+
// disabled: Proptypes.bool,
56+
// }
5557

5658
export default FormBox

style/src/components/MyPage/LeftSubMyPage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function LeftSubMyPage({ page, onClickHandler }) {
4646
page={page}
4747
onClick={onClickHandler}
4848
/>
49-
<TransButton
49+
{/* <TransButton
5050
context={'옷장'}
5151
option={'closet'}
5252
page={page}
@@ -57,7 +57,7 @@ function LeftSubMyPage({ page, onClickHandler }) {
5757
option={'style'}
5858
page={page}
5959
onClick={onClickHandler}
60-
/>
60+
/> */}
6161
</div>
6262
)
6363
}

style/src/components/MyPage/MyPage.js

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,54 @@ import styles from './MyPage.module.css'
33
import LeftSubMyPage from './LeftSubMyPage'
44
import RightSubMyPage from './RightSubMyPage'
55
import Navigation from '../Navigationbar/Nav.js'
6+
import { Navigate } from 'react-router-dom'
7+
import AlertMessage from './AlertMessage'
8+
9+
function MyPage({ currPage = 'privacy' }) {
10+
const [page, setPage] = useState(currPage)
11+
const [isSaveComplete, setIsSaveComplete] = useState(false)
12+
const [isShowAlert, setIsShowAlert] = useState(false)
613

7-
function MyPage() {
8-
const [page, setPage] = useState('privacy')
914
const changePage = (pageName) => {
1015
setPage(pageName)
11-
console.log(pageName)
1216
}
1317

14-
return (
15-
<>
16-
<Navigation />
17-
<div className={styles.mainContainer}>
18-
<LeftSubMyPage page={page} onClickHandler={changePage} />
19-
<RightSubMyPage page={page} />
20-
</div>
21-
</>
22-
)
18+
const lsUser = JSON.parse(localStorage.getItem('user'))
19+
const lsToken = localStorage.getItem('token')
20+
21+
if (lsUser && lsToken) {
22+
return (
23+
<>
24+
<div className={styles.myPageRoot}></div>
25+
<Navigation />
26+
<div className={styles.mainContainer}>
27+
<LeftSubMyPage page={page} onClickHandler={changePage} />
28+
<RightSubMyPage
29+
page={page}
30+
setIsShowAlert={setIsShowAlert}
31+
setIsSaveComplete={setIsSaveComplete}
32+
/>
33+
</div>
34+
{isSaveComplete ? (
35+
<AlertMessage
36+
variant="success"
37+
message={'저장에 성공하였습니다.'}
38+
show={isShowAlert}
39+
setShow={setIsShowAlert}
40+
/>
41+
) : (
42+
<AlertMessage
43+
variant="danger"
44+
message={'저장에 실패하였습니다. 다시 한번 시도해 주세요.'}
45+
show={isShowAlert}
46+
setShow={setIsShowAlert}
47+
/>
48+
)}
49+
</>
50+
)
51+
} else {
52+
return <Navigate to={'/'} />
53+
}
2354
}
2455

2556
export default MyPage

style/src/components/MyPage/MyPage.module.css

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
@import url('https://cdn.rawgit.com/moonspam/NanumSquare/master/nanumsquare.css');
99

10+
.myPageRoot {
11+
position: relative;
12+
}
13+
1014
.mainContainer {
1115
--nav-height : 95px;
1216
--max-width : 1920px;
@@ -86,12 +90,34 @@
8690
padding-left: var(--rightContainer-padding-left);
8791
}
8892

93+
.alertContainer {
94+
position: absolute;
95+
96+
}
97+
/* .alert {
98+
position: none;
99+
} */
100+
/* #alertMessageBox {
101+
position: absolute;
102+
top: 50%;
103+
left: 50%;
104+
transform: translate(-50%, -50%);
105+
z-index: 9999;
106+
} */
107+
.alertMessageBox {
108+
/* all: unset; */
109+
top: 10%;
110+
left: 50%;
111+
transform: translate(-50%, -50%);
112+
z-index: 9999;
113+
}
114+
89115
.formGroup {
90116
padding-right: var(--rightContainer-padding-left);
91117
}
92118

93119
.formLabel {
94-
margin: 0px;
120+
margin: 0px 0px 8px 0px;
95121
padding: 0px;
96122
}
97123

@@ -107,6 +133,48 @@
107133
font-weight: 600;
108134
}
109135

136+
.maleButton {
137+
width: 250px;
138+
height: 46px;
139+
border: 2px solid #d7d7d7;
140+
border-radius: 14px;
141+
background-color: white;
142+
margin-right: 18px;
143+
144+
color: #6d6d6d;
145+
font-family: 'NanumSquare';
146+
font-size: 18px;
147+
font-weight: 600;
148+
transition: all 0.2s ease-out;
149+
}
150+
151+
.maleSelected,
152+
.maleButton:hover {
153+
background-color: #c0dfff;
154+
color: black;
155+
}
156+
157+
.femaleButton {
158+
width: 250px;
159+
height: 46px;
160+
border: 2px solid #d7d7d7;
161+
border-radius: 14px;
162+
background-color: white;
163+
margin-left: 18px;
164+
165+
color: #6d6d6d;
166+
font-family: 'NanumSquare';
167+
font-size: 18px;
168+
font-weight: 600;
169+
transition: all 0.2s ease-out;
170+
}
171+
172+
.femaleSelected,
173+
.femaleButton:hover {
174+
background-color: #fca8a5;
175+
color: black;
176+
}
177+
110178
.submitWarpper {
111179
text-align: right;
112180
padding-right: var(--rightContainer-padding-left);

0 commit comments

Comments
 (0)