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

App Hotfixes #3222

Merged
merged 11 commits into from
Dec 14, 2024
Merged

App Hotfixes #3222

merged 11 commits into from
Dec 14, 2024

Conversation

rhahao
Copy link
Member

@rhahao rhahao commented Dec 14, 2024

No description provided.

Copy link
Contributor

coderabbitai bot commented Dec 14, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request encompasses multiple files across various features, focusing on TypeScript type refinements, UI component styling adjustments, and subtle logic modifications. The changes primarily involve simplifying type declarations, enhancing component interactions, and refining state management logic. Key areas of modification include styled components, report handling, assignment management, and user interface improvements.

Changes

File Path Change Summary
src/components/assignments_checklist/assignments_checklist.styles.tsx Removed TypeScript type annotations from styled components, cast to unknown and specific types. HeaderBox styling logic updated to remove disabled prop handling.
src/components/select/index.styles.tsx Updated import for styled, exported SelectStyled, added disabled icon styling.
src/components/select/index.tsx Consolidated imports, added disabled prop to FormControl, updated InputLabel styling, and enhanced SelectStyled with MenuProps.
src/components/timefield/index.tsx Renamed style to sx, updated logic for input text color based on value length, added opacity style for placeholder.
src/features/congregation/app_access/user_add/person_select/index.tsx Changed readOnly prop to disabled for Autocomplete component, affecting user interaction based on user type.
src/features/ministry/report/* Simplified time calculation and report data management logic in multiple hooks.
src/features/persons/assignment_group/useAssignmentGroup.tsx Enhanced group and assignment disabled state logic.
src/features/persons/assignments/useAssignments.tsx Refined assignment management logic in handleToggleGroup and handleToggleAssignment functions.
src/features/reminders/useReminders.tsx Updated role-based reminder determination.
src/features/reports/publisher_records_details/* Added new props and enhanced report status tracking.
src/features/reports/service_year_month_selector/month_selector/index.tsx Added disabled attribute to Select component based on readOnly prop.
src/features/congregation/field_service_groups/group_members/* Introduced new input handling in GroupMembers component and useGroupMembers hook for better interactivity.
src/features/persons/speakers_catalog/my_congregation/speaker_edit/index.tsx Added filtering functionality in AutocompleteMultiple component for improved usability.

Possibly related PRs

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. This feature will be included in our Pro Plan when released.


📜 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 51cb497 and e4c487d.

⛔ Files ignored due to path filters (1)
  • src/locales/en/ministry.json is excluded by !**/*.json
📒 Files selected for processing (25)
  • src/components/assignments_checklist/assignments_checklist.styles.tsx (3 hunks)
  • src/components/assignments_checklist/index.tsx (1 hunks)
  • src/components/select/index.styles.tsx (2 hunks)
  • src/components/select/index.tsx (2 hunks)
  • src/components/timefield/index.tsx (1 hunks)
  • src/features/congregation/app_access/user_add/person_select/index.tsx (1 hunks)
  • src/features/congregation/field_service_groups/group_members/index.tsx (2 hunks)
  • src/features/congregation/field_service_groups/group_members/useGroupMembers.tsx (3 hunks)
  • src/features/ministry/report/ministry_timer/add_time_dialog/useAddTimeDialog.tsx (1 hunks)
  • src/features/ministry/report/ministry_timer/useMinistryTimer.tsx (3 hunks)
  • src/features/ministry/report/report_form_dialog/service_time/useServiceTime.tsx (0 hunks)
  • src/features/ministry/report/standard_editor/index.styles.ts (1 hunks)
  • src/features/ministry/report/standard_editor/index.tsx (1 hunks)
  • src/features/persons/assignment_group/useAssignmentGroup.tsx (3 hunks)
  • src/features/persons/assignments/useAssignments.tsx (1 hunks)
  • src/features/persons/speakers_catalog/my_congregation/speaker_edit/index.tsx (1 hunks)
  • src/features/reminders/useReminders.tsx (2 hunks)
  • src/features/reports/field_service/persons_list/usePersonsList.tsx (3 hunks)
  • src/features/reports/publisher_records/years_stats/useYearsStats.tsx (2 hunks)
  • src/features/reports/publisher_records_details/month_item/index.tsx (2 hunks)
  • src/features/reports/publisher_records_details/month_item/useMonthItem.tsx (4 hunks)
  • src/features/reports/publisher_records_details/report_details/late_report/index.tsx (1 hunks)
  • src/features/reports/publisher_records_details/report_details/late_report/useLateReport.tsx (1 hunks)
  • src/features/reports/publisher_records_details/years_stats/useYearsStats.tsx (2 hunks)
  • src/features/reports/service_year_month_selector/month_selector/index.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.

