@olenbetong/synergi-react 5.3.1 → 5.5.0

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 (141) hide show
  1. package/dist/styles/styles.css +1 -1
  2. package/dist/styles/styles.css.map +1 -1
  3. package/es/charts/CallOffDeliveries/TicketScanDialog.d.ts +7 -0
  4. package/es/charts/CallOffDeliveries/TicketScanDialog.js +47 -0
  5. package/es/charts/CallOffDeliveries/chartOptions.d.ts +8 -0
  6. package/es/charts/CallOffDeliveries/chartOptions.js +138 -0
  7. package/es/charts/CallOffDeliveries/data.d.ts +35 -0
  8. package/es/charts/CallOffDeliveries/data.js +30 -0
  9. package/es/charts/CallOffDeliveries/index.css +1 -0
  10. package/es/charts/CallOffDeliveries/index.d.ts +24 -0
  11. package/es/charts/CallOffDeliveries/index.js +115 -0
  12. package/es/charts/CallOffDeliveries/model.d.ts +37 -0
  13. package/es/charts/CallOffDeliveries/model.js +59 -0
  14. package/es/charts/ProductionPlan/PlanValueDialog.d.ts +14 -0
  15. package/es/charts/ProductionPlan/PlanValueDialog.js +47 -0
  16. package/es/charts/ProductionPlan/chartOptions.d.ts +20 -0
  17. package/es/charts/ProductionPlan/chartOptions.js +353 -0
  18. package/es/charts/ProductionPlan/data.d.ts +105 -0
  19. package/es/charts/ProductionPlan/data.js +61 -0
  20. package/es/charts/ProductionPlan/index.css +1 -0
  21. package/es/charts/ProductionPlan/index.d.ts +31 -0
  22. package/es/charts/ProductionPlan/index.js +203 -0
  23. package/es/charts/ProductionPlan/model.d.ts +29 -0
  24. package/es/charts/ProductionPlan/model.js +65 -0
  25. package/es/charts/Pumping/chartOptions.d.ts +12 -0
  26. package/es/charts/Pumping/chartOptions.js +197 -0
  27. package/es/charts/Pumping/data.d.ts +65 -0
  28. package/es/charts/Pumping/data.js +20 -0
  29. package/es/charts/Pumping/index.css +1 -0
  30. package/es/charts/Pumping/index.d.ts +27 -0
  31. package/es/charts/Pumping/index.js +124 -0
  32. package/es/charts/Pumping/model.d.ts +34 -0
  33. package/es/charts/Pumping/model.js +88 -0
  34. package/es/charts/UnboundPreview/chartOptions.d.ts +3 -0
  35. package/es/charts/UnboundPreview/chartOptions.js +126 -0
  36. package/es/charts/UnboundPreview/index.css +1 -0
  37. package/es/charts/UnboundPreview/index.d.ts +20 -0
  38. package/es/charts/UnboundPreview/index.js +55 -0
  39. package/es/charts/UnboundPreview/model.d.ts +49 -0
  40. package/es/charts/UnboundPreview/model.js +67 -0
  41. package/es/charts/VehicleDeliveries/chartOptions.d.ts +13 -0
  42. package/es/charts/VehicleDeliveries/chartOptions.js +270 -0
  43. package/es/charts/VehicleDeliveries/data.d.ts +71 -0
  44. package/es/charts/VehicleDeliveries/data.js +20 -0
  45. package/es/charts/VehicleDeliveries/deliveryXRange.d.ts +4 -0
  46. package/es/charts/VehicleDeliveries/deliveryXRange.js +62 -0
  47. package/es/charts/VehicleDeliveries/index.css +1 -0
  48. package/es/charts/VehicleDeliveries/index.d.ts +24 -0
  49. package/es/charts/VehicleDeliveries/index.js +129 -0
  50. package/es/charts/VehicleDeliveries/model.d.ts +24 -0
  51. package/es/charts/VehicleDeliveries/model.js +106 -0
  52. package/es/charts/format.d.ts +12 -0
  53. package/es/charts/format.js +34 -0
  54. package/es/charts/index.d.ts +5 -0
  55. package/es/charts/index.js +5 -0
  56. package/es/charts/storage.d.ts +5 -0
  57. package/es/charts/storage.js +35 -0
  58. package/es/components/ColorCard/index.css +8 -8
  59. package/es/components/ImageEditor/ImageEditor.d.ts +6 -0
  60. package/es/components/ImageEditor/ImageEditor.js +6 -2
  61. package/es/components/ImageEditor/ResponsiveButton.d.ts +2 -1
  62. package/es/components/ImageEditor/ResponsiveButton.js +3 -3
  63. package/es/components/ImageEditor/plugins/cropPlugin/CropContext.d.ts +2 -1
  64. package/es/components/ImageEditor/plugins/cropPlugin/CropContext.js +2 -2
  65. package/es/components/ImageEditor/plugins/cropPlugin/CropToolbar.js +27 -7
  66. package/es/components/ImageEditor/types.d.ts +5 -0
  67. package/es/index.css +1 -1
  68. package/es/vehicles/VehicleInfoDialog/OutOfServiceForm.d.ts +4 -0
  69. package/es/vehicles/VehicleInfoDialog/OutOfServiceForm.js +51 -0
  70. package/es/vehicles/VehicleInfoDialog/data/dsDeliveryTickets.d.ts +99 -0
  71. package/es/vehicles/VehicleInfoDialog/data/dsDeliveryTickets.js +499 -0
  72. package/es/vehicles/VehicleInfoDialog/data/dsDriverStatus.d.ts +13 -0
  73. package/es/vehicles/VehicleInfoDialog/data/dsDriverStatus.js +69 -0
  74. package/es/vehicles/VehicleInfoDialog/data/dsVehicleInfo.d.ts +33 -0
  75. package/es/vehicles/VehicleInfoDialog/data/dsVehicleInfo.js +164 -0
  76. package/es/vehicles/VehicleInfoDialog/data/dsVehicleInfoLog.d.ts +15 -0
  77. package/es/vehicles/VehicleInfoDialog/data/dsVehicleInfoLog.js +80 -0
  78. package/es/vehicles/VehicleInfoDialog/formatting.d.ts +13 -0
  79. package/es/vehicles/VehicleInfoDialog/formatting.js +48 -0
  80. package/es/vehicles/VehicleInfoDialog/index.css +1 -0
  81. package/es/vehicles/VehicleInfoDialog/index.d.ts +11 -0
  82. package/es/vehicles/VehicleInfoDialog/index.js +46 -0
  83. package/es/vehicles/VehicleInfoDialog/tabs.d.ts +6 -0
  84. package/es/vehicles/VehicleInfoDialog/tabs.js +85 -0
  85. package/es/vehicles/index.d.ts +1 -0
  86. package/es/vehicles/index.js +1 -0
  87. package/package.json +19 -10
  88. package/src/charts/CallOffDeliveries/TicketScanDialog.tsx +79 -0
  89. package/src/charts/CallOffDeliveries/chartOptions.ts +160 -0
  90. package/src/charts/CallOffDeliveries/data.ts +67 -0
  91. package/src/charts/CallOffDeliveries/index.scss +51 -0
  92. package/src/charts/CallOffDeliveries/index.tsx +217 -0
  93. package/src/charts/CallOffDeliveries/model.test.ts +90 -0
  94. package/src/charts/CallOffDeliveries/model.ts +87 -0
  95. package/src/charts/ProductionPlan/PlanValueDialog.tsx +107 -0
  96. package/src/charts/ProductionPlan/chartOptions.ts +406 -0
  97. package/src/charts/ProductionPlan/data.ts +170 -0
  98. package/src/charts/ProductionPlan/index.scss +148 -0
  99. package/src/charts/ProductionPlan/index.tsx +432 -0
  100. package/src/charts/ProductionPlan/model.test.ts +132 -0
  101. package/src/charts/ProductionPlan/model.ts +102 -0
  102. package/src/charts/Pumping/chartOptions.ts +224 -0
  103. package/src/charts/Pumping/data.ts +91 -0
  104. package/src/charts/Pumping/index.scss +42 -0
  105. package/src/charts/Pumping/index.tsx +222 -0
  106. package/src/charts/Pumping/model.test.ts +122 -0
  107. package/src/charts/Pumping/model.ts +104 -0
  108. package/src/charts/UnboundPreview/chartOptions.ts +137 -0
  109. package/src/charts/UnboundPreview/index.scss +17 -0
  110. package/src/charts/UnboundPreview/index.tsx +100 -0
  111. package/src/charts/UnboundPreview/model.test.ts +129 -0
  112. package/src/charts/UnboundPreview/model.ts +110 -0
  113. package/src/charts/VehicleDeliveries/chartOptions.ts +311 -0
  114. package/src/charts/VehicleDeliveries/data.ts +98 -0
  115. package/src/charts/VehicleDeliveries/deliveryXRange.ts +80 -0
  116. package/src/charts/VehicleDeliveries/index.scss +43 -0
  117. package/src/charts/VehicleDeliveries/index.tsx +262 -0
  118. package/src/charts/VehicleDeliveries/model.test.ts +117 -0
  119. package/src/charts/VehicleDeliveries/model.ts +139 -0
  120. package/src/charts/format.ts +38 -0
  121. package/src/charts/index.ts +20 -0
  122. package/src/charts/storage.ts +36 -0
  123. package/src/components/ColorCard/index.css +8 -8
  124. package/src/components/ImageEditor/ImageEditor.test.tsx +103 -0
  125. package/src/components/ImageEditor/ImageEditor.tsx +18 -2
  126. package/src/components/ImageEditor/ResponsiveButton.tsx +4 -3
  127. package/src/components/ImageEditor/plugins/cropPlugin/CropContext.tsx +5 -2
  128. package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.test.tsx +118 -0
  129. package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.tsx +52 -18
  130. package/src/components/ImageEditor/types.ts +5 -0
  131. package/src/vehicles/VehicleInfoDialog/OutOfServiceForm.tsx +127 -0
  132. package/src/vehicles/VehicleInfoDialog/data/dsDeliveryTickets.ts +600 -0
  133. package/src/vehicles/VehicleInfoDialog/data/dsDriverStatus.ts +84 -0
  134. package/src/vehicles/VehicleInfoDialog/data/dsVehicleInfo.ts +198 -0
  135. package/src/vehicles/VehicleInfoDialog/data/dsVehicleInfoLog.ts +97 -0
  136. package/src/vehicles/VehicleInfoDialog/formatting.test.ts +57 -0
  137. package/src/vehicles/VehicleInfoDialog/formatting.ts +58 -0
  138. package/src/vehicles/VehicleInfoDialog/index.scss +131 -0
  139. package/src/vehicles/VehicleInfoDialog/index.tsx +106 -0
  140. package/src/vehicles/VehicleInfoDialog/tabs.tsx +188 -0
  141. package/src/vehicles/index.ts +1 -0
