@fayz-ai/plugin-agenda 0.1.3
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/README.md +51 -0
- package/dist/AgendaContext.d.ts +13 -0
- package/dist/AgendaContext.d.ts.map +1 -0
- package/dist/AgendaPage.d.ts +11 -0
- package/dist/AgendaPage.d.ts.map +1 -0
- package/dist/bridges/create-financial-bridge.d.ts +19 -0
- package/dist/bridges/create-financial-bridge.d.ts.map +1 -0
- package/dist/calendar-styles.d.ts +8 -0
- package/dist/calendar-styles.d.ts.map +1 -0
- package/dist/chunk-3LJKZQK4.js +12 -0
- package/dist/chunk-3LJKZQK4.js.map +1 -0
- package/dist/chunk-SYDBDI3Q.cjs +15 -0
- package/dist/chunk-SYDBDI3Q.cjs.map +1 -0
- package/dist/components/AgendaGeneralSettings.d.ts +3 -0
- package/dist/components/AgendaGeneralSettings.d.ts.map +1 -0
- package/dist/components/AppointmentModal.d.ts +16 -0
- package/dist/components/AppointmentModal.d.ts.map +1 -0
- package/dist/components/AppointmentPopover.d.ts +14 -0
- package/dist/components/AppointmentPopover.d.ts.map +1 -0
- package/dist/components/BookingPaymentPanel.d.ts +18 -0
- package/dist/components/BookingPaymentPanel.d.ts.map +1 -0
- package/dist/components/CalendarSidebar.d.ts +3 -0
- package/dist/components/CalendarSidebar.d.ts.map +1 -0
- package/dist/components/CalendarToolbar.d.ts +13 -0
- package/dist/components/CalendarToolbar.d.ts.map +1 -0
- package/dist/components/EventContextMenu.d.ts +14 -0
- package/dist/components/EventContextMenu.d.ts.map +1 -0
- package/dist/components/FloatingPanel.d.ts +27 -0
- package/dist/components/FloatingPanel.d.ts.map +1 -0
- package/dist/components/MiniCalendar.d.ts +9 -0
- package/dist/components/MiniCalendar.d.ts.map +1 -0
- package/dist/components/PaymentStatusBadge.d.ts +13 -0
- package/dist/components/PaymentStatusBadge.d.ts.map +1 -0
- package/dist/components/SearchCombobox.d.ts +38 -0
- package/dist/components/SearchCombobox.d.ts.map +1 -0
- package/dist/components/StatusBadge.d.ts +5 -0
- package/dist/components/StatusBadge.d.ts.map +1 -0
- package/dist/config.d.ts +151 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/data/index.d.ts +4 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/mock.d.ts +3 -0
- package/dist/data/mock.d.ts.map +1 -0
- package/dist/data/supabase.d.ts +3 -0
- package/dist/data/supabase.d.ts.map +1 -0
- package/dist/data/types.d.ts +26 -0
- package/dist/data/types.d.ts.map +1 -0
- package/dist/financial-bridge.d.ts +92 -0
- package/dist/financial-bridge.d.ts.map +1 -0
- package/dist/hooks/useAgendaSettings.d.ts +7 -0
- package/dist/hooks/useAgendaSettings.d.ts.map +1 -0
- package/dist/index.cjs +5135 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5120 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/tenant.d.ts +3 -0
- package/dist/lib/tenant.d.ts.map +1 -0
- package/dist/locales/en.d.ts +2 -0
- package/dist/locales/en.d.ts.map +1 -0
- package/dist/locales/index.d.ts +2 -0
- package/dist/locales/index.d.ts.map +1 -0
- package/dist/locales/pt-BR.d.ts +2 -0
- package/dist/locales/pt-BR.d.ts.map +1 -0
- package/dist/registries.d.ts +3 -0
- package/dist/registries.d.ts.map +1 -0
- package/dist/store.d.ts +66 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/tenant-222EHYUC.cjs +16 -0
- package/dist/tenant-222EHYUC.cjs.map +1 -0
- package/dist/tenant-LAUWVUYB.js +3 -0
- package/dist/tenant-LAUWVUYB.js.map +1 -0
- package/dist/types.d.ts +202 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/views/CalendarView.d.ts +3 -0
- package/dist/views/CalendarView.d.ts.map +1 -0
- package/dist/views/ConfirmationsView.d.ts +3 -0
- package/dist/views/ConfirmationsView.d.ts.map +1 -0
- package/package.json +63 -0
- package/src/AgendaContext.tsx +11 -0
- package/src/AgendaPage.tsx +33 -0
- package/src/bridges/create-financial-bridge.ts +298 -0
- package/src/calendar-styles.css +245 -0
- package/src/calendar-styles.ts +285 -0
- package/src/components/AgendaGeneralSettings.tsx +64 -0
- package/src/components/AppointmentModal.tsx +1031 -0
- package/src/components/AppointmentPopover.tsx +221 -0
- package/src/components/BookingPaymentPanel.tsx +394 -0
- package/src/components/CalendarSidebar.tsx +119 -0
- package/src/components/CalendarToolbar.tsx +83 -0
- package/src/components/EventContextMenu.tsx +122 -0
- package/src/components/FloatingPanel.tsx +123 -0
- package/src/components/MiniCalendar.tsx +120 -0
- package/src/components/PaymentStatusBadge.tsx +62 -0
- package/src/components/SearchCombobox.tsx +216 -0
- package/src/components/StatusBadge.tsx +23 -0
- package/src/config.ts +269 -0
- package/src/data/index.ts +3 -0
- package/src/data/mock.ts +324 -0
- package/src/data/supabase.ts +570 -0
- package/src/data/types.ts +37 -0
- package/src/financial-bridge.ts +96 -0
- package/src/hooks/useAgendaSettings.ts +17 -0
- package/src/index.ts +180 -0
- package/src/lib/tenant.ts +3 -0
- package/src/locales/en.ts +207 -0
- package/src/locales/index.ts +7 -0
- package/src/locales/pt-BR.ts +207 -0
- package/src/registries.ts +36 -0
- package/src/store.ts +304 -0
- package/src/types.ts +265 -0
- package/src/views/CalendarView.tsx +904 -0
- package/src/views/ConfirmationsView.tsx +155 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Agenda Plugin — Pure TypeScript types
|
|
3
|
+
// Zero dependencies. Maps to saas_core archetype tables.
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
|
|
6
|
+
// ============================================================
|
|
7
|
+
// ENUMS / LITERALS
|
|
8
|
+
// ============================================================
|
|
9
|
+
|
|
10
|
+
/** Booking status lifecycle */
|
|
11
|
+
export type BookingStatus =
|
|
12
|
+
| 'scheduled'
|
|
13
|
+
| 'confirmed'
|
|
14
|
+
| 'in_progress'
|
|
15
|
+
| 'completed'
|
|
16
|
+
| 'cancelled'
|
|
17
|
+
| 'no_show'
|
|
18
|
+
|
|
19
|
+
/** Confirmation outreach status */
|
|
20
|
+
export type ConfirmationStatus = 'pending' | 'sent' | 'confirmed' | 'declined'
|
|
21
|
+
|
|
22
|
+
/** Booking type identifier — extensible via string literal union */
|
|
23
|
+
export type BookingTypeId = 'appointment' | 'task' | 'out_of_office' | 'block' | (string & {})
|
|
24
|
+
|
|
25
|
+
/** Configuration for a booking type (event type) */
|
|
26
|
+
export interface BookingTypeConfig {
|
|
27
|
+
id: BookingTypeId
|
|
28
|
+
label: string
|
|
29
|
+
icon: string
|
|
30
|
+
color: string
|
|
31
|
+
fields: {
|
|
32
|
+
client: boolean
|
|
33
|
+
professional: boolean
|
|
34
|
+
services: boolean
|
|
35
|
+
location: boolean
|
|
36
|
+
status: boolean
|
|
37
|
+
}
|
|
38
|
+
requiresServices: boolean
|
|
39
|
+
requiresClient: boolean
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ============================================================
|
|
43
|
+
// CORE ENTITIES
|
|
44
|
+
// ============================================================
|
|
45
|
+
|
|
46
|
+
/** A booking service line item (from saas_core.booking_items) */
|
|
47
|
+
export interface BookingService {
|
|
48
|
+
id: string
|
|
49
|
+
serviceId: string | null
|
|
50
|
+
name: string
|
|
51
|
+
durationMinutes: number
|
|
52
|
+
price: number
|
|
53
|
+
assigneeId: string | null
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Calendar booking — the main entity rendered on the calendar (from v_bookings view on orders) */
|
|
57
|
+
export interface CalendarBooking {
|
|
58
|
+
id: string
|
|
59
|
+
tenantId: string
|
|
60
|
+
kind: string
|
|
61
|
+
/** Lifecycle stage: booked, invoiced, paid, etc. */
|
|
62
|
+
stage?: string
|
|
63
|
+
/** Financial direction: credit, debit, null */
|
|
64
|
+
direction?: string | null
|
|
65
|
+
startsAt: string
|
|
66
|
+
endsAt: string | null
|
|
67
|
+
status: BookingStatus
|
|
68
|
+
notes: string | null
|
|
69
|
+
/** In unified model, orderId === id (the booking IS the order) */
|
|
70
|
+
orderId: string | null
|
|
71
|
+
locationId: string | null
|
|
72
|
+
metadata: Record<string, unknown>
|
|
73
|
+
|
|
74
|
+
// Client (party)
|
|
75
|
+
clientId: string | null
|
|
76
|
+
clientName: string | null
|
|
77
|
+
clientPhone: string | null
|
|
78
|
+
clientEmail: string | null
|
|
79
|
+
clientAvatarUrl: string | null
|
|
80
|
+
|
|
81
|
+
// Professional (assignee)
|
|
82
|
+
professionalId: string | null
|
|
83
|
+
professionalName: string | null
|
|
84
|
+
professionalAvatarUrl: string | null
|
|
85
|
+
|
|
86
|
+
// Location
|
|
87
|
+
locationName: string | null
|
|
88
|
+
|
|
89
|
+
// Order totals
|
|
90
|
+
orderTotal: number | null
|
|
91
|
+
orderStatus: string | null
|
|
92
|
+
/** Payment status from financial bridge (enriched at runtime) */
|
|
93
|
+
paymentStatus?: import('./financial-bridge').BookingPaymentStatus
|
|
94
|
+
|
|
95
|
+
// Aggregated services
|
|
96
|
+
services: BookingService[] | null
|
|
97
|
+
totalDurationMinutes: number | null
|
|
98
|
+
|
|
99
|
+
createdAt: string
|
|
100
|
+
updatedAt: string
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Professional / staff resource for the calendar */
|
|
104
|
+
export interface Professional {
|
|
105
|
+
id: string
|
|
106
|
+
name: string
|
|
107
|
+
avatarUrl: string | null
|
|
108
|
+
locationId: string | null
|
|
109
|
+
locationName: string | null
|
|
110
|
+
isActive: boolean
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Working hours schedule (from saas_core.schedules) */
|
|
114
|
+
export interface Schedule {
|
|
115
|
+
id: string
|
|
116
|
+
tenantId: string
|
|
117
|
+
kind: string
|
|
118
|
+
assigneeId: string | null
|
|
119
|
+
locationId: string | null
|
|
120
|
+
dayOfWeek: number | null
|
|
121
|
+
specificDate: string | null
|
|
122
|
+
startsAt: string
|
|
123
|
+
endsAt: string
|
|
124
|
+
isActive: boolean
|
|
125
|
+
metadata: Record<string, unknown>
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Available time slot */
|
|
129
|
+
export interface TimeSlot {
|
|
130
|
+
start: string
|
|
131
|
+
end: string
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Confirmation record stored in booking metadata */
|
|
135
|
+
export interface ConfirmationRecord {
|
|
136
|
+
channel: string
|
|
137
|
+
sentAt: string
|
|
138
|
+
status: ConfirmationStatus
|
|
139
|
+
confirmedAt?: string
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// ============================================================
|
|
143
|
+
// STATUS CONFIGURATION
|
|
144
|
+
// ============================================================
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* When a status is available for selection relative to the booking date.
|
|
148
|
+
* - 'always' — any date (e.g. scheduled, confirmed, cancelled)
|
|
149
|
+
* - 'today_or_past' — booking is today or earlier (e.g. completed, no_show)
|
|
150
|
+
* - 'today_only' — booking is today (e.g. in_progress)
|
|
151
|
+
*/
|
|
152
|
+
export type StatusAvailability = 'always' | 'today_or_past' | 'today_only'
|
|
153
|
+
|
|
154
|
+
export interface StatusConfig {
|
|
155
|
+
value: string
|
|
156
|
+
label: string
|
|
157
|
+
color: string
|
|
158
|
+
/** When this status can be selected (default: 'always') */
|
|
159
|
+
availableWhen?: StatusAvailability
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Check if a status is available for a given booking date */
|
|
163
|
+
export function isStatusAvailable(status: StatusConfig, bookingStartsAt: string): boolean {
|
|
164
|
+
const when = status.availableWhen ?? 'always'
|
|
165
|
+
if (when === 'always') return true
|
|
166
|
+
const bookingDate = bookingStartsAt.slice(0, 10)
|
|
167
|
+
const today = new Date().toISOString().slice(0, 10)
|
|
168
|
+
if (when === 'today_or_past') return bookingDate <= today
|
|
169
|
+
if (when === 'today_only') return bookingDate === today
|
|
170
|
+
return true
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// ============================================================
|
|
174
|
+
// MODAL TAB EXTENSION
|
|
175
|
+
// ============================================================
|
|
176
|
+
|
|
177
|
+
/** Props passed to every booking modal tab component */
|
|
178
|
+
export interface BookingModalTabProps {
|
|
179
|
+
bookingId?: string
|
|
180
|
+
clientId: string
|
|
181
|
+
orderId: string | null
|
|
182
|
+
services: Array<{ name: string; price: number; durationMinutes: number }>
|
|
183
|
+
formatCurrency: (amount: number) => string
|
|
184
|
+
onDataChange?: () => void
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** A tab registered in the booking edit modal */
|
|
188
|
+
export interface BookingModalTab {
|
|
189
|
+
id: string
|
|
190
|
+
label: string
|
|
191
|
+
icon: string
|
|
192
|
+
order: number
|
|
193
|
+
component: React.ComponentType<BookingModalTabProps>
|
|
194
|
+
visible?: (ctx: { mode: 'create' | 'edit'; clientId?: string; orderId?: string }) => boolean
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// ============================================================
|
|
198
|
+
// INPUT TYPES (create / mutate)
|
|
199
|
+
// ============================================================
|
|
200
|
+
|
|
201
|
+
export interface CreateBookingInput {
|
|
202
|
+
kind?: BookingTypeId
|
|
203
|
+
clientId: string
|
|
204
|
+
professionalId: string
|
|
205
|
+
locationId?: string
|
|
206
|
+
startsAt: string
|
|
207
|
+
notes?: string
|
|
208
|
+
services: CreateBookingServiceInput[]
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export interface CreateBookingServiceInput {
|
|
212
|
+
serviceId: string
|
|
213
|
+
name: string
|
|
214
|
+
durationMinutes: number
|
|
215
|
+
price: number
|
|
216
|
+
assigneeId?: string
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface UpdateBookingInput {
|
|
220
|
+
clientId?: string
|
|
221
|
+
professionalId?: string
|
|
222
|
+
locationId?: string
|
|
223
|
+
startsAt?: string
|
|
224
|
+
endsAt?: string
|
|
225
|
+
status?: BookingStatus
|
|
226
|
+
notes?: string
|
|
227
|
+
services?: CreateBookingServiceInput[]
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface SaveScheduleInput {
|
|
231
|
+
assigneeId: string
|
|
232
|
+
locationId?: string
|
|
233
|
+
dayOfWeek?: number
|
|
234
|
+
specificDate?: string
|
|
235
|
+
startsAt: string
|
|
236
|
+
endsAt: string
|
|
237
|
+
isActive?: boolean
|
|
238
|
+
metadata?: Record<string, unknown>
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// ============================================================
|
|
242
|
+
// QUERY / FILTER TYPES
|
|
243
|
+
// ============================================================
|
|
244
|
+
|
|
245
|
+
export interface BookingQuery {
|
|
246
|
+
dateRange: { start: string; end: string }
|
|
247
|
+
professionalIds?: string[]
|
|
248
|
+
locationId?: string
|
|
249
|
+
statuses?: string[]
|
|
250
|
+
kind?: string
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export interface ConflictCheckParams {
|
|
254
|
+
assigneeId: string
|
|
255
|
+
startsAt: string
|
|
256
|
+
endsAt: string
|
|
257
|
+
excludeBookingId?: string
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export interface AvailableSlotsParams {
|
|
261
|
+
assigneeId: string
|
|
262
|
+
date: string
|
|
263
|
+
durationMinutes: number
|
|
264
|
+
slotInterval?: number
|
|
265
|
+
}
|