-
Notifications
You must be signed in to change notification settings - Fork 74
Feat(productivity): improve report functionality and performance #3618
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
Conversation
- Optimize API calls for APPS-URLS type reports - Fix LoadingSkeleton component TypeScript return type - Add proper return statement to React components - Improve code formatting and remove unnecessary Promise.all - Separate API calls based on report type for better performance - Fix date range initialization to show current month by default - Add proper TypeScript types and interfaces - Remove redundant API calls when only activity report is needed Breaking Changes: - Modified useReportActivity hook to handle report types separately - Changed default date range behavior to show full current month
WalkthroughThe changes integrate the Changes
Sequence Diagram(s)sequenceDiagram
participant Component as Productivity Component
participant TransHook as useTranslations Hook
participant Child as EmptyState / Table Headers
Component ->> TransHook: Call useTranslations()
TransHook -->> Component: Return translation function (t)
Component ->> Child: Pass 't' as prop for localized text
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
apps/web/app/[locale]/dashboard/app-url/[teamId]/page.tsxOops! Something went wrong! :( ESLint: 8.46.0 ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct. The config "next/core-web-vitals" was referenced from the config file in "/apps/web/.eslintrc.json". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. apps/web/app/[locale]/dashboard/app-url/components/productivity-project/index.tsxOops! Something went wrong! :( ESLint: 8.46.0 ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct. The config "next/core-web-vitals" was referenced from the config file in "/apps/web/.eslintrc.json". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. apps/web/app/[locale]/dashboard/app-url/components/productivity-project/types.tsOops! Something went wrong! :( ESLint: 8.46.0 ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct. The config "next/core-web-vitals" was referenced from the config file in "/apps/web/.eslintrc.json". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.
✨ Finishing Touches
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 comments (1)
apps/web/app/[locale]/dashboard/app-url/components/productivity-employee/ProductivityEmployeeTable.tsx (1)
13-19
: 🛠️ Refactor suggestionReplace hardcoded strings with translation keys.
The TABLE_HEADERS constant uses hardcoded English strings. For consistency with other components, these should use translation keys.
-const TABLE_HEADERS = [ - 'Date', - 'Project', - 'Application', - 'Time Spent', - 'Percent used' -] as const; +const TABLE_HEADERS = [ + t('common.DATE'), + t('common.PROJECT'), + t('common.APPLICATION'), + t('common.TIME_SPENT'), + t('common.PERCENT_USED') +] as const;
🧹 Nitpick comments (4)
apps/web/app/[locale]/dashboard/app-url/components/productivity-project/states.tsx (2)
56-61
: Consider using the current locale for date formatting.The date is being formatted using a hardcoded 'en-US' locale, which may not match the user's selected language.
- const formattedDate = selectedDate ? new Date(selectedDate).toLocaleDateString('en-US', { + const formattedDate = selectedDate ? new Date(selectedDate).toLocaleDateString(undefined, { weekday: 'long', day: '2-digit', month: 'long', year: 'numeric' }) : '';
22-26
: Consider using TypeScript const assertions for translation keys.Using const assertions for translation keys can help catch typos and ensure type safety.
+const TRANSLATION_KEYS = { + DATE: 'common.DATE', + MEMBER: 'common.MEMBER', + APPLICATION: 'common.APPLICATION', + TIME_SPENT: 'common.TIME_SPENT', + PERCENT_USED: 'common.PERCENT_USED', + NO_ACTIVITY_DATA: 'common.NO_ACTIVITY_DATA', + SELECT_DIFFERENT_DATE: 'common.SELECT_DIFFERENT_DATE', +} as const; -<TableHead className="font-semibold">{t('common.DATE')}</TableHead> +<TableHead className="font-semibold">{t(TRANSLATION_KEYS.DATE)}</TableHead>Also applies to: 66-66, 70-70
apps/web/app/[locale]/dashboard/app-url/components/productivity-project/index.tsx (1)
43-47
: Consider extracting shared translation keys.The translation keys are duplicated between this component and the LoadingSkeleton component. Consider extracting them to a shared constants file.
Create a new file
translationKeys.ts
:export const PRODUCTIVITY_TRANSLATION_KEYS = { DATE: 'common.DATE', MEMBER: 'common.MEMBER', APPLICATION: 'common.APPLICATION', TIME_SPENT: 'common.TIME_SPENT', PERCENT_USED: 'common.PERCENT_USED', NO_ACTIVITY_DATA: 'common.NO_ACTIVITY_DATA', SELECT_DIFFERENT_DATE: 'common.SELECT_DIFFERENT_DATE', } as const;apps/web/app/[locale]/dashboard/app-url/components/productivity-employee/ProductivityEmployeeTable.tsx (1)
31-39
: Use consistent locale for date formatting.The date formatting uses a hardcoded 'en-US' locale in multiple places. This should respect the user's locale preference.
- return date.toLocaleDateString('en-US', { + return date.toLocaleDateString(undefined, { weekday: 'long', day: '2-digit', month: 'long', year: 'numeric' });Also applies to: 174-174
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
apps/web/app/[locale]/dashboard/app-url/components/productivity-employee/ProductivityEmployeeTable.tsx
(3 hunks)apps/web/app/[locale]/dashboard/app-url/components/productivity-project/index.tsx
(3 hunks)apps/web/app/[locale]/dashboard/app-url/components/productivity-project/states.tsx
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Codacy Static Code Analysis
…ture handling - Reverted Props interface to accept array data format - Restored state management with localData and useEffect - Re-implemented groupedData logic using useMemo for data processing - Added proper error handling for invalid data structures - Maintained backward compatibility with existing data format - Fixed date sorting and employee grouping functionality
There was a problem hiding this 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
🧹 Nitpick comments (4)
apps/web/app/[locale]/dashboard/app-url/components/productivity-project/types.ts (2)
57-60
: Add clarifying documentation for new interface.Although the interface is self-explanatory, a short doc comment explaining its usage in consumer code might help readers understand how it fits into the overall reporting workflow.
62-69
: Unify the activity item type.Handling a union of
IActivityItem
orIActivityItem[]
tends to complicate type checks. If possible, consider always using an array for consistency or providing clear utilities to handle single vs. multiple items.apps/web/app/[locale]/dashboard/app-url/components/productivity-project/utils.ts (2)
4-23
: Validate fallback behavior for invalid durations.Returning
'00:00:00'
and logging a warning may be acceptable, but consider:
- Throwing or surfacing an explicit error in development.
- Providing a user-facing indication that the time is invalid.
This ensures developers/users quickly understand when the data is incorrect.
25-113
: Avoid usingany
casting and standardize data validation.Forcing the cast using
data as any
can hide potential issues ifdata
is not shaped as expected. A more robust solution is to narrow the type with explicit checks or use safer parsing techniques. Consider extracting validation logic into a helper or rewriting to ensure type safety without multiple logging statements.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
apps/web/app/[locale]/dashboard/app-url/[teamId]/page.tsx
(1 hunks)apps/web/app/[locale]/dashboard/app-url/components/productivity-project/index.tsx
(3 hunks)apps/web/app/[locale]/dashboard/app-url/components/productivity-project/types.ts
(1 hunks)apps/web/app/[locale]/dashboard/app-url/components/productivity-project/utils.ts
(1 hunks)apps/web/app/hooks/features/useReportActivity.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- apps/web/app/[locale]/dashboard/app-url/[teamId]/page.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/web/app/[locale]/dashboard/app-url/components/productivity-project/index.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: deploy
🔇 Additional comments (2)
apps/web/app/hooks/features/useReportActivity.ts (1)
328-328
: Good improvement: exposing fetchActivityReport functionThis change aligns perfectly with the PR objectives of improving report functionality and performance. By exposing the
fetchActivityReport
function through the hook's return object, consumers can now directly fetch only the activity report when needed, eliminating redundant API calls that would otherwise fetch all reports.apps/web/app/[locale]/dashboard/app-url/components/productivity-project/types.ts (1)
52-55
: Looks good!This interface is straightforward and aligns well with existing naming conventions.
Breaking Changes:
Description
Please include a summary of the changes and the related issues.
Type of Change
Checklist
Previous screenshots
Please add here videos or images of the previous status
Current screenshots
Please add here videos or images of the current (new) status
Summary by CodeRabbit