blixify-ui-web-mcp 0.1.3 → 0.1.19

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 (168) hide show
  1. package/lib/components/action/button/README.md +12 -11
  2. package/lib/components/action/button/button.stories.tsx +38 -27
  3. package/lib/components/action/buttonGroup/buttonGroup.stories.tsx +82 -16
  4. package/lib/components/action/iconButton/README.md +1 -0
  5. package/lib/components/action/iconButton/iconButton.stories.tsx +6 -12
  6. package/lib/components/action/radioList/radioList.stories.tsx +10 -16
  7. package/lib/components/action/slider/slider.stories.tsx +9 -15
  8. package/lib/components/action/textButton/textButton.stories.tsx +6 -12
  9. package/lib/components/action/toggle/toggle.stories.tsx +6 -12
  10. package/lib/components/advanced/collapse/collapse.stories.tsx +240 -24
  11. package/lib/components/advanced/infoWindow/infoWindow.stories.tsx +10 -16
  12. package/lib/components/advanced/popUp/README.md +33 -7
  13. package/lib/components/advanced/popUp/popUp.stories.tsx +9 -15
  14. package/lib/components/auth/bareSignIn/bareSignIn.stories.tsx +36 -16
  15. package/lib/components/auth/bareSignUp/bareSignUp.stories.tsx +7 -13
  16. package/lib/components/auth/signIn/signIn.stories.tsx +4 -10
  17. package/lib/components/auth/signUp/signUp.stories.tsx +4 -10
  18. package/lib/components/chart/areaChart/areaChart.stories.tsx +12 -18
  19. package/lib/components/chart/barChart/barChart.stories.tsx +12 -18
  20. package/lib/components/chart/boxPlotChart/boxPlotChart.stories.tsx +11 -17
  21. package/lib/components/chart/bubbleChart/bubbleChart.stories.tsx +11 -17
  22. package/lib/components/chart/card/card.stories.tsx +172 -38
  23. package/lib/components/chart/ganttChart/ganttChart.stories.tsx +10 -16
  24. package/lib/components/chart/heatmapChart/heatmapChart.stories.tsx +11 -17
  25. package/lib/components/chart/lineChart/lineChart.stories.tsx +8 -14
  26. package/lib/components/chart/pieChart/pieChart.stories.tsx +11 -17
  27. package/lib/components/chart/polarAreaChart/polarAreaChart.stories.tsx +11 -17
  28. package/lib/components/chart/radarChart/radarChart.stories.tsx +6 -12
  29. package/lib/components/chart/radialBar/radialChart.stories.tsx +4 -10
  30. package/lib/components/chart/rangeBarChart/rangeBarChart.stories.tsx +8 -14
  31. package/lib/components/chart/statsCard/statsCard.stories.tsx +12 -18
  32. package/lib/components/chart/treemapChart/treemapChart.stories.tsx +11 -17
  33. package/lib/components/chat/chatAnchor/README.md +7 -0
  34. package/lib/components/chat/chatAnchor/chatAnchor.stories.tsx +15 -21
  35. package/lib/components/chat/chatBase/README.md +103 -22
  36. package/lib/components/chat/chatBase/chatBase.stories.tsx +657 -57
  37. package/lib/components/chat/chatDashboard/README.md +17 -15
  38. package/lib/components/chat/chatDashboard/chatDashboard.stories.tsx +358 -46
  39. package/lib/components/data/dataGraph/dataGraph.stories.tsx +8 -14
  40. package/lib/components/data/dataReference/dataReference.stories.tsx +9 -15
  41. package/lib/components/data/dataTemplate/README.md +443 -129
  42. package/lib/components/data/dataTemplate/dataModule.stories.tsx +10 -15
  43. package/lib/components/data/dataTemplate/dataTemplate.stories.tsx +20 -34
  44. package/lib/components/data/dataWrapper/README.md +207 -84
  45. package/lib/components/data/dataWrapper/dataWrapper.consumer.stories.tsx +2125 -0
  46. package/lib/components/data/dataWrapper/dataWrapper.edit.stories.tsx +607 -0
  47. package/lib/components/data/dataWrapper/dataWrapper.utils.stories.tsx +576 -0
  48. package/lib/components/data/dataWrapper/dataWrapper.view.stories.tsx +1273 -0
  49. package/lib/components/data/flexFilter/flexFilter.stories.tsx +171 -0
  50. package/lib/components/data/queryForm/queryForm.stories.tsx +6 -12
  51. package/lib/components/data/readQuery/readQuery.stories.tsx +6 -11
  52. package/lib/components/data/readQueryHoc/readQueryHoc.stories.tsx +6 -12
  53. package/lib/components/data/writeQuery/README.md +21 -10
  54. package/lib/components/data/writeQuery/writeQuery.stories.tsx +6 -10
  55. package/lib/components/design/actionSection/actionSection.stories.tsx +10 -14
  56. package/lib/components/design/banner/banner.stories.tsx +6 -12
  57. package/lib/components/design/bannerAction/bannerAction.stories.tsx +100 -21
  58. package/lib/components/design/blogSection/blogSection.stories.tsx +6 -12
  59. package/lib/components/design/carouselSection/carouselSection.stories.tsx +6 -12
  60. package/lib/components/design/designList/designList.stories.tsx +6 -12
  61. package/lib/components/design/faq/faq.stories.tsx +53 -31
  62. package/lib/components/design/fileGrid/fileGrid.stories.tsx +10 -16
  63. package/lib/components/design/fileViewer/fileViewer.stories.tsx +6 -12
  64. package/lib/components/design/footerSection/footerSection.stories.tsx +6 -12
  65. package/lib/components/design/googleReview/googleReview.stories.tsx +6 -12
  66. package/lib/components/design/heroSection/heroSection.stories.tsx +10 -16
  67. package/lib/components/design/iconList/iconList.stories.tsx +6 -12
  68. package/lib/components/design/imageGallery/imageGallery.stories.tsx +6 -12
  69. package/lib/components/design/imageZoom/imageZoom.stories.tsx +6 -12
  70. package/lib/components/design/leftContent/leftContent.stories.tsx +6 -12
  71. package/lib/components/design/logoCloud/logoCloud.stories.tsx +6 -12
  72. package/lib/components/design/onboarding/onboarding.stories.tsx +8 -14
  73. package/lib/components/design/pricing/pricing.stories.tsx +6 -12
  74. package/lib/components/design/rightContent/rightContent.stories.tsx +6 -12
  75. package/lib/components/design/sectionList/sectionList.stories.tsx +6 -12
  76. package/lib/components/design/teams/teams.stories.tsx +6 -12
  77. package/lib/components/display/alert/alert.stories.tsx +8 -14
  78. package/lib/components/display/calendar/README.md +49 -0
  79. package/lib/components/display/calendar/calendar.stories.tsx +78 -35
  80. package/lib/components/display/clipboard/clipboard.stories.tsx +6 -12
  81. package/lib/components/display/detailList/detailList.stories.tsx +172 -48
  82. package/lib/components/display/drawer/README.md +44 -11
  83. package/lib/components/display/drawer/drawer.stories.tsx +71 -16
  84. package/lib/components/display/emptyState/emptyState.stories.tsx +47 -15
  85. package/lib/components/display/feeds/feeds.stories.tsx +6 -12
  86. package/lib/components/display/flexTable/README.md +11 -7
  87. package/lib/components/display/flexTable/flexTable.stories.tsx +318 -20
  88. package/lib/components/display/grid/README.md +29 -30
  89. package/lib/components/display/grid/grid.stories.tsx +16 -23
  90. package/lib/components/display/kanban/kanban.stories.tsx +17 -23
  91. package/lib/components/display/list/README.md +30 -29
  92. package/lib/components/display/list/list.stories.tsx +11 -17
  93. package/lib/components/display/loading/loading.stories.tsx +7 -12
  94. package/lib/components/display/mapView/mapView.stories.tsx +9 -15
  95. package/lib/components/display/modal/modal.stories.tsx +6 -13
  96. package/lib/components/display/newCalendar/README.md +163 -0
  97. package/lib/components/display/newCalendar/newCalendar.stories.tsx +292 -0
  98. package/lib/components/display/newFeeds/README.md +53 -0
  99. package/lib/components/display/newFeeds/newFeeds.stories.tsx +104 -0
  100. package/lib/components/display/newKanban/README.md +25 -0
  101. package/lib/components/display/newKanban/newKanban.stories.tsx +131 -0
  102. package/lib/components/display/newList/README.md +30 -0
  103. package/lib/components/display/newList/newList.stories.tsx +231 -0
  104. package/lib/components/display/newPagination/README.md +15 -0
  105. package/lib/components/display/newTable/README.md +121 -0
  106. package/lib/components/display/newTable/newTable.stories.tsx +551 -0
  107. package/lib/components/display/notification/notification.stories.tsx +6 -12
  108. package/lib/components/display/progress/progress.stories.tsx +7 -12
  109. package/lib/components/display/stepper/README.md +4 -0
  110. package/lib/components/display/stepper/stepper.stories.tsx +70 -23
  111. package/lib/components/display/table/README.md +38 -37
  112. package/lib/components/display/table/table.stories.tsx +34 -36
  113. package/lib/components/display/tag/tag.stories.tsx +34 -40
  114. package/lib/components/input/address/address.stories.tsx +12 -18
  115. package/lib/components/input/canvas/canvas.stories.tsx +12 -18
  116. package/lib/components/input/checkbox/checkbox.stories.tsx +7 -13
  117. package/lib/components/input/datePicker/datePicker.stories.tsx +41 -11
  118. package/lib/components/input/form/form.stories.tsx +11 -17
  119. package/lib/components/input/markdown/README.md +80 -2
  120. package/lib/components/input/markdown/markdown.stories.tsx +83 -32
  121. package/lib/components/input/monthYearPicker/monthYearPicker.stories.tsx +52 -24
  122. package/lib/components/input/netPromoterScore/netPromoterScore.stories.tsx +6 -12
  123. package/lib/components/input/rating/rating.stories.tsx +6 -12
  124. package/lib/components/input/select/README.md +31 -29
  125. package/lib/components/input/select/select.stories.tsx +33 -39
  126. package/lib/components/input/signature/signature.stories.tsx +12 -18
  127. package/lib/components/input/textArea/textArea.stories.tsx +6 -12
  128. package/lib/components/input/textInput/textinput.stories.tsx +14 -20
  129. package/lib/components/input/uploadInput/uploadInput.stories.tsx +143 -19
  130. package/lib/components/navigation/bars/README.md +27 -0
  131. package/lib/components/navigation/bars/bars.stories.tsx +56 -19
  132. package/lib/components/navigation/bottomTab/bottomTab.stories.tsx +7 -12
  133. package/lib/components/navigation/breadcrumb/breadcrumb.stories.tsx +8 -14
  134. package/lib/components/navigation/header/header.stories.tsx +33 -21
  135. package/lib/components/navigation/leftNav/leftNav.stories.tsx +10 -16
  136. package/lib/components/navigation/tabs/tabs.stories.tsx +10 -16
  137. package/lib/components/structure/column/column.stories.tsx +10 -15
  138. package/lib/components/structure/container/container.stories.tsx +8 -13
  139. package/lib/components/structure/link/link.stories.tsx +11 -17
  140. package/lib/components/structure/text/text.stories.tsx +12 -17
  141. package/lib/components/template/authPage/authPage.stories.tsx +6 -5
  142. package/lib/components/template/calendarView/calendarView.stories.tsx +726 -0
  143. package/lib/components/template/chatDashboard/chatDashboard.stories.tsx +497 -0
  144. package/lib/components/template/landingPage/landingPage.stories.tsx +10 -7
  145. package/lib/components/template/mapLayout/mapLayout.stories.tsx +519 -0
  146. package/lib/components/template/productListing/productListing.stories.tsx +7 -13
  147. package/lib/components/template/productOverview/productOverview.stories.tsx +5 -11
  148. package/lib/components/template/shoppingCart/shoppingCart.stories.tsx +6 -12
  149. package/lib/components/template/userHomePage/userHomePage.stories.tsx +384 -524
  150. package/lib/components/template/userRankingDashboard/userRankingDashboard.stories.tsx +145 -75
  151. package/lib/mcp/tools/componentsRoot.d.ts +2 -0
  152. package/lib/mcp/tools/componentsRoot.d.ts.map +1 -0
  153. package/lib/mcp/tools/componentsRoot.js +59 -0
  154. package/lib/mcp/tools/componentsRoot.js.map +1 -0
  155. package/lib/mcp/tools/getBackendComponent.d.ts.map +1 -1
  156. package/lib/mcp/tools/getBackendComponent.js +2 -5
  157. package/lib/mcp/tools/getBackendComponent.js.map +1 -1
  158. package/lib/mcp/tools/getComponent.d.ts.map +1 -1
  159. package/lib/mcp/tools/getComponent.js +2 -5
  160. package/lib/mcp/tools/getComponent.js.map +1 -1
  161. package/lib/mcp/tools/listComponents.d.ts.map +1 -1
  162. package/lib/mcp/tools/listComponents.js +15 -10
  163. package/lib/mcp/tools/listComponents.js.map +1 -1
  164. package/lib/mcp/tools/suggestTemplate.d.ts.map +1 -1
  165. package/lib/mcp/tools/suggestTemplate.js +107 -21
  166. package/lib/mcp/tools/suggestTemplate.js.map +1 -1
  167. package/package.json +1 -1
  168. package/lib/components/data/dataWrapper/dataWrapper.stories.tsx +0 -831
