Skip to content

Commit

Permalink
chore: 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
faddishcorn committed Nov 15, 2024
1 parent a2c1f5a commit bdc0ec0
Show file tree
Hide file tree
Showing 18 changed files with 135 additions and 199 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ module.exports = {
"no-underscore-dangle": "off",
"no-alert": "off",
"react-hooks/exhaustive-deps": "off",
"react/no-array-index-key": "off",
"no-nested-ternary": "off",
"@typescript-eslint/no-use-before-define": "off",
"react/jsx-no-constructed-context-values": "off",
"import/prefer-default-export": "off",
"@typescript-eslint/no-unused-expressions": "off",
"import/no-extraneous-dependencies": [
"error",
{
Expand Down
105 changes: 0 additions & 105 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,10 @@
"@storybook/blocks": "^8.3.0",
"@storybook/react": "^8.3.0",
"@storybook/react-vite": "^8.3.0",
"@storybook/test": "^8.3.0",
"@types/js-cookie": "^3.0.6",
"@types/react": "^18.2.66",
"@types/react-big-calendar": "^1.8.11",
"@types/react-dom": "^18.2.22",
"@types/testing-library__jest-dom": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@vitejs/plugin-react": "^4.2.1",
Expand Down
3 changes: 1 addition & 2 deletions src/api/firebaseConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { initializeApp } from "firebase/app";
// eslint-disable-next-line import/no-extraneous-dependencies

import {
getMessaging,
getToken,
Expand Down
3 changes: 1 addition & 2 deletions src/api/hooks/useTeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export const useDeleteTeam = () => {
alert("네트워크 오류가 발생했습니다. 인터넷 연결을 확인해 주세요.");
}
},

});
};

Expand All @@ -69,7 +68,7 @@ export const useLeaveTeam = () => {
mutationFn: async (teamId: number) => {
const confirmed = window.confirm("정말로 팀에서 나가시겠습니까?");
if (!confirmed) {
return;
return;
}
await apiClient.delete(`/api/teams/${teamId}/leave`);
},
Expand Down
13 changes: 10 additions & 3 deletions src/api/hooks/useUserData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,18 @@ const useUserData = () => {
.then(() => {
alert("구독이 완료되었습니다.");
})
.catch((error) => console.error("error subscribtion:", error));
.catch((error) => {
if (error.response && error.response.status === 400) {
// 409 Conflict가 이미 구독 중 상태로 가정
alert("이미 구독중입니다.");
} else {
// 다른 에러의 경우
alert("구독 처리 중 오류가 발생했습니다.");
}
console.error("error subscription:", error);
});
};



const handleDeleteAccount = () => {
// 회원 탈퇴 API 호출
if (window.confirm("정말로 회원 탈퇴를 하시겠습니까?")) {
Expand Down
10 changes: 8 additions & 2 deletions src/components/common/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ export type Props = {
value?: string;
placeholder?: string;
disabled?: boolean;
className? :string;
className?: string;
};

const Input: React.FC<Props> = ({ value, placeholder, onChange,className, ...props }) => {
const Input: React.FC<Props> = ({
value,
placeholder,
onChange,
className,
...props
}) => {
return (
<StyledInputContainer className={className}>
<StyledInput
Expand Down
72 changes: 40 additions & 32 deletions src/components/common/Notification/Notification.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
/** @jsxImportSource @emotion/react */
import { useState, useEffect } from 'react'
import { motion, AnimatePresence } from 'framer-motion'
import { X, CheckCircle, AlertCircle, Info } from 'lucide-react'
import styled from '@emotion/styled'
import { css } from '@emotion/react'
import { useState, useEffect } from "react";
import { motion, AnimatePresence } from "framer-motion";
import { X, CheckCircle, AlertCircle, Info } from "lucide-react";
import styled from "@emotion/styled";
import { css } from "@emotion/react";

type NotificationType = 'success' | 'error' | 'info'
type NotificationType = "success" | "error" | "info";

interface NotificationProps {
type: NotificationType
message: string
duration?: number
onClose?: () => void
type: NotificationType;
message: string;
duration?: number;
onClose?: () => void;
}

const iconMap = {
success: CheckCircle,
error: AlertCircle,
info: Info,
}
};

const bgColorMap = {
success: '#38A169', // Green
error: '#E53E3E', // Red
info: '#3182CE', // Blue
}
success: "#38A169", // Green
error: "#E53E3E", // Red
info: "#3182CE", // Blue
};

// Styled components
const NotificationContainer = styled(motion.div)<{ type: NotificationType }>`
Expand All @@ -38,24 +38,24 @@ const NotificationContainer = styled(motion.div)<{ type: NotificationType }>`
border-radius: 0.375rem;
box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
background-color: ${({ type }) => bgColorMap[type]};
`
`;

const NotificationContent = styled.div`
padding: 1rem;
display: flex;
align-items: start;
`
`;

const IconContainer = styled.div`
flex-shrink: 0;
`
`;

const MessageContainer = styled.div`
margin-left: 0.75rem;
width: 0;
flex-grow: 1;
padding-top: 0.125rem;
`
`;

const CloseButton = styled.button`
margin-left: 1rem;
Expand All @@ -71,7 +71,7 @@ const CloseButton = styled.button`
outline: none;
box-shadow: 0 0 0 2px white;
}
`
`;

const srOnly = css`
position: absolute;
Expand All @@ -82,26 +82,26 @@ const srOnly = css`
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
`
`;

export default function Notification({
type,
message,
duration = 5000,
onClose,
}: NotificationProps) {
const [isVisible, setIsVisible] = useState(true)
const [isVisible, setIsVisible] = useState(true);

useEffect(() => {
const timer = setTimeout(() => {
setIsVisible(false)
onClose && onClose()
}, duration)
setIsVisible(false);
onClose && onClose();
}, duration);

return () => clearTimeout(timer)
}, [duration, onClose])
return () => clearTimeout(timer);
}, [duration, onClose]);

const Icon = iconMap[type]
const Icon = iconMap[type];

return (
<AnimatePresence>
Expand All @@ -117,12 +117,20 @@ export default function Notification({
<Icon className="h-6 w-6" color="white" />
</IconContainer>
<MessageContainer>
<p style={{ fontSize: '0.875rem', fontWeight: 500, color: 'white' }}>{message}</p>
<p
style={{
fontSize: "0.875rem",
fontWeight: 500,
color: "white",
}}
>
{message}
</p>
</MessageContainer>
<CloseButton
onClick={() => {
setIsVisible(false)
onClose && onClose()
setIsVisible(false);
onClose && onClose();
}}
>
<span css={srOnly}>Close</span>
Expand All @@ -132,5 +140,5 @@ export default function Notification({
</NotificationContainer>
)}
</AnimatePresence>
)
);
}
Loading

0 comments on commit bdc0ec0

Please sign in to comment.