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

fix(dashboard): welcome banner not closing for pocket user #3189

Merged
merged 7 commits into from
Dec 10, 2024

Conversation

rhahao
Copy link
Member

@rhahao rhahao commented Dec 10, 2024

No description provided.

Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

Warning

Rate limit exceeded

@rhahao has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 29 minutes and 10 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 4d3d2ef and b21fe8e.

📒 Files selected for processing (26)
  • src/definition/api.ts (2 hunks)
  • src/features/app_start/pocket/signup/useSignup.tsx (1 hunks)
  • src/features/app_start/vip/startup/useStartup.tsx (1 hunks)
  • src/features/congregation/settings/import_export/export/useExport.tsx (5 hunks)
  • src/features/demo/start/index.tsx (2 hunks)
  • src/features/index.ts (0 hunks)
  • src/features/persons/app_user_profile/index.tsx (3 hunks)
  • src/features/persons/app_user_profile/useAppUserProfile.tsx (1 hunks)
  • src/features/persons/enrollments/index.tsx (2 hunks)
  • src/features/persons/privileges/index.tsx (2 hunks)
  • src/layouts/navbar/index.tsx (1 hunks)
  • src/layouts/root_layout/index.tsx (1 hunks)
  • src/pages/dashboard/congregation/index.tsx (1 hunks)
  • src/pages/dashboard/meeting_materials/index.tsx (1 hunks)
  • src/pages/dashboard/meetings/index.tsx (1 hunks)
  • src/pages/dashboard/ministry/index.tsx (1 hunks)
  • src/pages/dashboard/persons/index.tsx (1 hunks)
  • src/pages/dashboard/reports/index.tsx (1 hunks)
  • src/pages/meeting_materials/public_talks_list/index.tsx (1 hunks)
  • src/pages/meetings/midweek/index.tsx (1 hunks)
  • src/pages/meetings/weekend/index.tsx (1 hunks)
  • src/pages/persons/all_persons/index.tsx (1 hunks)
  • src/pages/persons/all_persons/useAllPersons.tsx (2 hunks)
  • src/pages/persons/person_details/index.tsx (3 hunks)
  • src/pages/persons/person_details/usePersonDetails.tsx (3 hunks)
  • src/services/dexie/assignment.ts (2 hunks)

Walkthrough

This pull request introduces several modifications across various components and hooks in the application. Key changes include updates to type definitions in SessionResponseType and CongregationUserType, the addition of new properties and functions in hooks related to user settings and data export, and the restructuring of import statements for clarity. Component names have been adjusted for specificity, and several hooks have been enhanced to incorporate new state management and data fetching logic. Overall, these changes aim to improve the organization and functionality of the codebase.

Changes