@@ -0,0 +1,726 @@
1
+ import { Disclosure, Menu, Popover, Transition } from "@headlessui/react";
2
+ import {
3
+ ArrowDownTrayIcon,
4
+ CalendarDaysIcon,
5
+ CheckCircleIcon,
6
+ ClockIcon,
7
+ DocumentTextIcon,
8
+ PhotoIcon,
9
+ } from "@heroicons/react/24/outline";
10
+ import {
11
+ CalendarIcon as CalendarSolid,
12
+ ChartBarIcon,
13
+ HomeIcon,
14
+ SparklesIcon,
15
+ UserIcon,
16
+ } from "@heroicons/react/24/solid";
17
+ import React, { useState } from "react";
18
+ import { Button } from "../../action/button";
19
+ import { ButtonGroup } from "../../action/buttonGroup";
20
+ import { Card } from "../../chart/card";
21
+ import { Container } from "../../structure/container";
22
+ import { FooterSection } from "../../design/footerSection";
23
+ import { Collapse } from "../../advanced/collapse";
24
+ import { DetailList, DetailListClass } from "../../display/detailList";
25
+ import { Modal } from "../../display/modal";
26
+ import { NewCalendar, NewCalendarEvent } from "../../display/newCalendar";
27
+ import { Progress } from "../../display/progress";
28
+ import { NewList, NewListItem } from "../../display/newList";
29
+ import { NewTable, NewTableColumn, NewTableRow } from "../../display/newTable";
30
+ import { BottomTab } from "../../navigation/bottomTab";
31
+ import { Breadcrumb } from "../../navigation/breadcrumb";
32
+ import { Header } from "../../navigation/header";
33
+
34
+ const meta = { title: "Template/App Calendar View" };
35
+ export default meta;
36
+
37
+
38
+ const Logo = new URL("../../../assets/logo.png", import.meta.url).href;
39
+
40
+ // ─── Sample data (domain-neutral, modelled on pe/dashboard) ───────────────
41
+
42
+ type InstallationType =
43
+ | "PV Delivery"
44
+ | "O&M Maintenance"
45
+ | "Roof Inspection"
46
+ | "Installation Defect"
47
+ | "Critical Load";
48
+
49
+ interface Installation {
50
+ id: string;
51
+ title: string;
52
+ type: InstallationType;
53
+ date: Date;
54
+ status: "Scheduled" | "In Progress" | "Completed";
55
+ client: string;
56
+ address: string;
57
+ capacity: string;
58
+ cost: number;
59
+ documents: { id: string; name: string; size: string; type: "pdf" | "image" | "doc" }[];
60
+ }
61
+
62
+ const TODAY = new Date();
63
+ const dayOffset = (days: number) =>
64
+ new Date(TODAY.getFullYear(), TODAY.getMonth(), TODAY.getDate() + days);
65
+
66
+ const INSTALLATIONS: Installation[] = [
67
+ {
68
+ id: "inst-1",
69
+ title: "Plant Alpha — PV Delivery",
70
+ type: "PV Delivery",
71
+ date: dayOffset(-2),
72
+ status: "Completed",
73
+ client: "Acme Energy Sdn Bhd",
74
+ address: "Lot 23, Jalan Persiaran, Selangor",
75
+ capacity: "1.2 MW",
76
+ cost: 184000,
77
+ documents: [
78
+ { id: "d1", name: "Installation Manual.pdf", size: "2.1 MB", type: "pdf" },
79
+ { id: "d2", name: "Permit Approval.pdf", size: "812 KB", type: "pdf" },
80
+ { id: "d3", name: "Site Photos.zip", size: "8.4 MB", type: "image" },
81
+ ],
82
+ },
83
+ {
84
+ id: "inst-2",
85
+ title: "Plant Bravo — Roof Inspection",
86
+ type: "Roof Inspection",
87
+ date: dayOffset(1),
88
+ status: "Scheduled",
89
+ client: "BrightSun Solar Bhd",
90
+ address: "Lot 14, Taman Industri, Johor",
91
+ capacity: "850 kW",
92
+ cost: 42000,
93
+ documents: [
94
+ { id: "d4", name: "Inspection Checklist.pdf", size: "640 KB", type: "pdf" },
95
+ { id: "d5", name: "Roof Drawings.pdf", size: "3.2 MB", type: "pdf" },
96
+ ],
97
+ },
98
+ {
99
+ id: "inst-3",
100
+ title: "Plant Charlie — O&M Maintenance",
101
+ type: "O&M Maintenance",
102
+ date: dayOffset(3),
103
+ status: "Scheduled",
104
+ client: "Acme Energy Sdn Bhd",
105
+ address: "Jalan Kepong, Kuala Lumpur",
106
+ capacity: "2.4 MW",
107
+ cost: 68000,
108
+ documents: [
109
+ { id: "d6", name: "Maintenance Report.pdf", size: "1.4 MB", type: "pdf" },
110
+ { id: "d7", name: "Service Log.xlsx", size: "92 KB", type: "doc" },
111
+ ],
112
+ },
113
+ {
114
+ id: "inst-4",
115
+ title: "Plant Delta — Installation Defect",
116
+ type: "Installation Defect",
117
+ date: dayOffset(5),
118
+ status: "In Progress",
119
+ client: "Verdant Solar Bhd",
120
+ address: "Lot 7, Persiaran Industri, Selangor",
121
+ capacity: "640 kW",
122
+ cost: 96000,
123
+ documents: [
124
+ { id: "d8", name: "Defect Report.pdf", size: "1.1 MB", type: "pdf" },
125
+ { id: "d9", name: "Repair Photos.zip", size: "5.6 MB", type: "image" },
126
+ { id: "d10", name: "Cost Estimate.xlsx", size: "108 KB", type: "doc" },
127
+ ],
128
+ },
129
+ {
130
+ id: "inst-5",
131
+ title: "Plant Echo — Critical Load",
132
+ type: "Critical Load",
133
+ date: dayOffset(7),
134
+ status: "Scheduled",
135
+ client: "Acme Energy Sdn Bhd",
136
+ address: "Jalan Persiaran, Perak",
137
+ capacity: "1.8 MW",
138
+ cost: 215000,
139
+ documents: [
140
+ { id: "d11", name: "Critical Load Assessment.pdf", size: "2.8 MB", type: "pdf" },
141
+ { id: "d12", name: "Site Survey.pdf", size: "1.9 MB", type: "pdf" },
142
+ ],
143
+ },
144
+ {
145
+ id: "inst-6",
146
+ title: "Plant Foxtrot — PV Delivery",
147
+ type: "PV Delivery",
148
+ date: dayOffset(9),
149
+ status: "Scheduled",
150
+ client: "BrightSun Solar Bhd",
151
+ address: "Persiaran Industri, Penang",
152
+ capacity: "920 kW",
153
+ cost: 132000,
154
+ documents: [
155
+ { id: "d13", name: "Delivery Schedule.pdf", size: "456 KB", type: "pdf" },
156
+ { id: "d14", name: "Equipment List.xlsx", size: "76 KB", type: "doc" },
157
+ ],
158
+ },
159
+ {
160
+ id: "inst-7",
161
+ title: "Plant Golf — Roof Inspection",
162
+ type: "Roof Inspection",
163
+ date: dayOffset(-5),
164
+ status: "Completed",
165
+ client: "Verdant Solar Bhd",
166
+ address: "Lot 9, Taman Industri, Pahang",
167
+ capacity: "720 kW",
168
+ cost: 38000,
169
+ documents: [
170
+ { id: "d15", name: "Inspection Report.pdf", size: "1.6 MB", type: "pdf" },
171
+ ],
172
+ },
173
+ ];
174
+
175
+ // INFO: NewCalendar's `type` field drives the color via colorRules.
176
+ // Modelled on the 5 categories from verdant-next pe/dashboard.
177
+ const COLOR_RULES = {
178
+ "PV Delivery": {
179
+ bg: "bg-emerald-500",
180
+ border: "border-emerald-600",
181
+ text: "text-white",
182
+ },
183
+ "O&M Maintenance": {
184
+ bg: "bg-blue-500",
185
+ border: "border-blue-600",
186
+ text: "text-white",
187
+ },
188
+ "Roof Inspection": {
189
+ bg: "bg-violet-500",
190
+ border: "border-violet-600",
191
+ text: "text-white",
192
+ },
193
+ "Installation Defect": {
194
+ bg: "bg-amber-500",
195
+ border: "border-amber-600",
196
+ text: "text-white",
197
+ },
198
+ "Critical Load": {
199
+ bg: "bg-rose-500",
200
+ border: "border-rose-600",
201
+ text: "text-white",
202
+ },
203
+ };
204
+
205
+ const LEGEND_ITEMS: { label: InstallationType; dot: string }[] = [
206
+ { label: "PV Delivery", dot: "bg-emerald-500" },
207
+ { label: "O&M Maintenance", dot: "bg-blue-500" },
208
+ { label: "Roof Inspection", dot: "bg-violet-500" },
209
+ { label: "Installation Defect", dot: "bg-amber-500" },
210
+ { label: "Critical Load", dot: "bg-rose-500" },
211
+ ];
212
+
213
+ const NAVIGATION = [
214
+ { name: "Dashboard", href: "#" },
215
+ { name: "Schedule", href: "#" },
216
+ { name: "Installations", href: "#" },
217
+ { name: "Settings", href: "#" },
218
+ ];
219
+
220
+ const USER_NAV = [
221
+ { name: "Your profile", action: () => {} },
222
+ { name: "Sign out", action: () => {} },
223
+ ];
224
+
225
+ const USER = { name: "Louis Ong", email: "louis@blixify.co", image: Logo };
226
+
227
+ const BOTTOM_TABS = [
228
+ { icon: HomeIcon, title: "Home", href: "#" },
229
+ { icon: CalendarSolid, title: "Schedule", href: "#" },
230
+ { icon: ChartBarIcon, title: "Stats", href: "#" },
231
+ { icon: UserIcon, title: "Profile", href: "#" },
232
+ ];
233
+
234
+ const FOOTER_LIST = [
235
+ { title: "Navigate", subList: NAVIGATION.map((n) => ({ name: n.name, link: n.href })) },
236
+ { title: "Account", subList: [{ name: "Profile", link: "#" }, { name: "Sign out", link: "#" }] },
237
+ ];
238
+
239
+ const VIEW_TOGGLE = [
240
+ { id: "calendar", name: "Calendar" },
241
+ { id: "list", name: "List" },
242
+ ];
243
+
244
+ // INFO: NewCalendarVariant subset that makes sense for "schedule" use case.
245
+ const CALENDAR_VARIANTS = [
246
+ { id: "fullMonth", name: "Month" },
247
+ { id: "weekStrip", name: "Week" },
248
+ { id: "agenda", name: "Agenda" },
249
+ ];
250
+
251
+ const DOC_ICON: Record<Installation["documents"][number]["type"], React.ReactElement> = {
252
+ pdf: <DocumentTextIcon className="h-9 w-9 rounded-full bg-rose-100 p-2 text-rose-600" />,
253
+ image: <PhotoIcon className="h-9 w-9 rounded-full bg-violet-100 p-2 text-violet-600" />,
254
+ doc: <DocumentTextIcon className="h-9 w-9 rounded-full bg-primary-100 p-2 text-primary-600" />,
255
+ };
256
+
257
+ // ─── Story ─────────────────────────────────────────────────────────────────
258
+
259
+ export const AppCalendarView = () => {
260
+ const [view, setView] = useState<"calendar" | "list">("calendar");
261
+ const [calendarVariant, setCalendarVariant] = useState<
262
+ "fullMonth" | "weekStrip" | "agenda"
263
+ >("fullMonth");
264
+ const [selectedId, setSelectedId] = useState<string | null>(null);
265
+ const [modalOpen, setModalOpen] = useState(false);
266
+
267
+ const selected =
268
+ selectedId !== null ? INSTALLATIONS.find((i) => i.id === selectedId) ?? null : null;
269
+
270
+ // Calendar events
271
+ const events: NewCalendarEvent[] = INSTALLATIONS.map((i) => ({
272
+ id: i.id,
273
+ title: i.title,
274
+ start: i.date,
275
+ end: i.date,
276
+ type: i.type,
277
+ meta: { source: i.type, status: i.status, client: i.client },
278
+ }));
279
+
280
+ // List view rows
281
+ const tableColumns: NewTableColumn[] = [
282
+ { key: "title", title: "Installation" },
283
+ { key: "type", title: "Type" },
284
+ { key: "client", title: "Client" },
285
+ { key: "date", title: "Date" },
286
+ { key: "status", title: "Status" },
287
+ ];
288
+ const tableData: NewTableRow[] = INSTALLATIONS.map((i) => ({
289
+ id: i.id,
290
+ title: i.title,
291
+ type: i.type,
292
+ client: i.client,
293
+ date: i.date.toLocaleDateString(),
294
+ status: i.status,
295
+ }));
296
+
297
+ // Stat tiles
298
+ const STAT_TILES = [
299
+ {
300
+ title: "Total events",
301
+ count: INSTALLATIONS.length,
302
+ icon: <CalendarDaysIcon className="h-4 w-4 text-primary-600" />,
303
+ },
304
+ {
305
+ title: "Upcoming",
306
+ count: INSTALLATIONS.filter((i) => i.status === "Scheduled").length,
307
+ icon: <ClockIcon className="h-4 w-4 text-primary-600" />,
308
+ },
309
+ {
310
+ title: "Completed",
311
+ count: INSTALLATIONS.filter((i) => i.status === "Completed").length,
312
+ icon: <CheckCircleIcon className="h-4 w-4 text-primary-600" />,
313
+ },
314
+ ];
315
+
316
+ const handleClickEvent = (id: string) => {
317
+ setSelectedId(id);
318
+ setModalOpen(true);
319
+ };
320
+
321
+ // ─── Renderers ────────────────────────────────────────────────────────────
322
+
323
+ const renderLegend = () => (
324
+ <div className="mt-3 flex flex-wrap gap-3">
325
+ {LEGEND_ITEMS.map((item) => (
326
+ <div key={item.label} className="flex items-center gap-1.5">
327
+ <span className={`h-3 w-3 rounded-full ${item.dot}`} />
328
+ <span className="text-xs text-gray-600">{item.label}</span>
329
+ </div>
330
+ ))}
331
+ </div>
332
+ );
333
+
334
+ const renderCalendarView = () => (
335
+ <div className="mt-4">
336
+ <div className="overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-sm">
337
+ <NewCalendar
338
+ variant={calendarVariant}
339
+ events={events}
340
+ colorRules={COLOR_RULES}
341
+ onClickEvent={(e) => handleClickEvent(e.id)}
342
+ />
343
+ </div>
344
+ </div>
345
+ );
346
+
347
+ // INFO: cost roll-ups for the list view. Total + per-status breakdown,
348
+ // mirroring how verdant-next surfaces cost summaries above its job lists.
349
+ const totalCost = INSTALLATIONS.reduce((s, i) => s + i.cost, 0);
350
+ const completedCost = INSTALLATIONS.filter((i) => i.status === "Completed").reduce(
351
+ (s, i) => s + i.cost,
352
+ 0
353
+ );
354
+ const scheduledCost = INSTALLATIONS.filter((i) => i.status === "Scheduled").reduce(
355
+ (s, i) => s + i.cost,
356
+ 0
357
+ );
358
+ const inProgressCost = INSTALLATIONS.filter((i) => i.status === "In Progress").reduce(
359
+ (s, i) => s + i.cost,
360
+ 0
361
+ );
362
+ const fmtRM = (n: number) =>
363
+ `RM ${n.toLocaleString("en-US", { minimumFractionDigits: 0 })}`;
364
+
365
+ const renderListView = () => (
366
+ <div className="mt-4 space-y-4">
367
+ <div className="relative">
368
+ <div className="calendar-ai-bg calendar-ai-halo absolute -inset-1 rounded-2xl" />
369
+ <div className="calendar-ai-bg relative rounded-2xl p-[2px]">
370
+ <div className="rounded-2xl bg-white overflow-hidden">
371
+ <Collapse
372
+ title="AI Summary"
373
+ summary="Generated just now · 7 installations analysed"
374
+ defaultOpen
375
+ icon={<SparklesIcon className="h-5 w-5 text-violet-500" />}
376
+ titleClassName="text-gray-900 text-base font-semibold"
377
+ summaryClassName="text-violet-600 text-xs"
378
+ collapseContainerCss="!border-0"
379
+ notCollapseContainerCss="!border-0"
380
+ contentClassName="px-4 pb-4 pt-3 border-t border-violet-100"
381
+ content={
382
+ <div className="space-y-2 text-sm text-gray-700">
383
+ <p>
384
+ {INSTALLATIONS.length} installations across{" "}
385
+ {Array.from(new Set(INSTALLATIONS.map((i) => i.client))).length}{" "}
386
+ clients this month — PV Delivery and Roof Inspection make up
387
+ the bulk. {INSTALLATIONS.filter((i) => i.status === "Completed").length}{" "}
388
+ completed, {INSTALLATIONS.filter((i) => i.status === "Scheduled").length}{" "}
389
+ upcoming, {INSTALLATIONS.filter((i) => i.status === "In Progress").length}{" "}
390
+ in progress.
391
+ </p>
392
+ <p className="text-xs text-gray-500">
393
+ Suggested next step: prioritise Plant Delta's Installation
394
+ Defect — only in-progress job and has the second-highest
395
+ cost exposure ({fmtRM(96000)}).
396
+ </p>
397
+ </div>
398
+ }
399
+ />
400
+ </div>
401
+ </div>
402
+ </div>
403
+
404
+ {/* Cost Summary — 1 total + 3 per-status breakdown columns */}
405
+ <div className="rounded-2xl border border-gray-200 bg-white p-4 shadow-sm">
406
+ <div className="mb-3 flex items-baseline justify-between">
407
+ <h3 className="text-sm font-bold uppercase tracking-wide text-gray-500">
408
+ Cost summary
409
+ </h3>
410
+ <span className="text-xs text-gray-400">All {INSTALLATIONS.length} jobs</span>
411
+ </div>
412
+ <div className="grid grid-cols-2 gap-4 sm:grid-cols-4">
413
+ <div>
414
+ <p className="text-xs text-gray-500">Total</p>
415
+ <p className="mt-1 text-xl font-bold text-gray-900">{fmtRM(totalCost)}</p>
416
+ </div>
417
+ <div>
418
+ <p className="text-xs text-gray-500">Completed</p>
419
+ <p className="mt-1 text-xl font-semibold text-emerald-600">
420
+ {fmtRM(completedCost)}
421
+ </p>
422
+ </div>
423
+ <div>
424
+ <p className="text-xs text-gray-500">Scheduled</p>
425
+ <p className="mt-1 text-xl font-semibold text-primary-600">
426
+ {fmtRM(scheduledCost)}
427
+ </p>
428
+ </div>
429
+ <div>
430
+ <p className="text-xs text-gray-500">In progress</p>
431
+ <p className="mt-1 text-xl font-semibold text-amber-600">
432
+ {fmtRM(inProgressCost)}
433
+ </p>
434
+ </div>
435
+ </div>
436
+ </div>
437
+
438
+ <NewTable
439
+ header={tableColumns}
440
+ data={tableData}
441
+ mobileView
442
+ onClickRow={(row) => handleClickEvent(String(row.id))}
443
+ />
444
+ </div>
445
+ );
446
+
447
+ // INFO: Modal-based detail follows the pe/dashboard pattern (clicking a
448
+ // calendar event opens an Installation Detail modal with all documents).
449
+ const renderDetailModalContent = () => {
450
+ if (!selected) return null;
451
+ const detailList: DetailListClass[] = [
452
+ { title: "Type", text: selected.type },
453
+ { title: "Status", text: selected.status },
454
+ { title: "Client", text: selected.client },
455
+ { title: "Address", text: selected.address },
456
+ { title: "Capacity", text: selected.capacity },
457
+ { title: "Scheduled date", text: selected.date.toLocaleDateString() },
458
+ { title: "Total cost", text: fmtRM(selected.cost) },
459
+ ];
460
+ // INFO: realistic split for an installation budget — parts dominate,
461
+ // labour second, travel/other smaller. Computed from total cost so
462
+ // it stays consistent if the cost changes.
463
+ const breakdown = {
464
+ parts: Math.round(selected.cost * 0.55),
465
+ labour: Math.round(selected.cost * 0.25),
466
+ travel: Math.round(selected.cost * 0.1),
467
+ other: Math.round(selected.cost * 0.1),
468
+ };
469
+ // INFO: per-installation AI summary — short narrative based on the
470
+ // installation's type / status / cost relative to the rest of the
471
+ // schedule.
472
+ const avgCost = INSTALLATIONS.reduce((s, i) => s + i.cost, 0) / INSTALLATIONS.length;
473
+ const costRel =
474
+ selected.cost > avgCost * 1.2
475
+ ? "above the monthly average"
476
+ : selected.cost < avgCost * 0.8
477
+ ? "below the monthly average"
478
+ : "in line with the monthly average";
479
+ const summaryText =
480
+ selected.status === "Completed"
481
+ ? `Closed out ${selected.type.toLowerCase()} job for ${selected.client}. Cost ${costRel} — keep this client's pricing as a benchmark for similar jobs.`
482
+ : selected.status === "In Progress"
483
+ ? `Active ${selected.type.toLowerCase()} job — ${selected.documents.length} reference document${selected.documents.length === 1 ? "" : "s"} on file. Cost ${costRel}; flag if it exceeds estimate.`
484
+ : `Upcoming ${selected.type.toLowerCase()} job for ${selected.client} (${selected.capacity}). Cost ${costRel}. Pre-stage parts the day before to avoid travel re-dispatch.`;
485
+ const docItems: NewListItem[] = selected.documents.map((doc) => ({
486
+ id: doc.id,
487
+ title: doc.name,
488
+ description: doc.size,
489
+ icon: DOC_ICON[doc.type],
490
+ action: (
491
+ <button
492
+ type="button"
493
+ className="rounded-full p-1.5 hover:bg-gray-100"
494
+ aria-label={`Download ${doc.name}`}
495
+ >
496
+ <ArrowDownTrayIcon className="h-4 w-4 text-gray-500" />
497
+ </button>
498
+ ),
499
+ }));
500
+ return (
501
+ <div className="space-y-5">
502
+ {/* Per-installation AI summary lives at the TOP of the modal so
503
+ the glowing gradient is the first thing the user sees. Same
504
+ animated-gradient pattern as the list-view AI summary. */}
505
+ <div className="relative">
506
+ <div className="calendar-ai-bg calendar-ai-halo absolute -inset-1 rounded-2xl" />
507
+ <div className="calendar-ai-bg relative rounded-2xl p-[2px]">
508
+ <div className="rounded-2xl bg-white overflow-hidden">
509
+ <Collapse
510
+ title="AI Summary"
511
+ summary={`Analysis for this job`}
512
+ defaultOpen
513
+ icon={<SparklesIcon className="h-5 w-5 text-violet-500" />}
514
+ titleClassName="text-gray-900 text-sm font-semibold"
515
+ summaryClassName="text-violet-600 text-xs"
516
+ collapseContainerCss="!border-0"
517
+ notCollapseContainerCss="!border-0"
518
+ contentClassName="px-4 pb-4 pt-3 border-t border-violet-100"
519
+ content={
520
+ <p className="text-sm text-gray-700">{summaryText}</p>
521
+ }
522
+ />
523
+ </div>
524
+ </div>
525
+ </div>
526
+
527
+ <DetailList
528
+ title={selected.title}
529
+ description={`${selected.documents.length} document${
530
+ selected.documents.length === 1 ? "" : "s"
531
+ } available`}
532
+ list={detailList}
533
+ size="compact"
534
+ className="border border-gray-200 rounded-2xl shadow-sm"
535
+ />
536
+
537
+ {/* Cost breakdown — per-installation parts / labour / travel /
538
+ other split. Collapse so it doesn't dominate the modal. */}
539
+ <div className="rounded-2xl border border-gray-200 bg-white shadow-sm overflow-hidden">
540
+ <Collapse
541
+ title="Cost breakdown"
542
+ summary={fmtRM(selected.cost)}
543
+ defaultOpen
544
+ icon={<ChartBarIcon className="h-5 w-5 text-primary-500" />}
545
+ titleClassName="text-gray-900 text-sm font-semibold"
546
+ summaryClassName="text-gray-500 text-xs"
547
+ contentClassName="px-4 pb-4 pt-3"
548
+ content={
549
+ <div className="space-y-2 text-sm">
550
+ {(
551
+ [
552
+ ["Parts / equipment", breakdown.parts, 55],
553
+ ["Labour", breakdown.labour, 25],
554
+ ["Travel", breakdown.travel, 10],
555
+ ["Other", breakdown.other, 10],
556
+ ] as const
557
+ ).map(([label, value, pct]) => (
558
+ <div key={label}>
559
+ <div className="mb-1 flex items-baseline justify-between">
560
+ <span className="text-xs font-medium text-gray-700">
561
+ {label}{" "}
562
+ <span className="text-gray-400">({pct}%)</span>
563
+ </span>
564
+ <span className="text-xs font-semibold text-gray-900">
565
+ {fmtRM(value)}
566
+ </span>
567
+ </div>
568
+ <Progress percentage={pct} className="h-1.5" />
569
+ </div>
570
+ ))}
571
+ <div className="flex justify-between border-t border-gray-100 pt-2 text-sm font-semibold">
572
+ <span className="text-gray-900">Total</span>
573
+ <span className="text-gray-900">{fmtRM(selected.cost)}</span>
574
+ </div>
575
+ </div>
576
+ }
577
+ />
578
+ </div>
579
+
580
+ <div>
581
+ <h3 className="mb-2 text-sm font-bold uppercase tracking-wide text-gray-500">
582
+ Documents
583
+ </h3>
584
+ <NewList list={docItems} />
585
+ </div>
586
+ <div className="flex justify-end gap-2">
587
+ <Button
588
+ type="light"
589
+ text="Close"
590
+ size="small"
591
+ onClick={() => setModalOpen(false)}
592
+ />
593
+ <Button type="normal" text="Open full record" size="small" onClick={() => {}} />
594
+ </div>
595
+ </div>
596
+ );
597
+ };
598
+
599
+ return (
600
+ <div className="min-h-screen bg-gray-50">
601
+ {/* INFO: AI-glow keyframes + classes registered at the component
602
+ root so they're in the DOM regardless of which view is active.
603
+ The modal needs them when opened from the Calendar view (where
604
+ renderListView hasn't been mounted yet). */}
605
+ <style>{`
606
+ @keyframes calendar-ai-glow {
607
+ 0% { background-position: 0% 50%; }
608
+ 100% { background-position: 400% 50%; }
609
+ }
610
+ @keyframes calendar-ai-pulse {
611
+ 0%, 100% { opacity: 0.12; }
612
+ 50% { opacity: 0.22; }
613
+ }
614
+ .calendar-ai-bg {
615
+ background-image: linear-gradient(
616
+ 120deg,
617
+ #6366f1 0%, #a855f7 25%, #ec4899 50%, #06b6d4 75%, #6366f1 100%
618
+ );
619
+ background-size: 400% 100%;
620
+ animation: calendar-ai-glow 8s linear infinite;
621
+ opacity: 0.65;
622
+ }
623
+ .calendar-ai-halo {
624
+ filter: blur(24px);
625
+ animation: calendar-ai-glow 8s linear infinite,
626
+ calendar-ai-pulse 5s ease-in-out infinite;
627
+ }
628
+ `}</style>
629
+
630
+ <Header
631
+ defaultNav="/"
632
+ page="Schedule"
633
+ logo={Logo}
634
+ navigation={NAVIGATION}
635
+ userNavigation={USER_NAV}
636
+ user={USER}
637
+ lib={{ Disclosure, Menu, Transition, Popover }}
638
+ />
639
+
640
+ <Container bgColor="bg-gray-50" className="pb-28">
641
+ <div className="mt-4">
642
+ <Breadcrumb
643
+ pages={[{ name: "Schedule", href: "#", current: true }]}
644
+ />
645
+ </div>
646
+
647
+ {/* Page header */}
648
+ <div className="mt-3 flex flex-wrap items-center justify-between gap-3">
649
+ <div>
650
+ <h1 className="text-2xl font-bold text-gray-900">Schedule</h1>
651
+ <p className="text-sm text-gray-500">
652
+ View installer calendar, installation progress, and documents
653
+ </p>
654
+ </div>
655
+ <Button type="normal" text="Add event" size="small" onClick={() => {}} />
656
+ </div>
657
+
658
+ {/* Stat tiles */}
659
+ <div className="mt-4 grid grid-cols-3 gap-3">
660
+ {STAT_TILES.map((s) => (
661
+ <Card
662
+ key={s.title}
663
+ size="compact"
664
+ icon={s.icon}
665
+ iconBgColor="bg-primary-100"
666
+ title={s.title}
667
+ count={s.count}
668
+ />
669
+ ))}
670
+ </div>
671
+
672
+ {/* Calendar / List toggle */}
673
+ <div className="mt-5 flex flex-wrap items-center justify-between gap-3">
674
+ <ButtonGroup
675
+ selection={VIEW_TOGGLE}
676
+ selectedId={view}
677
+ variant="tag"
678
+ size="small"
679
+ onClick={(id) => setView(id as "calendar" | "list")}
680
+ />
681
+ {view === "calendar" && (
682
+ <ButtonGroup
683
+ selection={CALENDAR_VARIANTS}
684
+ selectedId={calendarVariant}
685
+ variant="tag"
686
+ size="small"
687
+ onClick={(id) =>
688
+ setCalendarVariant(id as "fullMonth" | "weekStrip" | "agenda")
689
+ }
690
+ />
691
+ )}
692
+ </div>
693
+
694
+ {/* Legend — only shown for calendar view */}
695
+ {view === "calendar" && renderLegend()}
696
+
697
+ {view === "calendar" && renderCalendarView()}
698
+ {view === "list" && renderListView()}
699
+ </Container>
700
+
701
+ {/* Detail Modal — opens when an event is clicked */}
702
+ <Modal
703
+ open={modalOpen}
704
+ title="Installation Detail"
705
+ maxWidth="3xl"
706
+ onClose={() => setModalOpen(false)}
707
+ renderContent={renderDetailModalContent}
708
+ />
709
+
710
+ <div className="hidden md:block">
711
+ <FooterSection
712
+ caption={`© ${new Date().getFullYear()} Blixify. All rights reserved.`}
713
+ footerList={FOOTER_LIST}
714
+ />
715
+ </div>
716
+
717
+ <div className="md:hidden">
718
+ <BottomTab
719
+ tabData={BOTTOM_TABS}
720
+ selectedTab="Schedule"
721
+ bottomTabClassName="fixed bottom-0 left-0 right-0 shadow-lg"
722
+ />
723
+ </div>
724
+ </div>
725
+ );
726
+ };