@ossy/consultancy 3.21.0 → 3.23.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 (43) hide show
  1. package/package.json +4 -2
  2. package/src/AssignmentMarginCalculator.jsx +7 -32
  3. package/src/ConsultancyNav.jsx +17 -9
  4. package/src/Forecast.jsx +33 -384
  5. package/src/MonthDayGrid.jsx +68 -0
  6. package/src/Overview.jsx +10 -31
  7. package/src/RequestStatsPanel.jsx +66 -0
  8. package/src/consultancy.page.jsx +3 -40
  9. package/src/current-month.component.jsx +47 -25
  10. package/src/en.translations.json +52 -2
  11. package/src/extract-request.action.js +5 -0
  12. package/src/extract-request.task.js +117 -0
  13. package/src/extract-request.task.spec.js +131 -0
  14. package/src/forecast-panels.jsx +125 -0
  15. package/src/forecast-widget-menu.jsx +89 -0
  16. package/src/get-request-stats.action.js +6 -0
  17. package/src/get-request-stats.task.js +26 -0
  18. package/src/index.js +1 -0
  19. package/src/intake-categories.js +39 -0
  20. package/src/kpi-trend.component.jsx +17 -0
  21. package/src/margin-panels.jsx +7 -32
  22. package/src/org.page.jsx +1 -2
  23. package/src/reports.page.jsx +103 -0
  24. package/src/request-buckets.js +76 -0
  25. package/src/request-buckets.spec.js +33 -0
  26. package/src/request-stats.aggregate.js +52 -0
  27. package/src/request-stats.aggregate.spec.js +34 -0
  28. package/src/request-stats.component.jsx +16 -0
  29. package/src/request.schema.js +29 -0
  30. package/src/requests.page.jsx +26 -0
  31. package/src/resume-inbound-screening.task.js +77 -0
  32. package/src/resume-inbound-screening.task.spec.js +68 -0
  33. package/src/schema-ids.js +1 -0
  34. package/src/screen-inbound.task.js +133 -0
  35. package/src/screen-inbound.task.spec.js +154 -0
  36. package/src/sv.translations.json +52 -2
  37. package/src/use-chart-months.js +27 -0
  38. package/src/utilization-hours.js +21 -3
  39. package/src/utilization-hours.spec.js +23 -0
  40. package/src/utilization.component.jsx +17 -0
  41. package/src/year-totals.component.jsx +17 -0
  42. package/src/forecast-kpi-chart.js +0 -184
  43. package/src/forecast-kpi-chart.spec.js +0 -159
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ossy/consultancy",
3
3
  "description": "Consultancy feature package — schemas, forecasts UI, and assignment margins",
4
- "version": "3.21.0",
4
+ "version": "3.23.0",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
7
7
  "module": "./src/index.js",
@@ -25,6 +25,8 @@
25
25
  "README.md"
26
26
  ],
27
27
  "dependencies": {
28
+ "@ossy/email": "^3.23.0",
29
+ "@ossy/event-store": "^3.20.1",
28
30
  "@ossy/schema": "^3.20.1"
29
31
  },
30
32
  "peerDependencies": {
@@ -39,5 +41,5 @@
39
41
  "devDependencies": {
40
42
  "jest": "^30.2.0"
41
43
  },
42
- "gitHead": "f3eeb810cfdd6eb8be7951eb767669fa29a1b3d8"
44
+ "gitHead": "fba601366c69184bbd82d990429d1a43152645c9"
43
45
  }
@@ -1,5 +1,6 @@
1
1
  import React, { useEffect, useState } from 'react'
2
2
  import {
3
+ Panel,
3
4
  View,
4
5
  Text,
5
6
  Alert,
@@ -43,32 +44,6 @@ function parseNumber (value, fallback = 0) {
43
44
  return Number.isFinite(parsed) ? parsed : fallback
44
45
  }
45
46
 
46
- function SectionPanel ({ title, children, ...props }) {
47
- return (
48
- <View surface="primary" roundness="xs" style={{ minWidth: 0, overflow: 'hidden' }} {...props}>
49
- <View stack bordered>
50
- <View.Item
51
- data-surface="primary"
52
- layout="row"
53
- style={{
54
- alignItems: 'center',
55
- justifyContent: 'space-between',
56
- padding: 'var(--space-s) var(--space-m)',
57
- gap: 'var(--space-m)',
58
- height: '48px',
59
- flexShrink: 0,
60
- }}
61
- >
62
- <Text variant="small" as="h2" style={{ fontWeight: 'bold' }} text={title} />
63
- </View.Item>
64
- <View.Item>
65
- {children}
66
- </View.Item>
67
- </View>
68
- </View>
69
- )
70
- }
71
-
72
47
  function MetricRow ({ label, value }) {
73
48
  return (
74
49
  <View layout="row" justifyContent="space-between" gap="s">
@@ -157,15 +132,15 @@ export const AssignmentMarginCalculator = () => {
157
132
 
158
133
  <View layout="row-wrap" gap="m" style={{ alignItems: 'stretch' }}>
159
134
  <View style={{ flex: '1 1 320px', minWidth: 0 }}>
160
- <SectionPanel title="consultancy.margins.inputs.title">
135
+ <Panel title="consultancy.margins.inputs.title">
161
136
  <View inset="m" gap="m">
162
137
  <FieldFactory />
163
138
  </View>
164
- </SectionPanel>
139
+ </Panel>
165
140
  </View>
166
141
 
167
142
  <View style={{ flex: '1 1 320px', minWidth: 0 }}>
168
- <SectionPanel
143
+ <Panel
169
144
  title="consultancy.margins.results.title"
170
145
  data-margins-status={margin.isProfitable ? 'profitable' : 'unprofitable'}
171
146
  >
@@ -186,17 +161,17 @@ export const AssignmentMarginCalculator = () => {
186
161
  text={margin.coversEmployerCost ? 'consultancy.margins.results.coversCost' : 'consultancy.margins.results.missesCost'}
187
162
  />
188
163
  </View>
189
- </SectionPanel>
164
+ </Panel>
190
165
  </View>
191
166
  </View>
192
167
 
193
- <SectionPanel title="consultancy.margins.leakage.title" data-margins-leakage="on">
168
+ <Panel title="consultancy.margins.leakage.title" data-margins-leakage="on">
194
169
  <View gap="m" inset="m">
195
170
  <Text variant="small" color="secondary" text="consultancy.margins.leakage.description" />
196
171
  <MetricRow label="consultancy.margins.leakage.hours" value={hoursFormat(leakage.leakedHours)} />
197
172
  <MetricRow label="consultancy.margins.leakage.revenue" value={money(leakage.leakedRevenue)} />
198
173
  </View>
199
- </SectionPanel>
174
+ </Panel>
200
175
  </Form>
201
176
  )
202
177
  }
@@ -2,12 +2,28 @@ import React from 'react'
2
2
  import { Tabs } from '@ossy/design-system'
3
3
  import { useRouter } from '@ossy/router-react'
4
4
 
5
- /** Overview first, record lists, then Margins and Org Details. */
5
+ /** Overview, then the sales records, then the people and the company. */
6
6
  const TABS = [
7
7
  {
8
8
  id: 'consultancy/home',
9
9
  label: 'consultancy.nav.overview',
10
10
  },
11
+ {
12
+ id: 'consultancy/requests',
13
+ label: 'consultancy.nav.requests',
14
+ },
15
+ {
16
+ id: 'consultancy/opportunities',
17
+ label: 'consultancy.nav.opportunities',
18
+ },
19
+ {
20
+ id: 'consultancy/proposals',
21
+ label: 'consultancy.nav.proposals',
22
+ },
23
+ {
24
+ id: 'consultancy/reports',
25
+ label: 'consultancy.nav.reports',
26
+ },
11
27
  {
12
28
  id: 'consultancy/employees',
13
29
  label: 'consultancy.nav.employees',
@@ -20,14 +36,6 @@ const TABS = [
20
36
  id: 'consultancy/contracts',
21
37
  label: 'consultancy.nav.contracts',
22
38
  },
23
- {
24
- id: 'consultancy/opportunities',
25
- label: 'consultancy.nav.opportunities',
26
- },
27
- {
28
- id: 'consultancy/proposals',
29
- label: 'consultancy.nav.proposals',
30
- },
31
39
  {
32
40
  id: 'consultancy/margins',
33
41
  label: 'consultancy.nav.margins',
package/src/Forecast.jsx CHANGED
@@ -1,373 +1,46 @@
1
- import React, { useMemo } from 'react'
2
- import { View, Text, Separator, useLocale } from '@ossy/design-system'
3
- import { CalendarDaySurfaceStyles, sumFiscalYearTotals, useContracts, useEmployees, useForecast, useVacations } from '@ossy/calendar'
4
- import { ListResources } from '@ossy/resources'
5
- import { useSdk } from '@ossy/sdk-react'
6
- import { buildKpiChartLayout } from './forecast-kpi-chart.js'
7
- import { TIMESHEET_LOCATION, TIMESHEET_TYPE, withUtilizationHours } from './utilization-hours.js'
8
-
9
- const grid = {
10
- width: '100%',
11
- height: '100%',
12
- display: 'flex',
13
- flexDirection: 'row',
14
- flexWrap: 'wrap',
15
- gap: '1px',
16
- overflowX: 'auto',
17
- }
18
-
19
- const calendarGrid = {
20
- display: 'grid',
21
- justifyContent: 'center',
22
- alignItems: 'center',
23
- gridTemplateColumns: 'repeat(7, 40px)',
24
- gridAutoRows: 'repeat(6, 40px)',
25
- gap: 'var(--space-m)',
26
- justifyItems: 'center',
27
- }
28
-
29
- const calendarDayLayout = {
30
- boxSizing: 'border-box',
31
- display: 'flex',
32
- justifyContent: 'center',
33
- alignItems: 'center',
34
- borderRadius: '50%',
35
- padding: '8px',
36
- fontSize: '.6rem',
37
- margin: 0,
38
- }
39
-
40
- const KPI_SERIES = [
41
- // Contract forecast is dashed. Timesheet actuals are solid. Same color pairs the two.
42
- { key: 'projectedIncome', label: 'consultancy.forecasts.forecastIncome', color: 'var(--color-info, hsl(199, 89%, 43%))', dashed: true },
43
- { key: 'actualIncome', label: 'consultancy.forecasts.actualIncome', color: 'var(--color-info, hsl(199, 89%, 43%))' },
44
- { key: 'monthlyCostOfEmployees', label: 'consultancy.forecasts.salaryCost', color: 'var(--color-warning, hsl(38, 92%, 50%))', dashed: true },
45
- { key: 'revenue', label: 'consultancy.forecasts.forecastRevenue', color: 'var(--color-accent, hsl(167, 89%, 43%))', dashed: true },
46
- { key: 'actualRevenue', label: 'consultancy.forecasts.actualRevenue', color: 'var(--color-accent, hsl(167, 89%, 43%))' },
47
- ]
48
-
49
- const UTILIZATION_SERIES = [
50
- { key: 'forecastHours', label: 'consultancy.forecasts.forecastHours', color: 'var(--color-info, hsl(199, 89%, 43%))', scale: 'hours', dashed: true },
51
- { key: 'actualHours', label: 'consultancy.forecasts.actualHours', color: 'var(--color-accent, hsl(167, 89%, 43%))', scale: 'hours' },
52
- ]
53
-
54
- function ChartAxisLabel ({ x, y, viewWidth, viewHeight, children }) {
55
- return (
56
- <Text
57
- as="span"
58
- variant="small"
59
- data-chart-axis-label=""
60
- style={{
61
- position: 'absolute',
62
- left: `${(x / viewWidth) * 100}%`,
63
- top: `${(y / viewHeight) * 100}%`,
64
- transform: 'translate(-50%, -100%)',
65
- margin: 0,
66
- opacity: 0.75,
67
- lineHeight: 1,
68
- whiteSpace: 'nowrap',
69
- pointerEvents: 'none',
70
- }}
71
- >
72
- {children}
73
- </Text>
74
- )
75
- }
76
-
77
- function SectionPanel ({ title, children }) {
78
- return (
79
- <View surface="primary" roundness="xs" style={{ minWidth: 0, overflow: 'hidden', height: '100%' }}>
80
- <View stack bordered>
81
- <View.Item
82
- data-surface="primary"
83
- layout="row"
84
- style={{
85
- alignItems: 'center',
86
- justifyContent: 'space-between',
87
- padding: 'var(--space-s) var(--space-m)',
88
- gap: 'var(--space-m)',
89
- height: '48px',
90
- flexShrink: 0,
91
- }}
92
- >
93
- <Text variant="small" as="h2" style={{ fontWeight: 'bold' }}>{title}</Text>
94
- </View.Item>
95
- <View.Item>
96
- {children}
97
- </View.Item>
98
- </View>
99
- </View>
100
- )
101
- }
102
-
103
- /**
104
- * Hand-rolled multi-series line chart.
105
- * Matches the no-dependency SVG approach from analytics DailyBarChart (#917).
106
- */
107
- function ForecastKpiChart ({ months, series, unit }) {
108
- const { language, t } = useLocale()
109
- const chart = useMemo(
110
- () => buildKpiChartLayout({ months, series, language }),
111
- [months, series, language],
112
- )
113
-
114
- if (!chart) {
115
- return (
116
- <View inset="m">
117
- <Text variant="small" text="consultancy.forecasts.yearChartEmpty" />
118
- </View>
119
- )
120
- }
121
-
122
- return (
123
- <View gap="s" inset="m" style={{ width: '100%' }}>
124
- <View layout="row-wrap" gap="m" style={{ alignItems: 'center', justifyContent: 'space-between' }}>
125
- <View layout="row-wrap" gap="m" style={{ alignItems: 'center' }}>
126
- {series.map((entry) => (
127
- <View key={entry.key} layout="row" gap="s" style={{ alignItems: 'center' }}>
128
- <span
129
- aria-hidden
130
- style={{
131
- width: 10,
132
- height: 10,
133
- borderRadius: 2,
134
- background: entry.color,
135
- display: 'inline-block',
136
- flexShrink: 0,
137
- ...(entry.dashed
138
- ? {
139
- background: 'transparent',
140
- borderTop: `2px dashed ${entry.color}`,
141
- height: 0,
142
- borderRadius: 0,
143
- }
144
- : null),
145
- }}
146
- />
147
- <Text variant="small" style={{ marginBottom: 0 }} text={entry.label} />
148
- </View>
149
- ))}
150
- </View>
151
- {unit ? (
152
- <Text
153
- as="span"
154
- variant="small"
155
- data-consultancy-chart-unit=""
156
- text={unit}
157
- style={{ marginBottom: 0 }}
158
- />
159
- ) : null}
160
- </View>
161
- <div style={{ display: 'flex', alignItems: 'stretch', width: '100%', gap: 4 }}>
162
- {chart.yTicks.length > 0 ? (
163
- <div style={{ position: 'relative', flex: '0 0 auto' }}>
164
- <div aria-hidden style={{ display: 'grid' }}>
165
- {chart.yTicks.map((tick) => (
166
- <Text
167
- key={`tick-size-${tick.value}`}
168
- as="span"
169
- variant="small"
170
- style={{
171
- gridArea: '1 / 1',
172
- visibility: 'hidden',
173
- margin: 0,
174
- lineHeight: 1,
175
- whiteSpace: 'nowrap',
176
- }}
177
- >
178
- {tick.label}
179
- </Text>
180
- ))}
181
- </div>
182
- {chart.yTicks.map((tick) => (
183
- <Text
184
- key={`tick-label-${tick.value}`}
185
- as="span"
186
- variant="small"
187
- data-consultancy-chart-tick={tick.label}
188
- style={{
189
- position: 'absolute',
190
- right: 0,
191
- top: `${(tick.y / chart.viewHeight) * 100}%`,
192
- transform: 'translateY(-50%)',
193
- margin: 0,
194
- opacity: 0.75,
195
- lineHeight: 1,
196
- whiteSpace: 'nowrap',
197
- pointerEvents: 'none',
198
- }}
199
- >
200
- {tick.label}
201
- </Text>
202
- ))}
203
- </div>
204
- ) : null}
205
- <div style={{ position: 'relative', flex: '1 1 auto', minWidth: 0 }}>
206
- <svg
207
- data-consultancy-kpi-chart
208
- viewBox={`0 0 ${chart.viewWidth} ${chart.viewHeight}`}
209
- width="100%"
210
- role="img"
211
- aria-label={unit ? t(unit) : undefined}
212
- style={{
213
- display: 'block',
214
- width: '100%',
215
- height: 'auto',
216
- aspectRatio: `${chart.viewWidth} / ${chart.viewHeight}`,
217
- }}
218
- preserveAspectRatio="xMidYMid meet"
219
- >
220
- {chart.yTicks.map((tick) => (
221
- <line
222
- key={`tick-${tick.value}`}
223
- x1={tick.x1}
224
- x2={tick.x2}
225
- y1={tick.y}
226
- y2={tick.y}
227
- stroke="currentColor"
228
- strokeOpacity="0.15"
229
- vectorEffect="non-scaling-stroke"
230
- />
231
- ))}
232
- {chart.seriesPaths.map((series) => (
233
- series.path ? (
234
- <path
235
- key={series.key}
236
- d={series.path}
237
- fill="none"
238
- stroke={series.color}
239
- strokeWidth={2}
240
- strokeLinejoin="round"
241
- strokeLinecap="round"
242
- strokeDasharray={series.dashed ? '6 4' : undefined}
243
- vectorEffect="non-scaling-stroke"
244
- />
245
- ) : null
246
- ))}
247
- </svg>
248
- {chart.monthLabels.map((label) => (
249
- <ChartAxisLabel
250
- key={`month-${label.index}`}
251
- x={label.x}
252
- y={label.y}
253
- viewWidth={chart.viewWidth}
254
- viewHeight={chart.viewHeight}
255
- >
256
- <span data-consultancy-kpi-month={label.label}>{label.label}</span>
257
- </ChartAxisLabel>
258
- ))}
259
- </div>
260
- </div>
261
- </View>
262
- )
263
- }
264
-
265
- function UtilizationPanel ({ months }) {
266
- const { t } = useLocale()
267
-
268
- return (
269
- <SectionPanel title={t('consultancy.forecasts.utilization')}>
270
- <ForecastKpiChart months={months} series={UTILIZATION_SERIES} unit="consultancy.forecasts.unitHours" />
271
- </SectionPanel>
272
- )
273
- }
274
-
275
- function YearSummary ({ months, money, hours }) {
276
- const { t } = useLocale()
277
- const totals = useMemo(() => sumFiscalYearTotals(months), [months])
278
-
279
- return (
280
- <View
281
- data-consultancy-year-summary
282
- layout="row-wrap"
283
- gap="m"
284
- style={{ alignItems: 'stretch', width: '100%' }}
285
- >
286
- <View style={{ flex: '2 1 320px', minWidth: 0 }}>
287
- <SectionPanel title={t('consultancy.forecasts.yearChart')}>
288
- <ForecastKpiChart months={months} series={KPI_SERIES} unit="consultancy.forecasts.unitMoney" />
289
- </SectionPanel>
290
- </View>
291
- <View style={{ flex: '1 1 240px', minWidth: 0 }}>
292
- <SectionPanel title={t('consultancy.forecasts.yearSummary')}>
293
- <View gap="s" inset="m">
294
- <View layout="row" gap="s" style={{ justifyContent: 'space-between' }}>
295
- <Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.income" />
296
- <Text variant="m" style={{ marginBottom: 0 }}>{money(totals.projectedIncome)}</Text>
297
- </View>
298
- <View layout="row" gap="s" style={{ justifyContent: 'space-between' }}>
299
- <Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.salaryCost" />
300
- <Text variant="m" style={{ marginBottom: 0 }}>{money(totals.monthlyCostOfEmployees)}</Text>
301
- </View>
302
- <View layout="row" gap="s" style={{ justifyContent: 'space-between' }}>
303
- <Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.revenue" />
304
- <Text variant="m" style={{ marginBottom: 0 }}>{money(totals.revenue)}</Text>
305
- </View>
306
- <View layout="row" gap="s" style={{ justifyContent: 'space-between' }}>
307
- <Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.hoursWorked" />
308
- <Text variant="m" style={{ marginBottom: 0 }}>{hours(totals.hoursWorked)}</Text>
309
- </View>
310
- </View>
311
- </SectionPanel>
312
- </View>
313
- </View>
314
- )
315
- }
1
+ import React from 'react'
2
+ import { DashboardLayout, Panel, View, Text, useLocale } from '@ossy/design-system'
3
+ import { useForecast } from '@ossy/calendar'
4
+ import { CurrentMonthForecastPanel } from './current-month.component.jsx'
5
+ import { KpiTrendPanel, UtilizationPanel, YearTotalsPanel } from './forecast-panels.jsx'
6
+ import { MonthDayGrid } from './MonthDayGrid.jsx'
316
7
 
317
8
  export const Forecast = () => {
318
9
  const months = useForecast()
319
- const contracts = useContracts()
320
- const employees = useEmployees()
321
- const vacations = useVacations()
322
- const sdk = useSdk()
323
- const { data: timesheetResources = [] } = sdk.read(ListResources, { location: TIMESHEET_LOCATION })
324
- const chartMonths = useMemo(() => withUtilizationHours({
325
- months,
326
- timesheets: (Array.isArray(timesheetResources) ? timesheetResources : [])
327
- .filter((resource) => resource.type === TIMESHEET_TYPE),
328
- vacations,
329
- employees,
330
- contracts,
331
- }), [months, timesheetResources, vacations, employees, contracts])
332
10
  const { language } = useLocale()
333
11
  const money = (value) => new Intl.NumberFormat(language === 'sv' ? 'sv-SE' : 'en-SE', { style: "currency", currency: "SEK" }).format(value)
334
12
  const hours = (value) => new Intl.NumberFormat(language === 'sv' ? 'sv-SE' : 'en-GB', { style: "unit", unit: "hour" }).format(value)
335
13
 
336
14
  return (
337
15
  <>
338
- <CalendarDaySurfaceStyles />
339
- <style href="@ossy/website-ossy/forecast-separator" precedence="medium">
340
- {`
341
- [data-separator][data-forecast-current-month="true"] {
342
- box-shadow: 0 0 0 1px var(--color-accent, hsl(167, 89%, 43%));
343
- }
344
- `}
345
- </style>
346
- <View gap="m" style={{ width: '100%' }}>
347
- <YearSummary months={chartMonths} money={money} hours={hours} />
348
- <UtilizationPanel months={chartMonths} />
349
- <div style={grid}>
350
-
16
+ <DashboardLayout gap="xs">
17
+ <DashboardLayout.Widget span={4}>
18
+ <CurrentMonthForecastPanel />
19
+ </DashboardLayout.Widget>
20
+ <DashboardLayout.Widget span={8}>
21
+ <UtilizationPanel />
22
+ </DashboardLayout.Widget>
23
+ <DashboardLayout.Widget span={4}>
24
+ <YearTotalsPanel />
25
+ </DashboardLayout.Widget>
26
+ <DashboardLayout.Widget span={8}>
27
+ <KpiTrendPanel />
28
+ </DashboardLayout.Widget>
351
29
  {months.map(month => {
352
- const startPad = month.days[0].isoWeekday - 1
353
- const totalCells = startPad + month.days.length
354
- const endPad = (7 - (totalCells % 7)) % 7
355
30
  const monthKey = `${month.year}-${month.month}`
356
31
 
357
32
  return (
358
- <View
359
- key={monthKey}
360
- inset="l"
361
- gap="m"
362
- surface="primary"
363
- roundness="m"
33
+ <DashboardLayout.Widget key={monthKey} span={3}>
34
+ <Panel
35
+ status={month.isCurrentMonth ? 'success' : undefined}
36
+ title={(
37
+ <Text variant="small" as="h2" style={{ fontWeight: 'bold' }}>
38
+ {month.year} {month.month}
39
+ </Text>
40
+ )}
41
+ style={{ minWidth: 0, flex: '1 1 auto' }}
364
42
  >
365
- <Text variant="heading-tertiary" as="h3">{month.year} {month.month}</Text>
366
- <Separator
367
- data-forecast-current-month={month.isCurrentMonth}
368
- variant={month.isCurrentMonth ? 'accent' : 'primary'}
369
- />
370
- <View gap="s" style={{ flexGrow: '1' }}>
43
+ <View gap="s" inset="m" style={{ flexGrow: 1 }}>
371
44
 
372
45
  <View layout="row" gap="s" style={{ justifyContent: 'space-between'}}>
373
46
  <Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.income" />
@@ -399,36 +72,12 @@ export const Forecast = () => {
399
72
 
400
73
  </View>
401
74
 
402
- <View style={{ height: 'var(--space-m)' }} />
403
-
404
- <div style={calendarGrid}>
405
-
406
- {Array.from({ length: startPad }, (_, i) => (
407
- <div key={`${monthKey}-pad-s-${i}`} />
408
- ))}
409
-
410
- {month.days.map(day => (
411
- <Text
412
- key={`${monthKey}-${day.monthDay}`}
413
- variant="small"
414
- data-ossy-calendar-day
415
- data-day-off={!day.isWorkday}
416
- style={calendarDayLayout}
417
- >
418
- {day.monthDay}
419
- </Text>
420
- ))}
421
-
422
- {Array.from({ length: endPad }, (_, i) => (
423
- <div key={`${monthKey}-pad-e-${i}`} />
424
- ))}
425
-
426
- </div>
427
- </View>
75
+ <MonthDayGrid month={month} />
76
+ </Panel>
77
+ </DashboardLayout.Widget>
428
78
  )
429
79
  })}
430
- </div>
431
- </View>
80
+ </DashboardLayout>
432
81
  </>
433
82
  )
434
83
  }
@@ -0,0 +1,68 @@
1
+ import React from 'react'
2
+ import { Text } from '@ossy/design-system'
3
+ import { CalendarDaySurfaceStyles } from '@ossy/calendar'
4
+
5
+ const calendarGrid = {
6
+ display: 'grid',
7
+ width: '100%',
8
+ minWidth: 0,
9
+ gridTemplateColumns: 'repeat(7, minmax(0, 1fr))',
10
+ gap: '4px',
11
+ justifyItems: 'center',
12
+ alignItems: 'center',
13
+ }
14
+
15
+ const calendarDayLayout = {
16
+ boxSizing: 'border-box',
17
+ display: 'flex',
18
+ justifyContent: 'center',
19
+ alignItems: 'center',
20
+ width: '100%',
21
+ maxWidth: 32,
22
+ aspectRatio: '1',
23
+ minWidth: 0,
24
+ borderRadius: '50%',
25
+ padding: 0,
26
+ fontSize: '.6rem',
27
+ margin: 0,
28
+ }
29
+
30
+ /**
31
+ * Day numbers for one forecast month, Monday first.
32
+ * Days off use the shared calendar day surface.
33
+ *
34
+ * @param {{ month?: { year?: number|string, month?: string, days?: Array<{ monthDay?: number|string, isoWeekday?: number, isWorkday?: boolean }> } }} props
35
+ */
36
+ export function MonthDayGrid ({ month }) {
37
+ const days = Array.isArray(month?.days) ? month.days : []
38
+ if (!days.length) return null
39
+
40
+ const startPad = Math.max(0, (Number(days[0].isoWeekday) || 1) - 1)
41
+ const endPad = (7 - ((startPad + days.length) % 7)) % 7
42
+ const monthKey = `${month.year}-${month.month}`
43
+
44
+ return (
45
+ <>
46
+ <CalendarDaySurfaceStyles />
47
+ <div style={{ ...calendarGrid, padding: '0 var(--space-m) var(--space-m)' }}>
48
+ {Array.from({ length: startPad }, (_, index) => (
49
+ <div key={`${monthKey}-pad-s-${index}`} />
50
+ ))}
51
+ {days.map((day) => (
52
+ <Text
53
+ key={`${monthKey}-${day.monthDay}`}
54
+ variant="small"
55
+ data-ossy-calendar-day
56
+ data-day-off={!day.isWorkday}
57
+ style={calendarDayLayout}
58
+ >
59
+ {day.monthDay}
60
+ </Text>
61
+ ))}
62
+ {Array.from({ length: endPad }, (_, index) => (
63
+ <div key={`${monthKey}-pad-e-${index}`} />
64
+ ))}
65
+ </div>
66
+ </>
67
+ )
68
+ }