Skip to content

Conversation

@bokeeeey
Copy link
Member

@bokeeeey bokeeeey commented Jan 20, 2025

🚀 작업 내용

  • webview 환경에서 페이지 이동시 stack screen으로 동작 구현
  • useWebView => useDetectWebView hooks 개선 (platform 및 webview환경 통합 감지)

📝 참고 사항

  • modal 및 bottom sheet의 경우 크로스 플랫폼 컴포넌트를 제작하기 위해서는 expo환경과 react-native-web의존성을 web repo에 주입해주어야 합니다. (해석: 다시 만들어야함)

🖼️ 스크린샷

image

🚨 관련 이슈 (이슈 번호)

✅ 체크리스트

  • Code Review 요청
  • Label 설정
  • PR 제목 규칙에 맞는지 확인

Summary by CodeRabbit

  • 새로운 기능

    • 웹뷰 감지를 위한 새로운 맞춤형 후크 useDetectWebView 추가
    • iOS 및 Android 플랫폼에서 웹뷰 환경 감지 기능 구현
    • 팀 순서 업데이트 후 재정렬된 팀 목록 반환 기능 추가
    • EmptyState 컴포넌트에서 버튼의 동작을 웹뷰 환경에 따라 조정
  • 버그 수정

    • 팀 순서 업데이트 로직 개선
    • 라우팅 및 네비게이션 처리 안정성 향상
  • 리팩터링

    • 기존 useWebView 후크를 더 상세한 useDetectWebView로 대체
    • AuthGuard 컴포넌트에서 불필요한 웹뷰 체크 로직 제거
    • SettingButtons 컴포넌트의 함수 이름 변경
    • GnbMenu 컴포넌트에서 웹뷰 감지 방식 업데이트
  • 기타 변경사항

    • Next.js 구성에서 trailing slash 설정 제거

@bokeeeey bokeeeey requested a review from miraclee1226 January 20, 2025 10:45
@bokeeeey bokeeeey self-assigned this Jan 20, 2025
@bokeeeey bokeeeey linked an issue Jan 20, 2025 that may be closed by this pull request
@coderabbitai
Copy link

coderabbitai bot commented Jan 20, 2025

Caution

Review failed

The pull request is closed.

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/web/app/_components/AuthGuard.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "@repo/eslint-config/next.js" to extend from. Please check that the name of the config is correct.

The config "@repo/eslint-config/next.js" was referenced from the config file in "/apps/web/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

Walkthrough

이 풀 리퀘스트는 주로 웹뷰 감지 및 라우팅 로직과 관련된 여러 파일의 변경 사항을 포함하고 있습니다. 팀 컨트롤러와 모델에서는 팀 순서 업데이트 로직이 수정되었으며, 웹 애플리케이션의 여러 구성 요소에서 useWebView 훅이 useDetectWebView로 대체되었습니다. 이러한 변경은 애플리케이션의 라우팅 및 네비게이션 동작을 개선하는 데 중점을 두고 있습니다.

Changes

파일 변경 요약
apps/api/src/controllers/teamController.ts updateTeamOrder 함수의 응답 구조 변경, 재정렬된 팀 목록 반환
apps/api/src/models/teamModel.ts TeamSchemaorder 필드 제약 조건 제거
apps/web/app/_hooks/useDetectWebView.ts 새로운 웹뷰 감지 훅 추가
apps/web/app/_components/AuthGuard.tsx, apps/web/components/Gnb/GnbMenu.tsx useWebView 훅을 useDetectWebView로 대체
apps/web/app/dashboard/_components/EmptyState.tsx 버튼 클릭 핸들러 변경 및 라우팅 로직 수정
apps/web/app/settings/_components/SettingButtons.tsx 버튼 클릭 핸들러 이름 변경
apps/web/next.config.mjs trailingSlash 속성 제거

Possibly related issues

Possibly related PRs

Suggested labels

⚙ Setting, ✨ Feature, 📱 Mobile

Suggested reviewers

  • miraclee1226

Poem

🐰 웹뷰를 타고 떠나는 여행
라우팅은 부드럽게 흐르네
팀의 순서 바꾸고
훅은 새롭게 피어나
코드의 토끼 점프! 🚀


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1199a7e and 1bf9e1d.

📒 Files selected for processing (1)
  • apps/web/app/_components/AuthGuard.tsx (1 hunks)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link

github-actions bot commented Jan 20, 2025

🚀 Preview URL

Branch: 197-feat-web-router로직과-native-navigation로직-연동
Commit: a569dd3

Preview URL: https://codeit.click?pr=199

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🔭 Outside diff range comments (1)
apps/api/src/controllers/teamController.ts (1)