@@ -0,0 +1,188 @@
1
+ import { Heading, Paragraph, Table } from "@digdir/designsystemet-react";
2
+ import { CircleSlashIcon, TruckIcon } from "@navikt/aksel-icons";
3
+ import { getUserImage } from "@olenbetong/appframe-core";
4
+ import { useCurrentRow, useData } from "@olenbetong/appframe-react";
5
+ import type { ReactNode } from "react";
6
+
7
+ import { getLocalizedString } from "../../i18n.js";
8
+ import { dsDeliveryTickets } from "./data/dsDeliveryTickets.js";
9
+ import { dsDriverStatus } from "./data/dsDriverStatus.js";
10
+ import { dsVehicleInfo } from "./data/dsVehicleInfo.js";
11
+ import { dsVehicleInfoLog } from "./data/dsVehicleInfoLog.js";
12
+ import { formatDateTime, formatMinutes, formatPeriod } from "./formatting.js";
13
+
14
+ const MAPS_KEY = "AIzaSyAe-z4UXfbPedkmuAeFtMIdOaeqqgVciQk";
15
+
16
+ function InfoTable({ rows }: { rows: Array<[string, ReactNode | Date] | false> }) {
17
+ return (
18
+ <Table data-size="sm" data-color="neutral" zebra className="ObVehicleInfo-table">
19
+ <Table.Body>
20
+ {rows
21
+ .filter((row) => row !== false)
22
+ .map(([caption, value]) => (
23
+ <Table.Row key={caption}>
24
+ <Table.Cell>{caption}</Table.Cell>
25
+ <Table.Cell>{formatDateTime(value)}</Table.Cell>
26
+ </Table.Row>
27
+ ))}
28
+ </Table.Body>
29
+ </Table>
30
+ );
31
+ }
32
+
33
+ export function VehicleTab({ onEditPeriod }: { onEditPeriod: (id: number) => void }) {
34
+ let row = useCurrentRow(dsVehicleInfo);
35
+ // A period being added is in the data too, without an ID until it is saved.
36
+ let periods = useData(dsVehicleInfoLog).filter((period) => period.ID);
37
+
38
+ return (
39
+ <div className="ObVehicleInfo-tab">
40
+ <div className="ObVehicleInfo-columns">
41
+ <InfoTable
42
+ rows={[
43
+ [getLocalizedString("Last activity"), row.PositionTimestamp],
44
+ [getLocalizedString("Home location"), row.LocationID],
45
+ [getLocalizedString("Last assignment for"), row.LastStartLocationID],
46
+ [getLocalizedString("Registration no."), row.RegistrationNo],
47
+ [getLocalizedString("Model"), row.Model],
48
+ [getLocalizedString("Manufacturer"), row.Manufacturer],
49
+ [getLocalizedString("Production year"), row.ProductionYear],
50
+ [getLocalizedString("Group"), `${row.ParentTypeName ?? ""} ${row.TypeName ?? ""}`],
51
+ [getLocalizedString("Boom length"), row.BoomLength],
52
+ ]}
53
+ />
54
+ {row.Image && row.PrimKey ? (
55
+ <img
56
+ alt=""
57
+ className="ObVehicleInfo-image"
58
+ src={`${dsVehicleInfo.getBlobURL(row.PrimKey, "Image", `${row.ObjectNo}.jpg`)}?mwidth=300`}
59
+ />
60
+ ) : (
61
+ <TruckIcon aria-hidden className="ObVehicleInfo-placeholder" />
62
+ )}
63
+ </div>
64
+ {periods.length > 0 && (
65
+ <ul className="ObVehicleInfo-periods">
66
+ {periods.map((period) => (
67
+ <li key={period.ID}>
68
+ <button type="button" onClick={() => onEditPeriod(period.ID)}>
69
+ <CircleSlashIcon aria-hidden />
70
+ <span>
71
+ <strong>{period.Comment}</strong>
72
+ <br />
73
+ {period.IsPlanned ? `${getLocalizedString("Planned")}: ` : ""}
74
+ {formatPeriod(period.FromDateTime, period.ToDateTime)} ({getLocalizedString("Created by")}{" "}
75
+ {period.CreatedBy})
76
+ </span>
77
+ </button>
78
+ </li>
79
+ ))}
80
+ </ul>
81
+ )}
82
+ </div>
83
+ );
84
+ }
85
+
86
+ export function DeliveryTicketTab() {
87
+ let record = useCurrentRow(dsDeliveryTickets);
88
+
89
+ return (
90
+ <div className="ObVehicleInfo-tab">
91
+ <Heading level={3} data-size="xs">
92
+ {getLocalizedString("Last delivery ticket")}: {record.DeliveryTicketID}
93
+ </Heading>
94
+ <Heading level={4} data-size="2xs">
95
+ {getLocalizedString("Customer")}
96
+ </Heading>
97
+ <InfoTable
98
+ rows={[
99
+ [getLocalizedString("Customer nr"), record.CustomerNo],
100
+ [
101
+ getLocalizedString("Address"),
102
+ <>
103
+ {record.CustomerAdr1}
104
+ <br />
105
+ {record.CustomerAdr2}
106
+ <br />
107
+ {record.CustomerAdr3}
108
+ </>,
109
+ ],
110
+ [getLocalizedString("Build site"), record.BuildSiteAdr1],
111
+ ]}
112
+ />
113
+ <Heading level={4} data-size="2xs">
114
+ {getLocalizedString("Concrete")}
115
+ </Heading>
116
+ <InfoTable
117
+ rows={[
118
+ [getLocalizedString("Prod. time"), record.ProdTime],
119
+ [getLocalizedString("This load"), `${record.Qty} m³`],
120
+ [
121
+ getLocalizedString("Total delivered"),
122
+ `${record.QtyTotal} m³ ${getLocalizedString("of")} ${record.CallOffQty} m³`,
123
+ ],
124
+ [getLocalizedString("Concrete"), record.ConcreteName],
125
+ ]}
126
+ />
127
+ </div>
128
+ );
129
+ }
130
+
131
+ export function DriverTab() {
132
+ let row = useCurrentRow(dsDriverStatus);
133
+
134
+ if (!row.PrimKey) {
135
+ return <Paragraph>{getLocalizedString("No driver data")}</Paragraph>;
136
+ }
137
+
138
+ let image = getUserImage(row.PrimKey, row.PersonID, row.ImageHash, "md");
139
+
140
+ return (
141
+ <div className="ObVehicleInfo-columns">
142
+ <InfoTable
143
+ rows={[
144
+ [getLocalizedString("Name"), row.FullName],
145
+ [getLocalizedString("Work location"), row.WorkLocation],
146
+ [getLocalizedString("Phone number"), row.PhoneMob],
147
+ row.RemainingDrivingTimeCurrent !== null && [
148
+ getLocalizedString("Remaining driving time (current)"),
149
+ formatMinutes(row.RemainingDrivingTimeCurrent),
150
+ ],
151
+ row.RemainingDrivingTimeShift !== null && [
152
+ getLocalizedString("Remaining driving time (shift)"),
153
+ formatMinutes(row.RemainingDrivingTimeShift),
154
+ ],
155
+ row.DurationOfNextBreak !== null && [
156
+ getLocalizedString("Duration of next break"),
157
+ formatMinutes(row.DurationOfNextBreak),
158
+ ],
159
+ !!row.Timestamp && [getLocalizedString("Last updated"), row.Timestamp],
160
+ ]}
161
+ />
162
+ {image && <img alt="" className="ObVehicleInfo-image" src={image} />}
163
+ </div>
164
+ );
165
+ }
166
+
167
+ export function MapTab() {
168
+ let row = useCurrentRow(dsVehicleInfo);
169
+
170
+ if (!row.PrimKey || !row.Latitude || !row.Longitude) {
171
+ return <Paragraph>{getLocalizedString("No position data")}</Paragraph>;
172
+ }
173
+
174
+ let position = `${row.Latitude},${row.Longitude}`;
175
+
176
+ return (
177
+ <div>
178
+ <img
179
+ alt=""
180
+ className="ObVehicleInfo-image"
181
+ src={`https://maps.googleapis.com/maps/api/staticmap?center=${position}&zoom=12&size=600x340&markers=color:green%7Clabel:${row.ObjectNo}%7C${position}&key=${MAPS_KEY}`}
182
+ />
183
+ <Paragraph data-size="xs">
184
+ {getLocalizedString("Last position saved")}: {formatDateTime(row.PositionTimestamp)}
185
+ </Paragraph>
186
+ </div>
187
+ );
188
+ }
@@ -0,0 +1 @@
1
+ export { VehicleInfoDialog, type VehicleInfoDialogProps } from "./VehicleInfoDialog/index.js";