Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

develop to main #607

Merged
merged 25 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
524d657
chore: 불필요한 index.css 제거
not-using Jul 20, 2023
1b5c241
feat: 도서 상태 정보를 청구기호 순으로 정렬 (#549)
scarf005 Sep 20, 2023
1673943
refactor: search/CategoryFilter 가독성 개선 (#535)
not-using Oct 23, 2023
dc2e985
refactor: recoil localstorage effect 적용 (#492)
scarf005 Oct 23, 2023
f13d7f5
build: add animated lib
YeonSeong-Lee Nov 26, 2023
2efc288
chore: add paw.png
YeonSeong-Lee Nov 26, 2023
17d6e9e
wip: error cat
YeonSeong-Lee Nov 26, 2023
147bb18
feat: cat paw in NotFound component
YeonSeong-Lee Nov 27, 2023
f8b1ba1
feat: error_cat css
YeonSeong-Lee Nov 27, 2023
b16e5f0
fix: 검색창 입력시 기본 새로고침 해제 (#584)
not-using Nov 27, 2023
6b3b979
fix: change png -> svg
chanhihi Nov 27, 2023
20c83cc
Merge pull request #591 from jiphyeonjeon-42/589-error-cat
YeonSeong-Lee Nov 28, 2023
971e2a3
[fix] add env REACT_APP_SENTRY
weg901127 Jan 10, 2024
1ec68a2
[fix] delete cloudfront config
weg901127 Jan 10, 2024
41f1bc0
build: base 추가 (#603)
scarf005 Jan 12, 2024
55413e1
fix: 도서등록 카테고리 제대로 적용되지 않던 문제 수정
not-using Nov 29, 2023
90d95d8
fix: 바코드 버튼 글씨 대신 이미지로 변경
not-using Nov 29, 2023
94c557a
Merge pull request #523 from jiphyeonjeon-42/522-글씨체-오류
chanhihi Feb 21, 2024
a7638ab
chore: import 순서 정리 및 prettier 적용
not-using Jan 11, 2024
106dee5
chore: 구글 애널리틱스 타입 추가
not-using Jan 12, 2024
d1dfeb9
build: sentry type 설치 및 관련 라이브러리 정리
not-using Jan 12, 2024
b96997a
fix: 센트리 오류 수정 및 코드 분리
not-using Jan 12, 2024
35aa1a7
feat: 센트리 오류 발생시 녹화기능 추가
not-using Jan 12, 2024
25307d4
fix: 실행환경 파악을 위한 env REACT_APP_ENV 추가
not-using Jan 12, 2024
91aca3e
Merge pull request #605 from jiphyeonjeon-42/604-센트리가-제대로-동작하지-않는-문제
not-using Feb 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions .github/workflows/deploy-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
echo "REACT_APP_E_BOOK_LIBRARY=$REACT_APP_E_BOOK_LIBRARY" >> .env
echo "REACT_APP_SUGGESTION=$REACT_APP_SUGGESTION" >> .env
echo "REACT_APP_GA_ID=$REACT_APP_GA_ID" >> .env
echo "REACT_APP_SENTRY=$REACT_APP_SENTRY" >> .env
echo "PORT=$PORT" >> .env
env:
REACT_APP_API: ${{ secrets.REACT_APP_API }}
Expand All @@ -53,12 +54,4 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws s3 sync ./build s3://42library.kr --region ap-northeast-2

- name: invalidate CDN cache
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_CDN_DISTRIBUTION_ID: ${{ secrets.AWS_CDN_DISTRIBUTION_ID }}
run: |
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CDN_DISTRIBUTION_ID }} --paths "/*" --region ap-northeast-2
aws s3 sync ./build s3://42library.kr --region ap-northeast-2 --delete
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"private": true,
"dependencies": {
"@ladle/react": "^2.13.0",
"@react-spring/web": "^9.7.3",
"@sentry/react": "^7.53.0",
"@sentry/tracing": "^7.53.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
Expand Down Expand Up @@ -51,6 +51,7 @@
]
},
"devDependencies": {
"@sentry/types": "^7.93.0",
"@types/react": "^18.2.6",
"@types/react-dom": "^18.2.4",
"@types/react-router-dom": "^5.3.3",
Expand Down
69 changes: 59 additions & 10 deletions pnpm-lock.yaml

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

40 changes: 20 additions & 20 deletions src/App.jsx → src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { useEffect } from "react";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import { useSetRecoilState } from "recoil";
import { BrowserRouter, Route } from "react-router-dom";
import { useRecoilValue, useResetRecoilState } from "recoil";
import { install } from "ga-gtag";
import { isUserExpiredAtom, userAtom } from "./atom/userAtom";
import { SentryRoutes } from "./config/sentry";

import BookDetail from "./component/book/BookDetail";
import Footer from "./component/utils/Footer";
import NotFound from "./component/utils/NotFound";
Expand All @@ -18,31 +21,28 @@ import History from "./component/history/History";
import ReservedLoan from "./component/reservedloan/ReservedLoan";
import ReturnBook from "./component/return/ReturnBook";
import UserManagement from "./component/userManagement/UserManagement";
import AddBook from "./component/addbook/AddBook";
import MyPageRoutes from "./component/mypage/MyPageRoutes";
import userState from "./atom/userState";
import Mypage from "./component/mypage/Mypage";
import EditEmailOrPassword from "./component/mypage/EditEmailOrPassword";
import LimitedRoute from "./LimitedRoute";
import { isExpiredDate } from "./util/date";
import BookManagement from "./component/bookManagement/BookManagement";
import ReviewManagement from "./component/reviewManagement/ReviewManagement";
import BookStock from "./component/bookStock/BookStock";
import ELibraryIn42Box from "./component/eLibraryIn42Box/EventPage";
import SuperTagManagement from "./component/superTag/SuperTagManagement";
import SubTagManagement from "./component/subTag/SubTagManagement";
import Portals from "./component/utils/Portals";
import LimitedRoute from "./LimitedRoute";
import AddBook from "./component/addbook/AddBook";
import BookManagement from "./component/bookManagement/BookManagement";
import EditEmailOrPassword from "./component/mypage/EditEmailOrPassword";
import MyPageRoutes from "./component/mypage/MyPageRoutes";
import Mypage from "./component/mypage/Mypage";
import ReviewManagement from "./component/reviewManagement/ReviewManagement";
import "./asset/css/reset.css";

function App() {
const setUser = useSetRecoilState(userState);
useEffect(() => {
install(import.meta.env.REACT_APP_GA_ID);
const localUser = JSON.parse(window.localStorage.getItem("user"));
const isUserExpired = useRecoilValue(isUserExpiredAtom);
const resetUser = useResetRecoilState(userAtom);

if (localUser?.isLogin) {
if (!isExpiredDate(localUser?.expire)) setUser(localUser);
else window.localStorage.removeItem("user");
useEffect(() => install(import.meta.env.REACT_APP_GA_ID), []);
useEffect(() => {
if (isUserExpired) {
resetUser();
}
}, []);

Expand All @@ -51,7 +51,7 @@ function App() {
<div id="portal" />
<Portals />
<Header />
<Routes>
<SentryRoutes>
<Route path="/" element={<Main />} />
<Route path="/41" element={<ELibraryIn42Box />} />
<Route path="/information" element={<Information />} />
Expand Down Expand Up @@ -83,7 +83,7 @@ function App() {
</Route>
</Route>
<Route path="*" element={<NotFound />} />
</Routes>
</SentryRoutes>
<Footer />
</BrowserRouter>
);
Expand Down
12 changes: 4 additions & 8 deletions src/LimitedRoute.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import { Navigate, Outlet } from "react-router-dom";
import NotFound from "./component/utils/NotFound";
import { useRecoilValue } from "recoil";
import { userAtom } from "./atom/userAtom";

type Props = {
isLoginOnly?: boolean;
isAdminOnly?: boolean;
isLogoutOnly?: boolean;
};

const LimitedRoute = ({
isLoginOnly,
isAdminOnly,
isLogoutOnly,
}: Props) => {
// 로그인 정보를 확인
// recoil 전역상태는 새로고침시 초기화되기 때문에 로컬스토리지 참고
const user = JSON.parse(window.localStorage.getItem("user"));
const LimitedRoute = ({ isLoginOnly, isAdminOnly, isLogoutOnly }: Props) => {
const user = useRecoilValue(userAtom);

if (isAdminOnly && !user?.isAdmin) {
return <NotFound />;
Expand Down
14 changes: 7 additions & 7 deletions src/api/auth/useGetAuthMe.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { useSetRecoilState } from "recoil";
import { useApi } from "../../hook/useApi";
import { addHourDateObject } from "../../util/date";
import userState from "../../atom/userState";
import getErrorMessage from "../../constant/error";
import { useApi } from "~/hook/useApi";
import { addHourDateObject } from "~/util/date";
import { userAtom } from "~/atom/userAtom";
import getErrorMessage from "~/constant/error";
import { UserState } from "~/type";

export const useGetAuthMe = () => {
const { request } = useApi("get", "auth/me");
const setUser = useSetRecoilState(userState);
const setUser = useSetRecoilState(userAtom);

const onSuccess = (response: any) => {
const { data } = response;
const newUser = {
const newUser: UserState = {
isLogin: true,
id: data.id,
userName: data.intra,
Expand All @@ -19,7 +20,6 @@ export const useGetAuthMe = () => {
expire: addHourDateObject(new Date(), 8).toISOString(),
};
setUser(newUser);
window.localStorage.setItem("user", JSON.stringify(newUser));
};

const onError = (error: any) => {
Expand Down
51 changes: 16 additions & 35 deletions src/api/books/useGetBooksCreate.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,16 @@
import { useState, useEffect } from "react";
import { useApi } from "../../hook/useApi";
import { compareExpect } from "../../util/typeCheck";
import getErrorMessage from "../../constant/error";
import { Book } from "../../type";
import { useState } from "react";
import { useApi } from "~/hook/useApi";
import getErrorMessage from "~/constant/error";
import { type BookInfo } from "~/type";

export const useGetBooksCreate = (defalutBook: Book) => {
const [isbnQuery, setIsbnQuery] = useState("");
export const useGetBooksCreate = (defalutBook: Omit<BookInfo, "id">) => {
const [bookInfo, setBookInfo] = useState(defalutBook);
const [errorMessage, setErrorMessage] = useState("");

const { request } = useApi("get", "books/create", {
isbnQuery,
});

const expectedItem = [
{ key: "title", type: "string", isNullable: false },
{ key: "author", type: "string", isNullable: false },
{ key: "publisher", type: "string", isNullable: false },
{ key: "pubdate", type: "string", isNullable: false },
{ key: "category", type: "string", isNullable: false },
{ key: "image", type: "string", isNullable: true },
];
const { requestWithUrl } = useApi();

const refineResponse = (response: any) => {
const books = compareExpect(
"books/create",
[response.data.bookInfo],
expectedItem,
);
setBookInfo({
...books[0],
isbn: isbnQuery,
koreanDemicalClassification: books[0].category,
});
setBookInfo(response.data.bookInfo);
setErrorMessage("");
};

Expand All @@ -46,11 +24,14 @@ export const useGetBooksCreate = (defalutBook: Book) => {
setBookInfo(defalutBook);
};

useEffect(() => {
if (isbnQuery && isbnQuery.length) {
request(refineResponse, displayError);
}
}, [isbnQuery]);
const fetchData = (isbnQuery: string) => {
if (!isbnQuery) return;
requestWithUrl("get", "books/create", {
data: { isbnQuery },
onSuccess: refineResponse,
onError: displayError,
});
};

return { bookInfo, errorMessage, fetchData: setIsbnQuery, setBookInfo };
return { bookInfo, errorMessage, fetchData, setBookInfo };
};
Loading
Loading