Skip to content

Commit

Permalink
Merge pull request #90 from capstone-maru/dev
Browse files Browse the repository at this point in the history
release: v0.6.0
  • Loading branch information
cjeongmin authored May 20, 2024
2 parents 1476285 + 203d8bc commit a97c8f3
Show file tree
Hide file tree
Showing 129 changed files with 14,091 additions and 2,436 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@
],
"no-empty-pattern": ["warn", { "allowObjectPatternsAsParameters": true }],
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-empty-function": ["warn", {}],
"@typescript-eslint/no-empty-function": ["off", {}],
"react/no-array-index-key": "warn",
"react/require-default-props": "off",
"react/jsx-no-useless-fragment": "off",
Expand Down
11 changes: 9 additions & 2 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
// reactStrictMode: false,
reactStrictMode: true,
reactStrictMode: false,
compiler: {
styledComponents: true,
},
Expand All @@ -14,6 +13,14 @@ const nextConfig = {
];
},
trailingSlash: false /* 만약, 후행 슬래시가 필요하다면 true, default → false */,
webpack: config => {
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
});

return config;
},
};

export default nextConfig;
2 changes: 1 addition & 1 deletion package-lock.json

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

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maru",
"version": "0.5.0",
"version": "0.6.0",
"private": true,
"scripts": {
"dev": "next dev",
Expand All @@ -9,6 +9,8 @@
"lint": "next lint"
},
"dependencies": {
"@react-hook/media-query": "^1.1.1",
"@stomp/stompjs": "^7.0.0",
"@tanstack/react-query": "^5.25.0",
"@tanstack/react-query-devtools": "^5.25.0",
"axios": "^1.6.7",
Expand All @@ -18,14 +20,17 @@
"react-redux": "^9.1.0",
"recoil": "^0.7.7",
"sass": "^1.71.1",
"styled-components": "^6.1.8"
"styled-components": "^6.1.8",
"uuid": "^9.0.1"
},
"devDependencies": {
"@svgr/webpack": "^8.1.0",
"@tanstack/eslint-plugin-query": "^5.20.1",
"@types/navermaps": "^3.7.4",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^6.4.0",
"@typescript-eslint/parser": "^7.1.0",
"eslint": "^8.2.0",
Expand Down
6 changes: 6 additions & 0 deletions public/Bubble tip R.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions public/Bubble tip.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions public/Close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions public/Close_white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/__avatar_url.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/backward-arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/bottom-curve-vector R.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/bottom-curve-vector.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/kakao-login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/kebab-horizontal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/landing-page-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/naver-login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions public/option-img/location_on.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions public/option-img/meeting_room.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/option-img/person.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/option-img/visibility.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions public/read.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/app/chat/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use client';

import { MobileChattingBox } from '@/components/chat';

export default function Page() {
return <MobileChattingBox />;
}
9 changes: 9 additions & 0 deletions src/app/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ body {
min-height: 100dvh;
min-width: 90rem;
max-width: 100dvw;

@media (max-width: 768px) {
min-width: 390px;
}
}

* {
Expand All @@ -29,6 +33,11 @@ main {
margin-top: 4.5rem;
display: flex;
justify-content: center;

@media (max-width: 768px) {
justify-content: flex-start;
main: 100vw;
}
}

a {
Expand Down
15 changes: 10 additions & 5 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import './globals.scss';

import {
AuthProvider,
InitialzationProvider,
RecoilRootProvider,
StyledComponentsRegistry,
TanstackQueryProvider,
Expand Down Expand Up @@ -37,12 +38,16 @@ export default function RootLayout({
<TanstackQueryProvider>
<RecoilRootProvider>
<StyledComponentsRegistry>
<AuthProvider>
<InitialzationProvider>
<NavigationBar />
<main>{children}</main>
<FloatingChatting />
<ToastProvider />
</AuthProvider>
<AuthProvider>
<main>
{children}
<FloatingChatting />
</main>
<ToastProvider />
</AuthProvider>
</InitialzationProvider>
</StyledComponentsRegistry>
</RecoilRootProvider>
</TanstackQueryProvider>
Expand Down
85 changes: 64 additions & 21 deletions src/app/lib/providers/AuthProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,90 @@
'use client';

import { isAxiosError } from 'axios';
import { usePathname, useRouter } from 'next/navigation';
import { useEffect } from 'react';
import { useCallback, useLayoutEffect, useState } from 'react';

import {
getUserData,
postTokenRefresh,
useAuthActions,
useAuthValue,
} from '@/features/auth';
import { load } from '@/shared/storage';
import { load, remove } from '@/shared/storage';

export function AuthProvider({ children }: { children: React.ReactNode }) {
const auth = useAuthValue();
const { login } = useAuthActions();
const { setAuthUserData, login } = useAuthActions();

const router = useRouter();
const pathName = usePathname();
const [isLoading, setIsLoading] = useState(false);

useEffect(() => {
if (pathName === '/login') {
const handleLoginSuccess = useCallback(
(data: {
accessToken: string;
refreshToken: string;
expiresIn: number;
}) => {
login({
accessToken: data.accessToken,
refreshToken: data.refreshToken,
expiresIn: data.expiresIn,
});
},
[login],
);

const handleLoginError = useCallback(
(err: Error) => {
if (isAxiosError(err)) {
remove({ type: 'local', key: 'refreshToken' });
if (pathName !== '/') router.replace('/');
}
},
[router, pathName],
);

const checkAndRefreshToken = useCallback(() => {
if (pathName === '/login' || auth != null || isLoading) return;

const refreshToken = load<string>({ type: 'local', key: 'refreshToken' });
if (refreshToken == null) {
router.replace('/');
return;
}

if (auth === null) {
const refreshToken = load<string>({ type: 'local', key: 'refreshToken' });
if (refreshToken !== null) {
postTokenRefresh(refreshToken)
.then(({ data }) => {
login({
accessToken: data.accessToken,
refreshToken,
expiresIn: data.expiresIn,
});
setIsLoading(true);
postTokenRefresh(refreshToken)
.then(({ data }) => {
handleLoginSuccess(data);
getUserData()
.then(res => {
setAuthUserData(res.data);
})
.catch(err => {
console.error(err);
router.replace('/');
});
} else {
router.replace('/');
}
}
}, [auth, login, router, pathName]);
})
.catch(handleLoginError)
.finally(() => {
setIsLoading(false);
});
}, [
pathName,
auth,
isLoading,
handleLoginError,
router,
handleLoginSuccess,
setAuthUserData,
]);

useLayoutEffect(() => {
checkAndRefreshToken();
});

if (pathName !== '/' && pathName !== '/login' && (isLoading || auth == null))
return <></>;
return <>{children}</>;
}
31 changes: 31 additions & 0 deletions src/app/lib/providers/InitializationProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use client';

import { useRouter } from 'next/navigation';
import { useEffect } from 'react';

import { useAuthActions, useAuthValue, useUserData } from '@/features/auth';

export function InitialzationProvider({
children,
}: {
children: React.ReactNode;
}) {
const router = useRouter();

const auth = useAuthValue();
const { setAuthUserData } = useAuthActions();

const { data: userData } = useUserData(auth?.accessToken != null);

useEffect(() => {
console.log(userData);
if (userData != null) {
setAuthUserData(userData);
if (userData.initialized) {
router.replace('/profile');
}
}
}, [userData, router, setAuthUserData]);

return <>{children}</>;
}
1 change: 1 addition & 0 deletions src/app/lib/providers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './AuthProvider';
export * from './InitializationProvider';
export * from './RecoilRootProvider';
export * from './StyledComponentsRegistry';
export * from './TanstackQueryProvider';
Expand Down
13 changes: 12 additions & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
'use client';

import { LandingPage, MainPage } from './pages';
import { MobileLandingPage, MobileMainPage } from './pages/mobile';

import { useAuthIsLogin } from '@/features/auth';
import { useIsMobile } from '@/shared/mobile';

export default function Home() {
const isLogin = useAuthIsLogin();
return <>{isLogin ? <MainPage /> : <LandingPage />}</>;
const isMobile = useIsMobile();
return (
<>
{isLogin ? (
<>{isMobile ? <MobileMainPage /> : <MainPage />}</>
) : (
<>{isMobile ? <MobileLandingPage /> : <LandingPage />}</>
)}
</>
);
}
Loading

0 comments on commit a97c8f3

Please sign in to comment.