File Change Summary
src/definition/api.ts - Updated last_seen from number to string in SessionResponseType.
- Added optional createdAt property of type string in CongregationUserType.
src/features/app_start/pocket/signup/useSignup.tsx - Added 'cong_settings.cong_new': false to the object in handleUpdateSettings.
src/features/congregation/settings/import_export/export/useExport.tsx - Added assignmentState and weekTypeState variables.
- Introduced handleGetAssignments and handleGetWeekTypes functions.
- Updated handleDownload to include new data.
src/features/demo/start/index.tsx - Renamed component from DemoStatup to DemoStartup.
src/features/index.ts - Deleted file containing export statements for various components.
src/features/persons/app_user_profile/index.tsx - Updated imports and destructured properties in PersonAppUserProfile.
- Changed rendering logic for user description and button icon/text.
src/features/persons/app_user_profile/useAppUserProfile.tsx - Renamed hook from usePersonAppPersonProfile to useAppUserProfile.
- Updated logic for user retrieval and last seen time.
src/features/persons/enrollments/index.tsx - Renamed component from Enrollments to PersonEnrollments.
src/features/persons/privileges/index.tsx - Renamed component from Privileges to PersonPrivileges.
src/layouts/navbar/index.tsx - Replaced imports for AppNotification, DemoBanner, LanguageSwitcher, and ThemeSwitcher with direct imports from their respective paths.
src/layouts/root_layout/index.tsx - Updated imports for various components to individual paths instead of a centralized index file.
src/pages/dashboard/congregation/index.tsx - Updated import paths for DashboardCard and DashboardMenu to their specific files.
src/pages/dashboard/meeting_materials/index.tsx - Updated import paths for DashboardCard and DashboardMenu to their specific files.
src/pages/dashboard/meetings/index.tsx - Updated import paths for DashboardCard and DashboardMenu to their specific files.
src/pages/dashboard/ministry/index.tsx - Updated import paths for DashboardCard, DashboardMenu, and MinistryTimer to their specific files.
src/pages/dashboard/persons/index.tsx - Updated import paths for DashboardCard and DashboardMenu to their specific files.
src/pages/dashboard/reports/index.tsx - Updated import paths for DashboardCard and DashboardMenu to their specific files.
src/pages/meeting_materials/public_talks_list/index.tsx - Updated import path for PublicTalks.
src/pages/meetings/midweek/index.tsx - Updated import paths for MidweekExport, ScheduleAutofillDialog, and WeekSelector to their specific files.
src/pages/meetings/weekend/index.tsx - Updated import paths for ScheduleAutofillDialog and WeekSelector to their specific files.
src/pages/persons/all_persons/index.tsx - Updated import paths for PersonsFilter, PersonsList, and PersonsSearch to their specific files.
src/pages/persons/all_persons/useAllPersons.tsx - Added new imports and utilized useQuery for fetching congregation users.
- Integrated data fetching logic based on user roles and connection status.
src/pages/persons/person_details/index.tsx - Updated imports and rendering logic based on user roles and connection state.
- Renamed PersonAssignment to PersonAssignments.
src/pages/persons/person_details/usePersonDetails.tsx - Added isConnected state and updated return values.
src/services/dexie/assignment.ts - Modified translation assignments for chairman and prayer objects to include meeting types.
src/features/app_start/vip/startup/useStartup.tsx - Added condition to check congName.length === 0 when isAuthenticated is true in runStartupCheck.
- Adjusted error handling for API 404 status.

Possibly related PRs


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.

Copy link

netlify bot commented Dec 10, 2024

Deploy Preview for staging-organized ready!

Name Link
🔨 Latest commit b21fe8e
🔍 Latest deploy log https://app.netlify.com/sites/staging-organized/deploys/67589263bba00c000861978f
😎 Deploy Preview https://deploy-preview-3189--staging-organized.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@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: 4

🧹 Outside diff range and nitpick comments (4)
src/pages/persons/all_persons/useAllPersons.tsx (1)

26-31: Consider handling loading and error states from useQuery

Currently, the code does not handle loading or error states from the useQuery hook. Destructure isLoading, isError, and error from useQuery to provide feedback to users or to handle errors appropriately.

src/features/congregation/settings/import_export/export/useExport.tsx (1)

104-104: Consider keeping JSON formatting for backup files

Removing formatting options from JSON.stringify makes the backup file less readable for debugging purposes.

Consider keeping the formatting for better readability:

-      const prettyJsonData = JSON.stringify(backupData);
+      const prettyJsonData = JSON.stringify(backupData, null, 2);
src/layouts/root_layout/index.tsx (1)

6-26: Improve import organization

The reorganization of imports from centralized to direct paths improves maintainability and module independence. However, consider grouping related imports together (e.g., all feature imports, all component imports) for better readability.

src/layouts/navbar/index.tsx (1)

28-32: Improve import organization

Similar to the root layout, the imports have been reorganized from centralized to direct paths. Consider grouping related imports together for better maintainability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 162b208 and 8756fe2.

