Skip to content

Commit

Permalink
Merge pull request #107 from Beside-Potenday/seungbeom
Browse files Browse the repository at this point in the history
feat: 콘솔로그 수정 및 alert 추가
  • Loading branch information
seung365 authored Aug 8, 2024
2 parents c810358 + 0a57cbf commit 97c8074
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 29 deletions.
1 change: 0 additions & 1 deletion src/api/hooks/Mail/useGetMail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const getMailPath = (page: number, size: number) =>

const createApiClient = (job: string) => {
const token = sessionStorage.getItem('accessToken');
console.log(job);
return axios.create({
baseURL: BASE_URL,
headers: {
Expand Down
4 changes: 2 additions & 2 deletions src/api/hooks/Mail/useGoMail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export const useGoMail = () => {
const { mutate } = useMutation({
mutationFn: goMail,
onSuccess: (result) => {
console.log('Mail send successfully:', result);
alert('📨 메일을 보냈습니다!');
},
onError: (error) => {
console.error('Error sending mail:', error);
alert('⚠️ 메일 보내기에 실패하였습니다!');
},
});
return { mutate };
Expand Down
4 changes: 2 additions & 2 deletions src/api/hooks/Mail/usePostMail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export const usePostMail = () => {
const { mutate } = useMutation({
mutationFn: postMail,
onSuccess: (result) => {
console.log('Mail posted successfully:', result);
alert('📨 저장이 완료되었습니다!');
},
onError: (error) => {
console.error('Error posting mail:', error);
alert('⚠️ 저장에 실패하였습니다');
},
});
return { mutate };
Expand Down
1 change: 0 additions & 1 deletion src/api/hooks/useGetLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const getLoginPath = (code: string) => `${BASE_URL}/google/login/redirect
export const getLogin = async ({ code }: AuthResponse): Promise<LoginResponse> => {
try {
const response = await axios.get<LoginResponse>(getLoginPath(code));
console.log(response.data);
return response.data;
} catch (error) {
console.error('Error during login:', error);
Expand Down
2 changes: 0 additions & 2 deletions src/components/HomePage/TestersBox/Buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const Buttons = ({ handleListUniv, handleListBusiness, randomInput }: But
{ ...(randomInput as unknown as mailSendUniv) },
{
onSuccess: (data) => {
console.log(data);
setTitle(data.title || '메일 생성 성공');
setContent(data.content || '메일이 성공적으로 생성되었습니다.');
},
Expand All @@ -59,7 +58,6 @@ export const Buttons = ({ handleListUniv, handleListBusiness, randomInput }: But
{ ...(randomInput as unknown as mailSendBusiness) },
{
onSuccess: (data) => {
console.log(data);
setTitle(data.title || '메일 생성 성공');
setContent(data.content || '메일이 성공적으로 생성되었습니다.');
},
Expand Down
28 changes: 12 additions & 16 deletions src/components/Mail/MailModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,10 @@ export const MailModal = ({ isOpen, onOpen, onClose }: MailModalProps) => {
content: data.content,
};

console.log(univData);

univMutate(
{ ...(univData as unknown as mailSendUniv) },
{
onSuccess: (data) => {
console.log(data);
setTitle(data.title || '메일 생성 성공');
setContent(data.content || '메일이 성공적으로 생성되었습니다.');
setIsSubmitted(true);
Expand Down Expand Up @@ -142,13 +139,10 @@ export const MailModal = ({ isOpen, onOpen, onClose }: MailModalProps) => {
content: data.content,
};

console.log(businessData);

businessMutate(
{ ...(businessData as unknown as mailSendBusiness) },
{
onSuccess: (data) => {
console.log(data);
setTitle(data.title || '메일 생성 성공');
setContent(data.content || '메일이 성공적으로 생성되었습니다.');
setIsSubmitted(true);
Expand Down Expand Up @@ -217,7 +211,6 @@ export const MailModal = ({ isOpen, onOpen, onClose }: MailModalProps) => {
const handlePutMail = () => {
if (authInfo) {
mailmutate({ ...mailResult });
alert('📨 저장이 완료되었습니다!');
} else {
alert('로그인 후 메일을 저장 할 수 있습니다.');
}
Expand All @@ -226,19 +219,23 @@ export const MailModal = ({ isOpen, onOpen, onClose }: MailModalProps) => {

const handleGoMail = () => {
const recipientEmail = prompt('받는 사람의 이메일 주소를 입력해 주세요:');
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

if (authInfo) {
const myMailAddress = sessionStorage.getItem('email');

if (recipientEmail) {
const mailGoContent = {
to: recipientEmail,
from: myMailAddress as string,
subject: mailResult.subject,
body: mailResult.body,
};
mailGo({ ...mailGoContent });
alert('📨 메일을 보냈습니다!');
if (emailPattern.test(recipientEmail)) {
const mailGoContent = {
to: recipientEmail,
from: myMailAddress as string,
subject: mailResult.subject,
body: mailResult.body,
};
mailGo({ ...mailGoContent });
} else {
alert('유효한 이메일 주소를 입력해 주세요.');
}
} else {
alert('유효한 이메일 주소를 입력해 주세요.');
}
Expand Down Expand Up @@ -380,7 +377,6 @@ export const MailModal = ({ isOpen, onOpen, onClose }: MailModalProps) => {
) : (
<StyledButton
onClick={handleSubmit((data) => {
console.log('Form submitted', data);
if (isActive === 'univ') {
setMailInputUniv(data as mailSendUniv);
} else {
Expand Down
2 changes: 0 additions & 2 deletions src/pages/Login/AuthPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export const AuthPage = () => {

useEffect(() => {
if (data && !error) {
console.log('data', data);

updateAuthInfo({
accessToken: data.accessToken,
picture: data.picture,
Expand Down
3 changes: 0 additions & 3 deletions src/routes/components/PrivateRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ export const PrivateRoute = () => {

if (!authInfo) {
return <Navigate to={getDynamicPath.login()} />;
} else {
console.log(authInfo.accessToken);
}

return <Outlet />;
};

0 comments on commit 97c8074

Please sign in to comment.