Skip to content

Commit

Permalink
fix: send email to group own (#60)
Browse files Browse the repository at this point in the history
* fix: vercel auto deploy config

* fix: send email to group own
  • Loading branch information
JohnsonMao authored Jul 7, 2024
1 parent be32a73 commit c26c374
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 33 deletions.
3 changes: 1 addition & 2 deletions components/Group/detail/Contact/Feedback.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ function Feedback({ type, onClose }) {
error: {
imgSrc: contractErrorImg.src,
imgAlt: 'error cover',
// title: '哎呀!有不明錯誤',
title: '目前功能還在測試階段,敬請期待!',
title: '哎呀!有不明錯誤',
buttonText: '再試一次',
},
};
Expand Down
54 changes: 31 additions & 23 deletions components/Group/detail/Contact/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ import {
useMediaQuery,
} from '@mui/material';
import CloseIcon from '@mui/icons-material/Close';
import { BASE_URL } from '@/constants/common';
import { ROLE } from '@/constants/member';
import chatSvg from '@/public/assets/icons/chat.svg';
import useMutation from '@/hooks/useMutation';
import { mapToTable } from '@/utils/helper';
import Feedback from './Feedback';

const ROLELIST = mapToTable(ROLE);

const StyledTitle = styled.label`
display: block;
color: var(--black-white-gray-dark, #293a3d);
Expand Down Expand Up @@ -71,30 +74,35 @@ function ContactButton({
setMessage('');
setContact('');
};
const { mutate } = useMutation(`/email`, {
method: 'POST',
onSuccess: () => {
handleClose();
setFeedback('success');
},
onError: () => {
handleClose();
setFeedback('error');
},
});

const handleSubmit = () => {
fetch(`${BASE_URL}/email`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
...user,
subject: '【島島阿學】點開 Email,認識新夥伴',
title: '你發起的揪團有人來信!',
to: user.email,
text: message,
information: [me.email, contact],
}),
})
.then(() => {
handleClose();
setFeedback('success');
})
.catch(() => {
handleClose();
setFeedback('error');
});
mutate({
userId: me._id,
url: window.location.origin,
name: me.name,
roleList:
me.roleList.length > 0
? me.roleList.map((roleKey) => ROLELIST[roleKey])
: [''],
photoUrl: me.photoURL,
from: me.email,
to: user.email,
subject: '【島島阿學】點開 Email,認識新夥伴',
title: '你發起的揪團有人來信!',
text: message,
information: [me.email, contact],
});
};

useEffect(() => {
Expand Down
20 changes: 12 additions & 8 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const isDev = process.env.NODE_ENV === 'development';

const withPWA = require('next-pwa')({
dest: 'public',
});
Expand All @@ -10,14 +12,16 @@ module.exports = withPWA({
env: {
HOSTNAME: 'https://www.daoedu.tw',
},
async rewrites() {
return [
{
source: '/dev-proxy-api/:path*',
destination: `${process.env.NEXT_PUBLIC_API_URL}/:path*`,
},
];
},
...(isDev ? {
async rewrites() {
return [
{
source: '/dev-proxy-api/:path*',
destination: `${process.env.NEXT_PUBLIC_API_URL}/:path*`,
},
];
},
} : {})
// async redirects() {
// return [
// {
Expand Down

0 comments on commit c26c374

Please sign in to comment.