Skip to content

Comments

Add Languages Section -> Partner#1666

Open
rdonigian wants to merge 3 commits intodevelopfrom
partner-location
Open

Add Languages Section -> Partner#1666
rdonigian wants to merge 3 commits intodevelopfrom
partner-location

Conversation

@rdonigian
Copy link
Contributor

@rdonigian rdonigian commented May 20, 2025

API PR: SeedCompany/cord-api-v3#3438
Partner language section will expose reporting language, wider communication language, and consulting language details to the UI.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 20, 2025

📝 Walkthrough

"""

Walkthrough

This change extends multiple GraphQL fragments and TypeScript form models to include new language-related fields isWiderComm and isAvailableForReporting. It adds UI components and sections for displaying and editing these language attributes in language and partner detail and edit views, with permission checks and conditional rendering.

Changes

Files/Paths Change Summary
src/components/LanguageListItemCard/LanguageListItem.graphql
src/components/form/Lookup/Language/LanguageLookup.graphql
Extended LanguageListItem and LanguageLookupItem fragments to add isWiderComm { value } and isAvailableForReporting { value } fields.
src/scenes/Languages/Detail/LanguageDetail.graphql
src/scenes/Languages/LanguageForm/LangugeForm.graphql
Added isAvailableForReporting with canEdit, canRead, and value subfields to language fragments.
src/scenes/Languages/Detail/LanguageDetail.tsx Added a Grid container with a BooleanProperty for "Reporting Language" bound to isAvailableForReporting.
src/scenes/Languages/Edit/EditLanguage.tsx Updated initial form values to include isAvailableForReporting from language data.
src/scenes/Languages/LanguageForm/LanguageForm.tsx Removed makeStyles; applied inline sx styling; added a "Communication" section with a secured checkbox for isAvailableForReporting.
src/scenes/Partners/Detail/PartnerDetail.graphql Extended partnerOwnDetails fragment with languageOfWiderCommunication, languagesOfConsulting, and languageOfReporting fields including permissions and language fragments.
src/scenes/Partners/Detail/Tabs/Profile/PartnerDetailProfile.tsx Added a new grid item rendering PartnerLanguageSection component for partner language info and editing.
src/scenes/Partners/Detail/Tabs/Profile/PartnerLanguageSection.tsx Added new exported component displaying partner language categories with permission checks, loading states, and edit capability.
src/scenes/Partners/Detail/Tabs/Profile/PartnerTypesSection.tsx Increased max width of Stack container wrapping roles and financial reporting types from 350 to 700.
src/scenes/Partners/Edit/EditPartner.tsx Extended PartnerFormValues and form field mapping with new language fields; updated initial values and submit mutation variables; added option disabling logic.
src/components/Grid/Columns/LanguageNameColumn.tsx Narrowed valueGetter type parameter to return only displayName, name, and id properties of LanguageLookupItem.

Possibly related PRs

  • SeedCompany/cord-field#1650: Modifies the LanguageDetail component to display the language ID and update a label; both this PR and the current one update the LanguageDetail component, though they address different UI elements.
    """

📜 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 acc16cf and 275aad2.

📒 Files selected for processing (13)
  • src/components/Grid/Columns/LanguageNameColumn.tsx (1 hunks)
  • src/components/LanguageListItemCard/LanguageListItem.graphql (1 hunks)
  • src/components/form/Lookup/Language/LanguageLookup.graphql (1 hunks)
  • src/scenes/Languages/Detail/LanguageDetail.graphql (1 hunks)
  • src/scenes/Languages/Detail/LanguageDetail.tsx (1 hunks)
  • src/scenes/Languages/Edit/EditLanguage.tsx (1 hunks)
  • src/scenes/Languages/LanguageForm/LanguageForm.tsx (2 hunks)
  • src/scenes/Languages/LanguageForm/LangugeForm.graphql (1 hunks)
  • src/scenes/Partners/Detail/PartnerDetail.graphql (1 hunks)
  • src/scenes/Partners/Detail/Tabs/Profile/PartnerDetailProfile.tsx (2 hunks)
  • src/scenes/Partners/Detail/Tabs/Profile/PartnerLanguageSection.tsx (1 hunks)
  • src/scenes/Partners/Detail/Tabs/Profile/PartnerTypesSection.tsx (1 hunks)
  • src/scenes/Partners/Edit/EditPartner.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (13)
  • src/scenes/Languages/Edit/EditLanguage.tsx
  • src/scenes/Partners/Detail/Tabs/Profile/PartnerTypesSection.tsx
  • src/components/form/Lookup/Language/LanguageLookup.graphql
  • src/scenes/Languages/LanguageForm/LangugeForm.graphql
  • src/scenes/Languages/Detail/LanguageDetail.graphql
  • src/components/LanguageListItemCard/LanguageListItem.graphql
  • src/scenes/Languages/Detail/LanguageDetail.tsx
  • src/scenes/Languages/LanguageForm/LanguageForm.tsx
  • src/scenes/Partners/Detail/Tabs/Profile/PartnerDetailProfile.tsx
  • src/scenes/Partners/Detail/PartnerDetail.graphql
  • src/components/Grid/Columns/LanguageNameColumn.tsx
  • src/scenes/Partners/Detail/Tabs/Profile/PartnerLanguageSection.tsx
  • src/scenes/Partners/Edit/EditPartner.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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
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: 5

