[CSM][Mobile] Time cards (My sheets / All / Approvals, filters, approve-reject) - #1129
Conversation
…re/csm-microapp-timecards # Conflicts: # apps/csm-portal/microapp/src/App.tsx # apps/csm-portal/microapp/src/components/layout/TabBar.tsx # apps/csm-portal/microapp/src/pages/TimeCardsPage.tsx
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a complete timecard experience with typed API models, weekly grouping, filtering, infinite loading, approval/rejection dialogs, state indicators, and role-aware tabs. ChangesTimecards feature
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant TimeCardsPage
participant timecards
participant TimecardAPI
TimeCardsPage->>timecards: request timecard pages
timecards->>TimecardAPI: POST /time-cards/search
TimecardAPI-->>timecards: return paginated cards
timecards-->>TimeCardsPage: return grouped weekly sheets
TimeCardsPage->>timecards: submit approval or rejection
timecards->>TimecardAPI: PATCH /time-cards/{id}
TimecardAPI-->>TimeCardsPage: return updated timecard
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/csm-portal/microapp/src/utils/timecard.ts (1)
163-167: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valueGuard
sheetStatusagainst empty input.
Array.every()returnstruefor an empty array (vacuous truth), sosheetStatus([])returns"approved"— misleading for a sheet with no cards. The function is currently only called with non-empty arrays fromgroupIntoSheets, but it's exported and could be called from new code.🛡️ Proposed fix
export function sheetStatus(cards: CsmTimeCard[]): TimeSheetState { + if (cards.length === 0) return "submitted"; if (cards.some((c) => c.state === "rejected")) return "rejected"; if (cards.every((c) => c.state === "approved" || c.state === "processed")) return "approved"; return "submitted"; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/csm-portal/microapp/src/utils/timecard.ts` around lines 163 - 167, Add an explicit empty-array guard at the start of sheetStatus so sheetStatus([]) does not reach the cards.every() check and return "approved"; return the appropriate non-approved state consistent with the existing submitted fallback, while preserving the current rejected and approved behavior for non-empty card arrays.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/csm-portal/microapp/src/pages/TimeCardsPage.tsx`:
- Around line 198-199: Update the empty-state condition in the TimeCardsPage
render flow to return EmptyState only when sheets is empty and !hasNextPage. For
empty filtered pages with more results available, continue rendering the
sentinel and loading UI so fetchNextPage can load later matches.
---
Nitpick comments:
In `@apps/csm-portal/microapp/src/utils/timecard.ts`:
- Around line 163-167: Add an explicit empty-array guard at the start of
sheetStatus so sheetStatus([]) does not reach the cards.every() check and return
"approved"; return the appropriate non-approved state consistent with the
existing submitted fallback, while preserving the current rejected and approved
behavior for non-empty card arrays.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6b22c2b5-2bb5-4a30-be15-7358ba8f1de1
⛔ Files ignored due to path filters (1)
apps/csm-portal/microapp/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (13)
apps/csm-portal/microapp/package.jsonapps/csm-portal/microapp/src/components/timecards/TimeCardFiltersSheet.tsxapps/csm-portal/microapp/src/components/timecards/TimeCardReviewDialog.tsxapps/csm-portal/microapp/src/components/timecards/TimeCardStateChip.tsxapps/csm-portal/microapp/src/components/timecards/TimeSheetCard.tsxapps/csm-portal/microapp/src/config/endpoints.tsapps/csm-portal/microapp/src/pages/TimeCardsPage.tsxapps/csm-portal/microapp/src/services/timecards.tsapps/csm-portal/microapp/src/types/index.tsapps/csm-portal/microapp/src/types/timecard.dto.tsapps/csm-portal/microapp/src/types/timecard.model.tsapps/csm-portal/microapp/src/types/user.model.tsapps/csm-portal/microapp/src/utils/timecard.ts
|
@coderabbitai review |
✅ Action performedReview finished.
|
Known limitation: state-filtered progress count ("N of Y") is misleading
Side effect: Proposing to handle this in two parts:
Not a blocker for this PR (mirrors the same workaround the webapp already ships with), just flagging so it isn't mistaken for a new mobile-only bug. |
…when client-filtered
|
Done in b29afb1. When a state/work item/engineer filter is on, the count now shows just the shown count (e.g. "12 cards") instead of "N of total", since that total is pre filter. Kept "N of total" when unfiltered. Server side states fix out of scope here as you said. |
Purpose
Adds the Time Cards feature to the CSM microapp (mobile), replacing the ComingSoon placeholder reached at More → Time Cards. Brings mobile parity with the webapp's time-cards views.
Goals
Approach
services/timecards.ts— infinite (paged) React Query options for My sheets / All / Approvals + the approve-reject mutation, backed byPOST /time-cards/searchandPATCH /time-cards/{id}. Cards from every loaded page are flattened and grouped into weekly sheets in one pass.utils/timecard.ts— ISO-week grouping, state → chip meta, minute formatting, filter model + helpers.types/timecard.dto.ts/timecard.model.ts— wire shapes + the portal model and mapper (time is in minutes).components/timecards/—TimeSheetCard(tap-to-expand week accordion),TimeCardStateChip,TimeCardReviewDialog(reason required on reject),TimeCardFiltersSheet.pages/TimeCardsPage.tsx— the tabbed workspace; the active tab's query is lifted here so the filter sheet can offer the loaded work-item / engineer options.projectIds); work item + engineer are client-side over the loaded cards (no search endpoint for either); state is client-side; date range maps tostartDate/endDate.dev-app-csm-portal).@wso2/oxygen-ui*packages to0.2.1/0.4.0so the microapp installs — the0.6.1currently on the branch isn't published to npm, so a freshnpm installfails onETARGET.User stories
As a CS engineer, I can review my logged time by week on mobile; as an approver, I can approve or reject submitted time cards on the go.
Release note
Adds the Time Cards feature (My sheets / All / Approvals tabs, per-tab filters, approve-reject, infinite scroll) to the CSM microapp.
Documentation
N/A — internal CSM microapp UI, no external doc surface affected.
Automation tests
Security checks
Test environment
tsc) andnpm run lintpassing locally.Summary by CodeRabbit