📒 Files selected for processing (25)
  • src/definition/api.ts (2 hunks)
  • src/features/app_start/pocket/signup/useSignup.tsx (1 hunks)
  • src/features/congregation/settings/import_export/export/useExport.tsx (5 hunks)
  • src/features/demo/start/index.tsx (2 hunks)
  • src/features/index.ts (0 hunks)
  • src/features/persons/app_user_profile/index.tsx (3 hunks)
  • src/features/persons/app_user_profile/useAppUserProfile.tsx (1 hunks)
  • src/features/persons/enrollments/index.tsx (2 hunks)
  • src/features/persons/privileges/index.tsx (2 hunks)
  • src/layouts/navbar/index.tsx (1 hunks)
  • src/layouts/root_layout/index.tsx (1 hunks)
  • src/pages/dashboard/congregation/index.tsx (1 hunks)
  • src/pages/dashboard/meeting_materials/index.tsx (1 hunks)
  • src/pages/dashboard/meetings/index.tsx (1 hunks)
  • src/pages/dashboard/ministry/index.tsx (1 hunks)
  • src/pages/dashboard/persons/index.tsx (1 hunks)
  • src/pages/dashboard/reports/index.tsx (1 hunks)
  • src/pages/meeting_materials/public_talks_list/index.tsx (1 hunks)
  • src/pages/meetings/midweek/index.tsx (1 hunks)
  • src/pages/meetings/weekend/index.tsx (1 hunks)
  • src/pages/persons/all_persons/index.tsx (1 hunks)
  • src/pages/persons/all_persons/useAllPersons.tsx (2 hunks)
  • src/pages/persons/person_details/index.tsx (3 hunks)
  • src/pages/persons/person_details/usePersonDetails.tsx (3 hunks)
  • src/services/dexie/assignment.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • src/features/index.ts
✅ Files skipped from review due to trivial changes (5)
  • src/features/demo/start/index.tsx
  • src/pages/dashboard/persons/index.tsx
  • src/pages/dashboard/meetings/index.tsx
  • src/pages/dashboard/meeting_materials/index.tsx
  • src/pages/meeting_materials/public_talks_list/index.tsx
🔇 Additional comments (18)
src/pages/persons/all_persons/index.tsx (1)

14-16: LGTM! Good improvement in import organization.

The direct imports from specific feature paths instead of the index file is a good practice that improves maintainability and potentially helps with tree-shaking.

Let's verify the bundle size impact:

✅ Verification successful

Based on the shell script results, I can now generate the final response:

Import changes are properly aligned with the codebase structure

The direct imports from specific feature paths (@features/persons/list, @features/persons/filter, @features/persons/search) are consistent with the codebase organization, as evidenced by:

  1. No other files importing from @features/index
  2. Each feature has its own dedicated directory with an index file
  3. The persons feature components are properly organized in their respective directories:
    • src/features/persons/list/index.tsx
    • src/features/persons/filter/index.tsx
    • src/features/persons/search/index.tsx
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential bundle size impact
# Look for any other index files that might need similar restructuring

# Check for other potential index files with similar export patterns
rg -l "export \{ .+ \} from" --type ts --type tsx

# Look for other imports from @features/index to ensure consistency
rg "@features/index" --type ts --type tsx

Length of output: 149


Script:

#!/bin/bash
# Let's try without file type filters since tsx isn't recognized
# Check for other potential index files with similar export patterns
rg -l "export \{ .+ \} from"

# Look for other imports from @features/index
rg "@features/index"

# Also check for the existence and content of any index files in the features directory
fd "index\.(ts|tsx|js|jsx)$" src/features

# If we find any index files, let's look at their content
fd "index\.(ts|tsx|js|jsx)$" src/features -x cat {}

Length of output: 67531

src/pages/persons/person_details/usePersonDetails.tsx (1)

17-17: LGTM!

The integration of isConnected into the hook is correctly implemented.

Also applies to: 48-48

src/features/persons/app_user_profile/index.tsx (1)

Line range hint 12-43: Component properly updates UI based on user state

The component correctly adapts its display and behavior based on the presence of the user object, enhancing user experience.

src/features/persons/enrollments/index.tsx (1)

9-9: LGTM! Component rename improves clarity.

The rename from Enrollments to PersonEnrollments provides better context and aligns with the component's specific purpose.

Let's verify that all imports of this component have been updated:

Also applies to: 77-77

✅ Verification successful

Component rename is correctly implemented across the codebase

