task-fixdatetime
This commit is contained in:
259
plans/task-datetime.md
Normal file
259
plans/task-datetime.md
Normal file
@@ -0,0 +1,259 @@
|
||||
# Task: Global Date & Time Formatting Standard (Hydration-safe)
|
||||
|
||||
## Objective
|
||||
|
||||
Eliminate all React hydration mismatch issues caused by inconsistent date formatting between Server Components and Client Components.
|
||||
|
||||
Establish a single global date formatting standard across the entire application.
|
||||
|
||||
---
|
||||
|
||||
## Problem
|
||||
|
||||
Current implementation uses:
|
||||
|
||||
* Date.toLocaleString()
|
||||
* Date.toLocaleDateString()
|
||||
* Date.toLocaleTimeString()
|
||||
|
||||
These APIs depend on:
|
||||
|
||||
* Browser Locale
|
||||
* Operating System Locale
|
||||
* Server Locale
|
||||
* Server Timezone
|
||||
* Browser Timezone
|
||||
|
||||
This causes inconsistent rendering between SSR and Client Hydration.
|
||||
|
||||
Example
|
||||
|
||||
Server
|
||||
|
||||
16/6/2569 17:00:00
|
||||
|
||||
Client
|
||||
|
||||
6/16/2026, 5:00:00 PM
|
||||
|
||||
Result
|
||||
|
||||
React Hydration Error
|
||||
|
||||
---
|
||||
|
||||
## Requirements
|
||||
|
||||
### 1. Create Global Date Utility
|
||||
|
||||
Create
|
||||
|
||||
```
|
||||
src/lib/date-format.ts
|
||||
```
|
||||
|
||||
All UI must use this utility.
|
||||
|
||||
---
|
||||
|
||||
### 2. Never use
|
||||
|
||||
Forbidden
|
||||
|
||||
```
|
||||
toLocaleString()
|
||||
|
||||
toLocaleDateString()
|
||||
|
||||
toLocaleTimeString()
|
||||
|
||||
Intl.DateTimeFormat()
|
||||
|
||||
new Date().toString()
|
||||
```
|
||||
|
||||
directly inside React components.
|
||||
|
||||
---
|
||||
|
||||
### 3. Standard Display Format
|
||||
|
||||
Date only
|
||||
|
||||
```
|
||||
YYYY-MM-DD
|
||||
|
||||
Example
|
||||
|
||||
2026-06-25
|
||||
```
|
||||
|
||||
Date Time
|
||||
|
||||
```
|
||||
YYYY-MM-DD HH:mm:ss
|
||||
|
||||
Example
|
||||
|
||||
2026-06-25 14:35:20
|
||||
```
|
||||
|
||||
Time
|
||||
|
||||
```
|
||||
HH:mm:ss
|
||||
```
|
||||
|
||||
Month
|
||||
|
||||
```
|
||||
YYYY-MM
|
||||
```
|
||||
|
||||
Year
|
||||
|
||||
```
|
||||
YYYY
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 4. Timezone
|
||||
|
||||
Always
|
||||
|
||||
```
|
||||
Asia/Bangkok
|
||||
```
|
||||
|
||||
Never depend on browser timezone.
|
||||
|
||||
---
|
||||
|
||||
### 5. Calendar
|
||||
|
||||
Always use
|
||||
|
||||
Gregorian Calendar
|
||||
|
||||
Never Buddhist Calendar.
|
||||
|
||||
Display
|
||||
|
||||
2026
|
||||
|
||||
Never
|
||||
|
||||
2569
|
||||
|
||||
---
|
||||
|
||||
### 6. SSR Safe
|
||||
|
||||
Formatting must produce identical output on
|
||||
|
||||
* Server
|
||||
* Client
|
||||
* Static Render
|
||||
* Hydration
|
||||
|
||||
No locale-dependent output.
|
||||
|
||||
---
|
||||
|
||||
### 7. Usage
|
||||
|
||||
Replace every occurrence of
|
||||
|
||||
```
|
||||
toLocaleString()
|
||||
|
||||
toLocaleDateString()
|
||||
|
||||
toLocaleTimeString()
|
||||
|
||||
Intl.DateTimeFormat()
|
||||
```
|
||||
|
||||
with
|
||||
|
||||
```
|
||||
formatDate()
|
||||
|
||||
formatDateTime()
|
||||
|
||||
formatTime()
|
||||
|
||||
formatMonth()
|
||||
|
||||
formatYear()
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 8. Dashboard
|
||||
|
||||
Update all CRM Dashboard components.
|
||||
|
||||
Especially
|
||||
|
||||
* Approval Metrics
|
||||
* Lead Tables
|
||||
* Opportunity Tables
|
||||
* Quotation Tables
|
||||
* Activity Timeline
|
||||
* Follow-up
|
||||
* Reports
|
||||
|
||||
---
|
||||
|
||||
### 9. Tables
|
||||
|
||||
Default date column
|
||||
|
||||
```
|
||||
YYYY-MM-DD
|
||||
```
|
||||
|
||||
Only show time when business requires it.
|
||||
|
||||
---
|
||||
|
||||
### 10. Forms
|
||||
|
||||
Date Picker
|
||||
|
||||
Store
|
||||
|
||||
ISO8601 UTC
|
||||
|
||||
Display
|
||||
|
||||
YYYY-MM-DD
|
||||
|
||||
---
|
||||
|
||||
### 11. API
|
||||
|
||||
API returns
|
||||
|
||||
ISO8601
|
||||
|
||||
Example
|
||||
|
||||
```
|
||||
2026-06-25T10:35:20.000Z
|
||||
```
|
||||
|
||||
UI handles formatting.
|
||||
|
||||
---
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
* No Hydration mismatch.
|
||||
* No locale-dependent rendering.
|
||||
* Same output in Server and Client.
|
||||
* All dashboard pages use global formatter.
|
||||
* All table date columns display YYYY-MM-DD.
|
||||
* No usage of toLocaleString(), toLocaleDateString(), toLocaleTimeString() inside UI components.
|
||||
614
plans/task-gendata.md
Normal file
614
plans/task-gendata.md
Normal file
@@ -0,0 +1,614 @@
|
||||
# Prompt : Generate UAT Seed Data for ALLA CRM
|
||||
|
||||
Role:
|
||||
You are a Senior Solution Architect, Business Analyst, and Data Architect responsible for preparing realistic UAT seed data for the ALLA CRM system.
|
||||
|
||||
## Objective
|
||||
|
||||
Generate business-oriented seed data that demonstrates the complete CRM workflow.
|
||||
|
||||
The goal is NOT to create random records.
|
||||
|
||||
Every record must belong to a realistic business scenario so that end users can understand the system immediately during UAT.
|
||||
|
||||
---
|
||||
|
||||
## General Rules
|
||||
|
||||
* All data must be internally consistent.
|
||||
* Every document must reference existing related data.
|
||||
* Dates should simulate approximately the last 90 days.
|
||||
* Mix Draft, In Progress, Completed, Won, Lost and Cancelled cases.
|
||||
* Generate believable Thai company names, projects and contacts.
|
||||
* Avoid Lorem Ipsum.
|
||||
* Avoid fake meaningless values.
|
||||
|
||||
---
|
||||
|
||||
# Business Scenarios
|
||||
|
||||
Create at least 15 complete business stories.
|
||||
|
||||
Example:
|
||||
|
||||
## Story 1
|
||||
|
||||
Lead received from Website
|
||||
|
||||
Customer:
|
||||
Bangkok Food Industry Co.,Ltd.
|
||||
|
||||
Project:
|
||||
Warehouse Crane Installation
|
||||
|
||||
Flow
|
||||
|
||||
Lead
|
||||
↓
|
||||
|
||||
Marketing Follow-up
|
||||
|
||||
↓
|
||||
|
||||
Assign to Sales
|
||||
|
||||
↓
|
||||
|
||||
Opportunity
|
||||
|
||||
↓
|
||||
|
||||
Site Survey
|
||||
|
||||
↓
|
||||
|
||||
Requirement Gathering
|
||||
|
||||
↓
|
||||
|
||||
Quotation
|
||||
|
||||
↓
|
||||
|
||||
Approval
|
||||
|
||||
↓
|
||||
|
||||
Sent to Customer
|
||||
|
||||
↓
|
||||
|
||||
PO Received
|
||||
|
||||
Story should contain every related record.
|
||||
|
||||
---
|
||||
|
||||
Story 2
|
||||
|
||||
Lead Lost
|
||||
|
||||
Reason
|
||||
|
||||
Budget too high
|
||||
|
||||
Competitor:
|
||||
Konecranes
|
||||
|
||||
Outcome
|
||||
|
||||
Closed Lost
|
||||
|
||||
---
|
||||
|
||||
Story 3
|
||||
|
||||
Customer requested Revision
|
||||
|
||||
Quotation R01
|
||||
|
||||
↓
|
||||
|
||||
Rejected by customer
|
||||
|
||||
↓
|
||||
|
||||
Quotation R02
|
||||
|
||||
↓
|
||||
|
||||
Approved
|
||||
|
||||
↓
|
||||
|
||||
PO
|
||||
|
||||
---
|
||||
|
||||
Story 4
|
||||
|
||||
No Quotation
|
||||
|
||||
Reason
|
||||
|
||||
Customer cancelled project
|
||||
|
||||
---
|
||||
|
||||
Story 5
|
||||
|
||||
Large project
|
||||
|
||||
Multiple project parties
|
||||
|
||||
Billing Customer
|
||||
|
||||
Contractor
|
||||
|
||||
Consultant
|
||||
|
||||
End Customer
|
||||
|
||||
---
|
||||
|
||||
Story 6
|
||||
|
||||
Quotation waiting approval
|
||||
|
||||
Sales Manager pending
|
||||
|
||||
---
|
||||
|
||||
Story 7
|
||||
|
||||
Approval rejected
|
||||
|
||||
Return to Sales
|
||||
|
||||
Create Revision
|
||||
|
||||
---
|
||||
|
||||
Story 8
|
||||
|
||||
Follow-up overdue
|
||||
|
||||
Sales forgot to contact customer
|
||||
|
||||
---
|
||||
|
||||
Story 9
|
||||
|
||||
High Value Project
|
||||
|
||||
Estimated value
|
||||
|
||||
35 Million THB
|
||||
|
||||
Chance
|
||||
|
||||
80%
|
||||
|
||||
Priority
|
||||
|
||||
High
|
||||
|
||||
---
|
||||
|
||||
Story 10
|
||||
|
||||
Service Project
|
||||
|
||||
Product Type
|
||||
|
||||
Service
|
||||
|
||||
Maintenance Contract
|
||||
|
||||
---
|
||||
|
||||
Continue until at least 15 stories.
|
||||
|
||||
---
|
||||
|
||||
## Required Master Data
|
||||
|
||||
Generate realistic master data.
|
||||
|
||||
Organizations
|
||||
|
||||
Branches
|
||||
|
||||
Product Types
|
||||
|
||||
Sales Teams
|
||||
|
||||
Marketing Teams
|
||||
|
||||
Users
|
||||
|
||||
Approval Roles
|
||||
|
||||
Customers
|
||||
|
||||
Customer Groups
|
||||
|
||||
Contacts
|
||||
|
||||
Sites
|
||||
|
||||
Industries
|
||||
|
||||
Competitors
|
||||
|
||||
Lead Sources
|
||||
|
||||
Currencies
|
||||
|
||||
Units
|
||||
|
||||
Payment Terms
|
||||
|
||||
Delivery Terms
|
||||
|
||||
Master Options
|
||||
|
||||
---
|
||||
|
||||
## Customer Requirements
|
||||
|
||||
Create approximately
|
||||
|
||||
50 Customers
|
||||
|
||||
Each customer has
|
||||
|
||||
1–5 Sites
|
||||
|
||||
Each site has
|
||||
|
||||
2–6 Contacts
|
||||
|
||||
Different industries
|
||||
|
||||
Construction
|
||||
|
||||
Factory
|
||||
|
||||
Food
|
||||
|
||||
Automotive
|
||||
|
||||
Power Plant
|
||||
|
||||
Logistics
|
||||
|
||||
Hospital
|
||||
|
||||
Government
|
||||
|
||||
University
|
||||
|
||||
Commercial Building
|
||||
|
||||
---
|
||||
|
||||
## Lead Requirements
|
||||
|
||||
Generate approximately
|
||||
|
||||
80 Leads
|
||||
|
||||
Status distribution
|
||||
|
||||
20 New
|
||||
|
||||
15 Contacted
|
||||
|
||||
10 Assigned
|
||||
|
||||
15 Opportunity
|
||||
|
||||
10 Closed Won
|
||||
|
||||
8 Closed Lost
|
||||
|
||||
2 Cancelled
|
||||
|
||||
Different Lead Sources
|
||||
|
||||
Website
|
||||
|
||||
Facebook
|
||||
|
||||
LINE OA
|
||||
|
||||
Referral
|
||||
|
||||
Existing Customer
|
||||
|
||||
Sales Visit
|
||||
|
||||
Exhibition
|
||||
|
||||
Phone Call
|
||||
|
||||
---
|
||||
|
||||
## Opportunity Requirements
|
||||
|
||||
Generate approximately
|
||||
|
||||
40 Opportunities
|
||||
|
||||
Different pipeline stages
|
||||
|
||||
Requirement Gathering
|
||||
|
||||
Budget Checking
|
||||
|
||||
Competitor Analysis
|
||||
|
||||
Proposal Preparation
|
||||
|
||||
Quotation
|
||||
|
||||
Negotiation
|
||||
|
||||
PO Pending
|
||||
|
||||
---
|
||||
|
||||
## Quotation Requirements
|
||||
|
||||
Generate approximately
|
||||
|
||||
60 Quotations
|
||||
|
||||
Mix
|
||||
|
||||
Draft
|
||||
|
||||
Pending Approval
|
||||
|
||||
Approved
|
||||
|
||||
Sent
|
||||
|
||||
Following Up
|
||||
|
||||
Won
|
||||
|
||||
Lost
|
||||
|
||||
Cancelled
|
||||
|
||||
Around 20 quotations should have Revision R02 or R03.
|
||||
|
||||
---
|
||||
|
||||
Each quotation should contain
|
||||
|
||||
Header
|
||||
|
||||
Customer
|
||||
|
||||
Project
|
||||
|
||||
Project Parties
|
||||
|
||||
Items
|
||||
|
||||
Topics
|
||||
|
||||
Scope
|
||||
|
||||
Exclusion
|
||||
|
||||
Payment Terms
|
||||
|
||||
Delivery
|
||||
|
||||
Warranty
|
||||
|
||||
Attachments
|
||||
|
||||
Follow-ups
|
||||
|
||||
Approval History
|
||||
|
||||
Remarks
|
||||
|
||||
Currency
|
||||
|
||||
Tax
|
||||
|
||||
Discount
|
||||
|
||||
Totals
|
||||
|
||||
---
|
||||
|
||||
## Approval Data
|
||||
|
||||
Generate realistic approval history.
|
||||
|
||||
Sales Manager
|
||||
|
||||
Department Manager
|
||||
|
||||
Managing Director
|
||||
|
||||
Include
|
||||
|
||||
Approved
|
||||
|
||||
Rejected
|
||||
|
||||
Pending
|
||||
|
||||
Returned
|
||||
|
||||
Approval timestamps must be realistic.
|
||||
|
||||
---
|
||||
|
||||
## PO Data
|
||||
|
||||
Generate
|
||||
|
||||
25 Purchase Orders
|
||||
|
||||
Linked to approved quotations only.
|
||||
|
||||
Include
|
||||
|
||||
PO Number
|
||||
|
||||
PO Date
|
||||
|
||||
Currency
|
||||
|
||||
Amount
|
||||
|
||||
---
|
||||
|
||||
## Dashboard Distribution
|
||||
|
||||
Data should produce meaningful dashboards.
|
||||
|
||||
Examples
|
||||
|
||||
Sales Pipeline
|
||||
|
||||
Quotation by Status
|
||||
|
||||
Revenue Forecast
|
||||
|
||||
Won vs Lost
|
||||
|
||||
Top Customers
|
||||
|
||||
Top Salespersons
|
||||
|
||||
Follow-up Due Today
|
||||
|
||||
Overdue Follow-up
|
||||
|
||||
Opportunity Value
|
||||
|
||||
Monthly Revenue
|
||||
|
||||
Branch Comparison
|
||||
|
||||
Product Type Comparison
|
||||
|
||||
Lead Source Analysis
|
||||
|
||||
Competitor Analysis
|
||||
|
||||
Conversion Rate
|
||||
|
||||
---
|
||||
|
||||
## Follow-up Activities
|
||||
|
||||
Every Lead, Opportunity and Quotation should contain timeline activities.
|
||||
|
||||
Examples
|
||||
|
||||
Phone Call
|
||||
|
||||
LINE
|
||||
|
||||
Email
|
||||
|
||||
Meeting
|
||||
|
||||
Site Survey
|
||||
|
||||
Customer Visit
|
||||
|
||||
Quotation Sent
|
||||
|
||||
Reminder
|
||||
|
||||
PO Follow-up
|
||||
|
||||
Each activity should contain
|
||||
|
||||
Date
|
||||
|
||||
Owner
|
||||
|
||||
Remark
|
||||
|
||||
Next Follow-up Date
|
||||
|
||||
Status
|
||||
|
||||
---
|
||||
|
||||
## Data Quality
|
||||
|
||||
Every foreign key must be valid.
|
||||
|
||||
Every document number must follow project numbering rules.
|
||||
|
||||
No orphan records.
|
||||
|
||||
No duplicated business logic.
|
||||
|
||||
Statuses must match the workflow.
|
||||
|
||||
Approval history must match document status.
|
||||
|
||||
Won quotations must have PO.
|
||||
|
||||
Lost quotations must contain Lost Reason.
|
||||
|
||||
Cancelled documents must contain Cancel Reason.
|
||||
|
||||
No Quotation cases must contain No Quotation Reason.
|
||||
|
||||
---
|
||||
|
||||
## Output
|
||||
|
||||
Generate the seed in modular files.
|
||||
|
||||
seed/
|
||||
|
||||
master/
|
||||
|
||||
organization.seed.ts
|
||||
|
||||
branch.seed.ts
|
||||
|
||||
users.seed.ts
|
||||
|
||||
customers.seed.ts
|
||||
|
||||
contacts.seed.ts
|
||||
|
||||
lead.seed.ts
|
||||
|
||||
opportunity.seed.ts
|
||||
|
||||
quotation.seed.ts
|
||||
|
||||
approval.seed.ts
|
||||
|
||||
purchase-order.seed.ts
|
||||
|
||||
followup.seed.ts
|
||||
|
||||
attachments.seed.ts
|
||||
|
||||
dashboard.seed.ts
|
||||
|
||||
The seed must be idempotent.
|
||||
|
||||
Running multiple times should not create duplicated business records.
|
||||
|
||||
The generated data should allow UAT users to experience every important workflow in the CRM system without manually creating records.
|
||||
Reference in New Issue
Block a user