Copy link

netlify bot commented Dec 14, 2024

Deploy Preview for staging-organized ready!

Name Link
🔨 Latest commit e4c487d
🔍 Latest deploy log https://app.netlify.com/sites/staging-organized/deploys/675d53a4dd7ecd0008f14046
😎 Deploy Preview https://deploy-preview-3222--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 (11)
src/features/reports/publisher_records/years_stats/useYearsStats.tsx (2)

11-11: Fix typo in variable name.

The variable name 'intial_value' contains a typo and should be 'initial_value'.

-  const intial_value = useMemo(() => {
+  const initial_value = useMemo(() => {

Line range hint 1-31: Consider consolidating duplicate hook implementations.

This hook appears to be duplicated in both src/features/reports/publisher_records/years_stats/useYearsStats.tsx and src/features/reports/publisher_records_details/years_stats/useYearsStats.tsx. Consider extracting it to a shared location to avoid code duplication.

Consider moving this hook to a shared location, such as:

+ src/features/reports/shared/hooks/useYearsStats.tsx
src/features/reports/publisher_records_details/years_stats/useYearsStats.tsx (1)

11-11: Fix typo in variable name.

The variable name 'intial_value' contains a typo and should be 'initial_value'.

-  const intial_value = useMemo(() => {
+  const initial_value = useMemo(() => {
src/features/reports/service_year_month_selector/month_selector/index.tsx (1)

22-22: Consider consolidating readOnly and disabled props

The component uses both readOnly and disabled props with the same value. This is redundant and could lead to maintenance issues. Consider:

  1. Using only disabled prop
  2. Renaming readOnly to disabled throughout the codebase
  3. Documenting why both props are needed if they serve different purposes
src/components/assignments_checklist/assignments_checklist.styles.tsx (1)

Line range hint 4-49: Consider using a consistent type-safe pattern for styled components

The current approach of casting components as unknown and then to their respective types might bypass TypeScript's type checking benefits. Consider using a more type-safe pattern:

-export const HeaderBox = styled(Box)({
  // ...styles
-}) as unknown as typeof Box;

+export const HeaderBox = styled(Box)<{ disabled?: boolean }>({
  // ...styles
+});

This pattern would:

  1. Maintain type safety
  2. Make props explicitly visible in the component's type signature
  3. Enable better IDE support and type checking
src/components/timefield/index.tsx (1)

30-30: Consider accessibility implications of placeholder opacity

Setting placeholder opacity to 1 might affect accessibility. Consider:

  1. Color contrast ratios between placeholder text and background
  2. Distinguishability between placeholder and actual value

Consider using MUI's built-in placeholder styling or ensuring WCAG compliance:

-'&::placeholder': { opacity: 1 },
+'&::placeholder': { 
+  opacity: 1,
+  color: 'var(--accent-350)',
+},
src/features/reports/publisher_records_details/report_details/late_report/index.tsx (1)

23-56: Consider extracting warning box to a reusable component

The warning box styling could be reused across the application. Consider extracting it into a reusable component.

Create a new component like WarningBox:

interface WarningBoxProps {
  message: string;
  icon?: React.ReactNode;
}

const WarningBox: React.FC<WarningBoxProps> = ({ message, icon = <IconInfo /> }) => (
  <Box
    sx={{
      borderRadius: 'var(--radius-xl)',
      padding: '16px',
      backgroundColor: 'var(--orange-secondary)',
      display: 'flex',
      gap: '8px',
      alignItems: 'center',
    }}
  >
    {icon}
    <Typography className="body-small-regular" color="var(--orange-dark)">
      {message}
    </Typography>
  </Box>
);
src/components/select/index.tsx (1)

1-2: Consider using more specific imports for better tree-shaking.

Instead of importing multiple components in one line, consider separate imports for better tree-shaking:

-import { FormControl, InputLabel, Theme } from '@mui/material';
+import FormControl from '@mui/material/FormControl';
+import InputLabel from '@mui/material/InputLabel';
+import type { Theme } from '@mui/material/styles';
src/features/persons/assignment_group/useAssignmentGroup.tsx (1)

44-70: Consider simplifying complex MM assignment rules

The mutual exclusion logic between MM_AssistantOnly and other MM assignments is complex and could be simplified for better maintainability.

Consider extracting these checks into separate helper functions:

+const hasConflictingMMAssignments = (assignments: Assignment[]) => 
+  assignments.some(
+    (record) =>
+      (record.code >= AssignmentCode.MM_StartingConversation &&
+        record.code <= AssignmentCode.MM_Discussion) ||
+      record.code == AssignmentCode.MM_Talk
+  );

+const hasMMAssistantOnly = (assignments: Assignment[]) =>
+  assignments.some(
+    (record) => record.code === AssignmentCode.MM_AssistantOnly
+  );

 const checkAssignmentDisabled = (code: AssignmentCode) => {
   // ...
   if (code === AssignmentCode.MM_AssistantOnly) {
-    if (
-      assignments.some(
-        (record) =>
-          (record.code >= AssignmentCode.MM_StartingConversation &&
-            record.code <= AssignmentCode.MM_Discussion) ||
-          record.code == AssignmentCode.MM_Talk
-      )
-    ) {
+    if (hasConflictingMMAssignments(assignments)) {
       return true;
     }
   }
src/components/assignments_checklist/index.tsx (1)

121-121: Consider using standard opacity value format

The opacity value 24% is unconventional. Consider using the decimal format 0.24 or rounding to 0.25 (25%) for consistency with standard practices.

-          opacity: disabled && '24%',
+          opacity: disabled ? 0.24 : 1,
src/features/reports/publisher_records_details/month_item/index.tsx (1)

39-51: Consider optimizing tooltip performance

The tooltip implementation is well-structured, but wrapping the entire Box component might cause unnecessary re-renders. Consider moving the tooltip to wrap only the Typography component where the exclusion status is most relevant.

-    <Tooltip title={t('tr_reportExcluded')} followCursor show={not_publisher}>
-      <Box
+    <Box
        sx={{
          padding: '2px 8px',
          display: 'flex',
          alignItems: 'center',
          justifyContent: 'space-between',
          gap: '16px',
          minHeight: '28px',
        }}
        onMouseEnter={handleHover}
        onMouseLeave={handleUnhover}
-      >
+      >

Then wrap just the Typography component:

-            <Typography
+            <Tooltip title={t('tr_reportExcluded')} followCursor show={not_publisher}>
+              <Typography
                className="h4"
                sx={{
                  color:
                    isAhead || not_publisher ? 'var(--grey-300)' : 'var(--black)',
                }}
              >
                {monthname}
-              </Typography>
+              </Typography>
+            </Tooltip>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8e0df15 and e63a622.

⛔ Files ignored due to path filters (1)
  • src/locales/en/ministry.json is excluded by !**/*.json
📒 Files selected for processing (22)
  • src/components/assignments_checklist/assignments_checklist.styles.tsx (3 hunks)
  • src/components/assignments_checklist/index.tsx (1 hunks)
  • src/components/select/index.styles.tsx (2 hunks)
  • src/components/select/index.tsx (2 hunks)
  • src/components/timefield/index.tsx (1 hunks)
  • src/features/congregation/app_access/user_add/person_select/index.tsx (1 hunks)
  • src/features/ministry/report/ministry_timer/add_time_dialog/useAddTimeDialog.tsx (1 hunks)
  • src/features/ministry/report/ministry_timer/useMinistryTimer.tsx (3 hunks)
  • src/features/ministry/report/report_form_dialog/service_time/useServiceTime.tsx (0 hunks)
  • src/features/ministry/report/standard_editor/index.styles.ts (1 hunks)
  • src/features/ministry/report/standard_editor/index.tsx (1 hunks)
  • src/features/persons/assignment_group/useAssignmentGroup.tsx (3 hunks)
  • src/features/persons/assignments/useAssignments.tsx (1 hunks)
  • src/features/reminders/useReminders.tsx (2 hunks)
  • src/features/reports/field_service/persons_list/usePersonsList.tsx (3 hunks)
  • src/features/reports/publisher_records/years_stats/useYearsStats.tsx (2 hunks)
  • src/features/reports/publisher_records_details/month_item/index.tsx (2 hunks)
  • src/features/reports/publisher_records_details/month_item/useMonthItem.tsx (4 hunks)
  • src/features/reports/publisher_records_details/report_details/late_report/index.tsx (1 hunks)
  • src/features/reports/publisher_records_details/report_details/late_report/useLateReport.tsx (1 hunks)
  • src/features/reports/publisher_records_details/years_stats/useYearsStats.tsx (2 hunks)
  • src/features/reports/service_year_month_selector/month_selector/index.tsx (1 hunks)
💤 Files with no reviewable changes (1)
  • src/features/ministry/report/report_form_dialog/service_time/useServiceTime.tsx
🔇 Additional comments (21)
src/features/ministry/report/standard_editor/index.styles.ts (1)

25-25: Type assertion looks correct but verify type safety.

The type assertion ensures the styled component maintains the same type interface as the base TextField component. However, ensure that all TextField props are properly handled by the styled component to maintain type safety.

Let's verify the TextField component usage:

✅ Verification successful

Type assertion is safe and correctly implemented

The type assertion is appropriate because:

  • The styled component only adds CSS customizations without modifying the component's behavior
  • All TextField props are properly passed through to the base component
  • The implementation correctly handles number input fields with proper type safety through TextFieldStandardProps
  • The styling modifications are purely cosmetic (text alignment, spin button removal, border styling)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for TextFieldStandard usage to ensure proper prop passing
ast-grep --pattern 'TextFieldStandard $props={$$$}'

Length of output: 53


Script:

#!/bin/bash
# Let's try a different pattern to find TextFieldStandard usage
rg "TextFieldStandard" -A 2 -B 2

# Also search for the styled component definition
ast-grep --pattern 'const TextFieldStandard = styled(TextField)`$$$`'

Length of output: 3346


Script:

#!/bin/bash
# Let's check the TextFieldStandardProps type definition and usage
cat src/features/ministry/report/standard_editor/index.types.ts

# And check the actual implementation to see how props are handled
cat src/features/ministry/report/standard_editor/index.tsx

Length of output: 2146


Script:

#!/bin/bash
# Let's check the base TextField component's implementation to verify prop types
cat src/components/textfield/index.tsx

# And check the styled component implementation
cat src/features/ministry/report/standard_editor/index.styles.ts

Length of output: 6904

src/features/reports/publisher_records_details/years_stats/useYearsStats.tsx (1)

Line range hint 1-31: Duplicate implementation detected.

This is an identical implementation to the hook in src/features/reports/publisher_records/years_stats/useYearsStats.tsx. Please refer to the previous comment about consolidating these implementations into a shared location.

src/components/select/index.styles.tsx (1)

1-1: Verify the impact of changing the styled import source

The import source has changed from '@mui/system' to '@mui/material'. While this might work, it's a significant change for a hotfix.

src/components/assignments_checklist/assignments_checklist.styles.tsx (1)

4-9: Verify the disabled state handling across components

The HeaderBox no longer accepts the disabled prop directly. Ensure that the opacity styling for disabled states is properly handled in the parent component.

✅ Verification successful

Disabled state handling has been properly migrated

The opacity styling for disabled states has been correctly moved to the parent component in index.tsx, where it's applied directly through the sx prop: opacity: disabled && '24%'. This is a valid refactoring that moves the presentational logic closer to where the disabled prop is managed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for HeaderBox usage to verify disabled state handling
rg -A 5 "HeaderBox.*disabled" src/

Length of output: 36


Script:

#!/bin/bash
# First, let's find the index.tsx file in the assignments_checklist directory
fd "index.tsx" "src/components/assignments_checklist"

# Then, let's check its content to see how disabled state is handled
rg -B 2 -A 5 "HeaderBox" "src/components/assignments_checklist"

# Also search for any opacity-related styling in the same component
rg "opacity" "src/components/assignments_checklist"

Length of output: 2660

src/components/timefield/index.tsx (1)

27-29: Verify color logic edge cases

The condition props.value.length === 0 || props.value === '0:00' might have edge cases:

  1. What happens with whitespace-only values?
  2. Should we trim the value before checking?
✅ Verification successful

Let me analyze the TimeField component's implementation and usage to verify the color logic edge cases.


Let me analyze the complete implementation to understand how the value prop is handled and validate the color logic edge cases.


Color logic is properly handled for edge cases

The current color logic condition is correct and handles edge cases appropriately because:

  1. Empty values are handled explicitly through value.length === 0
  2. The default/initial state '0:00' is handled separately
  3. The useTimeField hook ensures proper value formatting:
    • Empty values are converted to '' on blur
    • Input validation prevents whitespace-only values
    • Value updates are strictly controlled through digit input and arrow controls
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for TimeField usage patterns and value handling
rg -A 5 "TimeField.*value=" src/

Length of output: 34


Script:

#!/bin/bash
# Search for TimeField component usage with a broader pattern
rg -l "TimeField" src/

# Then search for value prop handling in the TimeField component
ast-grep --pattern 'interface $_ {
  $$$
  value?: $_
  $$$
}'  src/components/timefield/index.tsx

# Check TimeField component's value handling
ast-grep --pattern 'const $_ = ({value, $$$}: $_Props) => {
  $$$
}' src/components/timefield/index.tsx

Length of output: 397


Script:

#!/bin/bash
# Check the TimeField component's type definitions
cat src/components/timefield/index.types.ts

# Check the implementation of useTimeField hook
cat src/components/timefield/useTimeField.tsx

# Check the actual usage in hours editor
cat src/features/ministry/report/hours_editor/index.tsx

Length of output: 7902

src/features/reports/publisher_records_details/report_details/late_report/index.tsx (1)

24-40: Verify accessibility and translation of the warning message

The warning message UI looks good, but consider:

  1. Verify the translation key exists
  2. Ensure color contrast meets WCAG standards
  3. Consider adding aria-label for screen readers
✅ Verification successful

Let me generate the final response based on the verification results:

Warning message implementation meets requirements

The implementation looks good because:

  1. Translation key tr_alreadySubmittedWarning exists across all language files with proper translations
  2. The warning pattern with IconInfo and orange colors is consistently used across similar warning messages in the codebase
  3. Color contrast is maintained using the established --orange-dark on --orange-secondary combination
  4. The warning is semantically structured using Typography component which preserves text accessibility
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if translation key exists
rg "tr_alreadySubmittedWarning" src/

# Search for similar warning patterns
rg -A 5 "IconInfo.*orange-dark" src/

Length of output: 9655

src/components/select/index.tsx (1)

13-13: Good accessibility improvement with disabled state handling!

The addition of proper disabled state handling and consistent color variables improves the component's accessibility and user experience.

Also applies to: 21-21

src/features/reports/publisher_records_details/report_details/late_report/useLateReport.tsx (1)

64-71: Clean addition of branch_submitted to return object.

The addition of branch_submitted to the return object is well-structured and maintains the existing functionality.

src/features/persons/assignment_group/useAssignmentGroup.tsx (4)

10-11: LGTM: State initialization is correctly positioned

The initialization of the person state using useRecoilValue is properly placed at the top level of the hook.


35-37: LGTM: Proper handling of deleted assignments

The filter ensures that deleted assignments don't affect the disabled state calculations.


93-93: LGTM: Cleaner gender-based restriction logic

The condition has been simplified while maintaining the same functionality.


16-18: Verify the bypass of publisher check for FR users

The new condition allows French users (isFR) to bypass the publisher check for the 'ministry' group. Please verify if this is the intended behavior.

✅ Verification successful

Let me gather more context about the ministry group and publisher checks.


Let me try a different approach to understand the context better.


Based on the comprehensive code analysis, I can now provide a final response about the FR-specific check in the ministry group.

The bypass of publisher check for FR users is the intended behavior

The code shows this is a deliberate design choice where:

  1. French Regular Pioneers (FR) are allowed to access the ministry group regardless of publisher status
  2. For non-FR users, the publisher check remains enforced
  3. This aligns with the broader codebase where FR users have special handling in ministry-related features, including ministry hours credit and reporting
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other FR-specific checks in the codebase
rg -A 3 "personIsFR" --type ts

Length of output: 2947


Script:

#!/bin/bash
# Search for the checkGroupDisabled function implementation
ast-grep --pattern 'checkGroupDisabled($$$) {
  $$$
}'

# Search for ministry group related code
rg -A 5 "ministry.*group" --type ts

Length of output: 94


Script:

#!/bin/bash
# Get the full content of the useAssignmentGroup file to understand the complete implementation
cat src/features/persons/assignment_group/useAssignmentGroup.tsx

# Search for ministry-related code with a broader pattern
rg "ministry" --type ts -A 5

Length of output: 66113

src/features/reminders/useReminders.tsx (1)

11-11: LGTM: Improved role state management

The change from hook-based to Recoil state-based secretary role check is more consistent with the application's state management approach.

Also applies to: 20-20, 25-25

✅ Verification successful

The verification shows consistent usage of secretaryRoleState across the codebase. The selector is defined in states/settings.ts and is properly consumed using useRecoilValue in multiple components including useReminders, useSubmitReport, useUnverifiedReports, and useGlobal. Let me verify the complete implementation of the selector to ensure it's properly defined.


LGTM: Verified proper implementation and usage of secretary role state

The selector is correctly implemented using Recoil's selector pattern, deriving from congRoleState and consistently used with useRecoilValue across the codebase. The change aligns well with the application's state management approach.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify consistent usage of secretaryRoleState
rg -A 2 "secretaryRoleState" --type ts

Length of output: 2454


Script:

#!/bin/bash
# Check the implementation of secretaryRoleState selector
ast-grep --pattern 'export const secretaryRoleState = selector({
  $$$
})'

Length of output: 449

src/features/congregation/app_access/user_add/person_select/index.tsx (1)

91-91: LGTM: Improved accessibility with disabled state

Using disabled instead of readOnly is more semantic and provides better accessibility feedback to users.

src/features/reports/publisher_records_details/month_item/index.tsx (1)

115-121: Well-implemented read-only state handling

The implementation of the read-only state with visual feedback through both color and tooltip is well done.

src/features/reports/publisher_records_details/month_item/useMonthItem.tsx (1)

32-36: Well-structured memoization of report status

The implementation of branch_report_submitted, not_publisher, and report_locked is well-structured with appropriate memoization dependencies.

Also applies to: 65-71, 137-139

src/features/ministry/report/ministry_timer/useMinistryTimer.tsx (2)

Line range hint 91-112: LGTM! Improved time handling logic

The enhanced logic correctly:

  • Preserves existing hours and minutes
  • Handles minute overflow into hours
  • Properly formats the time string with padded minutes

45-46: Verify timer state restoration edge cases

The simplified initial time calculation might overlook valid timer states. Consider adding test cases to verify that this simplification doesn't affect timer restoration in edge cases.

src/features/persons/assignments/useAssignments.tsx (1)

151-151: LGTM! Robust assignment toggle handling

The implementation correctly handles:

  • Gender-specific assignment restrictions
  • Assignment state management
  • Add/update scenarios with proper timestamps
src/features/reports/field_service/persons_list/usePersonsList.tsx (2)

2-2: LGTM! Clean state management setup

The implementation follows React/Recoil best practices for state management.

Also applies to: 10-10, 43-44


316-321: LGTM! Proper selection state cleanup

The effect correctly handles the cleanup of selected publisher state when the persons list becomes empty, preventing stale selections.

@rhahao rhahao linked an issue Dec 14, 2024 that may be closed by this pull request
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 14, 2024
@rhahao rhahao linked an issue Dec 14, 2024 that may be closed by this pull request
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: 0

🧹 Outside diff range and nitpick comments (2)
src/features/congregation/field_service_groups/group_members/useGroupMembers.tsx (1)

16-16: Consider memoizing handleInputChange

While the current implementation works correctly, consider memoizing the handleInputChange function using useCallback to prevent unnecessary re-renders of child components that receive this function as a prop.

- const handleInputChange = (value: string) => setInputValue(value);
+ const handleInputChange = useCallback((value: string) => setInputValue(value), []);

Also applies to: 84-85, 87-88

src/features/persons/speakers_catalog/my_congregation/speaker_edit/index.tsx (1)

121-135: Optimize filtering implementation

While the filtering logic works correctly, here are some suggestions to improve performance and maintainability:

  1. Move the filtering logic outside the render function
  2. Memoize the filtered results
  3. Extract the string normalization logic
+ const normalizeString = (str: string) => str.toString().toLowerCase();
+ 
+ const filterTalks = useCallback((options: PublicTalkType[], inputValue: string) => {
+   const normalizedInput = normalizeString(inputValue);
+   return options.filter(
+     (record) =>
+       normalizeString(record.talk_number).includes(normalizedInput) ||
+       normalizeString(record.talk_title).includes(normalizedInput)
+   );
+ }, []);

  return (
    // ...
    <AutocompleteMultiple
      // ...
-     filterOptions={(options, params) => {
-       const inputValue = params.inputValue.toLowerCase();
-       return options.filter((record) => {
-         const numberMatch = record.talk_number
-           .toString()
-           .includes(inputValue);
-         const titleMatch = record.talk_title
-           .toLowerCase()
-           .includes(inputValue);
-         return numberMatch || titleMatch;
-       });
-     }}
+     filterOptions={(options, params) => filterTalks(options, params.inputValue)}
      // ...
    />
  );
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 08e0125 and 51cb497.

📒 Files selected for processing (3)
  • src/features/congregation/field_service_groups/group_members/index.tsx (2 hunks)
  • src/features/congregation/field_service_groups/group_members/useGroupMembers.tsx (3 hunks)
  • src/features/persons/speakers_catalog/my_congregation/speaker_edit/index.tsx (1 hunks)
🔇 Additional comments (1)
src/features/congregation/field_service_groups/group_members/index.tsx (1)

19-20: LGTM: Input handling enhancement

The addition of handleInputChange and inputValue props improves the Autocomplete component's input management, providing better control over the input state.

Also applies to: 52-53

Copy link

sonarcloud bot commented Dec 14, 2024

@rhahao rhahao merged commit 84700a2 into sws2apps:main Dec 14, 2024
14 checks passed
Copy link

cypress bot commented Dec 14, 2024

organized-app    Run #1805

Run Properties:  status check passed Passed #1805  •  git commit 84700a27af: feat(persons): allow search for talk titles in speakers catalog
Project organized-app
Branch Review main
Run status status check passed Passed #1805
Run duration 00m 05s
Commit git commit 84700a27af: feat(persons): allow search for talk titles in speakers catalog
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
1 participant