The search results confirm that the component rename from Enrollments to PersonEnrollments is properly reflected in all imports. The only references to the new PersonEnrollments component are in:

  • The component definition file (src/features/persons/enrollments/index.tsx)
  • Its usage in the person details page (src/pages/persons/person_details/index.tsx)

All other occurrences of "Enrollments" in the codebase are unrelated to this component (they refer to different components like PrivilegesEnrollments or are part of variable names and data structures).

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to the old component name
rg "Enrollments" --type tsx --type ts

Length of output: 65


Script:

#!/bin/bash
# Search for any remaining references to the old component name using ripgrep
# Note: Using just file extensions instead of file types
rg "Enrollments" -g "*.tsx" -g "*.ts"

Length of output: 1559

src/features/persons/privileges/index.tsx (1)

9-9: LGTM! Consistent component naming.

The rename from Privileges to PersonPrivileges maintains consistency with other person-related components.

Let's verify that all imports of this component have been updated:

Also applies to: 79-79

✅ Verification successful

All references to the renamed component have been properly updated

The verification shows that all occurrences of "Privileges" in the codebase are either:

  • The new PersonPrivileges component name itself and its import
  • Related but different identifiers (like usePrivileges hook)
  • Unrelated usage in the services layer (personEndActivePrivileges)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to the old component name
rg "Privileges\s" --type tsx --type ts

Length of output: 68


Script:

#!/bin/bash
# Search for any remaining references to the old component name using ripgrep
# Note: Using just file extensions instead of file types
rg "Privileges\s" -g "*.tsx" -g "*.ts"

Length of output: 655

src/pages/persons/person_details/index.tsx (3)

9-18: LGTM: Improved import organization

The granular imports from @features/persons improve code maintainability by making dependencies explicit and easier to track.


89-89: Verify component rename impact

The rename from PersonAssignment to PersonAssignments suggests a change in data handling. Let's verify all references are updated.

✅ Verification successful

Component naming is consistent across the codebase

The search results show that PersonAssignments is being used consistently throughout the codebase. There are two related but distinct components:

  • PersonAssignments in @features/persons/assignments
  • PersonAssignmentsHistory in @features/persons/assignments_history

Both components are properly imported and used in person_details/index.tsx. There's no evidence of any remaining references to a singular "PersonAssignment" component, indicating the naming is consistent.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to old component name
rg "PersonAssignment[^s]"

Length of output: 27


Script:

#!/bin/bash
# Let's try a broader search to understand the component usage
rg "PersonAssignment" -A 2

Length of output: 1322


Script:

#!/bin/bash
# Also search for component definition
ast-grep --pattern 'const PersonAssignment'

Length of output: 45


Script:

#!/bin/bash
# Check git history for recent renames
git log --oneline -S "PersonAssignment" --since="1 month ago"

Length of output: 0


25-25: Verify access control implementation

The addition of isAdmin and isConnected checks suggests a security enhancement. However, let's verify this aligns with the access control requirements.

Also applies to: 27-27

✅ Verification successful

Let me gather more context about the access control implementation by checking the useCurrentUser hook and related components.


Access control implementation verified and properly layered

The access control implementation for the PersonAppUserProfile component follows a secure pattern with multiple conditions:

  • Component is only rendered when user is an admin (isAdmin)
  • Requires an active connection (isConnected)
  • Not available for new persons (!isNewPerson)

The broader access control using isPersonEditor and isAdmin is consistently implemented across the codebase, particularly in congregation and person management features.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other instances of isAdmin checks in person-related components
rg -A 3 "isAdmin.*PersonAppUserProfile" 

# Search for access control patterns in person features
ast-grep --pattern 'const { $$$, isAdmin } = useCurrentUser();'

Length of output: 1604


Script:

#!/bin/bash
# Check the implementation of useCurrentUser hook
ast-grep --pattern 'export function useCurrentUser() {
  $$$
}'

# Check PersonAppUserProfile component implementation
ast-grep --pattern 'function PersonAppUserProfile() {
  $$$
}'

# Look for other access control patterns in person details
rg -A 3 "isPersonEditor|isConnected" src/pages/persons/person_details/

