@ossy/consultancy 3.20.1 → 3.22.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 (48) hide show
  1. package/package.json +4 -2
  2. package/src/AssignmentMarginCalculator.jsx +7 -32
  3. package/src/ConsultancyNav.jsx +30 -1
  4. package/src/ConsultancyRecordList.jsx +172 -0
  5. package/src/CreateConsultancyButton.jsx +61 -13
  6. package/src/Forecast.jsx +42 -220
  7. package/src/Overview.jsx +10 -31
  8. package/src/RequestStatsPanel.jsx +66 -0
  9. package/src/consultancy.page.jsx +3 -40
  10. package/src/contracts.page.jsx +26 -0
  11. package/src/current-month.component.jsx +43 -25
  12. package/src/employees.page.jsx +26 -0
  13. package/src/en.translations.json +67 -2
  14. package/src/extract-request.action.js +5 -0
  15. package/src/extract-request.task.js +100 -0
  16. package/src/extract-request.task.spec.js +89 -0
  17. package/src/forecast-panels.jsx +125 -0
  18. package/src/forecast-widget-menu.jsx +89 -0
  19. package/src/get-request-stats.action.js +6 -0
  20. package/src/get-request-stats.task.js +26 -0
  21. package/src/index.js +1 -0
  22. package/src/intake-categories.js +39 -0
  23. package/src/kpi-trend.component.jsx +17 -0
  24. package/src/margin-panels.jsx +7 -32
  25. package/src/opportunities.page.jsx +26 -0
  26. package/src/opportunity.schema.js +1 -1
  27. package/src/org.page.jsx +1 -2
  28. package/src/proposals.page.jsx +26 -0
  29. package/src/reports.page.jsx +103 -0
  30. package/src/request-buckets.js +76 -0
  31. package/src/request-buckets.spec.js +33 -0
  32. package/src/request-stats.aggregate.js +52 -0
  33. package/src/request-stats.aggregate.spec.js +34 -0
  34. package/src/request-stats.component.jsx +16 -0
  35. package/src/request.schema.js +29 -0
  36. package/src/requests.page.jsx +26 -0
  37. package/src/schema-ids.js +1 -0
  38. package/src/screen-inbound.task.js +84 -0
  39. package/src/screen-inbound.task.spec.js +97 -0
  40. package/src/sv.translations.json +67 -2
  41. package/src/use-chart-months.js +27 -0
  42. package/src/utilization-hours.js +196 -0
  43. package/src/utilization-hours.spec.js +134 -0
  44. package/src/utilization.component.jsx +17 -0
  45. package/src/vacations.page.jsx +26 -0
  46. package/src/year-totals.component.jsx +17 -0
  47. package/src/forecast-kpi-chart.js +0 -137
  48. package/src/forecast-kpi-chart.spec.js +0 -122
package/src/Forecast.jsx CHANGED
@@ -1,26 +1,17 @@
1
- import React, { useMemo } from 'react'
2
- import { View, Text, Separator, useLocale } from '@ossy/design-system'
3
- import { CalendarDaySurfaceStyles, sumFiscalYearTotals, useForecast } from '@ossy/calendar'
4
- import { buildKpiChartLayout } from './forecast-kpi-chart.js'
5
-
6
- const grid = {
7
- width: '100%',
8
- height: '100%',
9
- display: 'flex',
10
- flexDirection: 'row',
11
- flexWrap: 'wrap',
12
- gap: '1px',
13
- overflowX: 'auto',
14
- }
1
+ import React from 'react'
2
+ import { DashboardLayout, Panel, View, Text, useLocale } from '@ossy/design-system'
3
+ import { CalendarDaySurfaceStyles, useForecast } from '@ossy/calendar'
4
+ import { CurrentMonthForecastPanel } from './current-month.component.jsx'
5
+ import { KpiTrendPanel, UtilizationPanel, YearTotalsPanel } from './forecast-panels.jsx'
15
6
 
16
7
  const calendarGrid = {
17
8
  display: 'grid',
18
- justifyContent: 'center',
19
- alignItems: 'center',
20
- gridTemplateColumns: 'repeat(7, 40px)',
21
- gridAutoRows: 'repeat(6, 40px)',
22
- gap: 'var(--space-m)',
9
+ width: '100%',
10
+ minWidth: 0,
11
+ gridTemplateColumns: 'repeat(7, minmax(0, 1fr))',
12
+ gap: '4px',
23
13
  justifyItems: 'center',
14
+ alignItems: 'center',
24
15
  }
