Skip to content

Commit

Permalink
Merge pull request #33 from daodaoedu/fix/sendemail
Browse files Browse the repository at this point in the history
fix: 發送 Email 內容- 角色及切換訂閱電子報
  • Loading branch information
hsuifang authored Jan 25, 2024
2 parents 10f41fa + d25d8b0 commit 1cb36b1
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const PartnerCardTag = ({ tagList = [] }) => {
tagList.length > 0 && (
<StyledTagContainer container gap="8px" mb="12px">
{showItems
.filter((t) => typeof t === 'string' && t !== '')
.filter((t) => typeof t === 'string' && t.trim() !== '')
.map((tag) => (
<StyledTagText item key={tag} fontWeight="400">
{tag}
Expand Down
78 changes: 43 additions & 35 deletions components/Profile/Accountsetting/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,25 @@ import {
import { useRouter } from 'next/router';
import { useDispatch, useSelector } from 'react-redux';
import { updateUser, userLogout } from '@/redux/actions/user';
import styled from '@emotion/styled';

const TypographyStyle = {
fontFamily: 'Noto Sans TC',
fontStyle: 'normal',
fontWeight: '500',
fontSize: '16px',
lineHeight: '140%',
color: '#293A3D',
};
const StyledTypographyStyle = styled(Typography)`
font-family: Noto Sans TC;
font-style: normal;
font-weight: 500;
font-size: 16px;
line-height: 1.4;
color: #293a3d;
`;

const StyledLogoutBtn = styled(Button)`
border-radius: 20px;
background: #fff;
color: #1f4645;
padding: 5px 0;
/* shadow-light-gray */
box-shadow: 0px 4px 10px 0px rgba(196, 194, 193, 0.4);
`;

const AccountSetting = () => {
const dispatch = useDispatch();
Expand All @@ -27,10 +37,11 @@ const AccountSetting = () => {
const [isSubscribeEmail, setIsSubscribeEmail] = useState(false);
const user = useSelector((state) => state.user);

const onUpdateUser = () => {
const onUpdateUser = (status) => {
const payload = {
id: user._id,
email: user.email,
isSubscribeEmail,
isSubscribeEmail: status,
};
dispatch(updateUser(payload));
};
Expand All @@ -42,7 +53,7 @@ const AccountSetting = () => {

useEffect(() => {
setIsSubscribeEmail(user?.isSubscribeEmail || false);
}, [user]);
}, [user.isSubscribeEmail]);

return (
<Box
Expand All @@ -69,14 +80,20 @@ const AccountSetting = () => {
}}
>
<Box sx={{ display: 'flex', flexDirection: 'column', width: '100%' }}>
<Typography sx={TypographyStyle}>電子信箱</Typography>
<Button
variant="contained"
disabled
sx={{ width: '100%', margin: '8px 0 30px 0' }}
<StyledTypographyStyle>電子信箱</StyledTypographyStyle>
<Box
sx={{
width: '100%',
margin: '8px 0 30px 0',
borderRadius: '8px',
border: '1px solid #DBDBDB',
background: '#F3F3F3',
padding: '12px 16px',
color: '#92989A',
}}
>
{user.email}
</Button>
</Box>
</Box>
{/* <Box sx={{ display: 'flex', flexDirection: 'column' }}>
<Typography sx={TypographyStyle}>電話驗證</Typography>
Expand All @@ -93,38 +110,29 @@ const AccountSetting = () => {
</Button>
</Box> */}
<Box sx={{ display: 'flex', flexDirection: 'column' }}>
<Typography sx={TypographyStyle}>電子報</Typography>
<StyledTypographyStyle>電子報</StyledTypographyStyle>
<FormControlLabel
sx={{
marginTop: '20px',
}}
control={
// eslint-disable-next-line react/jsx-wrap-multilines
<Checkbox
checked={isSubscribeEmail}
onChange={(event) => {
setIsSubscribeEmail(event.target.checked);
// onUpdateUser();//待處理取消訂閱
onUpdateUser(event.target.checked);
}}
/>
}
label="訂閱電子報與島島阿學的新資訊"
/>
</Box>
<Divider sx={{ color: '#F3F3F3', margin: '6px 0' }} />
<Divider
sx={{ width: '100%', color: '#000', margin: '30px 0', height: '2px' }}
/>
<Box sx={{ display: 'flex', flexDirection: 'column', width: '100%' }}>
<Typography sx={TypographyStyle}>登出帳號</Typography>
<Button
variant="contained"
sx={{
width: '100%',
margin: '24px 0 30px 0',
backgroundColor: 'white',
}}
onClick={logout}
>
登出
</Button>
<StyledTypographyStyle sx={{ mb: '24px' }}>
登出帳號
</StyledTypographyStyle>
<StyledLogoutBtn onClick={logout}>登出</StyledLogoutBtn>
</Box>
</Box>
</Box>
Expand Down
3 changes: 2 additions & 1 deletion pages/partner/detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const Detail = () => {
sendEmailToPartner({
to: partner.email,
name,
roleList: roleList.length > 0 ? roleList : [''],
roleList:
roleList.length > 0 ? roleList.map((role) => ROLELIST[role]) : [''],
photoURL,
text: message,
information: [loginUserEmail, contact],
Expand Down

1 comment on commit 1cb36b1

@vercel
Copy link

@vercel vercel bot commented on 1cb36b1 Jan 25, 2024

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.vercel.app
daodao-f2e-git-dev-daodaoedu.vercel.app

Please sign in to comment.