Length of output: 1988

src/pages/meetings/weekend/index.tsx (1)

9-9: LGTM: Component organization improvement

The imports have been moved to dedicated feature folders, improving code organization.

Also applies to: 13-13

src/features/congregation/settings/import_export/export/useExport.tsx (1)

88-88: Verify data model compatibility

The addition of assignments and week types to the export data structure needs verification for backward compatibility.

Also applies to: 100-100

✅ Verification successful

The initial search revealed backup-related files but we need to verify the data model and import functionality specifically. These new commands will help us understand:

  1. The backup data type structure
  2. The import functionality implementation
  3. How assignments are handled during import

This will help us determine if the addition of assignments to the export structure maintains backward compatibility.


The previous search revealed the backup data type definitions, but we need to understand:

  1. How the import functionality handles assignments
  2. How assignments are processed during export
  3. Any data transformations that might maintain backward compatibility

This will help us determine if the addition of assignments to the export structure is safely handled during import.


The previous search showed the export functionality for assignments is simple and only includes basic properties (code and name). We need to verify:

  1. How the import functionality handles assignments
  2. The assignment data structure/types
  3. Any version or compatibility checks during import

This will help us determine if there are any compatibility concerns with the assignment data structure.


Based on the gathered information, I can now provide the final response:

Export structure changes maintain backward compatibility

The addition of assignments to the export data structure is safe because:

  1. The export includes version information (PACKAGE_VERSION) in the payload
  2. The assignments export is minimal, only including basic properties (code and assignment_type_name)
  3. The backup data type definitions (BackupDataType) show assignments are optional fields
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for import functionality to verify compatibility
rg -A 5 "import.*backup" 

# Check for existing backup format documentation
fd -g "*backup*.md" -g "*export*.md"

Length of output: 27271


Script:

#!/bin/bash
# Let's check the backup data type definition and import functionality
ast-grep --pattern 'type BackupDataType = {
  $$$
}'

# Search for import functionality implementation
ast-grep --pattern 'const $_ = async ($$$) => {
  $$$
  import $$$
  $$$
}'

# Check for any existing assignments handling in backup/import
rg -A 5 "assignments.*import" 

Length of output: 4533


Script:

#!/bin/bash
# Let's check the import functionality implementation
rg -A 10 "handleImport.*=" 

# Check for assignments handling in the export functionality
rg -A 10 "handleGetAssignments.*=" 

# Check for any data transformation during import/export
rg -A 5 "transform.*assignments"

Length of output: 1122


Script:

#!/bin/bash
# Let's check the import functionality implementation
ast-grep --pattern 'const handleImport = ($$$) => {
  $$$
}'

# Check for assignment-related types and interfaces
rg -A 5 "type.*Assignment"
rg -A 5 "interface.*Assignment"

# Check for any version or compatibility checks in import/export
rg -A 5 "version.*import|compatibility.*import"

Length of output: 49380

src/definition/api.ts (2)

244-244: LGTM! Non-breaking change to user type

The addition of optional createdAt field is backward compatible.


29-29: Verify timestamp format consistency across the application

The change from number to string for last_seen suggests a shift in timestamp representation. Ensure all consumers of this type are updated to handle string timestamps correctly.

✅ Verification successful

Let's broaden our search to understand the usage context of last_seen and SessionResponseType in the codebase. This will help us verify if the type change impacts any date/time handling logic.


Type change to string is correctly handled across the codebase

The change from number to string for last_seen is safe as all consumers are already handling it as a string:

  • In useAppUserProfile.tsx, it's used with localeCompare for sorting and parsed with new Date(last_seen)
  • In useSessionItem.tsx, it's parsed using new Date(session.last_seen)
  • No direct numeric operations are performed on the value
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usages of SessionResponseType.last_seen to verify correct handling
ast-grep --pattern 'last_seen: $_' 
rg -A 2 'last_seen.*SessionResponseType'

Length of output: 79


Script:

#!/bin/bash
# Search for usages of last_seen in the codebase
rg "last_seen" -A 3 -B 1

