Skip to content

Conversation

@Jonroi
Copy link
Contributor

@Jonroi Jonroi commented Dec 9, 2024

📄 Pull Request Overview

This pull request refactors the project to enhance translation handling using Directus logic and updates the mapping framework accordingly.

closes #296

🔧 Changes Made

  1. Replaced the existing API logic with Directus for handling translations, ensuring more robust and scalable internationalization support.
  2. Refactored the mapping system to seamlessly integrate with Directus-based translation mechanisms.
  3. Updated the codebase to align with Directus's conventions and enhanced the flexibility of language handling.

Checklist Before Submission

  • Functionality: I have tested my code, and it works as expected.
  • JSDoc: I have added or updated JSDoc comments for all relevant code.
  • Debugging: No console.log() or other debugging statements are left.
  • Clean Code: Removed commented-out or unnecessary code.
  • Tests: Added new tests or updated existing ones for the changes made.
  • Documentation: Documentation has been updated (if applicable).

Jonroi added 28 commits December 2, 2024 12:40
Remove the redundant teams data rendering logic
This commit eliminates the member logo rendering logic for adjusting later
This update replaces the useGetTeamsQuery with useGetMembersQuery
Improved JSDoc comments for the envHelper object to include more detailed descriptions of environment variables. This includes the addition of company name and flag for development mode, providing clearer guidance on the usage of the object's properties. Removed outdated todo comment regarding JSDoc updates.
Refactor the members API to replace Strapi with Directus. Simplify UI components by removing redundant rendering functions and comments. Update TypeScript types to align with the new data structure, ensuring proper type safety and consistency across the application.
This update introduces a language prop to the MemberItem component within the SectionMembers.tsx file, enhancing its localization support. By passing the language context directly to each member item, this change allows for better translation handling and improves the user interface's adaptability to different languages.
This update refines the MemberItem component to support language-based translation for the member's task using the new language prop. It ensures that the task is displayed in the appropriate language if available, enhancing the user experience by providing content in their selected language context.
Renamed 'locale' to 'language' and introduced 'Translation' interface to handle multilingual support. Modified 'Department' and 'Team' interfaces to allow optional loading of members and departments. Generalized 'SuccessResponse' to handle both 'Member' and 'Department' data.
The query function now directly returns the fetched member data, eliminating the manual mapping of raw member objects into Member instances. Additionally, unnecessary field population for 'departments' and 'teams' has been removed for improved clarity and efficiency.
Previously, if no translation task was found, a default 'No Task Assigned' value was used. This change removes the default assignment, reflecting cases where a task might genuinely be absent.
Enhanced the Member interface by including an optional translations property, allowing for multilingual support. The Translation interface was expanded by adding new fields such as task, website, and various social media links to provide more detailed member information across different languages. These changes aim to improve data richness and localization capabilities.
The refactor simplifies type definitions for Member-related entities by removing unnecessary fields and updating some types, such as Logo. It introduces clearer structures for Department, Team, and their translations, enhancing maintainability and ease of understanding. This change aims to better organize the data model and align with the current application requirements.
The DepartmentItem component and its associated SCSS file have been deleted as part of the codebase cleanup. This component was no longer needed for the frontend-next-migration project, and its removal simplifies the code structure. No other files or components were affected by this change.
Clean up unused export to streamline the Member UI module. The DepartmentItem export is not required here and has been removed to simplify code maintenance.
Reorganized the logic for handling members and departments, replacing the traditional mapping functions with a new `organizeMembers` function. This function consolidates team and department associations, streamlining the code and enhancing maintainability by organizing members within a structured map of teams. Unnecessary comments and lengthy functions were removed for clarity and efficiency.
Update the members query to include additional fields such as department and team details, along with their translations. This change aims to provide a more comprehensive data set when fetching member information. Also, fix the variable naming convention to follow camelCase.
Simplify the type check for the member logo to improve readability. This change ensures the code clearly checks if the logo is an object containing an ID before constructing its URL.
The DepartmentItem export was removed as it is no longer required from this module. This cleanup ensures that only necessary components are exported, reducing potential unused references and simplifying module interface.
Improved readability by reformatting the department finding logic with multi-line arrow functions. Clarified comments about adding members to either a department or team-level member list. This aims to enhance code maintainability and understanding.
Updated the SectionMembers component to categorize and display members by teams and departments instead of a flat list. Implemented `organizeMembers` to process and structure the members data, enhancing readability and maintainability. Improved handling of loading and error states for a better user experience.
Clean up the `Member`, `Department`, and `Team` interfaces by removing unused `date_created`, `date_updated`, and `status` fields. This streamlines the code and ensures that only relevant data fields are included in these model types.
Simplify language code determination by extracting logic into reusable functions. This ensures cleaner code and better maintainability by using `getLanguageCode` and `getTaskTranslation` functions for translations.
Introduce a new module for handling translations in the Member entity, including utility functions to retrieve translations for tasks, departments, and teams with appropriate fallbacks. This update ensures consistent language support across different components of the application.
Updated the organizeMembers function to include sorting of members and teams based on a specified language order. Added detailed comments and improved code readability by extracting name translation functionality for teams and departments.
The refactor eliminates redundant comments in the membersApi.ts file that explained basic field inclusions. This change enhances code readability by reducing clutter, trusting that variable names clearly convey their purpose.
Simplify rendering logic by excluding unmatched departments and directly using the department name property. This change enhances readability and maintainability by reducing complexity in the component's JSX structure. Additionally, ensure import paths are correctly documented for better code clarity.
Updated translation functions to use an empty string as a default value instead of specific strings like 'Task unavailable'. This change ensures consistency across translations and simplifies handling of untranslated values. Added documentation for improved code clarity and maintainability.
Implemented comprehensive unit tests for the organizeMembers function, validating the organization of members into teams and departments with both English and Finnish translations. These tests ensure the function correctly maps members based on team and department identifiers and handles cases with no members.
@Jonroi Jonroi self-assigned this Dec 9, 2024
@leolabdev leolabdev merged commit 0538e1b into dev Dec 9, 2024
1 of 2 checks passed
@leolabdev leolabdev deleted the joni/refactor/296-refactor-memberspage-to-integrate-with-directus branch December 9, 2024 09:56
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 participants