Line range hint 354-359: 트랜잭션 처리 및 에러 핸들링 개선이 필요합니다.

데이터 일관성과 안정성을 위해 다음 개선사항들을 고려해주세요:

  1. 벌크 업데이트와 조회 작업을 트랜잭션으로 묶어 처리
  2. 데이터베이스 작업 실패 시의 구체적인 에러 핸들링 추가
  3. 불필요한 추가 쿼리 최적화

다음과 같이 개선할 수 있습니다:

-  await Team.bulkWrite(bulkOperations);
-
-  const reorderedTeams = await Team.find().sort({ order: 1 }).lean();
-
-  res.status(200).send({
-    message: "성공적으로 업데이트되었습니다.",
-    teams: reorderedTeams,
-  });
+  try {
+    const session = await Team.startSession();
+    let reorderedTeams;
+    
+    await session.withTransaction(async () => {
+      await Team.bulkWrite(bulkOperations, { session });
+      reorderedTeams = await Team.find()
+        .sort({ order: 1 })
+        .lean()
+        .session(session);
+    });
+    
+    await session.endSession();
+    
+    res.status(200).send({
+      message: "성공적으로 업데이트되었습니다.",
+      teams: reorderedTeams,
+    });
+  } catch (error) {
+    res.status(500).send({
+      message: "팀 순서 업데이트 중 오류가 발생했습니다.",
+      error: error instanceof Error ? error.message : "알 수 없는 오류",
+    });
+  }
🧹 Nitpick comments (5)
apps/web/app/_hooks/useAppRouter.ts (1)

4-4: 웹뷰 감지 로직이 개선되었습니다.

웹뷰와 웹 실행에 대한 주석이 명확하게 추가되었고, useDetectWebView로의 마이그레이션이 잘 이루어졌습니다. 다만 한 가지 제안사항이 있습니다.

주석에 각 실행 경로에서 어떤 동작이 발생하는지 더 자세히 설명하면 좋을 것 같습니다:

-    // web view 실행
+    // web view 실행: 네이티브에 라우팅 이벤트 전달
-    // web 실행
+    // web 실행: Next.js 라우터로 페이지 전환

Also applies to: 11-11, 15-24

apps/web/app/settings/_components/SettingButtons.tsx (1)

10-10: 함수 이름을 더 명확하게 변경하는 것이 좋겠습니다.

handleClick은 너무 일반적인 이름입니다. 함수의 구체적인 목적을 나타내는 이름을 사용하는 것이 좋습니다.

