Skip to content

Commit

Permalink
๐Ÿ”จ refactor: ์ฝ”๋“œ ์Šคํ”Œ๋ฆฌํŒ… ๋ฐ ์„ฑ๋Šฅ ํ–ฅ์ƒ ์ž‘์—… (#314)
Browse files Browse the repository at this point in the history
* ๐Ÿ“ฆ chore: ์›น ํฐํŠธ preload ์ ์šฉ

* ๐Ÿ“ฆ chore: ์ด๋ฏธ์ง€ ์—์…‹ webp๋กœ ๋ณ€๊ฒฝ

* ๐Ÿ“ฆ chore: ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋ณ„ ์ฝ”๋“œ ์Šคํ”Œ๋ฆฌํŒ… ๋ฐ Sentry ํŠธ๋ฆฌ ์…ฐ์ดํ‚น ์ ์šฉ

* ๐Ÿ”จ refactor: ๋กœ๋”ฉ UI ์ „์—ญ ์ฒ˜๋ฆฌ
  • Loading branch information
bbearcookie authored May 10, 2024
1 parent 08e28a6 commit 19e28a7
Show file tree
Hide file tree
Showing 44 changed files with 93 additions and 144 deletions.
8 changes: 3 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
<html lang="ko">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0 user-scalable=no"
/>
<link
href="https://cdn.jsdelivr.net/gh/sun-typeface/SUIT/fonts/static/woff2/SUIT.css"
rel="stylesheet"
/>
<link
rel="preload"
href="https://cdn.jsdelivr.net/gh/sun-typeface/SUIT/fonts/static/woff2/SUIT.css"
Expand All @@ -25,6 +20,8 @@
type="font/woff"
crossorigin="anonymous"
/>
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />

<!-- Open Graph -->
<meta property="og:type" content="website" />
<meta property="og:url" content="https://oceanletter.site/" />
Expand All @@ -38,6 +35,7 @@
<meta property="og:locale" content="ko_KR" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />

<!-- Open Graph - twitter -->
<meta name="twitter:card" content="summary_large_image" />
<meta property="twitter:domain" content="oceanletter.site" />
Expand Down
8 changes: 6 additions & 2 deletions src/AdminApp.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { Outlet } from 'react-router-dom';
import { ToastContainer } from 'react-toastify';
import { Suspense } from 'react';
import { css } from '@emotion/react';
import Background from '@/components/Background';
import BackgroundImg from '@/assets/background.png';
import BackgroundImg from '@/assets/background.webp';
import UnknownErrorBoundary from '@/components/ErrorBoundary/UnknownErrorBoundary';
import ApiErrorBoundary from '@/components/ErrorBoundary/ApiErrorBoundary';
import TitleHelmet from '@/components/TitleHelmet';
import RootUnknownFallback from './components/ErrorBoundary/fallback/RootUnknownFallback';
import RootApiFallback from './components/ErrorBoundary/fallback/RootApiFallback';
import LoadingScreen from './components/LoadingScreen';
import 'react-toastify/dist/ReactToastify.css';

const AdminApp = () => {
Expand All @@ -17,7 +19,9 @@ const AdminApp = () => {
<Background imageUrl={BackgroundImg}>
<UnknownErrorBoundary FallbackComponent={RootUnknownFallback}>
<ApiErrorBoundary FallbackComponent={RootApiFallback}>
<Outlet />
<Suspense fallback={<LoadingScreen />}>
<Outlet />
</Suspense>
</ApiErrorBoundary>
</UnknownErrorBoundary>
<ToastContainer
Expand Down
8 changes: 6 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { Outlet } from 'react-router-dom';
import { ToastContainer } from 'react-toastify';
import { Suspense } from 'react';
import { css } from '@emotion/react';
import Background from '@/components/Background';
import BackgroundMusic from '@/assets/background.mp3';
import BackgroundImg from '@/assets/background.png';
import BackgroundImg from '@/assets/background.webp';
import Audio from '@/components/Audio';
import UnknownErrorBoundary from '@/components/ErrorBoundary/UnknownErrorBoundary';
import ApiErrorBoundary from '@/components/ErrorBoundary/ApiErrorBoundary';
import TitleHelmet from '@/components/TitleHelmet';
import RootUnknownFallback from './components/ErrorBoundary/fallback/RootUnknownFallback';
import RootApiFallback from './components/ErrorBoundary/fallback/RootApiFallback';
import LoadingScreen from './components/LoadingScreen';
import 'react-toastify/dist/ReactToastify.css';

const App = () => {
Expand All @@ -20,7 +22,9 @@ const App = () => {
<div css={styles.root}>
<UnknownErrorBoundary FallbackComponent={RootUnknownFallback}>
<ApiErrorBoundary FallbackComponent={RootApiFallback}>
<Outlet />
<Suspense fallback={<LoadingScreen />}>
<Outlet />
</Suspense>
</ApiErrorBoundary>
</UnknownErrorBoundary>
<Audio src={BackgroundMusic} />
Expand Down
Binary file removed src/assets/background.png
Binary file not shown.
Binary file added src/assets/background.webp
Binary file not shown.
Binary file removed src/assets/images/bottleReception1.png
Binary file not shown.
Binary file added src/assets/images/bottleReception1.webp
Binary file not shown.
Binary file removed src/assets/images/bottleReception2.png
Binary file not shown.
Binary file added src/assets/images/bottleReception2.webp
Binary file not shown.
Binary file removed src/assets/images/bottleReception3.png
Binary file not shown.
Binary file added src/assets/images/bottleReception3.webp
Binary file not shown.
Binary file removed src/assets/images/bottleReception4.png
Binary file not shown.
Binary file added src/assets/images/bottleReception4.webp
Binary file not shown.
Binary file removed src/assets/images/bottleReply1.png
Binary file not shown.
Binary file added src/assets/images/bottleReply1.webp
Binary file not shown.
Binary file removed src/assets/images/bottleReply2.png
Binary file not shown.
Binary file added src/assets/images/bottleReply2.webp
Binary file not shown.
Binary file removed src/assets/images/bottleStorage.png
Binary file not shown.
Binary file added src/assets/images/bottleStorage.webp
Binary file not shown.
Binary file removed src/assets/images/sparkleBig.png
Binary file not shown.
Binary file added src/assets/images/sparkleBig.webp
Binary file not shown.
Binary file removed src/assets/images/sparkleSmall.png
Binary file not shown.
Binary file added src/assets/images/sparkleSmall.webp
Binary file not shown.
Binary file removed src/assets/letterBackground.png
Binary file not shown.
Binary file added src/assets/letterBackground.webp
Binary file not shown.
Binary file removed src/assets/storageDrawer.png
Binary file not shown.
Binary file added src/assets/storageDrawer.webp
Binary file not shown.
12 changes: 8 additions & 4 deletions src/components/ErrorBoundary/fallback/RootApiFallback.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { type FallbackProps } from 'react-error-boundary';
import { useEffect } from 'react';
import { isAxiosError } from 'axios';
import * as Sentry from '@sentry/react';
import {
getCurrentScope as SentryGetCurrentScope,
setContext as SentrySetContext,
captureException as SentryCaptureException,
} from '@sentry/react';
import ERROR_RESPONSES from '@/constants/errorMessages';
import ErrorImage from '@/assets/images/error.svg';
import Button from '../../Button';
Expand All @@ -20,7 +24,7 @@ const RootApiFallback = ({ error, resetErrorBoundary }: FallbackProps) => {
return;
}

const scope = Sentry.getCurrentScope();
const scope = SentryGetCurrentScope();
scope.setTag('type', 'api');

scope.setContext('API Request Detail', {
Expand All @@ -31,12 +35,12 @@ const RootApiFallback = ({ error, resetErrorBoundary }: FallbackProps) => {
headers: error.config?.headers,
});

Sentry.setContext('API Response Detail', {
SentrySetContext('API Response Detail', {
status: error.response?.status,
data: error.response?.data,
});

Sentry.captureException(error);
SentryCaptureException(error);
}, []);

if (shouldSkip) {
Expand Down
9 changes: 6 additions & 3 deletions src/components/ErrorBoundary/fallback/RootUnknownFallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { type FallbackProps } from 'react-error-boundary';
import { useEffect } from 'react';
import { Navigate, useNavigate } from 'react-router-dom';
import { isAxiosError } from 'axios';
import * as Sentry from '@sentry/react';
import {
getCurrentScope as SentryGetCurrentScope,
captureException as SentryCaptureException,
} from '@sentry/react';
import ERROR_RESPONSES from '@/constants/errorMessages';
import ErrorImage from '@/assets/images/error.svg';
import { ROUTER_PATHS } from '@/constants/routerPaths';
Expand All @@ -23,10 +26,10 @@ const RootUnknownFallback = ({ error }: FallbackProps) => {
return;
}

const scope = Sentry.getCurrentScope();
const scope = SentryGetCurrentScope();
scope.setTag('type', 'unknown');

Sentry.captureException(error);
SentryCaptureException(error);
}, []);

if (shouldSkip) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/LetterCard/styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { css } from '@emotion/react';
import LetterBackground from '@/assets/letterBackground.png';
import LetterBackground from '@/assets/letterBackground.webp';

export type Backgroundtype = 'primary' | 'white';

Expand Down
18 changes: 4 additions & 14 deletions src/layouts/AdminLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
import { Suspense } from 'react';
import { Navigate, Outlet } from 'react-router-dom';
import { useSuspenseQuery } from '@tanstack/react-query';
import { ROUTER_PATHS } from '@/constants/routerPaths';
import STORAGE_KEYS from '@/constants/storageKeys';
import LoadingScreen from '@/components/LoadingScreen';
import memberOptions from '@/api/member/queryOptions';

const SuspensedLayout = () => {
const AdminLayout = () => {
const { data } = useSuspenseQuery(memberOptions.detail());

if (data.role !== 'ADMIN') {
if (!localStorage.getItem(STORAGE_KEYS.accessToken)) {
return <Navigate to={ROUTER_PATHS.SIGNIN} />;
}

return <Outlet />;
};

const AdminLayout = () => {
if (!localStorage.getItem(STORAGE_KEYS.accessToken)) {
if (data.role !== 'ADMIN') {
return <Navigate to={ROUTER_PATHS.SIGNIN} />;
}

return (
<Suspense fallback={<LoadingScreen />}>
<SuspensedLayout />
</Suspense>
);
return <Outlet />;
};

export default AdminLayout;
14 changes: 2 additions & 12 deletions src/layouts/AuthLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
import { Suspense } from 'react';
import { Navigate, Outlet } from 'react-router-dom';
import { useSuspenseQuery } from '@tanstack/react-query';
import STORAGE_KEYS from '@/constants/storageKeys';
import memberOptions from '@/api/member/queryOptions';
import { ROUTER_PATHS } from '@/constants/routerPaths';
import LoadingScreen from '@/components/LoadingScreen';

const SuspensedLayout = () => {
const AuthLayout = () => {
useSuspenseQuery(memberOptions.detail());

return <Outlet />;
};

const AuthLayout = () => {
if (!localStorage.getItem(STORAGE_KEYS.accessToken)) {
return <Navigate to={ROUTER_PATHS.SIGNIN} />;
}

return (
<Suspense fallback={<LoadingScreen />}>
<SuspensedLayout />
</Suspense>
);
return <Outlet />;
};

export default AuthLayout;
12 changes: 8 additions & 4 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ import { HelmetProvider } from 'react-helmet-async';
import ReactDOM from 'react-dom/client';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { QueryClientProvider } from '@tanstack/react-query';
import * as Sentry from '@sentry/react';
import {
init as SentryInit,
browserTracingIntegration as SentryBrowserTracingIntegration,
replayIntegration as SentryReplayIntegration,
} from '@sentry/react';
import queryClient from '@/api/queryClient';
import { router } from '@/router';
import { SKIP_MSW_WARNING_URL } from './constants/msw';
import STORAGE_KEYS from './constants/storageKeys';
import 'reset-css';
import './main.css';

Sentry.init({
SentryInit({
dsn: import.meta.env.VITE_SENTRY_DSN,
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration({
SentryBrowserTracingIntegration(),
SentryReplayIntegration({
maskAllText: false,
blockAllMedia: false,
networkDetailAllowUrls: [import.meta.env.VITE_BACKEND_ENDPOINT],
Expand Down
7 changes: 2 additions & 5 deletions src/pages/AdminMainPage/tabs/ReportTab.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Suspense, useMemo, useState } from 'react';
import { useMemo, useState } from 'react';
import Paper from '@mui/material/Paper';
import {
Table,
Expand All @@ -9,7 +9,6 @@ import {
TableRow,
} from '@mui/material';
import Dropdown from '@/components/Dropdown';
import LoadingSpinner from '@/components/LoadingSpinner';
import { MoreHorizontal, TrashCan } from '@/assets/icons';
import COLORS from '@/constants/colors';
import { REPORT_TYPE_DICT } from '@/constants/report';
Expand Down Expand Up @@ -99,9 +98,7 @@ const ReportTab = () => {
placeholder="๊ฒ€์ƒ‰ํ•  ์ด๋ฉ”์ผ์„ ์ž…๋ ฅํ•˜์„ธ์š”"
/>

<Suspense fallback={<LoadingSpinner />}>
<SuspensedReportTab email={email} />
</Suspense>
<SuspensedReportTab email={email} />
</div>
);
};
Expand Down
7 changes: 2 additions & 5 deletions src/pages/AdminMainPage/tabs/UserTab.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Suspense, useMemo, useState } from 'react';
import { useMemo, useState } from 'react';
import Paper from '@mui/material/Paper';
import {
Table,
Expand All @@ -11,7 +11,6 @@ import {
import Dropdown from '@/components/Dropdown';
import { Copy, MoreHorizontal, TrashCan } from '@/assets/icons';
import COLORS from '@/constants/colors';
import LoadingSpinner from '@/components/LoadingSpinner';
import useBoolean from '@/hooks/useBoolean';
import { debounce } from '@/utils/timerUtils';
import usePagedUserQuery from '../hooks/usePagedUserQuery';
Expand Down Expand Up @@ -111,9 +110,7 @@ const UserTab = () => {
placeholder="๊ฒ€์ƒ‰ํ•  ์ด๋ฉ”์ผ์„ ์ž…๋ ฅํ•˜์„ธ์š”"
/>

<Suspense fallback={<LoadingSpinner />}>
<SuspensedUserTab searchEmail={email} />
</Suspense>
<SuspensedUserTab searchEmail={email} />
</div>
);
};
Expand Down
14 changes: 1 addition & 13 deletions src/pages/LetterReceptionPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { useParams } from 'react-router-dom';
import { Suspense } from 'react';
import { useSuspenseQuery } from '@tanstack/react-query';
import LoadingSpinner from '@/components/LoadingSpinner';
import UnknownErrorBoundary from '@/components/ErrorBoundary/UnknownErrorBoundary';
import LetterAccessFallback from '@/components/ErrorBoundary/fallback/LetterAccessFallback';
import letterOptions from '@/api/letter/queryOptions';
import OnboardingReception from './OnboardingReception';
import NormalReception from './NormalReception';
import style from './styles';

const SuspensedPage = () => {
const { letterId } = useParams();
Expand All @@ -26,16 +23,7 @@ const SuspensedPage = () => {
const LetterReceptionPage = () => {
return (
<UnknownErrorBoundary FallbackComponent={LetterAccessFallback}>
<Suspense
fallback={
<div css={style.loadingSpinner}>
<LoadingSpinner size="4rem" />
<p>ํ˜๋Ÿฌ์˜จ ํŽธ์ง€ ๊ฐ€์ ธ์˜ค๋Š” ์ค‘...</p>
</div>
}
>
<SuspensedPage />
</Suspense>
<SuspensedPage />
</UnknownErrorBoundary>
);
};
Expand Down
27 changes: 8 additions & 19 deletions src/pages/LetterReplyPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Suspense } from 'react';
import { useParams } from 'react-router-dom';
import LoadingSpinner from '@/components/LoadingSpinner';
import UnknownErrorBoundary from '@/components/ErrorBoundary/UnknownErrorBoundary';
import LetterAccessFallback from '@/components/ErrorBoundary/fallback/LetterAccessFallback';
import ReplyHeader from './components/ReplyHeader';
Expand All @@ -14,25 +12,16 @@ const LetterReplyPage = () => {

return (
<UnknownErrorBoundary FallbackComponent={LetterAccessFallback}>
<Suspense
fallback={
<div css={style.loadingSpinner}>
<LoadingSpinner size="4rem" />
<p>๋‹ต์žฅ ๋ฐ›์€ ํŽธ์ง€ ๊ฐ€์ ธ์˜ค๋Š” ์ค‘...</p>
</div>
}
>
<div css={style.container}>
<ReplyHeader letterId={Number(letterId)} />
<div css={style.content}>
<div css={style.letter}>
<SentLetter letterId={Number(letterId)} />
<ReplyLetter letterId={Number(letterId)} />
</div>
<BottomButton letterId={Number(letterId)} />
<div css={style.container}>
<ReplyHeader letterId={Number(letterId)} />
<div css={style.content}>
<div css={style.letter}>
<SentLetter letterId={Number(letterId)} />
<ReplyLetter letterId={Number(letterId)} />
</div>
<BottomButton letterId={Number(letterId)} />
</div>
</Suspense>
</div>
</UnknownErrorBoundary>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/pages/LetterStoragePage/components/StorageLetter.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useState } from 'react';
import { css } from '@emotion/react';
import { type Reply, type SendLetter } from '@/types/letter';
import DrowerImage from '@/assets/storageDrawer.png';
import BottleImage from '@/assets/images/bottleStorage.png';
import DrowerImage from '@/assets/storageDrawer.webp';
import BottleImage from '@/assets/images/bottleStorage.webp';
import useBoolean from '@/hooks/useBoolean';
import {
startIndexList,
Expand Down
Loading

0 comments on commit 19e28a7

Please sign in to comment.