25
16
 
26
17
  const calendarDayLayout = {
@@ -28,183 +19,16 @@ const calendarDayLayout = {
28
19
  display: 'flex',
29
20
  justifyContent: 'center',
30
21
  alignItems: 'center',
22
+ width: '100%',
23
+ maxWidth: 32,
24
+ aspectRatio: '1',
25
+ minWidth: 0,
31
26
  borderRadius: '50%',
32
- padding: '8px',
27
+ padding: 0,
33
28
  fontSize: '.6rem',
34
29
  margin: 0,
35
30
  }
36
31
 
37
- const KPI_SERIES = [
38
- // --color-primary is paper white in Cloud themes; income must stay visible on surface-primary.
39
- { key: 'projectedIncome', label: 'consultancy.forecasts.income', color: 'var(--color-info, hsl(199, 89%, 43%))' },
40
- { key: 'monthlyCostOfEmployees', label: 'consultancy.forecasts.salaryCost', color: 'var(--color-warning, hsl(38, 92%, 50%))' },
41
- { key: 'revenue', label: 'consultancy.forecasts.revenue', color: 'var(--color-accent, hsl(167, 89%, 43%))' },
42
- { key: 'hoursWorked', label: 'consultancy.forecasts.hoursWorked', color: 'var(--fg-secondary, hsl(220, 10%, 45%))', dashed: true },
43
- ]
44
-
45
- function SectionPanel ({ title, children }) {
46
- return (
47
- <View surface="primary" roundness="xs" style={{ minWidth: 0, overflow: 'hidden', height: '100%' }}>
48
- <View stack bordered>
49
- <View.Item
50
- data-surface="primary"
51
- layout="row"
52
- style={{
53
- alignItems: 'center',
54
- justifyContent: 'space-between',
55
- padding: 'var(--space-s) var(--space-m)',
56
- gap: 'var(--space-m)',
57
- height: '48px',
58
- flexShrink: 0,
59
- }}
60
- >
61
- <Text variant="small" as="h2" style={{ fontWeight: 'bold' }}>{title}</Text>
62
- </View.Item>
63
- <View.Item>
64
- {children}
65
- </View.Item>
66
- </View>
67
- </View>
68
- )
69
- }
70
-
71
- /**
72
- * Hand-rolled multi-series line chart for fiscal-year KPIs.
73
- * Matches the no-dependency SVG approach from analytics DailyBarChart (#917).
74
- * Money KPIs share one Y-scale; hours use a secondary scale (dashed stroke).
75
- */
76
- function ForecastKpiChart ({ months }) {
77
- const { language } = useLocale()
78
- const chart = useMemo(
79
- () => buildKpiChartLayout({ months, series: KPI_SERIES, language }),
80
- [months, language],
81
- )
82
-
83
- if (!chart) {
84
- return (
85
- <View inset="m">
86
- <Text variant="small" text="consultancy.forecasts.yearChartEmpty" />
87
- </View>
88
- )
89
- }
90
-
91
- return (
92
- <View gap="s" inset="m" style={{ width: '100%' }}>
93
- <View layout="row-wrap" gap="m" style={{ alignItems: 'center' }}>
94
- {KPI_SERIES.map((series) => (
95
- <View key={series.key} layout="row" gap="s" style={{ alignItems: 'center' }}>
96
- <span
97
- aria-hidden
98
- style={{
99
- width: 10,
100
- height: 10,
101
- borderRadius: 2,
102
- background: series.color,
103
- display: 'inline-block',
104
- flexShrink: 0,
105
- ...(series.dashed
106
- ? {
107
- background: 'transparent',
108
- borderTop: `2px dashed ${series.color}`,
109
- height: 0,
110
- borderRadius: 0,
111
- }
112
- : null),
113
- }}
114
- />
115
- <Text variant="small" style={{ marginBottom: 0 }} text={series.label} />
116
- </View>
117
- ))}
118
- </View>
119
- <svg
120
- data-consultancy-kpi-chart
121
- viewBox={`0 0 ${chart.viewWidth} ${chart.viewHeight}`}
122
- width="100%"
123
- role="img"
124
- style={{
125
- display: 'block',
126
- width: '100%',
127
- height: 'auto',
128
- aspectRatio: `${chart.viewWidth} / ${chart.viewHeight}`,
129
- }}
130
- preserveAspectRatio="xMidYMid meet"
131
- >
132
- {chart.seriesPaths.map((series) => (
133
- series.path ? (
134
- <path
135
- key={series.key}
136
- d={series.path}
137
- fill="none"
138
- stroke={series.color}
139
- strokeWidth={2}
140
- strokeLinejoin="round"
141
- strokeLinecap="round"
142
- strokeDasharray={series.dashed ? '6 4' : undefined}
143
- vectorEffect="non-scaling-stroke"
144
- />
145
- ) : null
146
- ))}
147
- {chart.monthLabels.map((label) => (
148
- <text
149
- key={`month-${label.index}`}
150
- data-consultancy-kpi-month={label.label}
151
- x={label.x}
152
- y={label.y}
153
- textAnchor="middle"
154
- fill="var(--fg-secondary, currentColor)"
155
- fontSize={12}
156
- style={{ opacity: 0.75 }}
157
- >
158
- {label.label}
159
- </text>
160
- ))}
161
- </svg>
162
- </View>
163
- )
164
- }
165
-
166
- function YearSummary ({ months, money, hours }) {
167
- const { t } = useLocale()
168
- const totals = useMemo(() => sumFiscalYearTotals(months), [months])
169
-
170
- return (
171
- <View
172
- data-consultancy-year-summary
173
- layout="row-wrap"
174
- gap="m"
175
- style={{ alignItems: 'stretch', width: '100%' }}
176
- >
177
- <View style={{ flex: '2 1 320px', minWidth: 0 }}>
178
- <SectionPanel title={t('consultancy.forecasts.yearChart')}>
179
- <ForecastKpiChart months={months} />
180
- </SectionPanel>
181
- </View>
182
- <View style={{ flex: '1 1 240px', minWidth: 0 }}>
183
- <SectionPanel title={t('consultancy.forecasts.yearSummary')}>
184
- <View gap="s" inset="m">
185
- <View layout="row" gap="s" style={{ justifyContent: 'space-between' }}>
186
- <Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.income" />
187
- <Text variant="m" style={{ marginBottom: 0 }}>{money(totals.projectedIncome)}</Text>
188
- </View>
189
- <View layout="row" gap="s" style={{ justifyContent: 'space-between' }}>
190
- <Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.salaryCost" />
191
- <Text variant="m" style={{ marginBottom: 0 }}>{money(totals.monthlyCostOfEmployees)}</Text>
192
- </View>
193
- <View layout="row" gap="s" style={{ justifyContent: 'space-between' }}>
194
- <Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.revenue" />
195
- <Text variant="m" style={{ marginBottom: 0 }}>{money(totals.revenue)}</Text>
196
- </View>
197
- <View layout="row" gap="s" style={{ justifyContent: 'space-between' }}>
198
- <Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.hoursWorked" />
199
- <Text variant="m" style={{ marginBottom: 0 }}>{hours(totals.hoursWorked)}</Text>
200
- </View>
201
- </View>
202
- </SectionPanel>
203
- </View>
204
- </View>
205
- )
206
- }
207
-
208
32
  export const Forecast = () => {
209
33
  const months = useForecast()
210
34
  const { language } = useLocale()
@@ -214,17 +38,19 @@ export const Forecast = () => {
214
38
  return (
215
39
  <>
216
40
  <CalendarDaySurfaceStyles />
217
- <style href="@ossy/website-ossy/forecast-separator" precedence="medium">
218
- {`
219
- [data-separator][data-forecast-current-month="true"] {
220
- box-shadow: 0 0 0 1px var(--color-accent, hsl(167, 89%, 43%));
221
- }
222
- `}
223
- </style>
224
- <View gap="m" style={{ width: '100%' }}>
225
- <YearSummary months={months} money={money} hours={hours} />
226
- <div style={grid}>
227
-
41
+ <DashboardLayout gap="xs">
42
+ <DashboardLayout.Widget span={4}>
43
+ <CurrentMonthForecastPanel />
44
+ </DashboardLayout.Widget>
45
+ <DashboardLayout.Widget span={8}>
46
+ <UtilizationPanel />
47
+ </DashboardLayout.Widget>
48
+ <DashboardLayout.Widget span={4}>
49
+ <YearTotalsPanel />
50
+ </DashboardLayout.Widget>
51
+ <DashboardLayout.Widget span={8}>
52
+ <KpiTrendPanel />
53
+ </DashboardLayout.Widget>
228
54
  {months.map(month => {
229
55
  const startPad = month.days[0].isoWeekday - 1
230
56
  const totalCells = startPad + month.days.length
@@ -232,19 +58,17 @@ export const Forecast = () => {
232
58
  const monthKey = `${month.year}-${month.month}`
233
59
 
234
60
  return (
235
- <View
236
- key={monthKey}
237
- inset="l"
238
- gap="m"
239
- surface="primary"
240
- roundness="m"
61
+ <DashboardLayout.Widget key={monthKey} span={3}>
62
+ <Panel
63
+ status={month.isCurrentMonth ? 'success' : undefined}
64
+ title={(
65
+ <Text variant="small" as="h2" style={{ fontWeight: 'bold' }}>
66
+ {month.year} {month.month}
67
+ </Text>
68
+ )}
69
+ style={{ minWidth: 0, flex: '1 1 auto' }}
241
70
  >
242
- <Text variant="heading-tertiary" as="h3">{month.year} {month.month}</Text>
243
- <Separator
244
- data-forecast-current-month={month.isCurrentMonth}
245
- variant={month.isCurrentMonth ? 'accent' : 'primary'}
246
- />
247
- <View gap="s" style={{ flexGrow: '1' }}>
71
+ <View gap="s" inset="m" style={{ flexGrow: 1 }}>
248
72
 
249
73
  <View layout="row" gap="s" style={{ justifyContent: 'space-between'}}>
250
74
  <Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.income" />
@@ -276,9 +100,7 @@ export const Forecast = () => {
276
100
 
277
101
  </View>
278
102
 
279
- <View style={{ height: 'var(--space-m)' }} />
280
-
281
- <div style={calendarGrid}>
103
+ <div style={{ ...calendarGrid, padding: '0 var(--space-m) var(--space-m)' }}>
282
104
 
283
105
  {Array.from({ length: startPad }, (_, i) => (
284
106
  <div key={`${monthKey}-pad-s-${i}`} />
@@ -301,11 +123,11 @@ export const Forecast = () => {
301
123
  ))}
302
124
 
303
125
  </div>
304
- </View>
126
+ </Panel>
127
+ </DashboardLayout.Widget>
305
128
  )
306
129
  })}
307
- </div>
308
- </View>
130
+ </DashboardLayout>
309
131
  </>
310
132
  )
311
133
  }
package/src/Overview.jsx CHANGED
@@ -1,33 +1,7 @@
1
1
  import React from 'react'
2
- import { View, Text, useLocale } from '@ossy/design-system'
2
+ import { Panel, View, Text, useLocale } from '@ossy/design-system'
3
3
  import { useCompany } from '@ossy/calendar'
4
4
 
5
- function SectionPanel ({ title, children }) {
6
- return (
7
- <View surface="primary" roundness="xs" style={{ minWidth: 0, overflow: 'hidden', height: '100%' }}>
8
- <View stack bordered>
9
- <View.Item
10
- data-surface="primary"
11
- layout="row"
12
- style={{
13
- alignItems: 'center',
14
- justifyContent: 'space-between',
15
- padding: 'var(--space-s) var(--space-m)',
16
- gap: 'var(--space-m)',
17
- height: '48px',
18
- flexShrink: 0,
19
- }}
20
- >
21
- <Text variant="small" as="h2" style={{ fontWeight: 'bold' }}>{title}</Text>
22
- </View.Item>
23
- <View.Item>
24
- {children}
25
- </View.Item>
26
- </View>
27
- </View>
28
- )
29
- }
30
-
31
5
  function InfoRow ({ label, value }) {
32
6
  return (
33
7
  <View layout="row" justifyContent="space-between" gap="s">
@@ -63,7 +37,7 @@ export const Overview = () => {
63
37
  style={{ alignItems: 'stretch' }}
64
38
  >
65
39
  <View style={{ flex: '1 1 280px', minWidth: 0 }}>
66
- <SectionPanel title={t('consultancy.overview.fiscalYears')}>
40
+ <Panel title="consultancy.overview.fiscalYears" style={{ height: '100%' }}>
67
41
  <View gap="s" inset="m">
68
42
  {fiscalYears.length === 0 ? (
69
43
  <Text variant="small" text="consultancy.overview.noFiscalYears" />
@@ -74,11 +48,16 @@ export const Overview = () => {
74
48
  </View>
75
49
  ))}
76
50
  </View>
77
- </SectionPanel>
51
+ </Panel>
78
52
  </View>
79
53
 
80
54
  <View style={{ flex: '1 1 280px', minWidth: 0 }}>
81
- <SectionPanel title={company?.name || t('consultancy.overview.company')}>
55
+ <Panel
56
+ style={{ height: '100%' }}
57
+ title={company?.name
58
+ ? <Text variant="small" as="h2" style={{ fontWeight: 'bold' }}>{company.name}</Text>
59
+ : 'consultancy.overview.company'}
60
+ >
82
61
  <View gap="s" inset="m">
83
62
  <InfoRow
84
63
  label={t('@ossy/consultancy/schema/company-basic-info.registrationDate.label')}
@@ -105,7 +84,7 @@ export const Overview = () => {
105
84
  value={vatPeriodLabel}
106
85
  />
107
86
  </View>
108
- </SectionPanel>
87
+ </Panel>
109
88
  </View>
110
89
  </View>
111
90
  )
@@ -0,0 +1,66 @@
1
+ import React, { useEffect, useState } from 'react'
2
+ import { LineChart, Panel } from '@ossy/design-system'
3
+ import { useSdk } from '@ossy/sdk-react'
4
+ import { ForecastWidgetMenu } from './forecast-widget-menu.jsx'
5
+
6
+ export const REQUEST_STATS_WIDGET_ID = '@ossy/consultancy/view/request-stats'
7
+ const GetRequestStats = { id: '@ossy/consultancy/actions/get-request-stats' }
8
+
9
+ const SERIES = [
10
+ {
11
+ key: 'count',
12
+ label: 'consultancy.requests.statsSeries',
13
+ color: 'var(--color-info, hsl(199, 89%, 43%))',
14
+ },
15
+ ]
16
+
17
+ /**
18
+ * Monthly incoming requests, dated by the email Date header.
19
+ */
20
+ export function RequestStatsChart () {
21
+ const sdk = useSdk()
22
+ const [months, setMonths] = useState([])
23
+
24
+ useEffect(() => {
25
+ let cancelled = false
26
+ sdk.invoke(GetRequestStats, {})
27
+ .then((json) => {
28
+ if (cancelled) return
29
+ setMonths(Array.isArray(json?.months) ? json.months : [])
30
+ })
31
+ .catch(() => {
32
+ if (!cancelled) setMonths([])
33
+ })
34
+ return () => {
35
+ cancelled = true
36
+ }
37
+ }, [sdk])
38
+
39
+ return (
40
+ <LineChart
41
+ months={months}
42
+ series={SERIES}
43
+ unit="consultancy.requests.statsUnit"
44
+ empty="consultancy.requests.statsEmpty"
45
+ />
46
+ )
47
+ }
48
+
49
+ export function RequestStatsPanel ({ dashboardId, pinnedWidgetId }) {
50
+ return (
51
+ <Panel
52
+ title="consultancy.requests.statsTitle"
53
+ style={{ height: 'auto', flex: '0 0 auto' }}
54
+ data-request-stats
55
+ actions={(
56
+ <ForecastWidgetMenu
57
+ componentId={REQUEST_STATS_WIDGET_ID}
58
+ dashboardId={dashboardId}
59
+ pinnedWidgetId={pinnedWidgetId}
60
+ />
61
+ )}
62
+ >
63
+ <RequestStatsChart />
64
+ </Panel>
65
+ )
66
+ }
@@ -1,7 +1,5 @@
1
- import React, { useState } from 'react'
2
- import { Button, Text, View, Page, Tags } from '@ossy/design-system'
3
- import { useSdk } from '@ossy/sdk-react'
4
- import { PinWidget } from '@ossy/dashboard'
1
+ import React from 'react'
2
+ import { View, Page, Tags } from '@ossy/design-system'
5
3
  import { Forecast } from './Forecast.jsx'
6
4
  import { DataLoader } from '@ossy/calendar'
7
5
  import { Definition } from './Definition.js'
@@ -16,56 +14,21 @@ export const metadata = {
16
14
  },
17
15
  }
18
16
 
19
- const FORECAST_WIDGET_ID = '@ossy/consultancy/view/current-month'
20
-
21
17
  export const ConsultancyPage = () => {
22
- const sdk = useSdk()
23
- const [pinState, setPinState] = useState('idle')
24
-
25
18
  const statusTags = (Definition.status ?? [])
26
19
  .map((s) => ({ beta: 'Beta', 'coming-soon': 'Coming Soon' }[s]))
27
20
  .filter(Boolean)
28
21
 
29
- const pinToDashboard = async () => {
30
- if (pinState === 'pending') return
31
- setPinState('pending')
32
- try {
33
- await sdk.invoke(PinWidget, { componentId: FORECAST_WIDGET_ID })
34
- setPinState('done')
35
- } catch {
36
- setPinState('error')
37
- }
38
- }
39
-
40
22
  return (
41
23
  <Page
42
24
  data-forecasts-status="on"
43
25
  title="consultancy.home.title"
44
26
  near={statusTags.length > 0 ? <Tags tags={statusTags} size="s" /> : undefined}
45
27
  description="consultancy.home.description"
46
- far={(
47
- <View layout="row" gap="s" style={{ flexWrap: 'wrap' }}>
48
- <Button
49
- {...PinWidget}
50
- variant="primary"
51
- disabled={pinState === 'pending' || pinState === 'done'}
52
- label={
53
- pinState === 'done'
54
- ? 'consultancy.forecasts.pin.done'
55
- : pinState === 'error'
56
- ? 'consultancy.forecasts.pin.error'
57
- : 'consultancy.forecasts.pin.forecast'
58
- }
59
- onClick={pinToDashboard}
60
- data-forecasts-pin
61
- />
62
- <CreateConsultancyButton />
63
- </View>
64
- )}
28
+ far={<CreateConsultancyButton />}
65
29
  >
66
30
  <View gap="m">
67
31
  <ConsultancyNav active="consultancy/home" />
68
- <Text variant="heading-secondary" as="h2" text="design-system.overview" />
69
32
  <DataLoader content={<Forecast />} />
70
33
  </View>
71
34
  </Page>
@@ -0,0 +1,26 @@
1
+ import React from 'react'
2
+ import { ConsultancyRecordPage } from './ConsultancyRecordList.jsx'
3
+ import { ConsultancySchema } from './schema-ids.js'
4
+ import contractSchema from './contract.schema.js'
5
+
6
+ export const metadata = {
7
+ id: 'consultancy/contracts',
8
+ path: {
9
+ sv: '/konsultverksamhet/avtal',
10
+ en: '/consultancy/contracts',
11
+ },
12
+ }
13
+
14
+ export const ContractsPage = () => (
15
+ <ConsultancyRecordPage
16
+ active="consultancy/contracts"
17
+ title="consultancy.contracts.title"
18
+ description="consultancy.contracts.description"
19
+ schemaId={ConsultancySchema.contract}
20
+ icon={contractSchema.icon}
21
+ listHeader="consultancy.nav.contracts"
22
+ emptyText="consultancy.contracts.empty"
23
+ />
24
+ )
25
+
26
+ export default ContractsPage
@@ -1,6 +1,11 @@
1
1
  import React from 'react'
2
- import { View, Text, useLocale } from '@ossy/design-system'
2
+ import { Panel, Text, View, useLocale } from '@ossy/design-system'
3
3
  import { DataLoader, useForecast } from '@ossy/calendar'
4
+ import { ForecastWidgetMenu } from './forecast-widget-menu.jsx'
5
+
6
+ export const CURRENT_MONTH_WIDGET_ID = '@ossy/consultancy/view/current-month'
7
+
8
+ const panelStyle = { height: '100%', flex: '1 1 auto', minWidth: 0 }
4
9
 
5
10
  function MetricRow ({ label, value }) {
6
11
  return (
@@ -12,11 +17,11 @@ function MetricRow ({ label, value }) {
12
17
  }
13
18
 
14
19
  /**
15
- * Compact current-month forecast metrics (standalone dashboard panel).
20
+ * Compact current-month forecast metrics, using the shared Panel header.
16
21
  */
17
- export function CurrentMonthForecastPanel () {
22
+ export function CurrentMonthForecastPanel ({ dashboardId, pinnedWidgetId }) {
18
23
  const months = useForecast()
19
- const { language } = useLocale()
24
+ const { language, t } = useLocale()
20
25
  const money = (value) => new Intl.NumberFormat(language === 'sv' ? 'sv-SE' : 'en-SE', {
21
26
  style: 'currency',
22
27
  currency: 'SEK',
@@ -29,38 +34,51 @@ export function CurrentMonthForecastPanel () {
29
34
  const current = (Array.isArray(months) ? months : []).find((m) => m.isCurrentMonth)
30
35
  ?? (Array.isArray(months) ? months[0] : null)
31
36
 
32
- if (!current) {
33
- return (
34
- <Text
35
- color="secondary"
36
- text="consultancy.forecasts.widget.empty"
37
- data-forecasts-widget="current-month"
38
- />
39
- )
40
- }
37
+ const actions = (
38
+ <ForecastWidgetMenu
39
+ componentId={CURRENT_MONTH_WIDGET_ID}
40
+ dashboardId={dashboardId}
41
+ pinnedWidgetId={pinnedWidgetId}
42
+ />
43
+ )
41
44
 
42
45
  return (
43
- <View gap="s" data-forecasts-widget="current-month">
44
- <Text variant="heading-tertiary" as="h3">
45
- {current.year} {current.month}
46
- </Text>
47
- <MetricRow label="consultancy.forecasts.income" value={money(current.projectedIncome)} />
48
- <MetricRow label="consultancy.forecasts.salaryCost" value={money(current.monthlyCostOfEmployees)} />
49
- <MetricRow label="consultancy.forecasts.revenue" value={money(current.revenue)} />
50
- <MetricRow label="consultancy.forecasts.hoursWorked" value={hours(current.hoursWorked)} />
51
- </View>
46
+ <Panel
47
+ title={current ? (
48
+ <Text variant="small" as="h2" style={{ fontWeight: 'bold' }}>
49
+ {t('consultancy.forecasts.monthForecast', { month: current.month })}
50
+ </Text>
51
+ ) : 'consultancy.widgets.forecastCurrentMonth.title'}
52
+ style={panelStyle}
53
+ actions={actions}
54
+ data-forecasts-widget="current-month"
55
+ >
56
+ {!current ? (
57
+ <View inset="m">
58
+ <Text color="secondary" text="consultancy.forecasts.widget.empty" />
59
+ </View>
60
+ ) : (
61
+ <View gap="s" inset="m">
62
+ <MetricRow label="consultancy.forecasts.income" value={money(current.projectedIncome)} />
63
+ <MetricRow label="consultancy.forecasts.salaryCost" value={money(current.monthlyCostOfEmployees)} />
64
+ <MetricRow label="consultancy.forecasts.revenue" value={money(current.revenue)} />
65
+ <MetricRow label="consultancy.forecasts.hoursWorked" value={hours(current.hoursWorked)} />
66
+ </View>
67
+ )}
68
+ </Panel>
52
69
  )
53
70
  }
54
71
 
55
72
  export const metadata = {
56
- id: '@ossy/consultancy/view/current-month',
73
+ id: CURRENT_MONTH_WIDGET_ID,
57
74
  widget: {
58
75
  title: 'consultancy.widgets.forecastCurrentMonth.title',
59
76
  description: 'consultancy.widgets.forecastCurrentMonth.description',
77
+ ownsHeader: true,
60
78
  },
61
79
  }
62
80
 
63
81
  /** Slot widget — current-month forecast panel for dashboards. */
64
- export default function CurrentMonthForecastWidget () {
65
- return <DataLoader content={<CurrentMonthForecastPanel />} />
82
+ export default function CurrentMonthForecastWidget (props) {
83
+ return <DataLoader content={<CurrentMonthForecastPanel {...props} />} />
66
84
  }
@@ -0,0 +1,26 @@
1
+ import React from 'react'
2
+ import { ConsultancyRecordPage } from './ConsultancyRecordList.jsx'
3
+ import { ConsultancySchema } from './schema-ids.js'
4
+ import employeeSchema from './employee.schema.js'
5
+
6
+ export const metadata = {
7
+ id: 'consultancy/employees',
8
+ path: {
9
+ sv: '/konsultverksamhet/anstallda',
10
+ en: '/consultancy/employees',
11
+ },
12
+ }
13
+
14
+ export const EmployeesPage = () => (
15
+ <ConsultancyRecordPage
16
+ active="consultancy/employees"
17
+ title="consultancy.employees.title"
18
+ description="consultancy.employees.description"
19
+ schemaId={ConsultancySchema.employee}
20
+ icon={employeeSchema.icon}
21
+ listHeader="consultancy.nav.employees"
22
+ emptyText="consultancy.employees.empty"
23
+ />
24
+ )
25
+
26
+ export default EmployeesPage