Added tasks, reminders, and role-specific dashboards
This commit is contained in:
@@ -68,7 +68,7 @@ Public routes are `/` and `/login`. CRM routes are `/app`, `/app/merchants`, `/a
|
||||
| GET | `/api/merchants?search=&status=&country=&industry=&ownerId=&page=1` | Scoped combined filters; 8 records per page |
|
||||
| GET | `/api/merchants/:id` | Overview, checklist, notes, tasks, history |
|
||||
| GET | `/api/pipeline` | Scoped merchants grouped in the UI |
|
||||
| GET | `/api/tasks?filter=ALL` | ALL / OPEN / OVERDUE / UPCOMING / DONE |
|
||||
| GET | `/api/tasks?filter=ALL` | TODAY / UPCOMING / OVERDUE / DONE; ALL / OPEN retained |
|
||||
| GET | `/api/review-queue` | Compliance-only, oldest review first |
|
||||
|
||||
Passwords are salted with scrypt. A random session token lives in an HttpOnly, SameSite=Lax cookie; only its SHA-256 digest is stored in PostgreSQL. Sessions expire after eight hours. Every mutation, including login/logout, requires an exact trusted `Origin` and rejects cross-site Fetch Metadata. Local login limits allow 100 attempts per IP and 20 per normalized email per five minutes, include `Retry-After`, and bound the in-memory bucket map to 10,000 entries. These limits are designed for this single-process local prototype. The UI clears private query caches on logout, login and API session rejection.
|
||||
@@ -108,9 +108,9 @@ Apply checked-in additive migrations with `pnpm db:migrate` when upgrading an ex
|
||||
|
||||
The successful path is **New Lead → Contacted → Qualified → KYB → Compliance Review → Integration → Testing → Live**. **Rejected** is a separate terminal outcome. Luma Labs demonstrates a historical return from Compliance Review to KYB for corrections.
|
||||
|
||||
The seed creates 45 merchants, 90 commercial tasks, additional personal compliance tasks, interactions, document checklists and change history, review cycles and chronological stage history spanning 90 days. Fresh fixtures include 7 New Leads, 5 Contacted, 5 Qualified, 6 KYB, 6 Compliance Review, 4 Integration, 4 Testing, 5 Live and 3 Rejected. Dates are relative to the first seed, then preserved. There are no fabricated trend percentages or payment metrics. The dashboard counts visible merchants, current review records, open overdue tasks, and non-initial status changes during the past 30 days. Its activity feed uses persisted interactions and immutable audit events; counts naturally change as fixtures age.
|
||||
The seed creates 45 merchants, 90 commercial tasks, additional personal compliance tasks, interactions, document checklists and change history, review cycles and chronological stage history spanning 90 days. Fresh fixtures include 7 New Leads, 5 Contacted, 5 Qualified, 6 KYB, 6 Compliance Review, 4 Integration, 4 Testing, 5 Live and 3 Rejected. Dates are relative to the first seed, then preserved. There are no fabricated trend percentages or payment metrics. Role-specific dashboards derive portfolio, workload and review metrics from scoped database records. Its activity feed uses persisted interactions and immutable audit events; counts naturally change as fixtures age.
|
||||
|
||||
English is the default; EN/RU selection persists in local storage, including across sign-out. Dates and numbers use `Intl` and the viewer's local timezone. Status, role, industry and document labels are translated from canonical codes. Names, task titles and user notes remain verbatim. Checklist collection, review decisions, interaction logging and task management are available from merchant details. Reminders are derived from stored dates and refresh inside the app, without background notification infrastructure.
|
||||
English is the default; EN/RU selection persists in local storage, including across sign-out. Dates and numbers use `Intl` and the viewer's local timezone. Status, role, industry and document labels are translated from canonical codes. Names, task titles and user notes remain verbatim. Checklist collection, review decisions, interaction logging and task management are available from merchant details. Reminders and their dismissals persist in PostgreSQL and refresh in the app while visible and on focus or reconnection.
|
||||
|
||||
## Verification
|
||||
|
||||
@@ -140,7 +140,7 @@ The [product brief](docs/product-brief.md) and [implementation checklist](docs/i
|
||||
|
||||
## Editing and workflow rules
|
||||
|
||||
Head of Sales can edit commercial details for the portfolio, assign/reassign Account Managers, collect KYB documents, and manage commercial activities/tasks. Managers can perform commercial actions only for currently assigned merchants and cannot change ownership. Compliance can read merchant context and KYB across every stage, record reviews and KYB notes, and manage only personal compliance tasks. Head and managers can view related compliance tasks but cannot change them. Query predicates enforce these scopes on lists, search, totals, dashboard, detail children, and mutation targets.
|
||||
Head of Sales can edit commercial details for the portfolio, assign/reassign Account Managers, collect KYB documents, and manage commercial activities/tasks. Managers can perform commercial actions only for currently assigned merchants and cannot change ownership. Compliance can read merchant context and KYB across every stage, record reviews and KYB notes, and manage only personal compliance tasks. Personal Compliance tasks are private; Head and managers see commercial tasks only. Query predicates enforce these scopes on lists, search, totals, dashboard, detail children, and mutation targets.
|
||||
|
||||
Only adjacent commercial stage advances are accepted, plus the explicit legacy return-to-KYB action described below. A manager must be assigned before leaving New Lead. Contacted requires a logged call or email. Qualified requires company name, website, contact name/email, country, industry and an estimated volume; zero is valid. In KYB, Head or the assigned Manager records Missing/Received status and collection notes for company registration, ownership structure and authorized-representative identification. These are checklist records, with no uploads. Submission requires all three required checklist records to have received-history evidence and creates one pending review. Company/KYB fields freeze while that review is pending. Compliance can approve with Low/Medium/High risk and a required rationale (atomically advancing to Integration), reject with a reason, or request item-specific corrections stored with the review, separately from collection notes (returning to KYB). Resubmission creates a new review cycle. Decisions and system history cannot be edited.
|
||||
|
||||
@@ -203,3 +203,25 @@ Current review policy version 2 requires exactly three active KYB records. `docu
|
||||
Merchant detail includes review snapshots, risk and immutable correction notes, activation check history, and server-derived handoff/edit capabilities. Review links use `?tab=onboarding#review-<id>` and remain valid after decisions.
|
||||
|
||||
Apply the two new additive migrations with `pnpm db:migrate`; do not reset or reseed development data. Old review cycles retain policy version 1 and their original evidence. Legacy beneficial-owner ID and business-activity items become read-only historical requirements. Unfinished merchants receive a new Missing representative-identification record; terminal records remain untouched. Old pending reviews require corrections/resubmission or rejection. Old approvals cannot authorize further activation: use Return to KYB for re-review. Existing decisions, notes, timestamps and passwords are preserved, and no risk or demo results are inferred for existing fixtures. Fresh fixtures include current-policy approval/check evidence; seed reruns preserve existing records.
|
||||
|
||||
## Tasks, reminders, and operational dashboards
|
||||
|
||||
Apply migration `202609240007_tasks_dashboards` with `pnpm db:migrate`; no reset or reseed is required. It adds reminder dismissal, a revision number and an assignee/status/reminder index without changing existing task values.
|
||||
|
||||
Tasks and merchant details share creation, editing, completion and reopening controls. The merchant selector uses the scoped directory. Mutation payloads retain the existing `{version,title,dueAt,remindAt,status}` contract; assignee and task kind are server-derived. Responses include merchant version and task action capabilities. An open editor retains its starting version; a conflict preserves inputs and offers an explicit current-version refresh before resubmission.
|
||||
|
||||
Sales tasks follow the merchant owner; unassigned lead tasks belong to the Head. Reassignment atomically transfers open commercial tasks and resets their reminder dismissal. Completed attribution and Compliance tasks stay intact. A new manager may reopen an inherited completed task; its previous completion is audited before it is assigned to the current manager. Personal Compliance tasks never appear in Sales task lists or dashboards.
|
||||
|
||||
| Endpoint | Behavior |
|
||||
| -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `GET /api/tasks?filter=TODAY&timeZone=Europe/Kyiv` | Open tasks due during the viewer’s local day, including overdue tasks due today. `UPCOMING` begins tomorrow, `OVERDUE` is due before now, and `DONE` is completed. `ALL` and `OPEN` remain supported. Optional `merchantId` and authorized `assigneeId` filters combine with role scope. |
|
||||
| `GET /api/reminders` | Only the caller’s visible, open, undismissed tasks with `remindAt <= now`; includes `reminderRevision`. |
|
||||
| `POST /api/tasks/:id/reminder-dismissal` | `{reminderRevision}`; persists dismissal, is idempotent for that revision, and rejects stale revisions with 409. |
|
||||
| `GET /api/merchants` | Adds UTC `createdFrom`/`createdTo` inclusive bounds and `cohort=ACTIVE_ONBOARDING\|REACHED_LIVE` to the existing combined filters. |
|
||||
| `GET /api/review-queue?view=DECISIONS` | Compliance-only decided review history, newest decision first, with optional `decision`, `decidedFrom`, and `decidedTo`. Default view remains pending reviews. |
|
||||
|
||||
The inbox polls every 30 seconds while visible and refreshes immediately on mount, focus, visibility restoration and reconnection. Completion suppresses reminders; reopening preserves dismissal. A change to reminder time or assignee starts a fresh revision. Title-only edits preserve exact stored reminder timestamps. UTC instants are stored and transported; the UI shows local dates/times and uses DST-aware local-day boundaries. No browser storage, external notifications or scheduler is required for reminders.
|
||||
|
||||
Head dashboards show total merchants, created leads during the last 30 days, active onboarding (KYB through Testing), Live merchants, all-stage distribution, manager workload, overdue sales tasks and unassigned New Leads. Workload shows assigned merchants, active onboarding, open sales tasks and overdue sales tasks, including managers with zero work. Managers get their assigned scope and own workload, with next actions first. Compliance gets pending reviews, oldest waiting cycles, 30-day decision counts by outcome and personal review tasks.
|
||||
|
||||
Activation rate is **currently Live / all visible merchants**, including Rejected. Average onboarding duration is **creation to earliest recorded Live transition**, once per visible merchant with such an event. Neither uses current-stage entry time as a substitute. The UI shows denominators/sample counts and honest empty states. Totals and charts come from a repeatable-read database snapshot with one captured time; their drilldowns reuse the same predicates. Thirty-day drilldowns preserve the snapshot’s UTC period bounds in the URL. Live operational lists refresh as records and time change.
|
||||
|
||||
Reference in New Issue
Block a user