@seriousgaming/sdk-tools 1.4.0 → 1.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.
- package/dist/cli.js +830 -99
- package/dist/client.js +114 -11
- package/dist/dev/console/assets/{index-BvB-LFQZ.js → index-BVF8exas.js} +21 -21
- package/dist/dev/console/index.html +1 -1
- package/dist/dev/public-origins.d.ts +61 -0
- package/dist/dev/shell.d.ts +32 -4
- package/dist/docs/ai-agents.md +5 -0
- package/dist/docs/changelog-0.x.md +2 -2
- package/dist/docs/changelog.md +37 -4
- package/dist/docs/cli-and-dev-server.md +58 -0
- package/dist/docs/cli-error-codes.md +39 -36
- package/dist/docs/cli-reference.md +68 -21
- package/dist/docs/environment-variables.md +10 -5
- package/dist/docs/guides/ai-facilitation.md +2 -0
- package/dist/docs/guides/capabilities.md +2 -0
- package/dist/docs/guides/designing-a-game.md +2 -0
- package/dist/docs/guides/designing-screens.md +133 -0
- package/dist/docs/guides/endpoints.md +2 -0
- package/dist/docs/guides/engine-testing.md +5 -1
- package/dist/docs/guides/engine.md +2 -0
- package/dist/docs/guides/file-handling.md +3 -1
- package/dist/docs/guides/games.md +3 -1
- package/dist/docs/guides/global-settings.md +2 -0
- package/dist/docs/guides/guide.md +2 -0
- package/dist/docs/guides/hooks.md +2 -0
- package/dist/docs/guides/index.md +9 -0
- package/dist/docs/guides/internationalization.md +2 -0
- package/dist/docs/guides/llm-integration.md +4 -2
- package/dist/docs/guides/multi-team-games.md +3 -1
- package/dist/docs/guides/patterns.md +2 -0
- package/dist/docs/guides/presentation.md +1 -1
- package/dist/docs/guides/production-constraints.md +2 -0
- package/dist/docs/guides/scenario-editor.md +2 -0
- package/dist/docs/guides/scenarios.md +6 -2
- package/dist/docs/guides/session-game-flow.md +365 -0
- package/dist/docs/guides/session-hooks.md +205 -0
- package/dist/docs/guides/session.md +27 -565
- package/dist/docs/guides/settings.md +2 -0
- package/dist/docs/guides/setup.md +3 -1
- package/dist/docs/guides/speech-generation.md +2 -0
- package/dist/docs/guides/starter-game.md +61 -21
- package/dist/docs/guides/testing.md +2 -0
- package/dist/docs/guides/tick-controller.md +3 -1
- package/dist/docs/guides/type-safety.md +2 -0
- package/dist/docs/guides/ui-files-and-llms.md +328 -0
- package/dist/docs/guides/ui-participants.md +281 -0
- package/dist/docs/guides/ui-styling.md +263 -0
- package/dist/docs/guides/ui-ticks.md +247 -0
- package/dist/docs/guides/ui.md +11 -1092
- package/dist/docs/guides/upgrading.md +2 -0
- package/dist/docs/guides/validators.md +2 -0
- package/dist/docs/guides/waiting-room.md +1 -1
- package/dist/docs/index.md +2 -1
- package/dist/docs/page-index.md +145 -0
- package/dist/docs/recipes/adapt-a-game-for-walkthroughs.md +1 -1
- package/dist/docs/recipes/adapt-ui-for-observers.md +1 -1
- package/dist/docs/recipes/create-presentation.md +11 -0
- package/dist/docs/recipes/create-scenario-editor.md +1 -0
- package/dist/docs/recipes/create-session-ui.md +2 -1
- package/dist/docs/recipes/create-setup.md +1 -0
- package/dist/docs/recipes/create-user-interface.md +1 -0
- package/dist/docs/recipes/create-waiting-room-ui.md +1 -0
- package/dist/docs/recipes/design-state-for-concurrent-writes.md +1 -1
- package/dist/docs/recipes/fix-duplicate-packages.md +2 -2
- package/dist/docs/recipes/index.md +3 -0
- package/dist/docs/recipes/screenshot-a-surface.md +80 -0
- package/dist/docs/recipes/test-a-multi-role-game.md +1 -1
- package/dist/docs/recipes/use-request-tick.md +2 -2
- package/dist/execution/config-resolver.d.ts +4 -1
- package/dist/runtime/manifest-version.d.ts +1 -1
- package/dist/runtime.js +1 -1
- package/dist/templates/package/CLAUDE.md.template +14 -5
- package/dist/templates/package/DESIGN.md.liquid +39 -7
- package/dist/templates/package/README.md.liquid +1 -1
- package/dist/templates/package/claude/rules/workflow-create-user-interface.md +1 -1
- package/dist/templates/package/pnpm-workspace.yaml.template +13 -0
- package/dist/templates/starter-game/capabilities/pacing/capability.sdk.json +18 -0
- package/dist/templates/starter-game/package.json +2 -0
- package/dist/templates/starter-game/presentation/defaults.ts +52 -0
- package/dist/templates/starter-game/presentation/index.html +20 -0
- package/dist/templates/starter-game/presentation/presentation.sdk.json +10 -0
- package/dist/templates/starter-game/presentation/src/App.tsx +55 -0
- package/dist/templates/starter-game/presentation/src/Band.tsx +40 -0
- package/dist/templates/starter-game/presentation/src/Slides.tsx +415 -0
- package/dist/templates/starter-game/presentation/src/WeatherIcon.tsx +21 -0
- package/dist/templates/starter-game/presentation/src/i18n.ts +88 -0
- package/dist/templates/starter-game/presentation/src/main.tsx +15 -0
- package/dist/templates/starter-game/presentation/src/stalls.test.ts +196 -0
- package/dist/templates/starter-game/presentation/src/stalls.ts +199 -0
- package/dist/templates/starter-game/presentation/types.ts +94 -0
- package/dist/templates/starter-game/seriousgaming.sdk.json +2 -1
- package/dist/templates/starter-game/session/defaults.ts +6 -0
- package/dist/templates/starter-game/session/index.html +1 -1
- package/dist/templates/starter-game/session/session.sdk.json +2 -2
- package/dist/templates/starter-game/session/src/App.test.tsx +436 -115
- package/dist/templates/starter-game/session/src/App.tsx +372 -222
- package/dist/templates/starter-game/session/src/JoinCodes.tsx +184 -0
- package/dist/templates/starter-game/session/src/ManagePanel.tsx +188 -0
- package/dist/templates/starter-game/session/src/Results.tsx +340 -0
- package/dist/templates/starter-game/session/src/SessionBar.tsx +179 -0
- package/dist/templates/starter-game/session/src/SessionPanels.tsx +105 -0
- package/dist/templates/starter-game/session/src/SidePanel.tsx +89 -0
- package/dist/templates/starter-game/session/src/StallCard.tsx +253 -0
- package/dist/templates/starter-game/session/src/TopBar.tsx +36 -0
- package/dist/templates/starter-game/session/src/i18n.ts +91 -24
- package/dist/templates/starter-game/session/src/status.ts +28 -0
- package/dist/templates/starter-game/session/types.ts +8 -2
- package/dist/templates/starter-game/shared/Awning.tsx +31 -0
- package/dist/templates/starter-game/shared/HostLogo.test.tsx +38 -0
- package/dist/templates/starter-game/shared/HostLogo.tsx +48 -0
- package/dist/templates/starter-game/shared/StallIcons.tsx +83 -0
- package/dist/templates/starter-game/shared/days.ts +11 -0
- package/dist/templates/starter-game/shared/format.test.ts +13 -0
- package/dist/templates/starter-game/{ui/src → shared}/format.ts +1 -1
- package/dist/templates/starter-game/testing/e2e/game.spec.ts +42 -8
- package/dist/templates/starter-game/ui/defaults.ts +3 -0
- package/dist/templates/starter-game/ui/src/App.test.tsx +197 -29
- package/dist/templates/starter-game/ui/src/App.tsx +176 -99
- package/dist/templates/starter-game/ui/src/DayBar.test.tsx +50 -7
- package/dist/templates/starter-game/ui/src/DayBar.tsx +96 -38
- package/dist/templates/starter-game/ui/src/DaysTable.tsx +69 -0
- package/dist/templates/starter-game/ui/src/FirstDay.tsx +37 -0
- package/dist/templates/starter-game/ui/src/Header.tsx +257 -0
- package/dist/templates/starter-game/ui/src/Lesson.tsx +63 -0
- package/dist/templates/starter-game/ui/src/MakeRow.tsx +98 -71
- package/dist/templates/starter-game/ui/src/Notices.tsx +59 -0
- package/dist/templates/starter-game/ui/src/PastDay.tsx +88 -0
- package/dist/templates/starter-game/ui/src/Section.tsx +26 -26
- package/dist/templates/starter-game/ui/src/ThemeToggle.tsx +25 -11
- package/dist/templates/starter-game/ui/src/TodayPanel.test.tsx +37 -33
- package/dist/templates/starter-game/ui/src/TodayPanel.tsx +66 -52
- package/dist/templates/starter-game/ui/src/WeatherCard.tsx +47 -0
- package/dist/templates/starter-game/ui/src/WeekOver.tsx +145 -0
- package/dist/templates/starter-game/ui/src/YesterdayPanel.tsx +65 -114
- package/dist/templates/starter-game/ui/src/days.ts +58 -0
- package/dist/templates/starter-game/ui/src/i18n.ts +86 -32
- package/dist/templates/starter-game/ui/src/test-helpers.ts +1 -0
- package/dist/templates/starter-game/ui/src/theme.ts +8 -8
- package/dist/templates/starter-game/ui/types.ts +6 -0
- package/dist/templates/starter-game/ui/ui.sdk.json +1 -1
- package/dist/templates/starter-game/validators/daylimit/defaults.ts +13 -0
- package/dist/templates/starter-game/validators/daylimit/logic/logic.test.ts +20 -0
- package/dist/templates/starter-game/validators/daylimit/logic/logic.ts +23 -0
- package/dist/templates/starter-game/validators/daylimit/types.ts +23 -0
- package/dist/templates/starter-game/validators/daylimit/validator.sdk.json +10 -0
- package/dist/templates/starter-game/waiting_room/src/App.test.tsx +83 -5
- package/dist/templates/starter-game/waiting_room/src/App.tsx +262 -119
- package/dist/templates/starter-game/waiting_room/src/i18n.ts +8 -4
- package/dist/utils/error-codes.d.ts +12 -0
- package/package.json +11 -4
- package/dist/templates/starter-game/session/src/Section.tsx +0 -37
- package/dist/templates/starter-game/session/src/TeamDoor.tsx +0 -96
- package/dist/templates/starter-game/session/src/format.ts +0 -8
- package/dist/templates/starter-game/ui/src/HistoryPanel.test.tsx +0 -74
- package/dist/templates/starter-game/ui/src/HistoryPanel.tsx +0 -120
- package/dist/templates/starter-game/ui/src/HostLogo.test.tsx +0 -25
- package/dist/templates/starter-game/ui/src/HostLogo.tsx +0 -38
|
@@ -1,87 +1,138 @@
|
|
|
1
|
+
import HistoryRounded from '@mui/icons-material/HistoryRounded';
|
|
1
2
|
import {
|
|
2
3
|
Alert,
|
|
3
|
-
AppBar,
|
|
4
4
|
Box,
|
|
5
|
-
Chip,
|
|
6
5
|
CssBaseline,
|
|
7
6
|
LinearProgress,
|
|
8
|
-
Snackbar,
|
|
9
7
|
Stack,
|
|
10
8
|
ThemeProvider,
|
|
11
|
-
Toolbar,
|
|
12
9
|
Typography,
|
|
13
10
|
useMediaQuery,
|
|
14
11
|
useTheme,
|
|
15
12
|
} from '@mui/material';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
useUserInterfaceData,
|
|
20
|
-
useUserInterfaceParticipant,
|
|
21
|
-
useUserInterfaceValidationRejections,
|
|
22
|
-
} from '@seriousgaming/sdk/ui';
|
|
13
|
+
import { alpha } from '@mui/material/styles';
|
|
14
|
+
import { useMutationReporter, useUserInterfaceData } from '@seriousgaming/sdk/ui';
|
|
15
|
+
import { useState } from 'react';
|
|
23
16
|
import { useTranslation } from 'react-i18next';
|
|
24
17
|
|
|
18
|
+
import { Awning } from '../../shared/Awning';
|
|
25
19
|
import type { Settings, Context } from '../types';
|
|
26
20
|
import DayBar from './DayBar';
|
|
27
|
-
import
|
|
28
|
-
import
|
|
21
|
+
import { useDays, WEEK_LENGTH } from './days';
|
|
22
|
+
import DaysTable from './DaysTable';
|
|
23
|
+
import FirstDay from './FirstDay';
|
|
24
|
+
import Header, { type Phase } from './Header';
|
|
25
|
+
import Notices from './Notices';
|
|
26
|
+
import PastDay from './PastDay';
|
|
27
|
+
import Section from './Section';
|
|
29
28
|
import { useAppTheme } from './theme';
|
|
30
|
-
import ThemeToggle from './ThemeToggle';
|
|
31
29
|
import TodayPanel from './TodayPanel';
|
|
30
|
+
import WeatherCard from './WeatherCard';
|
|
31
|
+
import WeekOver from './WeekOver';
|
|
32
32
|
import { WriteContext } from './writes';
|
|
33
33
|
import YesterdayPanel from './YesterdayPanel';
|
|
34
34
|
|
|
35
|
-
/** Wide enough for
|
|
36
|
-
const CONTENT_MAX_WIDTH =
|
|
35
|
+
/** Wide enough for two columns on a laptop without letting them drift apart on an ultrawide monitor. */
|
|
36
|
+
const CONTENT_MAX_WIDTH = 1180;
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* One screen, decision first.
|
|
40
|
+
*
|
|
41
|
+
* Top to bottom: the stall's sign, the forecast, what to make, then how
|
|
42
|
+
* yesterday went. The order is the order a team thinks in at the start of a
|
|
43
|
+
* day, and it puts the controls under the thumb before any results. At laptop
|
|
44
|
+
* width the results move to a column of their own beside the decision rather
|
|
45
|
+
* than below it, because a team round one screen reads both at once.
|
|
46
|
+
*
|
|
47
|
+
* The screen has four states, each designed rather than left to fall out of
|
|
48
|
+
* the data: before the first day, mid-week, looking back at a past day, and
|
|
49
|
+
* after the last day.
|
|
50
|
+
*/
|
|
38
51
|
function Shell() {
|
|
39
|
-
const { data,
|
|
40
|
-
Context,
|
|
41
|
-
Settings
|
|
42
|
-
>();
|
|
43
|
-
const participant = useUserInterfaceParticipant();
|
|
44
|
-
const ownTeam = useUserInterfaceOwnTeam();
|
|
45
|
-
const { rejections, clearRejections } = useUserInterfaceValidationRejections();
|
|
52
|
+
const { data, completedTicks, isRoundProcessing } = useUserInterfaceData<Context, Settings>();
|
|
46
53
|
const reporter = useMutationReporter();
|
|
47
54
|
const { t } = useTranslation();
|
|
48
55
|
const theme = useTheme();
|
|
49
|
-
const
|
|
56
|
+
const wide = useMediaQuery(theme.breakpoints.up('md'));
|
|
57
|
+
const { days } = useDays();
|
|
58
|
+
const [lookingAtChoice, setLookingAt] = useState<number | null>(null);
|
|
50
59
|
|
|
51
|
-
const
|
|
52
|
-
|
|
60
|
+
const phase: Phase =
|
|
61
|
+
completedTicks >= WEEK_LENGTH ? 'over' : completedTicks === 0 ? 'first' : 'week';
|
|
62
|
+
const day = completedTicks + 1;
|
|
63
|
+
const held = day > data.pacing.LastOpenDay;
|
|
53
64
|
const briefing = data.briefing.Message;
|
|
54
65
|
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
reporter.failure && reporter.failure.outcome.kind !== 'validation-rejected'
|
|
61
|
-
? reporter.failure
|
|
66
|
+
// An undo can take away the day being looked at; the screen then simply
|
|
67
|
+
// comes back to today rather than showing a day that no longer happened.
|
|
68
|
+
const lookingAt =
|
|
69
|
+
phase === 'week' && lookingAtChoice !== null && lookingAtChoice <= completedTicks
|
|
70
|
+
? lookingAtChoice
|
|
62
71
|
: null;
|
|
63
72
|
|
|
73
|
+
const decision = (
|
|
74
|
+
<Stack spacing={3}>
|
|
75
|
+
<WeatherCard />
|
|
76
|
+
<TodayPanel wide={wide} />
|
|
77
|
+
</Stack>
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
let main;
|
|
81
|
+
if (lookingAt !== null) {
|
|
82
|
+
main = (
|
|
83
|
+
<Box sx={{ maxWidth: 640, mx: 'auto', width: '100%' }}>
|
|
84
|
+
<PastDay results={days.find((d) => d.Day === lookingAt)} />
|
|
85
|
+
</Box>
|
|
86
|
+
);
|
|
87
|
+
} else if (phase === 'over') {
|
|
88
|
+
main = (
|
|
89
|
+
<Box sx={{ maxWidth: 760, mx: 'auto', width: '100%' }}>
|
|
90
|
+
<WeekOver days={days} wide={wide} />
|
|
91
|
+
</Box>
|
|
92
|
+
);
|
|
93
|
+
} else if (phase === 'first') {
|
|
94
|
+
main = wide ? (
|
|
95
|
+
<Columns left={decision} right={<FirstDay held={held} />} />
|
|
96
|
+
) : (
|
|
97
|
+
<Stack spacing={3}>
|
|
98
|
+
<FirstDay held={held} />
|
|
99
|
+
{decision}
|
|
100
|
+
</Stack>
|
|
101
|
+
);
|
|
102
|
+
} else {
|
|
103
|
+
main = wide ? (
|
|
104
|
+
<Columns
|
|
105
|
+
left={decision}
|
|
106
|
+
right={
|
|
107
|
+
<Stack spacing={2}>
|
|
108
|
+
<YesterdayPanel days={days} wide />
|
|
109
|
+
<Section title={t('history.title')}>
|
|
110
|
+
<DaysTable days={days} wide />
|
|
111
|
+
</Section>
|
|
112
|
+
</Stack>
|
|
113
|
+
}
|
|
114
|
+
/>
|
|
115
|
+
) : (
|
|
116
|
+
<Stack spacing={3}>
|
|
117
|
+
{decision}
|
|
118
|
+
<YesterdayPanel days={days} />
|
|
119
|
+
</Stack>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
64
123
|
return (
|
|
65
124
|
<WriteContext.Provider value={reporter}>
|
|
66
125
|
<Box sx={{ display: 'flex', flexDirection: 'column', height: '100vh' }}>
|
|
67
|
-
<
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
size="small"
|
|
78
|
-
color="primary"
|
|
79
|
-
label={t('shell.day', { day: completedTicks + 1 })}
|
|
80
|
-
data-testid="day"
|
|
81
|
-
/>
|
|
82
|
-
<ThemeToggle />
|
|
83
|
-
</Toolbar>
|
|
84
|
-
</AppBar>
|
|
126
|
+
<Box sx={{ flex: '0 0 auto' }}>
|
|
127
|
+
<Header
|
|
128
|
+
phase={phase}
|
|
129
|
+
held={held}
|
|
130
|
+
lookingAt={lookingAt}
|
|
131
|
+
onLook={setLookingAt}
|
|
132
|
+
wide={wide}
|
|
133
|
+
/>
|
|
134
|
+
<Awning depth={14} />
|
|
135
|
+
</Box>
|
|
85
136
|
|
|
86
137
|
{/* One band per reason the screen is not simply waiting for the
|
|
87
138
|
team. Each says which reason it is: a surface that only greys
|
|
@@ -109,62 +160,88 @@ function Shell() {
|
|
|
109
160
|
</Alert>
|
|
110
161
|
)}
|
|
111
162
|
|
|
112
|
-
<Box
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
163
|
+
<Box
|
|
164
|
+
component="main"
|
|
165
|
+
sx={{ flex: 1, minHeight: 0, overflowY: 'auto', pt: 1, pb: 3 }}
|
|
166
|
+
>
|
|
167
|
+
<Stack
|
|
168
|
+
spacing={2.25}
|
|
169
|
+
sx={{ maxWidth: CONTENT_MAX_WIDTH, mx: 'auto', px: wide ? 4 : 2 }}
|
|
170
|
+
>
|
|
171
|
+
{/* After the last day there is no bar to carry them. */}
|
|
172
|
+
{phase === 'over' && <Notices />}
|
|
173
|
+
{lookingAt !== null && <LookingBack day={lookingAt} today={day} />}
|
|
174
|
+
{main}
|
|
117
175
|
</Stack>
|
|
118
176
|
</Box>
|
|
119
177
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
{unexplained?.outcome.kind === 'tick-failed'
|
|
144
|
-
? t('shell.weekOver')
|
|
145
|
-
: t('shell.writeFailed')}
|
|
146
|
-
</Alert>
|
|
147
|
-
</Snackbar>
|
|
148
|
-
|
|
149
|
-
{/* Not a failure. The change landed, but in the day after the one
|
|
150
|
-
they were looking at, and nothing else on screen says so. */}
|
|
151
|
-
<Snackbar
|
|
152
|
-
open={reporter.late !== null}
|
|
153
|
-
onClose={reporter.dismiss}
|
|
154
|
-
autoHideDuration={8000}
|
|
155
|
-
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
|
|
156
|
-
>
|
|
157
|
-
<Alert severity="info" onClose={reporter.dismiss}>
|
|
158
|
-
{t('shell.countedNextDay', {
|
|
159
|
-
day: (reporter.late?.committedAtTick ?? 0) + 1,
|
|
160
|
-
})}
|
|
161
|
-
</Alert>
|
|
162
|
-
</Snackbar>
|
|
178
|
+
{phase !== 'over' && (
|
|
179
|
+
<Box
|
|
180
|
+
component="footer"
|
|
181
|
+
sx={{
|
|
182
|
+
flex: '0 0 auto',
|
|
183
|
+
bgcolor: 'background.paper',
|
|
184
|
+
borderTop: 1,
|
|
185
|
+
borderColor: 'divider',
|
|
186
|
+
px: wide ? 4 : 2,
|
|
187
|
+
pt: 1.5,
|
|
188
|
+
pb: 2.5,
|
|
189
|
+
}}
|
|
190
|
+
>
|
|
191
|
+
<Box sx={{ maxWidth: CONTENT_MAX_WIDTH, mx: 'auto' }}>
|
|
192
|
+
<Notices />
|
|
193
|
+
<DayBar
|
|
194
|
+
lookingAt={lookingAt}
|
|
195
|
+
onBack={() => setLookingAt(null)}
|
|
196
|
+
wide={wide}
|
|
197
|
+
/>
|
|
198
|
+
</Box>
|
|
199
|
+
</Box>
|
|
200
|
+
)}
|
|
163
201
|
</Box>
|
|
164
202
|
</WriteContext.Provider>
|
|
165
203
|
);
|
|
166
204
|
}
|
|
167
205
|
|
|
206
|
+
function Columns({ left, right }: { left: React.ReactNode; right: React.ReactNode }) {
|
|
207
|
+
return (
|
|
208
|
+
<Box
|
|
209
|
+
sx={{
|
|
210
|
+
display: 'grid',
|
|
211
|
+
gridTemplateColumns: 'minmax(0, 7fr) minmax(0, 5fr)',
|
|
212
|
+
gap: 4,
|
|
213
|
+
alignItems: 'start',
|
|
214
|
+
}}
|
|
215
|
+
>
|
|
216
|
+
<Box>{left}</Box>
|
|
217
|
+
<Box component="aside">{right}</Box>
|
|
218
|
+
</Box>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** Says, before anything else on the page, that this is the past and cannot be touched. */
|
|
223
|
+
function LookingBack({ day, today }: { day: number; today: number }) {
|
|
224
|
+
const { t } = useTranslation();
|
|
225
|
+
return (
|
|
226
|
+
<Box
|
|
227
|
+
role="status"
|
|
228
|
+
data-testid="looking-back"
|
|
229
|
+
sx={(theme) => ({
|
|
230
|
+
display: 'flex',
|
|
231
|
+
gap: 1.25,
|
|
232
|
+
alignItems: 'flex-start',
|
|
233
|
+
bgcolor: alpha(theme.palette.info.main, 0.12),
|
|
234
|
+
borderRadius: '12px',
|
|
235
|
+
px: 1.5,
|
|
236
|
+
py: 1.25,
|
|
237
|
+
})}
|
|
238
|
+
>
|
|
239
|
+
<HistoryRounded aria-hidden sx={{ fontSize: 20, color: 'info.main', flex: 'none' }} />
|
|
240
|
+
<Typography variant="body2">{t('lookingBack.notice', { day, today })}</Typography>
|
|
241
|
+
</Box>
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
168
245
|
export default function App() {
|
|
169
246
|
const theme = useAppTheme();
|
|
170
247
|
|
|
@@ -8,8 +8,11 @@ import { baseSettings, baseContext } from './test-helpers';
|
|
|
8
8
|
|
|
9
9
|
const ada = createMockParticipant({ id: 'participant-1', name: 'Ada' });
|
|
10
10
|
|
|
11
|
-
const render = (
|
|
12
|
-
|
|
11
|
+
const render = (
|
|
12
|
+
options: Parameters<typeof renderUserInterface>[1] = {},
|
|
13
|
+
props: Partial<Parameters<typeof DayBar>[0]> = {}
|
|
14
|
+
) =>
|
|
15
|
+
renderUserInterface(<DayBar lookingAt={null} onBack={() => {}} {...props} />, {
|
|
13
16
|
data: baseContext,
|
|
14
17
|
settings: baseSettings,
|
|
15
18
|
participant: ada,
|
|
@@ -32,16 +35,16 @@ describe('opening the stall', () => {
|
|
|
32
35
|
await waitFor(() => expect(requestTick).toHaveBeenCalled());
|
|
33
36
|
});
|
|
34
37
|
|
|
35
|
-
it('says which day
|
|
38
|
+
it('says which day it opens', () => {
|
|
36
39
|
render({ completedTicks: 4 });
|
|
37
40
|
|
|
38
|
-
expect(screen.
|
|
41
|
+
expect(screen.getByTestId('open-stall')).toHaveTextContent('Open the stall for day 5');
|
|
39
42
|
});
|
|
40
43
|
|
|
41
|
-
it('says
|
|
44
|
+
it('says how much room is left before opening', () => {
|
|
42
45
|
render();
|
|
43
46
|
|
|
44
|
-
expect(screen.getByText('
|
|
47
|
+
expect(screen.getByText('Room for 50 more before you open')).toBeInTheDocument();
|
|
45
48
|
});
|
|
46
49
|
|
|
47
50
|
it('will not open a stall that has decided nothing', () => {
|
|
@@ -65,7 +68,7 @@ describe('opening the stall', () => {
|
|
|
65
68
|
});
|
|
66
69
|
|
|
67
70
|
expect(screen.getByTestId('open-stall')).toBeDisabled();
|
|
68
|
-
expect(screen.getByText(
|
|
71
|
+
expect(screen.getByText(/30 more than the stall can make/)).toBeInTheDocument();
|
|
69
72
|
});
|
|
70
73
|
|
|
71
74
|
// An observer has no participant identity, so there is nothing for the
|
|
@@ -76,3 +79,43 @@ describe('opening the stall', () => {
|
|
|
76
79
|
expect(screen.getByTestId('open-stall')).toBeDisabled();
|
|
77
80
|
});
|
|
78
81
|
});
|
|
82
|
+
|
|
83
|
+
describe('when the facilitator is holding the room', () => {
|
|
84
|
+
/**
|
|
85
|
+
* `validators/daylimit` refuses the tick on the server whatever the button
|
|
86
|
+
* does. The button reads the same limit so it can say why, rather than
|
|
87
|
+
* letting the stall press it and be refused.
|
|
88
|
+
*/
|
|
89
|
+
it('says who opens the next day, and does not offer to open it', () => {
|
|
90
|
+
render({
|
|
91
|
+
completedTicks: 3,
|
|
92
|
+
data: { ...baseContext, pacing: { LastOpenDay: 3 } },
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
expect(screen.getByTestId('open-stall')).toBeDisabled();
|
|
96
|
+
expect(screen.getByTestId('open-stall')).toHaveTextContent('Your facilitator opens day 4');
|
|
97
|
+
expect(screen.getByText('Your numbers are saved as you change them')).toBeInTheDocument();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('opens the day the facilitator has let them reach', () => {
|
|
101
|
+
render({
|
|
102
|
+
completedTicks: 2,
|
|
103
|
+
data: { ...baseContext, pacing: { LastOpenDay: 3 } },
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
expect(screen.getByTestId('open-stall')).toBeEnabled();
|
|
107
|
+
expect(screen.getByTestId('open-stall')).toHaveTextContent('Open the stall for day 3');
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('looking back at a past day', () => {
|
|
112
|
+
it('offers the way back to today instead of opening the stall', () => {
|
|
113
|
+
const onBack = vi.fn();
|
|
114
|
+
render({ completedTicks: 2 }, { lookingAt: 1, onBack });
|
|
115
|
+
|
|
116
|
+
expect(screen.queryByTestId('open-stall')).not.toBeInTheDocument();
|
|
117
|
+
fireEvent.click(screen.getByRole('button', { name: 'Back to day 3' }));
|
|
118
|
+
|
|
119
|
+
expect(onBack).toHaveBeenCalled();
|
|
120
|
+
});
|
|
121
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Box, Button,
|
|
1
|
+
import { Box, Button, Typography } from '@mui/material';
|
|
2
2
|
import {
|
|
3
3
|
useUserInterfaceCallbacks,
|
|
4
4
|
useUserInterfaceData,
|
|
@@ -10,6 +10,13 @@ import type { Settings, Context } from '../types';
|
|
|
10
10
|
import { totalPlanned } from './menu';
|
|
11
11
|
import { useWrite } from './writes';
|
|
12
12
|
|
|
13
|
+
type Props = {
|
|
14
|
+
/** The past day being looked at, when the reader is looking back. */
|
|
15
|
+
lookingAt: number | null;
|
|
16
|
+
onBack: () => void;
|
|
17
|
+
wide?: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
13
20
|
/**
|
|
14
21
|
* The stall opens its own day.
|
|
15
22
|
*
|
|
@@ -18,55 +25,106 @@ import { useWrite } from './writes';
|
|
|
18
25
|
* with it instead of waiting for the room. The facilitator watches, and can
|
|
19
26
|
* undo a day, but does not drive the session.
|
|
20
27
|
*
|
|
28
|
+
* What the facilitator can do is hold the room at a day. `pacing.LastOpenDay`
|
|
29
|
+
* is theirs, and `validators/daylimit` refuses a stall that asks for a later
|
|
30
|
+
* one. The button reads the same number so it can say why it will not open,
|
|
31
|
+
* rather than letting the stall press it and be told off: the validator is the
|
|
32
|
+
* rule, and this is the courtesy.
|
|
33
|
+
*
|
|
21
34
|
* It is a shared control with no lock on it, which is deliberate. Somebody can
|
|
22
|
-
* open the stall while a team-mate is still
|
|
23
|
-
* happens the change lands on the following day rather than being lost: that
|
|
24
|
-
* what `reporter.late` reports, and why the notice for it exists.
|
|
35
|
+
* open the stall while a team-mate is still changing a number, and when that
|
|
36
|
+
* happens the change lands on the following day rather than being lost: that
|
|
37
|
+
* is what `reporter.late` reports, and why the notice for it exists.
|
|
38
|
+
*
|
|
39
|
+
* The bar is part of the page's layout, not laid over it, so it never covers
|
|
40
|
+
* the last item on the menu.
|
|
25
41
|
*/
|
|
26
|
-
export default function DayBar() {
|
|
42
|
+
export default function DayBar({ lookingAt, onBack, wide = false }: Props) {
|
|
27
43
|
const { data, settings, completedTicks } = useUserInterfaceData<Context, Settings>();
|
|
28
44
|
const participant = useUserInterfaceParticipant();
|
|
29
45
|
const { requestTick } = useUserInterfaceCallbacks();
|
|
30
46
|
const { run, pending } = useWrite();
|
|
31
47
|
const { t } = useTranslation();
|
|
32
48
|
|
|
33
|
-
const
|
|
34
|
-
const over = planned > settings.menu.Capacity;
|
|
35
|
-
const empty = planned === 0;
|
|
49
|
+
const day = completedTicks + 1;
|
|
36
50
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
elevation={3}
|
|
41
|
-
sx={{ flex: '0 0 auto', borderTop: 1, borderColor: 'divider', px: 2, py: 1.5 }}
|
|
42
|
-
>
|
|
43
|
-
<Stack
|
|
44
|
-
direction="row"
|
|
45
|
-
spacing={2}
|
|
46
|
-
sx={{ alignItems: 'center', justifyContent: 'space-between', mx: 'auto' }}
|
|
47
|
-
>
|
|
48
|
-
<Box>
|
|
49
|
-
<Typography variant="subtitle2">
|
|
50
|
-
{t('day.making', { planned, capacity: settings.menu.Capacity })}
|
|
51
|
-
</Typography>
|
|
52
|
-
<Typography variant="caption" color="text.secondary">
|
|
53
|
-
{over
|
|
54
|
-
? t('day.tooMany')
|
|
55
|
-
: empty
|
|
56
|
-
? t('day.nothing')
|
|
57
|
-
: t('day.ready', { day: completedTicks + 1 })}
|
|
58
|
-
</Typography>
|
|
59
|
-
</Box>
|
|
51
|
+
if (lookingAt !== null) {
|
|
52
|
+
return (
|
|
53
|
+
<Bar wide={wide}>
|
|
60
54
|
<Button
|
|
61
|
-
variant="
|
|
55
|
+
variant="outlined"
|
|
62
56
|
size="large"
|
|
63
|
-
|
|
64
|
-
data-testid="
|
|
65
|
-
|
|
57
|
+
onClick={onBack}
|
|
58
|
+
data-testid="back-to-today"
|
|
59
|
+
sx={{
|
|
60
|
+
height: 52,
|
|
61
|
+
borderRadius: '14px',
|
|
62
|
+
fontSize: '1.05rem',
|
|
63
|
+
...barButton(wide),
|
|
64
|
+
}}
|
|
66
65
|
>
|
|
67
|
-
{t('
|
|
66
|
+
{t('timeline.backTo', { day })}
|
|
68
67
|
</Button>
|
|
69
|
-
</
|
|
70
|
-
|
|
68
|
+
</Bar>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const planned = totalPlanned(data.plan.Make);
|
|
73
|
+
const room = settings.menu.Capacity - planned;
|
|
74
|
+
const held = day > data.pacing.LastOpenDay;
|
|
75
|
+
|
|
76
|
+
const status =
|
|
77
|
+
room < 0
|
|
78
|
+
? t('day.tooMany', { over: -room })
|
|
79
|
+
: planned === 0
|
|
80
|
+
? t('day.nothing')
|
|
81
|
+
: held
|
|
82
|
+
? t('day.saved')
|
|
83
|
+
: room === 0
|
|
84
|
+
? t('day.full')
|
|
85
|
+
: t('day.room', { room });
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<Bar wide={wide}>
|
|
89
|
+
<Button
|
|
90
|
+
variant="contained"
|
|
91
|
+
size="large"
|
|
92
|
+
disableElevation
|
|
93
|
+
disabled={!participant || pending || held || room < 0 || planned === 0}
|
|
94
|
+
data-testid="open-stall"
|
|
95
|
+
onClick={() => void run(() => requestTick(), 'open-stall')}
|
|
96
|
+
sx={{ height: 52, borderRadius: '14px', fontSize: '1.05rem', ...barButton(wide) }}
|
|
97
|
+
>
|
|
98
|
+
{held ? t('day.held', { day }) : t('day.open', { day })}
|
|
99
|
+
</Button>
|
|
100
|
+
<Typography
|
|
101
|
+
variant="body2"
|
|
102
|
+
color={room < 0 ? 'error.main' : 'text.secondary'}
|
|
103
|
+
data-testid="day-status"
|
|
104
|
+
sx={{ textAlign: 'center', fontVariantNumeric: 'tabular-nums' }}
|
|
105
|
+
>
|
|
106
|
+
{status}
|
|
107
|
+
</Typography>
|
|
108
|
+
</Bar>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const barButton = (wide: boolean) => (wide ? { px: 3.5 } : { width: '100%' });
|
|
113
|
+
|
|
114
|
+
function Bar({ wide, children }: { wide: boolean; children: React.ReactNode }) {
|
|
115
|
+
return (
|
|
116
|
+
<Box
|
|
117
|
+
sx={{
|
|
118
|
+
display: 'flex',
|
|
119
|
+
// At laptop width the status reads first and the button sits
|
|
120
|
+
// at the end of the line, where the eye finishes.
|
|
121
|
+
flexDirection: wide ? 'row-reverse' : 'column',
|
|
122
|
+
alignItems: wide ? 'center' : 'stretch',
|
|
123
|
+
justifyContent: wide ? 'flex-start' : undefined,
|
|
124
|
+
gap: wide ? 2.5 : 1,
|
|
125
|
+
}}
|
|
126
|
+
>
|
|
127
|
+
{children}
|
|
128
|
+
</Box>
|
|
71
129
|
);
|
|
72
130
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Table, TableBody, TableCell, TableHead, TableRow } from '@mui/material';
|
|
2
|
+
import { useUserInterfaceData } from '@seriousgaming/sdk/ui';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
|
|
5
|
+
import { count, money } from '../../shared/format';
|
|
6
|
+
import type { Context, Settings } from '../types';
|
|
7
|
+
import { type DayResults, totalsOf } from './days';
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
days: DayResults[];
|
|
11
|
+
/** Room for the 'Turned away' column, at laptop width. */
|
|
12
|
+
wide?: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Every day so far, newest first, so the day the team is thinking about is at
|
|
17
|
+
* the top.
|
|
18
|
+
*
|
|
19
|
+
* Four columns on a phone and five on a laptop. A table that scrolls sideways
|
|
20
|
+
* on a phone hides the column the reader wanted behind the one they did not,
|
|
21
|
+
* so the narrow version drops a column rather than shrinking the type.
|
|
22
|
+
* Everything a day holds is one tap away in the timeline above.
|
|
23
|
+
*/
|
|
24
|
+
export default function DaysTable({ days, wide = false }: Props) {
|
|
25
|
+
const { settings } = useUserInterfaceData<Context, Settings>();
|
|
26
|
+
const { t } = useTranslation();
|
|
27
|
+
const symbol = settings.ui.CurrencySymbol;
|
|
28
|
+
const best = Math.max(...days.map((day) => day.Profit));
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Table size="small" sx={{ tableLayout: 'fixed', width: '100%' }}>
|
|
32
|
+
<TableHead>
|
|
33
|
+
<TableRow>
|
|
34
|
+
<TableCell sx={{ width: '16%' }}>{t('history.day')}</TableCell>
|
|
35
|
+
<TableCell>{t('history.weather')}</TableCell>
|
|
36
|
+
<TableCell align="right">{t('history.sold')}</TableCell>
|
|
37
|
+
{wide && <TableCell align="right">{t('history.turnedAway')}</TableCell>}
|
|
38
|
+
<TableCell align="right" sx={{ pr: 0 }}>
|
|
39
|
+
{t('history.profit')}
|
|
40
|
+
</TableCell>
|
|
41
|
+
</TableRow>
|
|
42
|
+
</TableHead>
|
|
43
|
+
<TableBody>
|
|
44
|
+
{[...days].reverse().map((day) => {
|
|
45
|
+
const totals = totalsOf(day);
|
|
46
|
+
return (
|
|
47
|
+
<TableRow key={day.Day} data-testid={`day-${day.Day}`}>
|
|
48
|
+
<TableCell>{day.Day}</TableCell>
|
|
49
|
+
<TableCell>{t(`weather.${day.Weather}Short`)}</TableCell>
|
|
50
|
+
<TableCell align="right">{count(totals.sold)}</TableCell>
|
|
51
|
+
{wide && (
|
|
52
|
+
<TableCell align="right">{count(totals.turnedAway)}</TableCell>
|
|
53
|
+
)}
|
|
54
|
+
<TableCell
|
|
55
|
+
align="right"
|
|
56
|
+
sx={{
|
|
57
|
+
pr: 0,
|
|
58
|
+
fontWeight: days.length > 1 && day.Profit === best ? 700 : 400,
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
{money(symbol, day.Profit)}
|
|
62
|
+
</TableCell>
|
|
63
|
+
</TableRow>
|
|
64
|
+
);
|
|
65
|
+
})}
|
|
66
|
+
</TableBody>
|
|
67
|
+
</Table>
|
|
68
|
+
);
|
|
69
|
+
}
|