-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from daodaoedu/feature/1.2_profile_login
Feature/1.2 profile login
- Loading branch information
Showing
27 changed files
with
1,239 additions
and
1,158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React from 'react'; | ||
import { useState, useEffect } from 'react'; | ||
import { | ||
Box, | ||
Typography, | ||
|
@@ -8,7 +8,8 @@ import { | |
FormControlLabel, | ||
} from '@mui/material'; | ||
import { useRouter } from 'next/router'; | ||
import useFirebase from '../../../hooks/useFirebase'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { updateUser, userLogout } from '@/redux/actions/user'; | ||
|
||
const TypographyStyle = { | ||
fontFamily: 'Noto Sans TC', | ||
|
@@ -20,15 +21,35 @@ const TypographyStyle = { | |
}; | ||
|
||
const AccountSetting = () => { | ||
const { push } = useRouter(); | ||
const { auth, user, signInWithFacebook, signOutWithGoogle } = useFirebase(); | ||
const dispatch = useDispatch(); | ||
const router = useRouter(); | ||
|
||
const [isSubscribeEmail, setIsSubscribeEmail] = useState(false); | ||
const user = useSelector((state) => state.user); | ||
|
||
const onUpdateUser = () => { | ||
const payload = { | ||
email: user.email, | ||
isSubscribeEmail, | ||
}; | ||
dispatch(updateUser(payload)); | ||
}; | ||
|
||
const logout = () => { | ||
dispatch(userLogout()); | ||
router.push('/'); | ||
}; | ||
|
||
useEffect(() => { | ||
setIsSubscribeEmail(user?.isSubscribeEmail || false); | ||
}, [user]); | ||
|
||
return ( | ||
<Box | ||
sx={{ | ||
backgroundColor: '#ffffff', | ||
width: '672px', | ||
borderRadius: '16px', | ||
// border: '1px solid black', | ||
padding: '36px 40px', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
|
@@ -54,10 +75,10 @@ const AccountSetting = () => { | |
disabled | ||
sx={{ width: '100%', margin: '8px 0 30px 0' }} | ||
> | ||
[email protected] | ||
{user.email} | ||
</Button> | ||
</Box> | ||
<Box sx={{ display: 'flex', flexDirection: 'column' }}> | ||
{/* <Box sx={{ display: 'flex', flexDirection: 'column' }}> | ||
<Typography sx={TypographyStyle}>電話驗證</Typography> | ||
<Button | ||
variant="contained" | ||
|
@@ -70,15 +91,23 @@ const AccountSetting = () => { | |
> | ||
進行驗證 | ||
</Button> | ||
</Box> | ||
</Box> */} | ||
<Box sx={{ display: 'flex', flexDirection: 'column' }}> | ||
<Typography sx={TypographyStyle}>電子報</Typography> | ||
<FormControlLabel | ||
sx={{ | ||
marginTop: '20px', | ||
color: '#536166', | ||
}} | ||
control={<Checkbox />} | ||
control={ | ||
// eslint-disable-next-line react/jsx-wrap-multilines | ||
<Checkbox | ||
checked={isSubscribeEmail} | ||
onChange={(event) => { | ||
setIsSubscribeEmail(event.target.checked); | ||
// onUpdateUser();//待處理取消訂閱 | ||
}} | ||
/> | ||
} | ||
label="訂閱電子報與島島阿學的新資訊" | ||
/> | ||
</Box> | ||
|
@@ -92,10 +121,7 @@ const AccountSetting = () => { | |
margin: '24px 0 30px 0', | ||
backgroundColor: 'white', | ||
}} | ||
onClick={() => { | ||
signOutWithGoogle(); | ||
push('/'); | ||
}} | ||
onClick={logout} | ||
> | ||
登出 | ||
</Button> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
e6179ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
daodao-f2e – ./
daodao-f2e-daodaoedu.vercel.app
daodao-f2e-git-dev-daodaoedu.vercel.app
daodao-f2e.vercel.app