# Search for SessionResponseType definition and usage
rg "SessionResponseType" -A 5 -B 1

# Search for any date/time parsing or formatting of last_seen
rg "last_seen.*(?:parse|format|Date|moment|dayjs)" -A 2

Length of output: 8330

src/features/app_start/pocket/signup/useSignup.tsx (1)

105-105: LGTM! Fix for welcome banner persistence

Setting cong_settings.cong_new to false during signup should prevent the welcome banner from appearing unnecessarily for pocket users.

✅ Verification successful

Let me gather more information about the welcome banner implementation to verify this change properly.


Let me search specifically for the welcome banner implementation and its relationship with settings.


Let me check the initial setup component to understand how the welcome state is handled.


Based on the gathered evidence, I can now provide the final response:

Setting cong_new to false is the correct approach for preventing the welcome banner

The code review confirms this change is correct because:

  • The useInitialSetup hook controls the welcome/setup flow based on cong_settings.cong_new
  • The same pattern of setting cong_new: false is consistently used across other signup/authentication flows
  • The initial setup is only shown when isNew && isAdmin is true, where isNew is derived from cong_settings.cong_new
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify welcome banner's dependency on cong_new setting
rg -A 5 "cong_new.*welcome.*banner"
ast-grep --pattern 'cong_settings.cong_new'

Length of output: 165


Script:

#!/bin/bash
# Search for welcome banner related code and its conditions
rg -A 5 "welcome.*banner|WelcomeBanner"

# Search for any other occurrences of cong_new
rg "cong_new"

# Look for settings related to new user or welcome states
ast-grep --pattern 'const $_ = useSelector((state: RootState) => state.settings)'

Length of output: 2079


Script:

#!/bin/bash
# Search for files containing WelcomeBanner component
fd -e tsx -e jsx WelcomeBanner

# Search for welcome banner component implementation
ast-grep --pattern 'const WelcomeBanner = $_'

# Search for isNew usage in components
ast-grep --pattern 'const isNew = $_'

Length of output: 240


Script:

#!/bin/bash
# Check the implementation of initial setup component
cat src/features/dashboard/initial_setup/useInitialSetup.tsx

# Look for any components that might render based on isNew
rg -A 5 "isNew.*render|isNew.*show|isNew.*display"

Length of output: 1018

src/services/dexie/assignment.ts (1)

146-168: LGTM! Consistent naming pattern for weekend meeting assignments

The weekend meeting chairman and prayer assignment names follow the same clear pattern of combining role and meeting type.

src/pages/dashboard/ministry/index.tsx (1)

9-11: Import refactoring appears unrelated to PR objective

While the import path changes improve code organization, they seem unrelated to fixing the welcome banner closing issue for pocket users. Please clarify how these changes contribute to the PR's objective.

Let's verify if there are any welcome banner related files that should be modified instead:

src/pages/dashboard/reports/index.tsx (1)

9-10: Scope of changes exceeds PR objective

These import refactoring changes, while beneficial for code organization, appear to be outside the scope of fixing the welcome banner closing issue. Consider separating these refactoring changes into a different PR to maintain focused changesets.

Let's check if there are any welcome banner components that import from @features/index:

src/pages/dashboard/congregation/index.tsx (1)

10-11: Consider separating refactoring from bug fix

The import path changes across multiple files suggest a broader refactoring effort. However, the PR's title and objective specifically mention fixing the welcome banner closing functionality for pocket users. These changes don't appear to address that issue.

Let's verify if we're missing any welcome banner related changes:

src/layouts/navbar/index.tsx (1)

Line range hint 1-391: Verify PR objective alignment

The changes in this file appear to be refactoring imports without addressing the stated PR objective of fixing the welcome banner closure for pocket users. Please verify if there are missing changes or if these changes are prerequisites for the fix.

src/services/dexie/assignment.ts Outdated Show resolved Hide resolved
src/pages/dashboard/congregation/index.tsx Show resolved Hide resolved
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 10, 2024
Copy link
Contributor

@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: 1