🧹 Nitpick comments (4)
src/scenes/Partners/Detail/Tabs/Profile/PartnerTypesSection.tsx (1)

56-56: Reevaluate fixed maxWidth for responsiveness
Increasing maxWidth to 700px may cause overflow or cramped layouts on narrow viewports. Consider using responsive breakpoints or fluid sizing (for example: maxWidth={{ xs: '100%', md: 700 }}) to maintain a flexible, mobile-friendly layout.

src/scenes/Partners/Detail/PartnerDetail.graphql (1)

68-71: Fix inconsistent property order

The order of canEdit and canRead properties in languagesOfConsulting is different from the other language fields. While functionally equivalent, maintaining consistent ordering improves code readability.

-    canEdit
-    canRead
+    canRead
+    canEdit
src/scenes/Partners/Detail/Tabs/Profile/PartnerLanguageSection.tsx (1)

53-158: Consider refactoring to reduce code duplication

The code for rendering "Language of Reporting" and "Language of Wider Communication" sections is nearly identical. Consider refactoring this into a reusable function or component to reduce duplication and improve maintainability.

You could create a helper function like:

const renderLanguageSection = (
  title: string,
  languageField: {
    canRead: boolean;
    value: { name: { value: string } } | null;
  },
  redactedMessage: string
) => (
  <Box>
    <Typography component="h4" variant="body2" color="textSecondary" gutterBottom>
      {title}
    </Typography>
    {!partner ? (
      <Skeleton width="75%" />
    ) : languageField.canRead ? (
      languageField.value ? (
        <Stack component="ul" sx={{ m: 0, p: 0, gap: 1 }}>
          <Typography component="li" variant="h4" sx={{ listStyleType: 'none' }}>
            {languageField.value.name.value}
          </Typography>
        </Stack>
      ) : (
        <Typography component="p" variant="h4">
          None
        </Typography>
      )
    ) : (
      <Redacted info={redactedMessage} width="75%" />
    )}
  </Box>
);

Then use it in your JSX:

{renderLanguageSection(
  "Language of Reporting",
  partner?.languageOfReporting,
  "You cannot view this partner's reporting language"
)}
{renderLanguageSection(
  "Language of Wider Communication",
  partner?.languageOfWiderCommunication,
  "You cannot view this partner's language of wider communication"
)}
src/scenes/Partners/Edit/EditPartner.tsx (1)

119-137: Consider consistent handling of CreateDialogForm across language fields

The CreateDialogForm prop is explicitly set to undefined for reporting and wider communication language fields, but not specified for consulting languages field. This inconsistency should be addressed for better maintainability.

Either add the prop to the consulting languages field:

-  'partner.languagesOfConsulting': ({ props }) => (
-    <LanguageField {...props} multiple label="Languages of Consulting" />
+  'partner.languagesOfConsulting': ({ props }) => (
+    <LanguageField 
+      {...props} 
+      multiple 
+      label="Languages of Consulting" 
+      CreateDialogForm={undefined} 
+    />

Or document why the behavior is different for this field if that's intentional.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 72b3a57 and 2710332.

📒 Files selected for processing (12)
  • src/components/LanguageListItemCard/LanguageListItem.graphql (1 hunks)
  • src/components/form/Lookup/Language/LanguageLookup.graphql (1 hunks)
  • src/scenes/Languages/Detail/LanguageDetail.graphql (1 hunks)
  • src/scenes/Languages/Detail/LanguageDetail.tsx (1 hunks)
  • src/scenes/Languages/Edit/EditLanguage.tsx (1 hunks)
  • src/scenes/Languages/LanguageForm/LanguageForm.tsx (2 hunks)
  • src/scenes/Languages/LanguageForm/LangugeForm.graphql (1 hunks)
  • src/scenes/Partners/Detail/PartnerDetail.graphql (1 hunks)
  • src/scenes/Partners/Detail/Tabs/Profile/PartnerDetailProfile.tsx (2 hunks)
  • src/scenes/Partners/Detail/Tabs/Profile/PartnerLanguageSection.tsx (1 hunks)
  • src/scenes/Partners/Detail/Tabs/Profile/PartnerTypesSection.tsx (1 hunks)
  • src/scenes/Partners/Edit/EditPartner.tsx (5 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/scenes/Languages/Detail/LanguageDetail.tsx (1)
src/components/BooleanProperty/BooleanProperty.tsx (1)
  • BooleanProperty (21-40)
src/scenes/Languages/LanguageForm/LanguageForm.tsx (2)
src/common/secured.ts (1)
  • canReadAny (66-78)
src/components/form/SecuredField.tsx (1)
  • SecuredField (39-74)
🔇 Additional comments (14)
src/components/form/Lookup/Language/LanguageLookup.graphql (1)

19-24: Regenerate GraphQL types after extending LanguageLookupItem
You've added isWiderComm { value } and isAvailableForReporting { value } to the LanguageLookupItem fragment. Ensure your GraphQL schema supports these fields and run your codegen tooling (e.g., yarn graphql-codegen) so that the new fields propagate into the generated TypeScript types and downstream components.

src/components/LanguageListItemCard/LanguageListItem.graphql (1)

20-25: Update GraphQL codegen for new list item flags
The LanguageListItem fragment now includes isWiderComm { value } and isAvailableForReporting { value }. Confirm these match the server schema and regenerate your client types so components consuming this fragment (such as PartnerLanguageSection) can safely access the new flags.

src/scenes/Languages/Edit/EditLanguage.tsx (1)

58-59: Map new language flags into initial form values
You've added isAvailableForReporting: language.isAvailableForReporting.value and isWiderComm: language.isWiderComm.value to the initialValues object. Verify that LanguageForm defines inputs (e.g., secured checkboxes) bound to these fields and that the form’s dirty-state tracking correctly captures changes to them.

src/scenes/Languages/LanguageForm/LangugeForm.graphql (1)

91-100: Add new secured fields to LanguageForm fragment; regenerate types
The LanguageForm fragment now includes isWiderComm and isAvailableForReporting with canEdit, canRead, and value subfields. Ensure that the form UI renders these as secured checkbox fields and that you refresh your GraphQL codegen outputs so the new fields are available in your TypeScript definitions.

src/scenes/Languages/Detail/LanguageDetail.graphql (1)

80-89: LGTM! The new language capability fields are properly structured.

The new isWiderComm and isAvailableForReporting fields follow the established pattern for secured fields with the necessary permission properties (canEdit, canRead, and value).

src/scenes/Partners/Detail/Tabs/Profile/PartnerDetailProfile.tsx (2)

8-8: Correct import of the new language section component.

The import statement is properly added for the new PartnerLanguageSection component.


39-50: Properly implemented language section in the partner profile.

The new language section is correctly integrated into the partner profile grid layout. The onEdit callback properly handles the three language-related fields: reporting language, wider communication language, and consulting languages.

src/scenes/Languages/Detail/LanguageDetail.tsx (1)

168-181: Language capability indicators correctly implemented.

The new grid with BooleanProperty components for reporting and wider communication language capabilities is well structured. Both components include appropriate labels and redacted messages for permission handling.

src/scenes/Languages/LanguageForm/LanguageForm.tsx (2)

89-95: Modern styling approach using the sx prop.

Good modernization by replacing makeStyles with direct styling via the sx prop for the overflow handling.


331-356: Well-structured communication section with proper permission handling.

The new Communication section is:

  1. Correctly conditional based on read permissions using canReadAny
  2. Properly styled with margin for visual separation
  3. Well organized with appropriate form fields
  4. Correctly implements permission-based rendering with SecuredField components

The checkbox labels clearly communicate the purpose of each field.

src/scenes/Partners/Detail/PartnerDetail.graphql (1)

60-83: New language-related fields added correctly

The addition of three language-related fields (languageOfWiderCommunication, languagesOfConsulting, and languageOfReporting) to the Partner fragment follows the established pattern in the codebase. Each field correctly includes permission fields and nested fragments.

src/scenes/Partners/Edit/EditPartner.tsx (3)

44-46: Language fields properly added to PartnerFormValues

The language fields are correctly added to the PartnerFormValues type, maintaining type safety for the form implementation.


176-179: Initial values correctly set for language fields

The language fields are properly initialized from the partner data. The form correctly handles null values for single language fields and the array for consulting languages.


201-206: Language fields correctly included in mutation variables

The submission logic correctly processes the language fields, extracting IDs where needed and handling null values appropriately.

@sethmcknight sethmcknight linked an issue May 27, 2025 that may be closed by this pull request
@CarsonF CarsonF force-pushed the partner-location branch from acc16cf to 275aad2 Compare July 8, 2025 22:06
Copy link
Member

@CarsonF CarsonF left a comment

Choose a reason for hiding this comment

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

I rebased this and dropped most of the isWiderComm flag. I left some comments here, and will do a final pass tomorrow.

WithValueGetterReturning<
Pick<LanguageLookupItem, 'displayName' | 'name' | 'id'>,
Row
>
Copy link
Member

Choose a reason for hiding this comment

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

I don't like picking apart fragments. IMO they should be used 1-1 between GQL-TS.
If columns need a different language shape, then they should declare their own fragment to be used.

Strictly, this is not necessary for this case either, I would just revert.

Comment on lines +20 to +25
isWiderComm {
value
}
isAvailableForReporting {
value
}
Copy link
Member

Choose a reason for hiding this comment

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

Remove these. This prop is not consumed in the <LanguageListItem> component.

}
}
isAvailableForReporting {
canEdit
Copy link
Member

Choose a reason for hiding this comment

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

not used in language detail

Suggested change
canEdit

Comment on lines +92 to +93
...LanguageListItem
...LanguageLookupItem
Copy link
Member

Choose a reason for hiding this comment

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

<LanguageListItem> is not used here, so don't use its fragment.
Declare the fields read inline, or creating a new fragment is fine too.

LanguageLookupItem is fine here, since it's used in the form. But we shouldn't rely on what fields it asks for either for my above statement.

Comment on lines +66 to +74
<Stack component="ul" sx={{ m: 0, p: 0, gap: 1 }}>
<Typography
component="li"
variant="h4"
sx={{ listStyleType: 'none' }}
>
{partner.languageOfReporting.value.name.value}
</Typography>
</Stack>
Copy link
Member

Choose a reason for hiding this comment

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

This data point is not a list, so it shouldn't use <ul>/<li>

countries: readonly DisplayLocationFragment[];
languageOfReportingId: LanguageLookupItem | null;
languageOfWiderCommunicationId: LanguageLookupItem | null;
languagesOfConsulting: PartnerDetailsFragment['languagesOfConsulting']['value'];
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
languagesOfConsulting: PartnerDetailsFragment['languagesOfConsulting']['value'];
languagesOfConsulting: readonly LanguageLookupItem[];

{...props}
label="Language of Wider Communication"
CreateDialogForm={undefined}
getOptionDisabled={(option) => !option.isWiderComm.value}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
getOptionDisabled={(option) => !option.isWiderComm.value}

/>
),
'partner.languagesOfConsulting': ({ props }) => (
<LanguageField {...props} multiple label="Languages of Consulting" />
Copy link
Member

Choose a reason for hiding this comment

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

outlined variant looks better for multiple values aka chips. the gray chips on filled variant gray bg looks bad.

Suggested change
<LanguageField {...props} multiple label="Languages of Consulting" />
<LanguageField {...props} multiple label="Languages of Consulting" variant="outlined" />

<LanguageField
{...props}
label="Language of Reporting"
CreateDialogForm={undefined}
Copy link
Member

Choose a reason for hiding this comment

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

I would not try to forcibly disable language creation here. This is a deviation from the standard practice of the app. It is also not necessary because only admins can create languages, so only admins would have the create language option anyways.

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.

3 - CF-Partner Profile- Languages of Communications

2 participants