-
Notifications
You must be signed in to change notification settings - Fork 2
joni/refactor/296-refactor-memberspage-to-integrate-with-directus #306
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
Merged
leolabdev
merged 28 commits into
dev
from
joni/refactor/296-refactor-memberspage-to-integrate-with-directus
Dec 9, 2024
Merged
joni/refactor/296-refactor-memberspage-to-integrate-with-directus #306
leolabdev
merged 28 commits into
dev
from
joni/refactor/296-refactor-memberspage-to-integrate-with-directus
Dec 9, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
leolabdev
approved these changes
Dec 9, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📄 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
✅ Checklist Before Submission
console.log()or other debugging statements are left.