🧹 Outside diff range and nitpick comments (1)
src/features/app_start/vip/startup/useStartup.tsx (1)

Line range hint 150-171: LGTM! Consider refactoring for maintainability.

The logic for handling authenticated users with missing congregation setup looks correct. However, the runStartupCheck function has grown quite complex with deep nesting levels.

Consider extracting the congregation setup logic into a separate function for better maintainability:

+ const handleCongregationSetup = (
+   result: { cong_id: string; cong_master_key?: string; cong_access_code?: string },
+   masterKeyNeeded: boolean
+ ) => {
+   setCongID(result.cong_id);
+   
+   if (masterKeyNeeded && result.cong_master_key?.length === 0) {
+     setCurrentStep(1);
+   }
+   
+   if (
+     masterKeyNeeded &&
+     result.cong_master_key?.length > 0 &&
+     result.cong_access_code?.length === 0
+   ) {
+     setCurrentStep(2);
+   }
+   
+   setIsLoading(false);
+   setIsStart(false);
+   setCongCreate(true);
+ };

  // In runStartupCheck:
- if (
-   isAuthenticated &&
-   congName.length === 0 &&
-   (remoteMasterKey.length === 0 || remoteAccessCode.length === 0)
- ) {
-   setCongID(result.cong_id);
-   
-   if (masterKeyNeeded && remoteMasterKey.length === 0) {
-     setCurrentStep(1);
-   }
-   
-   if (
-     masterKeyNeeded &&
-     remoteMasterKey.length > 0 &&
-     remoteAccessCode.length === 0
-   ) {
-     setCurrentStep(2);
-   }
-   
-   setIsLoading(false);
-   setIsStart(false);
-   setCongCreate(true);
-   return;
- }
+ if (
+   isAuthenticated &&
+   congName.length === 0 &&
+   (remoteMasterKey.length === 0 || remoteAccessCode.length === 0)
+ ) {
+   handleCongregationSetup(result, masterKeyNeeded);
+   return;
+ }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8756fe2 and 4d3d2ef.

📒 Files selected for processing (3)
  • src/features/app_start/vip/startup/useStartup.tsx (1 hunks)
  • src/features/persons/app_user_profile/useAppUserProfile.tsx (1 hunks)
  • src/services/dexie/assignment.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/services/dexie/assignment.ts
🔇 Additional comments (7)
src/features/persons/app_user_profile/useAppUserProfile.tsx (6)

1-18: LGTM! Hook renaming improves clarity

The rename from usePersonAppPersonProfile to useAppUserProfile makes the hook name more concise while maintaining clarity about its purpose.


19-24: LGTM! Proper memoization of user lookup

The memoization is correctly implemented with appropriate dependencies, and the user lookup logic is sound.


33-35: Fix potential incorrect sorting of sessions by last_seen timestamp

Sorting dates using localeCompare on strings may not yield correct chronological order.


40-52: LGTM! Well-structured user description logic

The implementation properly handles all cases with appropriate translations and date formatting.


54-61: LGTM! Clean navigation logic

The navigation logic is clear and handles both registered and unregistered user cases appropriately.


63-66: LGTM! Clean and focused exports

The hook exports exactly what's needed for the welcome banner functionality.

src/features/app_start/vip/startup/useStartup.tsx (1)

Line range hint 150-171: Verify error handling for congregation setup.

The new congregation setup flow might need additional error handling for edge cases.

Let's verify the error handling in the codebase:

@rhahao rhahao merged commit 0f50543 into sws2apps:main Dec 10, 2024
14 checks passed
Copy link

cypress bot commented Dec 10, 2024

organized-app    Run #1778

Run Properties:  status check passed Passed #1778  •  git commit 0f505432e9: chore(persons): update sorting option to get last seen
Project organized-app
Branch Review main
Run status status check passed Passed #1778
Run duration 00m 09s
Commit git commit 0f505432e9: chore(persons): update sorting option to get last seen
Committer rhahao
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 1
View all changes introduced in this branch ↗︎

@rhahao
Copy link
Member Author

rhahao commented Dec 15, 2024

🎉 This PR is included in version 3.4.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant