@devalok/shilp-sutra-karm 0.18.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/components/admin/admin-dashboard.md +215 -0
- package/docs/components/admin/admin-types.md +167 -0
- package/docs/components/admin/admin-utils.md +165 -0
- package/docs/components/admin/break-admin.md +167 -0
- package/docs/components/board/board-column.md +35 -0
- package/docs/components/board/board-provider.md +73 -0
- package/docs/components/board/board-toolbar.md +36 -0
- package/docs/components/board/board-types.md +62 -0
- package/docs/components/board/bulk-action-bar.md +38 -0
- package/docs/components/board/column-empty.md +33 -0
- package/docs/components/board/column-header.md +36 -0
- package/docs/components/board/kanban-board.md +53 -0
- package/docs/components/board/task-card.md +58 -0
- package/docs/components/board/task-context-menu.md +36 -0
- package/docs/components/chat/chat-input.md +37 -0
- package/docs/components/chat/chat-panel.md +58 -0
- package/docs/components/chat/conversation-list.md +47 -0
- package/docs/components/chat/message-list.md +44 -0
- package/docs/components/chat/streaming-text.md +29 -0
- package/docs/components/client/accent-provider.md +29 -0
- package/docs/components/client/client-portal-header.md +40 -0
- package/docs/components/client/project-card.md +39 -0
- package/docs/components/dashboard/attendance-cta.md +47 -0
- package/docs/components/dashboard/daily-brief.md +45 -0
- package/docs/components/dashboard/scratchpad-widget.md +52 -0
- package/docs/components/dashboard/sidebar-scratchpad.md +39 -0
- package/docs/components/other/karm-command-registry.md +61 -0
- package/docs/components/other/page-skeletons.md +52 -0
- package/docs/components/tasks/activity-tab.md +41 -0
- package/docs/components/tasks/conversation-tab.md +52 -0
- package/docs/components/tasks/files-tab.md +51 -0
- package/docs/components/tasks/review-tab.md +49 -0
- package/docs/components/tasks/subtasks-tab.md +56 -0
- package/docs/components/tasks/task-detail-panel.md +103 -0
- package/docs/components/tasks/task-properties.md +79 -0
- package/package.json +4 -2
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# AdminDashboard
|
|
2
|
+
|
|
3
|
+
- Import: @devalok/shilp-sutra-karm/admin
|
|
4
|
+
- Server-safe: No
|
|
5
|
+
- Category: admin
|
|
6
|
+
|
|
7
|
+
Compound component for the admin attendance dashboard. Uses React Context internally.
|
|
8
|
+
All sub-components must be rendered inside `<AdminDashboard.Root>`.
|
|
9
|
+
|
|
10
|
+
Exports: AdminDashboard (compound), AdminDashboardSkeleton, Calendar, BreakRequestCard, LeaveRequests, DashboardHeader, AttendanceOverview, AssociateDetail, CorrectionList, RenderDate
|
|
11
|
+
|
|
12
|
+
## Props
|
|
13
|
+
|
|
14
|
+
### AdminDashboard.Root (AdminDashboardRootProps)
|
|
15
|
+
currentUserId: string (REQUIRED)
|
|
16
|
+
currentUserRole: UserRole (REQUIRED)
|
|
17
|
+
currentUser: AdminUser
|
|
18
|
+
assetsBaseUrl: string (default: "")
|
|
19
|
+
userImages: Record<string, string> (default: {})
|
|
20
|
+
isLoading: boolean (default: false)
|
|
21
|
+
onAssociateChange: (user: AdminUser | null) => void
|
|
22
|
+
children: ReactNode (REQUIRED)
|
|
23
|
+
...HTMLDivElement attributes (className, etc.)
|
|
24
|
+
|
|
25
|
+
### AdminDashboard.Calendar (AdminDashboardCalendarProps)
|
|
26
|
+
dateAttendanceMap: Map<string, DateAttendanceInfo> | null (default: null)
|
|
27
|
+
onDateChange: (date: string) => void
|
|
28
|
+
onTimeFrameChange: (timeFrame: string) => void
|
|
29
|
+
users: AdminUser[] (default: [])
|
|
30
|
+
selectedUserAttendance: AttendanceRecord | null (default: null)
|
|
31
|
+
...HTMLDivElement attributes
|
|
32
|
+
|
|
33
|
+
### AdminDashboard.AttendanceOverview (AdminDashboardAttendanceOverviewProps)
|
|
34
|
+
groupedAttendance: GroupedAttendance | null (default: null)
|
|
35
|
+
users: AdminUser[] (default: [])
|
|
36
|
+
...HTMLDivElement attributes
|
|
37
|
+
|
|
38
|
+
### AdminDashboard.AssociateDetail (AdminDashboardAssociateDetailProps)
|
|
39
|
+
attendance: AttendanceRecord | null (default: null)
|
|
40
|
+
tasks: TaskItem[] (default: [])
|
|
41
|
+
breakRequest: BreakRequest | null (default: null)
|
|
42
|
+
onUpdateAttendanceStatus: (params: { userId: string; date: string; isPresent: boolean }) => void | Promise<void>
|
|
43
|
+
onToggleTaskStatus: (taskId: string, newStatus: string) => void | Promise<void>
|
|
44
|
+
onAddTask: (title: string, assigneeId: string) => void | Promise<void>
|
|
45
|
+
onReorderTasks: (draggedTaskId: string, targetTaskId: string) => void | Promise<void>
|
|
46
|
+
onCancelBreak: (params: { requestId: string; deleteSingleDay: boolean; dateToCancel: string | Date; userId: string }) => void | Promise<void>
|
|
47
|
+
onRefreshSelectedUserAttendance: () => void | Promise<void>
|
|
48
|
+
onRefreshAttendanceData: () => void | Promise<void>
|
|
49
|
+
...HTMLDivElement attributes
|
|
50
|
+
|
|
51
|
+
### AdminDashboard.LeaveRequests (AdminDashboardLeaveRequestsProps)
|
|
52
|
+
requests: BreakRequest[] (default: [])
|
|
53
|
+
corrections: AttendanceCorrection[] (default: [])
|
|
54
|
+
onApproveBreak: (params: { requestId: string; adminComment: string; userId: string }) => void | Promise<void>
|
|
55
|
+
onRejectBreak: (params: { requestId: string; adminComment: string; userId: string }) => void | Promise<void>
|
|
56
|
+
onApproveCorrection: (correctionId: string) => void | Promise<void>
|
|
57
|
+
onRejectCorrection: (correctionId: string) => void | Promise<void>
|
|
58
|
+
...HTMLDivElement attributes
|
|
59
|
+
|
|
60
|
+
### AdminDashboard.Content (AdminDashboardContentProps)
|
|
61
|
+
children: ReactNode (REQUIRED)
|
|
62
|
+
...HTMLDivElement attributes
|
|
63
|
+
|
|
64
|
+
### Calendar (CalendarProps) — standalone
|
|
65
|
+
onDateSelect: (date: Date) => void (REQUIRED)
|
|
66
|
+
hasCorrection: (date: Date) => boolean
|
|
67
|
+
...HTMLDivElement attributes
|
|
68
|
+
|
|
69
|
+
### BreakRequestCard (BreakRequestProps) — standalone
|
|
70
|
+
selectedDate: string | Date (REQUIRED)
|
|
71
|
+
userId: string (REQUIRED)
|
|
72
|
+
breakRequest: BreakRequest | null
|
|
73
|
+
assetsBaseUrl: string
|
|
74
|
+
onCancelBreak: (params: { requestId: string; deleteSingleDay: boolean; dateToCancel: string | Date; userId: string }) => void | Promise<void>
|
|
75
|
+
onRefreshAttendance: () => void | Promise<void>
|
|
76
|
+
onRefreshGroupedAttendance: () => void | Promise<void>
|
|
77
|
+
...HTMLDivElement attributes
|
|
78
|
+
|
|
79
|
+
### LeaveRequests (LeaveRequestsProps) — standalone
|
|
80
|
+
requests: BreakRequest[] (REQUIRED)
|
|
81
|
+
currentUserId: string (REQUIRED)
|
|
82
|
+
userImages: Record<string, string>
|
|
83
|
+
activeTimeFrame: string
|
|
84
|
+
onApproveBreak: (params: { requestId: string; adminComment: string; userId: string }) => void | Promise<void>
|
|
85
|
+
onRejectBreak: (params: { requestId: string; adminComment: string; userId: string }) => void | Promise<void>
|
|
86
|
+
...HTMLDivElement attributes
|
|
87
|
+
|
|
88
|
+
### DashboardHeader (DashboardHeaderProps) — standalone
|
|
89
|
+
selectedMonth: string (REQUIRED)
|
|
90
|
+
yearsList: string[] (REQUIRED)
|
|
91
|
+
isTodaySelected: boolean (REQUIRED)
|
|
92
|
+
selectedAssociate: AdminUser | null (REQUIRED)
|
|
93
|
+
users: AdminUser[] (REQUIRED)
|
|
94
|
+
userImages: Record<string, string> (REQUIRED)
|
|
95
|
+
activeTimeFrame: string (REQUIRED)
|
|
96
|
+
onMonthSelection: (monthYear: string) => void (REQUIRED)
|
|
97
|
+
onTodayClick: () => void (REQUIRED)
|
|
98
|
+
onSelectAssociate: (user: AdminUser | null) => void (REQUIRED)
|
|
99
|
+
onTimeFrameChange: (id: string) => void (REQUIRED)
|
|
100
|
+
onDateChange: (direction: "prev" | "next") => void (REQUIRED)
|
|
101
|
+
...HTMLDivElement attributes
|
|
102
|
+
|
|
103
|
+
### AttendanceOverview (AttendanceOverviewProps) — standalone
|
|
104
|
+
isFutureDate: boolean (REQUIRED)
|
|
105
|
+
users: AdminUser[] (REQUIRED)
|
|
106
|
+
groupedAttendance: GroupedAttendance | null (REQUIRED)
|
|
107
|
+
userImages: Record<string, string> (REQUIRED)
|
|
108
|
+
selectedDate: string (REQUIRED)
|
|
109
|
+
...HTMLDivElement attributes
|
|
110
|
+
|
|
111
|
+
### AssociateDetail (AssociateDetailProps) — standalone
|
|
112
|
+
selectedAssociate: AdminUser (REQUIRED)
|
|
113
|
+
selectedDate: string (REQUIRED)
|
|
114
|
+
selectedUserAttendance: AttendanceRecord | null (REQUIRED)
|
|
115
|
+
userTasks: TaskItem[] (REQUIRED)
|
|
116
|
+
selectedBreakRequest: BreakRequest | null (REQUIRED)
|
|
117
|
+
isFutureDate: boolean (REQUIRED)
|
|
118
|
+
assetsBaseUrl: string (REQUIRED)
|
|
119
|
+
onUpdateAttendanceStatus: (params: { userId: string; date: string; isPresent: boolean }) => void | Promise<void>
|
|
120
|
+
onToggleTaskStatus: (taskId: string, newStatus: string) => void | Promise<void>
|
|
121
|
+
onAddTask: (title: string, assigneeId: string) => void | Promise<void>
|
|
122
|
+
onReorderTasks: (draggedTaskId: string, targetTaskId: string) => void | Promise<void>
|
|
123
|
+
onCancelBreak: (params: { requestId: string; deleteSingleDay: boolean; dateToCancel: string | Date; userId: string }) => void | Promise<void>
|
|
124
|
+
onRefreshSelectedUserAttendance: () => void | Promise<void>
|
|
125
|
+
onRefreshAttendanceData: () => void | Promise<void>
|
|
126
|
+
...HTMLDivElement attributes
|
|
127
|
+
|
|
128
|
+
### CorrectionList (CorrectionListProps) — standalone
|
|
129
|
+
corrections: AttendanceCorrection[] (REQUIRED)
|
|
130
|
+
currentUserId: string (REQUIRED)
|
|
131
|
+
userImages: Record<string, string> (REQUIRED)
|
|
132
|
+
assetsBaseUrl: string (REQUIRED)
|
|
133
|
+
activeTimeFrame: string (REQUIRED)
|
|
134
|
+
onApproveCorrection: (correctionId: string) => void | Promise<void>
|
|
135
|
+
onRejectCorrection: (correctionId: string) => void | Promise<void>
|
|
136
|
+
...HTMLDivElement attributes
|
|
137
|
+
|
|
138
|
+
### RenderDate (RenderDateProps) — standalone
|
|
139
|
+
day: DayInfo (REQUIRED)
|
|
140
|
+
isAdmin: boolean (REQUIRED)
|
|
141
|
+
selectedDate: string | Date (REQUIRED)
|
|
142
|
+
dateAttendanceMap: Map<string, DateAttendanceInfo> | null (REQUIRED)
|
|
143
|
+
activeTimeFrame: string (REQUIRED)
|
|
144
|
+
...HTMLDivElement attributes
|
|
145
|
+
|
|
146
|
+
### AdminDashboardSkeleton (DashboardSkeleton)
|
|
147
|
+
...HTMLDivElement attributes (className, etc.)
|
|
148
|
+
|
|
149
|
+
## Supporting Types
|
|
150
|
+
TaskItem: { id: string; title: string; status: string; assigneeIds?: string; priority?: string }
|
|
151
|
+
AttendanceCorrection: { id: string; date: string; reason?: string; requestedDate?: string; correctionStatus: CorrectionStatus; user?: AdminUser }
|
|
152
|
+
DateAttendanceInfo: { status: AttendanceStatus | null; hasCorrectionOrApproval?: boolean; isBreakApproved?: boolean }
|
|
153
|
+
|
|
154
|
+
## Defaults
|
|
155
|
+
assetsBaseUrl="", userImages={}, isLoading=false
|
|
156
|
+
|
|
157
|
+
## Example
|
|
158
|
+
```jsx
|
|
159
|
+
<AdminDashboard.Root
|
|
160
|
+
currentUserId="user-1"
|
|
161
|
+
currentUserRole="Admin"
|
|
162
|
+
currentUser={currentUser}
|
|
163
|
+
assetsBaseUrl="/assets"
|
|
164
|
+
userImages={userImageMap}
|
|
165
|
+
isLoading={isLoading}
|
|
166
|
+
onAssociateChange={(user) => setSelected(user)}
|
|
167
|
+
>
|
|
168
|
+
<AdminDashboard.Calendar
|
|
169
|
+
dateAttendanceMap={dateMap}
|
|
170
|
+
onDateChange={handleDateChange}
|
|
171
|
+
onTimeFrameChange={handleTimeFrameChange}
|
|
172
|
+
users={allUsers}
|
|
173
|
+
selectedUserAttendance={attendance}
|
|
174
|
+
/>
|
|
175
|
+
<AdminDashboard.Content>
|
|
176
|
+
<AdminDashboard.AttendanceOverview
|
|
177
|
+
groupedAttendance={grouped}
|
|
178
|
+
users={allUsers}
|
|
179
|
+
/>
|
|
180
|
+
<AdminDashboard.AssociateDetail
|
|
181
|
+
attendance={selectedAttendance}
|
|
182
|
+
tasks={tasks}
|
|
183
|
+
breakRequest={breakReq}
|
|
184
|
+
onUpdateAttendanceStatus={handleUpdateStatus}
|
|
185
|
+
onToggleTaskStatus={handleToggleTask}
|
|
186
|
+
onAddTask={handleAddTask}
|
|
187
|
+
/>
|
|
188
|
+
<AdminDashboard.LeaveRequests
|
|
189
|
+
requests={pendingRequests}
|
|
190
|
+
corrections={corrections}
|
|
191
|
+
onApproveBreak={handleApproveBreak}
|
|
192
|
+
onRejectBreak={handleRejectBreak}
|
|
193
|
+
onApproveCorrection={handleApproveCorrection}
|
|
194
|
+
onRejectCorrection={handleRejectCorrection}
|
|
195
|
+
/>
|
|
196
|
+
</AdminDashboard.Content>
|
|
197
|
+
</AdminDashboard.Root>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Gotchas
|
|
201
|
+
- All sub-components must be inside `<AdminDashboard.Root>` or they throw a context error
|
|
202
|
+
- `AdminDashboard.AttendanceOverview` only renders when NO associate is selected
|
|
203
|
+
- `AdminDashboard.AssociateDetail` only renders when an associate IS selected
|
|
204
|
+
- `AdminDashboard.LeaveRequests` auto-hides when there are zero requests AND zero pending corrections
|
|
205
|
+
- `AdminDashboard.LeaveRequests` auto-switches tabs when new requests arrive
|
|
206
|
+
- The `Calendar` standalone export is a simpler calendar without the compound context — use it for non-admin pages
|
|
207
|
+
- `BreakRequestCard` standalone export displays a single break with cancel dialog — used inside AssociateDetail internally
|
|
208
|
+
- Date callbacks fire ISO-formatted strings via `format(date, "yyyy-MM-dd'T'HH:mm:ssxxx")`
|
|
209
|
+
- `isLoading=true` on Root renders `DashboardSkeleton` instead of children
|
|
210
|
+
|
|
211
|
+
## Changes
|
|
212
|
+
### v0.9.0
|
|
213
|
+
- **Added** Compound component API replacing 29-prop monolith (BREAKING)
|
|
214
|
+
- **Added** AdminDashboard.Content wrapper for rounded-corner management
|
|
215
|
+
- **Added** Standalone exports for Calendar, BreakRequestCard, LeaveRequests, DashboardHeader, AttendanceOverview, AssociateDetail, CorrectionList, RenderDate
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Admin Types
|
|
2
|
+
|
|
3
|
+
- Import: @devalok/shilp-sutra-karm/admin
|
|
4
|
+
- Server-safe: Yes
|
|
5
|
+
- Category: admin
|
|
6
|
+
|
|
7
|
+
Type-only exports for the admin module. No runtime code.
|
|
8
|
+
|
|
9
|
+
## Types
|
|
10
|
+
|
|
11
|
+
### UserRole
|
|
12
|
+
```ts
|
|
13
|
+
type UserRole = 'Apprentice' | 'Associate' | 'Admin' | 'SuperAdmin'
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### AttendanceStatus
|
|
17
|
+
```ts
|
|
18
|
+
type AttendanceStatus = 'PRESENT' | 'ABSENT' | 'BREAK' | 'Not_Marked' | 'HOLIDAY' | 'WEEKEND'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### CorrectionStatus
|
|
22
|
+
```ts
|
|
23
|
+
type CorrectionStatus = 'PENDING' | 'APPROVED' | 'REJECTED'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### BreakRequestStatus
|
|
27
|
+
```ts
|
|
28
|
+
type BreakRequestStatus = 'PENDING' | 'APPROVED' | 'REJECTED' | 'CANCELLED'
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### AdminUser
|
|
32
|
+
```ts
|
|
33
|
+
interface AdminUser {
|
|
34
|
+
id: string
|
|
35
|
+
name: string
|
|
36
|
+
firstName?: string
|
|
37
|
+
lastName?: string
|
|
38
|
+
email: string
|
|
39
|
+
devalokEmail?: string
|
|
40
|
+
designation: string | null
|
|
41
|
+
image: string | null
|
|
42
|
+
role: UserRole
|
|
43
|
+
isActive: boolean
|
|
44
|
+
createdAt: string | Date
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### AttendanceRecord
|
|
49
|
+
```ts
|
|
50
|
+
interface AttendanceRecord {
|
|
51
|
+
id: string
|
|
52
|
+
userId: string
|
|
53
|
+
date: string
|
|
54
|
+
timeIn: string | null
|
|
55
|
+
timeOut: string | null
|
|
56
|
+
status: AttendanceStatus
|
|
57
|
+
correctionStatus?: CorrectionStatus | null
|
|
58
|
+
reason?: string | null
|
|
59
|
+
adminComment?: string | null
|
|
60
|
+
requestedDate?: string | null
|
|
61
|
+
newTimeIn?: string | null
|
|
62
|
+
newTimeOut?: string | null
|
|
63
|
+
oldTimeIn?: string | null
|
|
64
|
+
oldTimeOut?: string | null
|
|
65
|
+
user?: AdminUser
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### BreakRequest
|
|
70
|
+
```ts
|
|
71
|
+
interface BreakRequest {
|
|
72
|
+
id: string
|
|
73
|
+
userId: string
|
|
74
|
+
startDate: string
|
|
75
|
+
endDate: string
|
|
76
|
+
numberOfDays: number
|
|
77
|
+
reason: string
|
|
78
|
+
status: BreakRequestStatus
|
|
79
|
+
adminComment?: string | null
|
|
80
|
+
correction?: boolean
|
|
81
|
+
user?: Pick<AdminUser, 'id' | 'name' | 'firstName' | 'image'>
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### BreakBalanceData
|
|
86
|
+
```ts
|
|
87
|
+
interface BreakBalanceData {
|
|
88
|
+
id: string
|
|
89
|
+
userId: string
|
|
90
|
+
totalDays: number
|
|
91
|
+
usedDays?: number
|
|
92
|
+
carryForward: number
|
|
93
|
+
cashout: number
|
|
94
|
+
yearlyBalance?: number
|
|
95
|
+
other?: number
|
|
96
|
+
user?: Pick<AdminUser, 'id' | 'name' | 'firstName' | 'image'>
|
|
97
|
+
createdAt: string
|
|
98
|
+
updatedAt: string
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Adjustment
|
|
103
|
+
```ts
|
|
104
|
+
interface Adjustment {
|
|
105
|
+
id: string
|
|
106
|
+
userId: string
|
|
107
|
+
numberOfDays: number
|
|
108
|
+
type: string
|
|
109
|
+
reason: string
|
|
110
|
+
status: string
|
|
111
|
+
comment: string | null
|
|
112
|
+
approvedBy: string | null
|
|
113
|
+
createdAt: string
|
|
114
|
+
updatedAt: string
|
|
115
|
+
user?: Pick<AdminUser, 'name' | 'email'>
|
|
116
|
+
approver?: Pick<AdminUser, 'name' | 'email'>
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### GroupedAttendance
|
|
121
|
+
```ts
|
|
122
|
+
interface GroupedAttendance {
|
|
123
|
+
present: Array<{ user: AdminUser; attendance: AttendanceRecord }>
|
|
124
|
+
absent: Array<{ user: AdminUser; attendance?: AttendanceRecord }>
|
|
125
|
+
onBreak: Array<{ user: AdminUser; attendance: AttendanceRecord; breakRequest?: BreakRequest }>
|
|
126
|
+
yetToMark: Array<{ user: AdminUser }>
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### DayInfo
|
|
131
|
+
```ts
|
|
132
|
+
interface DayInfo {
|
|
133
|
+
day: string
|
|
134
|
+
date: number
|
|
135
|
+
fullDate: Date
|
|
136
|
+
isToday: boolean
|
|
137
|
+
isActive: boolean
|
|
138
|
+
isPadding?: boolean
|
|
139
|
+
hasBreak?: boolean
|
|
140
|
+
isAbsent?: boolean
|
|
141
|
+
isDisabled?: boolean
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### RealtimeCallbacks
|
|
146
|
+
```ts
|
|
147
|
+
interface RealtimeCallbacks {
|
|
148
|
+
onBreakRequestCreated?: (data: BreakRequest) => void
|
|
149
|
+
onBreakRequestApproved?: (data: BreakRequest) => void
|
|
150
|
+
onBreakRequestRejected?: (data: BreakRequest) => void
|
|
151
|
+
onBreakRequestCancelled?: (data: BreakRequest) => void
|
|
152
|
+
onAttendanceCorrectionCreated?: (data: AttendanceRecord) => void
|
|
153
|
+
onAttendanceCorrectionProcessed?: (data: AttendanceRecord) => void
|
|
154
|
+
onTaskUpdated?: (data: unknown) => void
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Gotchas
|
|
159
|
+
- `AttendanceStatus` includes `'Not_Marked'` (mixed case with underscore) — not `'NOT_MARKED'`
|
|
160
|
+
- `BreakRequest.correction` is a boolean flag that indicates the request is an attendance correction, not a break
|
|
161
|
+
- `AdminUser.designation` and `AdminUser.image` are nullable (`string | null`)
|
|
162
|
+
- `AdminUser.createdAt` accepts both `string` and `Date`
|
|
163
|
+
- `DayInfo` is used by the calendar components — `isPadding` marks days from adjacent months
|
|
164
|
+
|
|
165
|
+
## Changes
|
|
166
|
+
### v0.9.0
|
|
167
|
+
- **Added** Initial release with all admin domain types
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Admin Utilities
|
|
2
|
+
|
|
3
|
+
- Import: @devalok/shilp-sutra-karm/admin
|
|
4
|
+
- Server-safe: Partial (date/emoji utils are server-safe; renderAdjustmentType and renderStatus return JSX)
|
|
5
|
+
- Category: admin
|
|
6
|
+
|
|
7
|
+
Utility functions for date formatting, status rendering, and emoji handling.
|
|
8
|
+
|
|
9
|
+
Exports: AdjustmentType, renderAdjustmentType, renderStatus, formatDate, formatDateIST, formatTimeIST, formatDateWithWeekday, formatOptionalDate, getDaySuffix, isSameDay, getWeekDays, getMonthDays, getStartOfDay, getEndOfDay, removeAllEmojis, removeEmojiAtStart, ApprovedAdjustments
|
|
10
|
+
|
|
11
|
+
## Functions
|
|
12
|
+
|
|
13
|
+
### renderAdjustmentType
|
|
14
|
+
```ts
|
|
15
|
+
function renderAdjustmentType(type: keyof typeof AdjustmentType): JSX.Element
|
|
16
|
+
```
|
|
17
|
+
Maps an adjustment type key to a human-readable label wrapped in a `<div>`.
|
|
18
|
+
|
|
19
|
+
### AdjustmentType (constant)
|
|
20
|
+
```ts
|
|
21
|
+
const AdjustmentType = {
|
|
22
|
+
YEARLY_BALANCE: 'YEARLY_BALANCE',
|
|
23
|
+
CARRY_FORWARD: 'CARRY_FORWARD',
|
|
24
|
+
CASHOUT: 'CASHOUT',
|
|
25
|
+
OTHER: 'OTHER',
|
|
26
|
+
} as const
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### renderStatus
|
|
30
|
+
```ts
|
|
31
|
+
function renderStatus(status: string, correction?: boolean): ReactNode
|
|
32
|
+
```
|
|
33
|
+
Returns a `<Badge>` with color and label based on status. When `correction=true`, uses correction-specific labels (e.g. "Corrected" instead of "Approved", "Denied" instead of "Rejected").
|
|
34
|
+
|
|
35
|
+
Status map (default): APPROVED=success "Approved", PENDING=warning "Pending", REJECTED=error "Denied", CANCELLED=error "Redacted", MISSING=error "Missed"
|
|
36
|
+
|
|
37
|
+
Status map (correction): APPROVED=accent "Corrected", PENDING=warning "Pending", REJECTED=error "Denied", MISSING=error "Missed"
|
|
38
|
+
|
|
39
|
+
### formatDate
|
|
40
|
+
```ts
|
|
41
|
+
function formatDate(date: Date | string): string
|
|
42
|
+
```
|
|
43
|
+
Formats to IST locale short date, e.g. `"14 Mar '26"`. Uses `en-IN` locale with `Asia/Kolkata` timezone.
|
|
44
|
+
|
|
45
|
+
### formatDateIST
|
|
46
|
+
```ts
|
|
47
|
+
function formatDateIST(date: Date | string, options?: Intl.DateTimeFormatOptions): string
|
|
48
|
+
```
|
|
49
|
+
Formats date to IST locale string with custom options. Defaults to `Asia/Kolkata` timezone.
|
|
50
|
+
|
|
51
|
+
### formatTimeIST
|
|
52
|
+
```ts
|
|
53
|
+
function formatTimeIST(date: Date | string, options?: Intl.DateTimeFormatOptions): string
|
|
54
|
+
```
|
|
55
|
+
Formats time to IST locale string with custom options. Defaults to `Asia/Kolkata` timezone.
|
|
56
|
+
|
|
57
|
+
### formatDateWithWeekday
|
|
58
|
+
```ts
|
|
59
|
+
function formatDateWithWeekday(date: Date): string
|
|
60
|
+
```
|
|
61
|
+
Returns formatted date with weekday, e.g. `"14 Mar '26, Thursday"`.
|
|
62
|
+
|
|
63
|
+
### formatOptionalDate
|
|
64
|
+
```ts
|
|
65
|
+
function formatOptionalDate(date: Date | string | '-'): string
|
|
66
|
+
```
|
|
67
|
+
Like `formatDate` but returns `"-"` if input is `"-"`.
|
|
68
|
+
|
|
69
|
+
### getDaySuffix
|
|
70
|
+
```ts
|
|
71
|
+
function getDaySuffix(day: number): string
|
|
72
|
+
```
|
|
73
|
+
Returns day with ordinal suffix: `1` -> `"1st"`, `2` -> `"2nd"`, `11` -> `"11th"`, etc.
|
|
74
|
+
|
|
75
|
+
### isSameDay
|
|
76
|
+
```ts
|
|
77
|
+
function isSameDay(date1: Date, date2: Date): boolean
|
|
78
|
+
```
|
|
79
|
+
Checks if two dates are the same calendar day. Returns `false` if either argument is not a valid Date.
|
|
80
|
+
|
|
81
|
+
### getWeekDays
|
|
82
|
+
```ts
|
|
83
|
+
function getWeekDays(currentDate: string | Date, selectedDate: string | Date): WeekDay[]
|
|
84
|
+
```
|
|
85
|
+
Returns 7-day array (Sun-Sat) for the week containing `currentDate`. Each entry has `{ day, date, fullDate, isToday, isActive }`.
|
|
86
|
+
|
|
87
|
+
### getMonthDays
|
|
88
|
+
```ts
|
|
89
|
+
function getMonthDays(currentDate: Date | string, selectedDate: Date | string): MonthDay[]
|
|
90
|
+
```
|
|
91
|
+
Returns full month grid including padding days from adjacent months. Each entry has `{ day, date, fullDate, isToday, isActive, isPadding }`.
|
|
92
|
+
|
|
93
|
+
### getStartOfDay
|
|
94
|
+
```ts
|
|
95
|
+
function getStartOfDay(date?: Date): Date
|
|
96
|
+
```
|
|
97
|
+
Returns start of day (00:00:00.000). Defaults to current date.
|
|
98
|
+
|
|
99
|
+
### getEndOfDay
|
|
100
|
+
```ts
|
|
101
|
+
function getEndOfDay(date?: Date): Date
|
|
102
|
+
```
|
|
103
|
+
Returns end of day (23:59:59.999). Defaults to current date.
|
|
104
|
+
|
|
105
|
+
### removeAllEmojis
|
|
106
|
+
```ts
|
|
107
|
+
function removeAllEmojis(text?: string): string
|
|
108
|
+
```
|
|
109
|
+
Strips all emoji characters from a string. Returns `""` if input is undefined.
|
|
110
|
+
|
|
111
|
+
### removeEmojiAtStart
|
|
112
|
+
```ts
|
|
113
|
+
function removeEmojiAtStart(text: string): string
|
|
114
|
+
```
|
|
115
|
+
Strips emoji characters only from the beginning of a string.
|
|
116
|
+
|
|
117
|
+
### ApprovedAdjustments (ApprovedAdjustmentsProps) — component
|
|
118
|
+
adjustments: Adjustment[] (REQUIRED)
|
|
119
|
+
adminId: string (REQUIRED)
|
|
120
|
+
...HTMLDivElement attributes
|
|
121
|
+
|
|
122
|
+
Renders a table of approved adjustments showing user, date, days, type, reason, and approver. Displays "You" for self-approved items.
|
|
123
|
+
|
|
124
|
+
## Example
|
|
125
|
+
```jsx
|
|
126
|
+
import {
|
|
127
|
+
renderStatus,
|
|
128
|
+
renderAdjustmentType,
|
|
129
|
+
formatDate,
|
|
130
|
+
formatDateIST,
|
|
131
|
+
removeAllEmojis,
|
|
132
|
+
ApprovedAdjustments,
|
|
133
|
+
} from '@devalok/shilp-sutra-karm/admin'
|
|
134
|
+
|
|
135
|
+
// Render a status badge
|
|
136
|
+
{renderStatus('APPROVED')} // -> <Badge color="success">Approved</Badge>
|
|
137
|
+
{renderStatus('PENDING', true)} // -> <Badge color="warning">Pending</Badge>
|
|
138
|
+
|
|
139
|
+
// Render adjustment type
|
|
140
|
+
{renderAdjustmentType('CASHOUT')} // -> <div>Cashout</div>
|
|
141
|
+
|
|
142
|
+
// Format dates
|
|
143
|
+
formatDate(new Date()) // "14 Mar '26"
|
|
144
|
+
formatDateIST(new Date(), { weekday: 'long' }) // "Thursday"
|
|
145
|
+
formatDateWithWeekday(new Date()) // "14 Mar '26, Thursday"
|
|
146
|
+
getDaySuffix(3) // "3rd"
|
|
147
|
+
|
|
148
|
+
// Clean emoji text
|
|
149
|
+
removeAllEmojis("Hello World") // "Hello World"
|
|
150
|
+
removeEmojiAtStart("Hello") // "Hello"
|
|
151
|
+
|
|
152
|
+
// Approved adjustments table
|
|
153
|
+
<ApprovedAdjustments adjustments={approvedList} adminId="admin-1" />
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Gotchas
|
|
157
|
+
- All date functions use `Asia/Kolkata` timezone and `en-IN` locale by default
|
|
158
|
+
- `renderAdjustmentType` and `renderStatus` return JSX — call them as functions, not as components
|
|
159
|
+
- `renderStatus` falls back to the REJECTED config for unknown status values
|
|
160
|
+
- `getWeekDays` starts weeks on Sunday (weekStartsOn: 0)
|
|
161
|
+
- `getMonthDays` includes padding days from previous/next months with `isPadding: true`
|
|
162
|
+
|
|
163
|
+
## Changes
|
|
164
|
+
### v0.9.0
|
|
165
|
+
- **Added** Initial release with all admin utility functions
|