- const handleClick = (component: ModalComponentType<SettingsModalProps>): void => {
+ const handleSettingsModalOpen = (component: ModalComponentType<SettingsModalProps>): void => {
    openModal(component);
  };

  // ...
  onClick={() => {
-   handleClick(component);
+   handleSettingsModalOpen(component);
  }}

Also applies to: 23-23

apps/web/app/dashboard/_components/EmptyState.tsx (1)

25-36: 웹뷰 분기 처리가 잘 구현되었습니다.

Button 컴포넌트의 조건부 렌더링이 깔끔하게 구현되었습니다. 다만 몇 가지 개선사항을 제안드립니다:

  1. 버튼 variant를 상수로 추출하면 좋을 것 같습니다:
const EMPTY_STATE_BUTTON_VARIANT = "Secondary" as const;
  1. 웹뷰/웹 분기에 따른 props를 별도 객체로 분리하면 가독성이 개선될 것 같습니다:
const buttonProps = isWebView
  ? {
      as: 'button' as const,
      type: 'button' as const,
      onClick: handleButtonClick,
    }
  : {
      as: Link,
      href: PAGE_NAME.MEETINGS,
    };

return (
  <Button
    variant={EMPTY_STATE_BUTTON_VARIANT}
    {...buttonProps}
  >
    미팅 잡기
  </Button>
);
apps/web/app/_hooks/useDetectWebView.ts (1)

23-31: iOS 웹뷰 감지 로직 개선이 필요합니다.

현재 Safari 감지 로직이 불완전할 수 있습니다. Safari 버전에 따라 정확도가 달라질 수 있으며, 일부 엣지 케이스를 놓칠 수 있습니다.

다음과 같이 개선해보세요:

-const isSafari = userAgent.includes("Safari") || /Version\/[\d.]+.*Safari/.test(userAgent);
+const isSafari = /Version\/[\d.]+.*Safari/.test(userAgent) && !userAgent.includes("Chrome");
apps/web/components/Gnb/GnbMenu.tsx (1)

Line range hint 34-57: 웹뷰 조건부 렌더링 로직 개선이 필요합니다.

현재 구현에서는 웹뷰 상태에 따라 Link와 button 사이를 전환하고 있습니다. 이 부분을 더 명확하게 분리하여 관리하면 좋을 것 같습니다.

다음과 같은 방식으로 리팩토링을 고려해보세요:

-as={isWebView ? "button" : Link}
-{...(isWebView
-  ? {
-      type: "button",
-      onClick: () => {
-        handleButtonClick(href);
-      },
-    }
-  : {
-      href,
-    })}
+{...getNavigationProps({ isWebView, href, handleButtonClick })}

그리고 별도의 유틸리티 함수를 추가하세요:

interface NavigationProps {
  isWebView: boolean;
  href: string;
  handleButtonClick: (path: string) => void;
}

const getNavigationProps = ({ isWebView, href, handleButtonClick }: NavigationProps) => {
  if (isWebView) {
    return {
      as: "button",
      type: "button",
      onClick: () => handleButtonClick(href),
    };
  }
  return {
    as: Link,
    href,
  };
};
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dadcbc8 and 1199a7e.

📒 Files selected for processing (10)
  • apps/api/src/controllers/teamController.ts (1 hunks)
  • apps/api/src/models/teamModel.ts (1 hunks)
  • apps/web/app/_components/AuthGuard.tsx (2 hunks)
  • apps/web/app/_hooks/useAppRouter.ts (2 hunks)
  • apps/web/app/_hooks/useDetectWebView.ts (1 hunks)
  • apps/web/app/_hooks/useWebView.ts (0 hunks)
  • apps/web/app/dashboard/_components/EmptyState.tsx (2 hunks)
  • apps/web/app/settings/_components/SettingButtons.tsx (2 hunks)
  • apps/web/components/Gnb/GnbMenu.tsx (2 hunks)
  • apps/web/next.config.mjs (0 hunks)
💤 Files with no reviewable changes (2)
  • apps/web/next.config.mjs
  • apps/web/app/_hooks/useWebView.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: preview
🔇 Additional comments (3)
apps/web/app/_hooks/useDetectWebView.ts (2)

3-9: 인터페이스 정의가 명확하고 잘 구조화되어 있습니다.

각 플랫폼별 상태를 명확하게 구분하여 타입 안정성을 보장합니다.


20-43: useEffect 의존성 배열 최적화가 필요합니다.

useEffect 내부에서 사용되는 모든 외부 의존성이 의존성 배열에 포함되어 있는지 확인이 필요합니다. 현재는 빈 배열이지만, navigator.userAgent가 동적으로 변경될 가능성은 없는지 검토가 필요합니다.

apps/web/components/Gnb/GnbMenu.tsx (1)

11-11: useDetectWebView 훅 통합이 적절히 이루어졌습니다.

기존 useWebView에서 새로운 useDetectWebView로의 마이그레이션이 올바르게 수행되었습니다.

Also applies to: 34-34

import { redirect, useRouter } from "next/navigation";
import { useAuthStore } from "@/app/store/useAuthStore";
import { useWebView } from "../_hooks/useWebView";
import { useDetectWebView } from "../_hooks/useDetectWebView";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

웹뷰 리다이렉트 로직 개선이 필요합니다.

현재 구현에서 몇 가지 개선이 필요한 부분이 있습니다:

  1. 웹뷰 감지 상태가 변경될 경우를 대비하여 useEffect 내부로 리다이렉트 로직을 이동하는 것이 안전합니다:
- if (isWebView) redirect(PAGE_NAME.DASHBOARD);

  useEffect(() => {
+   if (isWebView) {
+     router.replace(PAGE_NAME.DASHBOARD);
+     return;
+   }
    if (isLoggedIn) {
      router.replace(PAGE_NAME.DASHBOARD);
    }
    setIsLoading(false);
-  }, [isLoggedIn, router]);
+  }, [isLoggedIn, router, isWebView]);
  1. 주석을 더 명확하게 작성하면 좋을 것 같습니다:
- // 웹뷰 작업 추가
+ // 웹뷰에서 접근 시 대시보드로 즉시 리다이렉트

Also applies to: 16-17

Copy link
Collaborator

@miraclee1226 miraclee1226 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생많았으👍


// 웹뷰 작업 추가
const { isWebView } = useWebView();
const { isWebView } = useDetectWebView();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 line은 내쪽에서 로직 짜놔서 없애도 돼!

@bokeeeey bokeeeey merged commit a3e078b into develop Jan 22, 2025
1 of 2 checks passed
@bokeeeey bokeeeey deleted the 197-feat-web-router로직과-native-navigation로직-연동 branch January 22, 2025 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] web router로직과 native navigation로직 연동

3 participants