@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.
Files changed (114) hide show
  1. package/README.md +51 -0
  2. package/dist/AgendaContext.d.ts +13 -0
  3. package/dist/AgendaContext.d.ts.map +1 -0
  4. package/dist/AgendaPage.d.ts +11 -0
  5. package/dist/AgendaPage.d.ts.map +1 -0
  6. package/dist/bridges/create-financial-bridge.d.ts +19 -0
  7. package/dist/bridges/create-financial-bridge.d.ts.map +1 -0
  8. package/dist/calendar-styles.d.ts +8 -0
  9. package/dist/calendar-styles.d.ts.map +1 -0
  10. package/dist/chunk-3LJKZQK4.js +12 -0
  11. package/dist/chunk-3LJKZQK4.js.map +1 -0
  12. package/dist/chunk-SYDBDI3Q.cjs +15 -0
  13. package/dist/chunk-SYDBDI3Q.cjs.map +1 -0
  14. package/dist/components/AgendaGeneralSettings.d.ts +3 -0
  15. package/dist/components/AgendaGeneralSettings.d.ts.map +1 -0
  16. package/dist/components/AppointmentModal.d.ts +16 -0
  17. package/dist/components/AppointmentModal.d.ts.map +1 -0
  18. package/dist/components/AppointmentPopover.d.ts +14 -0
  19. package/dist/components/AppointmentPopover.d.ts.map +1 -0
  20. package/dist/components/BookingPaymentPanel.d.ts +18 -0
  21. package/dist/components/BookingPaymentPanel.d.ts.map +1 -0
  22. package/dist/components/CalendarSidebar.d.ts +3 -0
  23. package/dist/components/CalendarSidebar.d.ts.map +1 -0
  24. package/dist/components/CalendarToolbar.d.ts +13 -0
  25. package/dist/components/CalendarToolbar.d.ts.map +1 -0
  26. package/dist/components/EventContextMenu.d.ts +14 -0
  27. package/dist/components/EventContextMenu.d.ts.map +1 -0
  28. package/dist/components/FloatingPanel.d.ts +27 -0
  29. package/dist/components/FloatingPanel.d.ts.map +1 -0
  30. package/dist/components/MiniCalendar.d.ts +9 -0
  31. package/dist/components/MiniCalendar.d.ts.map +1 -0
  32. package/dist/components/PaymentStatusBadge.d.ts +13 -0
  33. package/dist/components/PaymentStatusBadge.d.ts.map +1 -0
  34. package/dist/components/SearchCombobox.d.ts +38 -0
  35. package/dist/components/SearchCombobox.d.ts.map +1 -0
  36. package/dist/components/StatusBadge.d.ts +5 -0
  37. package/dist/components/StatusBadge.d.ts.map +1 -0
  38. package/dist/config.d.ts +151 -0
  39. package/dist/config.d.ts.map +1 -0
  40. package/dist/data/index.d.ts +4 -0
  41. package/dist/data/index.d.ts.map +1 -0
  42. package/dist/data/mock.d.ts +3 -0
  43. package/dist/data/mock.d.ts.map +1 -0
  44. package/dist/data/supabase.d.ts +3 -0
  45. package/dist/data/supabase.d.ts.map +1 -0
  46. package/dist/data/types.d.ts +26 -0
  47. package/dist/data/types.d.ts.map +1 -0
  48. package/dist/financial-bridge.d.ts +92 -0
  49. package/dist/financial-bridge.d.ts.map +1 -0
  50. package/dist/hooks/useAgendaSettings.d.ts +7 -0
  51. package/dist/hooks/useAgendaSettings.d.ts.map +1 -0
  52. package/dist/index.cjs +5135 -0
  53. package/dist/index.cjs.map +1 -0
  54. package/dist/index.d.ts +9 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +5120 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/lib/tenant.d.ts +3 -0
  59. package/dist/lib/tenant.d.ts.map +1 -0
  60. package/dist/locales/en.d.ts +2 -0
  61. package/dist/locales/en.d.ts.map +1 -0
  62. package/dist/locales/index.d.ts +2 -0
  63. package/dist/locales/index.d.ts.map +1 -0
  64. package/dist/locales/pt-BR.d.ts +2 -0
  65. package/dist/locales/pt-BR.d.ts.map +1 -0
  66. package/dist/registries.d.ts +3 -0
  67. package/dist/registries.d.ts.map +1 -0
  68. package/dist/store.d.ts +66 -0
  69. package/dist/store.d.ts.map +1 -0
  70. package/dist/tenant-222EHYUC.cjs +16 -0
  71. package/dist/tenant-222EHYUC.cjs.map +1 -0
  72. package/dist/tenant-LAUWVUYB.js +3 -0
  73. package/dist/tenant-LAUWVUYB.js.map +1 -0
  74. package/dist/types.d.ts +202 -0
  75. package/dist/types.d.ts.map +1 -0
  76. package/dist/views/CalendarView.d.ts +3 -0
  77. package/dist/views/CalendarView.d.ts.map +1 -0
  78. package/dist/views/ConfirmationsView.d.ts +3 -0
  79. package/dist/views/ConfirmationsView.d.ts.map +1 -0
  80. package/package.json +63 -0
  81. package/src/AgendaContext.tsx +11 -0
  82. package/src/AgendaPage.tsx +33 -0
  83. package/src/bridges/create-financial-bridge.ts +298 -0
  84. package/src/calendar-styles.css +245 -0
  85. package/src/calendar-styles.ts +285 -0
  86. package/src/components/AgendaGeneralSettings.tsx +64 -0
  87. package/src/components/AppointmentModal.tsx +1031 -0
  88. package/src/components/AppointmentPopover.tsx +221 -0
  89. package/src/components/BookingPaymentPanel.tsx +394 -0
  90. package/src/components/CalendarSidebar.tsx +119 -0
  91. package/src/components/CalendarToolbar.tsx +83 -0
  92. package/src/components/EventContextMenu.tsx +122 -0
  93. package/src/components/FloatingPanel.tsx +123 -0
  94. package/src/components/MiniCalendar.tsx +120 -0
  95. package/src/components/PaymentStatusBadge.tsx +62 -0
  96. package/src/components/SearchCombobox.tsx +216 -0
  97. package/src/components/StatusBadge.tsx +23 -0
  98. package/src/config.ts +269 -0
  99. package/src/data/index.ts +3 -0
  100. package/src/data/mock.ts +324 -0
  101. package/src/data/supabase.ts +570 -0
  102. package/src/data/types.ts +37 -0
  103. package/src/financial-bridge.ts +96 -0
  104. package/src/hooks/useAgendaSettings.ts +17 -0
  105. package/src/index.ts +180 -0
  106. package/src/lib/tenant.ts +3 -0
  107. package/src/locales/en.ts +207 -0
  108. package/src/locales/index.ts +7 -0
  109. package/src/locales/pt-BR.ts +207 -0
  110. package/src/registries.ts +36 -0
  111. package/src/store.ts +304 -0
  112. package/src/types.ts +265 -0
  113. package/src/views/CalendarView.tsx +904 -0
  114. 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
+ }