diff --git a/src/App.jsx b/src/App.jsx index 9fb4120..2f17e95 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,27 +1,33 @@ import './assets/styles/base.scss'; import { Route, Routes } from 'react-router-dom'; +import { Suspense, lazy } from 'react'; import Header from './components/layout/Header/Header'; -import RecipientList from './pages/RecipientList/RecipientList'; -import Home from './pages/Home/Home'; -import CreateRecipient from './pages/CreateRecipient/CreateRecipient'; -import Recipient from './pages/Recipient/Recipient'; -import MessageForm from './pages/MessageForm/MessageForm'; + +const RecipientList = lazy(() => import('./pages/RecipientList/RecipientList')); +const Home = lazy(() => import('./pages/Home/Home')); +const CreateRecipient = lazy( + () => import('./pages/CreateRecipient/CreateRecipient'), +); +const Recipient = lazy(() => import('./pages/Recipient/Recipient')); +const MessageForm = lazy(() => import('./pages/MessageForm/MessageForm')); export default function App() { return ( <>
- - } /> - } /> - } /> - } /> - } - /> - } /> - + 로딩중...}> + + } /> + } /> + } /> + } /> + } + /> + } /> + + ); } diff --git a/src/components/recipient/HeaderService/HeaderService.jsx b/src/components/recipient/HeaderService/HeaderService.jsx index 3caca13..10ad70a 100644 --- a/src/components/recipient/HeaderService/HeaderService.jsx +++ b/src/components/recipient/HeaderService/HeaderService.jsx @@ -4,6 +4,12 @@ import emojiAdd from '../../../assets/images/emoji-add.svg'; import chevronDown from '../../../assets/images/chevron-down.svg'; import { fetchReactions, addReaction } from '../../../api/emojiReactions'; import ShareButton from './Share/ShareButton'; +import { formatCount } from '../../../utils/numberFormat'; + +function getProfileExtraCount(count) { + if (count > 99) return '99'; + return count; +} export default function HeaderService({ recipient }) { const [reactions, setReactions] = useState([]); @@ -164,7 +170,7 @@ export default function HeaderService({ recipient }) { ))} {recipient?.messageCount > 3 && (
- +{recipient.messageCount - 3} + +{getProfileExtraCount(recipient.messageCount - 3)}
)} @@ -187,9 +193,9 @@ export default function HeaderService({ recipient }) { > {reaction.emoji} - {' '} + - {reaction.count} + {formatCount(reaction.count)} )) @@ -235,9 +241,9 @@ export default function HeaderService({ recipient }) { > {reaction.emoji} - {' '} + - {reaction.count} + {formatCount(reaction.count)} )) diff --git a/src/utils/numberFormat.js b/src/utils/numberFormat.js new file mode 100644 index 0000000..71fd968 --- /dev/null +++ b/src/utils/numberFormat.js @@ -0,0 +1,5 @@ +export function formatCount(count) { + if (count >= 1000000) return `${(count / 1000000).toFixed(1)}M`; + if (count >= 1000) return `${(count / 1000).toFixed(1)}K`; + return count.toString(); +}