@composable-os/pack-rostering 0.0.0-stage → 0.1.0-beta.13
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/LICENSE +109 -0
- package/dist/blocks/rostering-away/away-list.d.ts +8 -0
- package/dist/blocks/rostering-away/away-list.js +101 -0
- package/dist/blocks/rostering-checklist/checklist.d.ts +9 -0
- package/dist/blocks/rostering-checklist/checklist.js +132 -0
- package/dist/blocks/rostering-checklist/my-shifts-with-checklist.d.ts +11 -0
- package/dist/blocks/rostering-checklist/my-shifts-with-checklist.js +6 -0
- package/dist/blocks/rostering-checklists/checklists.d.ts +11 -0
- package/dist/blocks/rostering-checklists/checklists.js +76 -0
- package/dist/blocks/rostering-my-availability/my-availability.d.ts +7 -0
- package/dist/blocks/rostering-my-availability/my-availability.js +143 -0
- package/dist/blocks/rostering-my-calendar/my-calendar.d.ts +6 -0
- package/dist/blocks/rostering-my-calendar/my-calendar.js +92 -0
- package/dist/blocks/rostering-my-shifts/my-hours.d.ts +6 -0
- package/dist/blocks/rostering-my-shifts/my-hours.js +63 -0
- package/dist/blocks/rostering-my-shifts/my-shifts.d.ts +17 -0
- package/dist/blocks/rostering-my-shifts/my-shifts.js +53 -0
- package/dist/blocks/rostering-native-checklist/checklist-screen.d.ts +8 -0
- package/dist/blocks/rostering-native-checklist/checklist-screen.js +110 -0
- package/dist/blocks/rostering-native-my-availability/my-availability-screen.d.ts +7 -0
- package/dist/blocks/rostering-native-my-availability/my-availability-screen.js +110 -0
- package/dist/blocks/rostering-native-my-calendar/my-calendar-screen.d.ts +10 -0
- package/dist/blocks/rostering-native-my-calendar/my-calendar-screen.js +72 -0
- package/dist/blocks/rostering-native-my-shifts/my-hours-screen.d.ts +6 -0
- package/dist/blocks/rostering-native-my-shifts/my-hours-screen.js +60 -0
- package/dist/blocks/rostering-native-my-shifts/my-shifts-screen.d.ts +12 -0
- package/dist/blocks/rostering-native-my-shifts/my-shifts-screen.js +56 -0
- package/dist/blocks/rostering-native-offers/offers-screen.d.ts +7 -0
- package/dist/blocks/rostering-native-offers/offers-screen.js +56 -0
- package/dist/blocks/rostering-native-roster/roster-screen.d.ts +7 -0
- package/dist/blocks/rostering-native-roster/roster-screen.js +31 -0
- package/dist/blocks/rostering-offers/offers.d.ts +7 -0
- package/dist/blocks/rostering-offers/offers.js +52 -0
- package/dist/blocks/rostering-patterns/patterns.d.ts +7 -0
- package/dist/blocks/rostering-patterns/patterns.js +58 -0
- package/dist/blocks/rostering-pay/pay.d.ts +7 -0
- package/dist/blocks/rostering-pay/pay.js +160 -0
- package/dist/blocks/rostering-qualifications/qualifications.d.ts +6 -0
- package/dist/blocks/rostering-qualifications/qualifications.js +48 -0
- package/dist/blocks/rostering-week/assign.d.ts +12 -0
- package/dist/blocks/rostering-week/assign.js +99 -0
- package/dist/blocks/rostering-week/week.d.ts +13 -0
- package/dist/blocks/rostering-week/week.js +82 -0
- package/dist/client/index.d.ts +3113 -0
- package/dist/client/index.js +654 -0
- package/dist/index.d.ts +1594 -0
- package/dist/index.js +541 -0
- package/dist/tools.d.ts +1094 -0
- package/dist/tools.js +1047 -0
- package/package.json +36 -4
- package/README.md +0 -3
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// Pay (stage 45 step 7), for someone who handles pay, a person only: the pay periods, who is
|
|
3
|
+
// counted and how, a period's hours and shifts per person and kind of work with each shift's
|
|
4
|
+
// evidence (its class list taken, by whom, flagged when not by its person), locking a period that
|
|
5
|
+
// has ended, reopening one with why, and its CSV for payroll. No rates and no money: the host
|
|
6
|
+
// holds none.
|
|
7
|
+
//
|
|
8
|
+
// Everything is the host's answer: which periods exist, what each counts (a locked period's
|
|
9
|
+
// locked lines, an open one's preview), whether it may be locked, and each refusal (the period
|
|
10
|
+
// not set, not ended, already locked or overlapping one, the roster changed while locking, a
|
|
11
|
+
// shift inside a locked period). Shown only when the host says the reader handles pay
|
|
12
|
+
// (`me.pays`), so no one else's screen asks for any of it. Figures are kept in the app's cache no
|
|
13
|
+
// longer than they are shown, hidden when the page is left, and the CSV is handed to the person
|
|
14
|
+
// and not kept; why a period was reopened is forgotten once the call is over.
|
|
15
|
+
import { basisLabel, dayLabel, forgetAfter, refusalNext, rosterRefusal, } from "@composable-os/pack-rostering/client";
|
|
16
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
17
|
+
import { Button } from "../ui-button/button.js";
|
|
18
|
+
/** Hides what is shown when the page is left; shows it again only once read again. */
|
|
19
|
+
function useForgetOnLeave(forget, cameBack) {
|
|
20
|
+
const latest = useRef({ forget, cameBack });
|
|
21
|
+
latest.current = { forget, cameBack };
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const hide = () => latest.current.forget();
|
|
24
|
+
const show = (event) => {
|
|
25
|
+
if (!event.persisted)
|
|
26
|
+
return;
|
|
27
|
+
latest.current.forget();
|
|
28
|
+
latest.current.cameBack();
|
|
29
|
+
};
|
|
30
|
+
window.addEventListener("pagehide", hide);
|
|
31
|
+
window.addEventListener("pageshow", show);
|
|
32
|
+
return () => {
|
|
33
|
+
window.removeEventListener("pagehide", hide);
|
|
34
|
+
window.removeEventListener("pageshow", show);
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
}
|
|
38
|
+
/** Hands a CSV to the person as a file to save; nothing of it is kept here. */
|
|
39
|
+
function saveFile(filename, csv) {
|
|
40
|
+
const url = URL.createObjectURL(new Blob([csv], { type: "text/csv" }));
|
|
41
|
+
const a = document.createElement("a");
|
|
42
|
+
a.href = url;
|
|
43
|
+
a.download = filename;
|
|
44
|
+
a.rel = "noopener";
|
|
45
|
+
document.body.append(a);
|
|
46
|
+
a.click();
|
|
47
|
+
a.remove();
|
|
48
|
+
setTimeout(() => URL.revokeObjectURL(url), 1000);
|
|
49
|
+
}
|
|
50
|
+
export function Pay({ rostering, locale = "en-AU" }) {
|
|
51
|
+
const me = rostering.useMe();
|
|
52
|
+
const pays = me.data?.pays === true;
|
|
53
|
+
const [hidden, setHidden] = useState(false);
|
|
54
|
+
const periods = rostering.usePeriods({ count: 8 }, pays && !hidden);
|
|
55
|
+
const [chosen, setChosen] = useState(null);
|
|
56
|
+
const headingId = useId();
|
|
57
|
+
useForgetOnLeave(() => {
|
|
58
|
+
setHidden(true);
|
|
59
|
+
setChosen(null);
|
|
60
|
+
}, () => setHidden(false));
|
|
61
|
+
if (me.isPending)
|
|
62
|
+
return _jsx("p", { "aria-busy": "true", children: "Loading\u2026" });
|
|
63
|
+
if (me.error || !me.data)
|
|
64
|
+
return _jsx("p", { role: "alert", children: rosterRefusal(me.error).message });
|
|
65
|
+
if (!pays) {
|
|
66
|
+
return (_jsx("p", { role: "status", "data-refusal": "forbidden", children: "Pay is seen only by whoever handles pay, at the screen themselves." }));
|
|
67
|
+
}
|
|
68
|
+
if (hidden)
|
|
69
|
+
return _jsx("p", { "aria-busy": "true", children: "Loading\u2026" });
|
|
70
|
+
const period = periods.data?.periods.find((p) => p.start === chosen) ?? null;
|
|
71
|
+
return (_jsxs("section", { className: "grid gap-4", "aria-labelledby": headingId, children: [_jsx("h2", { id: headingId, className: "text-lg font-medium", children: "Pay periods" }), _jsx("p", { className: "text-sm text-muted-foreground", children: "Hours and shifts for payroll. No rates or money are kept here: payroll applies them." }), periods.isPending ? _jsx("p", { "aria-busy": "true", children: "Loading the periods\u2026" }) : null, periods.error ? _jsx("p", { role: "alert", children: rosterRefusal(periods.error).message }) : null, periods.data && !periods.data.set ? (_jsxs("p", { role: "status", "data-refusal": "pay_period_unset", children: ["The date a pay period starts is not set yet, so nothing is totalled. Set it in Settings, Rostering (", periods.data.setting.period, ")."] })) : null, periods.data?.set ? (_jsx("ul", { className: "grid gap-2 sm:grid-cols-2", "aria-label": "Periods", children: periods.data.periods.map((p) => (_jsx("li", { children: _jsxs("button", { type: "button", className: "block w-full rounded-md border p-2 text-left text-sm", "aria-pressed": chosen === p.start, "data-start": p.start, "aria-label": `${dayLabel(p.start, locale)} to ${dayLabel(p.end, locale)}, ${p.state === "locked" ? "locked" : p.ended ? "ended, open" : "open"}`, onClick: () => setChosen(p.start), children: [_jsxs("span", { className: "block font-medium", children: [dayLabel(p.start, locale), " \u2013 ", dayLabel(p.end, locale)] }), _jsx("span", { className: "block text-xs", children: p.state === "locked"
|
|
72
|
+
? `Locked (version ${p.versions.at(-1)?.version ?? 1})`
|
|
73
|
+
: p.ended
|
|
74
|
+
? "Ended, not locked"
|
|
75
|
+
: "Open" })] }) }, p.start))) })) : null, period ? (_jsx(PeriodView, { rostering: rostering, period: period, locale: locale, onChanged: () => periods.refetch?.() }, period.start)) : null, _jsx(Counted, { rostering: rostering, today: me.data.today })] }));
|
|
76
|
+
}
|
|
77
|
+
function PeriodView({ rostering, period, locale, onChanged, }) {
|
|
78
|
+
const totals = rostering.usePeriodTotals({ start: period.start });
|
|
79
|
+
const lock = rostering.useLock();
|
|
80
|
+
const reopen = rostering.useReopen();
|
|
81
|
+
const exported = rostering.useExport();
|
|
82
|
+
const [confirmLock, setConfirmLock] = useState(false);
|
|
83
|
+
const [reason, setReason] = useState("");
|
|
84
|
+
const [refusal, setRefusal] = useState(null);
|
|
85
|
+
const [said, setSaid] = useState(null);
|
|
86
|
+
const id = useId();
|
|
87
|
+
useForgetOnLeave(() => setReason(""), () => undefined);
|
|
88
|
+
async function run(what, done) {
|
|
89
|
+
setRefusal(null);
|
|
90
|
+
setSaid(null);
|
|
91
|
+
try {
|
|
92
|
+
await what();
|
|
93
|
+
setSaid(done);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
setRefusal(rosterRefusal(error));
|
|
97
|
+
}
|
|
98
|
+
onChanged();
|
|
99
|
+
await totals.refetch?.();
|
|
100
|
+
}
|
|
101
|
+
async function doReopen(event) {
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
const why = reason.trim();
|
|
104
|
+
if (!why) {
|
|
105
|
+
setRefusal({ kind: "invalid", message: "Say why it is reopened." });
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
await run(() => forgetAfter(reopen, { start: period.start, reason: why }), "Reopened. Its locked version is kept; lock it again for a new one.");
|
|
109
|
+
setReason("");
|
|
110
|
+
}
|
|
111
|
+
async function download() {
|
|
112
|
+
setRefusal(null);
|
|
113
|
+
try {
|
|
114
|
+
const file = await forgetAfter(exported, { start: period.start });
|
|
115
|
+
saveFile(file.filename, file.csv);
|
|
116
|
+
setSaid(file.locked ? "The CSV was saved." : "The CSV was saved, marked as a preview.");
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
setRefusal(rosterRefusal(error));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const data = totals.data;
|
|
123
|
+
const locked = period.state === "locked";
|
|
124
|
+
return (_jsxs("section", { className: "grid gap-3 rounded-md border p-3", "aria-labelledby": `${id}-h`, children: [_jsxs("h3", { id: `${id}-h`, className: "font-medium", children: [dayLabel(period.start, locale, true), " to ", dayLabel(period.end, locale, true)] }), data?.period.preview ? (_jsx("p", { className: "text-sm", role: "status", children: "A preview from the roster as it stands: it changes until the period is locked." })) : null, refusal ? (_jsxs("div", { role: "alert", className: "text-sm", "data-refusal": refusal.kind, children: [_jsx("p", { children: refusal.message }), refusalNext(refusal.kind, false) ? _jsx("p", { children: refusalNext(refusal.kind, false) }) : null] })) : null, said ? (_jsx("p", { role: "status", className: "text-sm", children: said })) : null, totals.isPending ? _jsx("p", { "aria-busy": "true", children: "Loading\u2026" }) : null, totals.error ? _jsx("p", { role: "alert", children: rosterRefusal(totals.error).message }) : null, data ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "max-w-full overflow-x-auto", children: _jsxs("table", { className: "text-sm", "aria-label": "Hours and shifts per person", children: [_jsx("thead", { children: _jsxs("tr", { className: "text-left", children: [_jsx("th", { scope: "col", className: "p-1", children: "Person" }), _jsx("th", { scope: "col", className: "p-1", children: "Counted" }), _jsx("th", { scope: "col", className: "p-1", children: "Kind of work" }), _jsx("th", { scope: "col", className: "p-1", children: "Shifts" }), _jsx("th", { scope: "col", className: "p-1", children: "Hours" }), _jsx("th", { scope: "col", className: "p-1", children: "Not worked" }), _jsx("th", { scope: "col", className: "p-1", children: "To check" })] }) }), _jsx("tbody", { children: data.totals.map((t) => (_jsxs("tr", { className: "border-t", children: [_jsx("th", { scope: "row", className: "p-1 text-left font-normal", children: t.name }), _jsx("td", { className: "p-1", children: basisLabel(t.basis) }), _jsx("td", { className: "p-1", children: t.kindName }), _jsx("td", { className: "p-1", children: t.shifts }), _jsx("td", { className: "p-1", children: t.hours }), _jsx("td", { className: "p-1", children: t.notWorked }), _jsx("td", { className: "p-1", children: t.flagged ? `${t.flagged} flagged` : "" })] }, `${t.account}:${t.kind?.id ?? ""}`))) })] }) }), _jsxs("p", { className: "text-sm", children: ["All counted hours: ", data.hours] }), _jsxs("details", { children: [_jsx("summary", { className: "cursor-pointer text-sm", children: "Each shift, with its evidence" }), _jsx("div", { className: "max-w-full overflow-x-auto", children: _jsxs("table", { className: "text-sm", "aria-label": "Each shift", children: [_jsx("thead", { children: _jsxs("tr", { className: "text-left", children: [_jsx("th", { scope: "col", className: "p-1", children: "Date" }), _jsx("th", { scope: "col", className: "p-1", children: "Time" }), _jsx("th", { scope: "col", className: "p-1", children: "Person" }), _jsx("th", { scope: "col", className: "p-1", children: "Shift" }), _jsx("th", { scope: "col", className: "p-1", children: "Minutes counted" }), _jsx("th", { scope: "col", className: "p-1", children: "Evidence" })] }) }), _jsx("tbody", { children: data.lines.map((l) => (_jsxs("tr", { className: "border-t", "data-flagged": l.flagged ? "true" : undefined, children: [_jsx("td", { className: "p-1", children: dayLabel(l.localDate, locale) }), _jsxs("td", { className: "p-1", children: [l.localStart.slice(11, 16), "\u2013", l.localEnd.slice(11, 16)] }), _jsx("td", { className: "p-1", children: l.name }), _jsxs("td", { className: "p-1", children: [l.title, l.place ? ` · ${l.place}` : ""] }), _jsxs("td", { className: "p-1", children: [l.counted ? l.countedMinutes : "Not worked", l.notWorkedReason ? ` (${l.notWorkedReason})` : ""] }), _jsxs("td", { className: "p-1", children: [l.listTaken === null
|
|
125
|
+
? ""
|
|
126
|
+
: l.listTaken
|
|
127
|
+
? `List taken${l.markedBy ? ` by ${l.markedBy}` : ""}`
|
|
128
|
+
: "List not taken", l.flagged ? " · check who ran it" : ""] })] }, `${l.object}:${l.id}`))) })] }) })] }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsx(Button, { type: "button", variant: "outline", disabled: exported.isPending, onClick: download, children: locked ? "Export CSV" : "Export a preview CSV" }), !locked && period.ended ? (confirmLock ? (_jsxs("div", { role: "alertdialog", "aria-label": "Lock this period", className: "grid gap-2 rounded-md border p-2", children: [_jsx("p", { className: "text-sm", children: "Lock it? Its hours are kept as they are now, and its shifts can no longer be changed until it is reopened." }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { type: "button", disabled: lock.isPending, onClick: () => {
|
|
129
|
+
setConfirmLock(false);
|
|
130
|
+
void run(() => lock.mutateAsync({ start: period.start }), "Locked.");
|
|
131
|
+
}, children: "Lock the period" }), _jsx(Button, { type: "button", variant: "outline", onClick: () => setConfirmLock(false), children: "Not yet" })] })] })) : (_jsx(Button, { type: "button", onClick: () => setConfirmLock(true), children: "Lock\u2026" }))) : null] }), !locked && !period.ended ? (_jsx("p", { className: "text-xs text-muted-foreground", children: "It can be locked once it has ended." })) : null, locked ? (_jsxs("form", { className: "grid gap-1", onSubmit: doReopen, "aria-label": "Reopen this period", children: [_jsx("label", { htmlFor: `${id}-why`, className: "text-sm", children: "Reopen to correct it: why?" }), _jsx("input", { id: `${id}-why`, className: "rounded-md border border-input px-2 py-1 text-sm", value: reason, maxLength: 500, autoComplete: "off", onChange: (e) => setReason(e.target.value) }), _jsx(Button, { type: "submit", variant: "outline", disabled: reopen.isPending, children: "Reopen" })] })) : null] })) : null] }));
|
|
132
|
+
}
|
|
133
|
+
function Counted({ rostering, today, }) {
|
|
134
|
+
const bases = rostering.usePayBases({ everyone: true });
|
|
135
|
+
const setBasis = rostering.usePayBasis();
|
|
136
|
+
const [editing, setEditing] = useState(null);
|
|
137
|
+
const [basis, setBasisValue] = useState("not_counted");
|
|
138
|
+
const [from, setFrom] = useState(today);
|
|
139
|
+
const [refusal, setRefusal] = useState(null);
|
|
140
|
+
const id = useId();
|
|
141
|
+
async function save(event) {
|
|
142
|
+
event.preventDefault();
|
|
143
|
+
if (!editing)
|
|
144
|
+
return;
|
|
145
|
+
setRefusal(null);
|
|
146
|
+
try {
|
|
147
|
+
await forgetAfter(setBasis, { account: editing, basis, from });
|
|
148
|
+
setEditing(null);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
setRefusal(rosterRefusal(error));
|
|
152
|
+
}
|
|
153
|
+
await bases.refetch?.();
|
|
154
|
+
}
|
|
155
|
+
return (_jsxs("section", { className: "grid gap-2", "aria-labelledby": `${id}-h`, children: [_jsx("h3", { id: `${id}-h`, className: "font-medium", children: "Who is counted" }), bases.isPending ? _jsx("p", { "aria-busy": "true", children: "Loading\u2026" }) : null, bases.error ? _jsx("p", { role: "alert", children: rosterRefusal(bases.error).message }) : null, refusal ? (_jsx("p", { role: "alert", className: "text-sm", "data-refusal": refusal.kind, children: refusal.message })) : null, _jsx("ul", { className: "grid gap-1 text-sm", children: (bases.data?.items ?? []).map((item) => (_jsxs("li", { className: "grid gap-1 rounded border p-2", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsxs("span", { children: [item.name, " \u00B7 ", basisLabel(item.basis)] }), _jsx(Button, { type: "button", size: "sm", variant: "outline", "aria-label": `Change how ${item.name} is counted`, onClick: () => {
|
|
156
|
+
setEditing(item.account);
|
|
157
|
+
setBasisValue(item.basis);
|
|
158
|
+
setFrom(today);
|
|
159
|
+
}, children: "Change" })] }), editing === item.account ? (_jsxs("form", { className: "flex flex-wrap items-end gap-2", onSubmit: save, "aria-label": `How ${item.name} is counted`, children: [_jsxs("label", { className: "grid gap-1", children: [_jsx("span", { children: "Counted" }), _jsxs("select", { className: "rounded-md border border-input px-2 py-1", value: basis, onChange: (e) => setBasisValue(e.target.value), children: [_jsx("option", { value: "not_counted", children: basisLabel("not_counted") }), _jsx("option", { value: "by_time", children: basisLabel("by_time") }), _jsx("option", { value: "by_class", children: basisLabel("by_class") })] })] }), _jsxs("label", { className: "grid gap-1", children: [_jsx("span", { children: "From" }), _jsx("input", { type: "date", className: "rounded-md border border-input px-2 py-1", value: from, onChange: (e) => setFrom(e.target.value) })] }), _jsx(Button, { type: "submit", size: "sm", disabled: setBasis.isPending, children: "Save" })] })) : null] }, item.account))) }), bases.data?.truncated ? (_jsx("p", { className: "text-xs text-muted-foreground", children: "Only the first people are listed." })) : null] }));
|
|
160
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type RosteringHooks } from "@composable-os/pack-rostering/client";
|
|
2
|
+
type Hooks = Pick<RosteringHooks, "useMe" | "usePeople" | "useQualifications" | "useQualify">;
|
|
3
|
+
export declare function Qualifications({ rostering }: {
|
|
4
|
+
rostering: Hooks;
|
|
5
|
+
}): import("react").JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Qualifications (stage 45 step 7), for someone who rosters: people down, kinds of work across
|
|
3
|
+
// (each class type, each duty), a tick each. A ticked person may take an offered shift of that
|
|
4
|
+
// kind without anybody approving; putting someone unticked on one is made with a warning. Who is
|
|
5
|
+
// qualified is the host's (`qualifications`), and each tick is the host's write (`qualify`).
|
|
6
|
+
//
|
|
7
|
+
// Shown only when the host says the reader rosters (`me.rosters`). On a phone the grid scrolls
|
|
8
|
+
// sideways inside its own box; the page does not.
|
|
9
|
+
import { rosterRefusal, } from "@composable-os/pack-rostering/client";
|
|
10
|
+
import { useId, useState } from "react";
|
|
11
|
+
const key = (account, object, id) => `${account}\u0000${object}\u0000${id}`;
|
|
12
|
+
export function Qualifications({ rostering }) {
|
|
13
|
+
const me = rostering.useMe();
|
|
14
|
+
const rosters = me.data?.rosters === true;
|
|
15
|
+
const people = rostering.usePeople(rosters);
|
|
16
|
+
const ticks = rostering.useQualifications({}, rosters);
|
|
17
|
+
const qualify = rostering.useQualify();
|
|
18
|
+
const [refusal, setRefusal] = useState(null);
|
|
19
|
+
const [pending, setPending] = useState(null);
|
|
20
|
+
const headingId = useId();
|
|
21
|
+
if (me.isPending)
|
|
22
|
+
return _jsx("p", { "aria-busy": "true", children: "Loading\u2026" });
|
|
23
|
+
if (me.error || !me.data)
|
|
24
|
+
return _jsx("p", { role: "alert", children: rosterRefusal(me.error).message });
|
|
25
|
+
if (!rosters) {
|
|
26
|
+
return (_jsx("p", { role: "status", "data-refusal": "rostering", children: "Who may do which work is set by whoever rosters." }));
|
|
27
|
+
}
|
|
28
|
+
const held = new Set((ticks.data?.items ?? []).map((q) => key(q.account, q.kind.object, q.kind.id)));
|
|
29
|
+
const kinds = people.data?.kinds ?? [];
|
|
30
|
+
async function toggle(account, kind, on) {
|
|
31
|
+
const k = key(account, kind.object, kind.id);
|
|
32
|
+
setRefusal(null);
|
|
33
|
+
setPending(k);
|
|
34
|
+
try {
|
|
35
|
+
await qualify.mutateAsync({ account, kind, qualified: on });
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
setRefusal(rosterRefusal(error));
|
|
39
|
+
}
|
|
40
|
+
await ticks.refetch?.();
|
|
41
|
+
setPending(null);
|
|
42
|
+
}
|
|
43
|
+
return (_jsxs("section", { className: "grid gap-3", "aria-labelledby": headingId, children: [_jsx("h2", { id: headingId, className: "text-lg font-medium", children: "Who may do which work" }), _jsx("p", { className: "text-sm text-muted-foreground", children: "A ticked person can take an offered shift of that kind without anyone approving it." }), refusal ? (_jsx("p", { role: "alert", className: "text-sm", "data-refusal": refusal.kind, children: refusal.message })) : null, people.isPending || ticks.isPending ? _jsx("p", { "aria-busy": "true", children: "Loading\u2026" }) : null, people.error ? _jsx("p", { role: "alert", children: rosterRefusal(people.error).message }) : null, people.data && !kinds.length ? (_jsx("p", { children: "There are no class types or duties yet. Add them first." })) : null, people.data && kinds.length ? (_jsx("div", { className: "max-w-full overflow-x-auto rounded-md border", "data-testid": "qualifications-grid", children: _jsxs("table", { className: "text-sm", children: [_jsx("caption", { className: "sr-only", children: "People down, kinds of work across" }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", className: "sticky left-0 bg-background p-2 text-left", children: "Person" }), kinds.map((k) => (_jsxs("th", { scope: "col", className: "p-2 text-left font-medium", children: [k.name, _jsx("span", { className: "block text-xs font-normal text-muted-foreground", children: k.objectLabel })] }, `${k.object}:${k.id}`)))] }) }), _jsx("tbody", { children: people.data.people.map((p) => (_jsxs("tr", { className: "border-t", children: [_jsx("th", { scope: "row", className: "sticky left-0 bg-background p-2 text-left font-normal", children: p.name }), kinds.map((k) => {
|
|
44
|
+
const ck = key(p.account, k.object, k.id);
|
|
45
|
+
const on = held.has(ck);
|
|
46
|
+
return (_jsx("td", { className: "p-2 text-center", children: _jsx("input", { type: "checkbox", className: "size-5", "aria-label": `${p.name} may do ${k.name}`, checked: on, disabled: pending === ck, onChange: (e) => toggle(p.account, { object: k.object, id: k.id }, e.target.checked) }) }, ck));
|
|
47
|
+
})] }, p.account))) })] }) })) : null, people.data?.truncated ? (_jsx("p", { className: "text-xs text-muted-foreground", children: "Only the first people are listed." })) : null] }));
|
|
48
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type RosteringHooks, type RosterShift } from "@composable-os/pack-rostering/client";
|
|
2
|
+
export type AssignHooks = Pick<RosteringHooks, "useCandidates" | "useAssign" | "useFollow" | "useOffer" | "useMarkNotWorked">;
|
|
3
|
+
export declare function Assign({ rostering, shift, zone, today, locale, onClose, onChanged, }: {
|
|
4
|
+
rostering: AssignHooks;
|
|
5
|
+
shift: RosterShift;
|
|
6
|
+
zone: string;
|
|
7
|
+
/** Today's date in the business's zone, as the host gave it (`me.today`). */
|
|
8
|
+
today: string;
|
|
9
|
+
locale?: string;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
onChanged: () => void;
|
|
12
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// Putting someone on a shift (stage 45 step 7), for someone who rosters: opened from a shift on the
|
|
3
|
+
// roster week. The people the host says could take it come first (qualified, free, available),
|
|
4
|
+
// the rest below with the host's warnings, and those it would clash with or cannot name last,
|
|
5
|
+
// each saying why. "Back to the pattern" for a shift of a weekly pattern that keeps its own
|
|
6
|
+
// person; nobody on it; offer it to everyone who could take it; and, once it has started, mark it
|
|
7
|
+
// not worked with why.
|
|
8
|
+
//
|
|
9
|
+
// Every answer is the host's: who is eligible and why not (`candidates`, the same dry run a write
|
|
10
|
+
// is made with), the warnings a write was made with, and each refusal (double_booked naming the
|
|
11
|
+
// other shift, nobody_qualified, the cut-off, a locked pay period, someone who no longer rosters).
|
|
12
|
+
// Why a shift was not worked is forgotten once the call is over and when the page is left.
|
|
13
|
+
import { dateIn, forgetAfter, refusalNext, rosterRefusal, shiftTime, warningLabel, } from "@composable-os/pack-rostering/client";
|
|
14
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
15
|
+
import { Button } from "../ui-button/button.js";
|
|
16
|
+
/** Forgets what was typed when the page is left, or brought back from the back-forward cache. */
|
|
17
|
+
function useForgetOnLeave(forget) {
|
|
18
|
+
const latest = useRef(forget);
|
|
19
|
+
latest.current = forget;
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const hide = () => latest.current();
|
|
22
|
+
const show = (event) => {
|
|
23
|
+
if (event.persisted)
|
|
24
|
+
latest.current();
|
|
25
|
+
};
|
|
26
|
+
window.addEventListener("pagehide", hide);
|
|
27
|
+
window.addEventListener("pageshow", show);
|
|
28
|
+
return () => {
|
|
29
|
+
window.removeEventListener("pagehide", hide);
|
|
30
|
+
window.removeEventListener("pageshow", show);
|
|
31
|
+
};
|
|
32
|
+
}, []);
|
|
33
|
+
}
|
|
34
|
+
export function Assign({ rostering, shift, zone, today, locale = "en-AU", onClose, onChanged, }) {
|
|
35
|
+
const candidates = rostering.useCandidates({ object: shift.object, id: shift.id });
|
|
36
|
+
const assign = rostering.useAssign();
|
|
37
|
+
const follow = rostering.useFollow();
|
|
38
|
+
const offer = rostering.useOffer();
|
|
39
|
+
const notWorked = rostering.useMarkNotWorked();
|
|
40
|
+
const [refusal, setRefusal] = useState(null);
|
|
41
|
+
const [done, setDone] = useState(null);
|
|
42
|
+
const [reason, setReason] = useState("");
|
|
43
|
+
const headingId = useId();
|
|
44
|
+
const reasonId = useId();
|
|
45
|
+
useForgetOnLeave(() => setReason(""));
|
|
46
|
+
const busy = assign.isPending || follow.isPending || offer.isPending || notWorked.isPending;
|
|
47
|
+
async function act(what, said) {
|
|
48
|
+
setRefusal(null);
|
|
49
|
+
setDone(null);
|
|
50
|
+
try {
|
|
51
|
+
const answer = (await what());
|
|
52
|
+
const warnings = answer?.warnings ?? [];
|
|
53
|
+
setDone(warnings.length
|
|
54
|
+
? `${said} With warnings: ${warnings.map((w) => w.message).join(" ")}`
|
|
55
|
+
: said);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
setRefusal(rosterRefusal(error));
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
onChanged();
|
|
62
|
+
await candidates.refetch?.();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async function markNotWorked(event) {
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
const why = reason.trim();
|
|
68
|
+
if (!why) {
|
|
69
|
+
setRefusal({ kind: "invalid", message: "Say why it was not worked." });
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
await act(() => forgetAfter(notWorked, {
|
|
73
|
+
object: shift.object,
|
|
74
|
+
id: shift.id,
|
|
75
|
+
notWorked: true,
|
|
76
|
+
reason: why,
|
|
77
|
+
}), "Marked as not worked: it counts for nothing in its pay period.");
|
|
78
|
+
setReason("");
|
|
79
|
+
}
|
|
80
|
+
const data = candidates.data;
|
|
81
|
+
const groups = data
|
|
82
|
+
? [
|
|
83
|
+
{ title: "Could take it", people: data.people.filter((p) => p.eligible) },
|
|
84
|
+
{
|
|
85
|
+
title: "With warnings",
|
|
86
|
+
people: data.people.filter((p) => !p.eligible && !p.clash && !p.noProfile),
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
title: "On another shift then, or no profile",
|
|
90
|
+
people: data.people.filter((p) => p.clash || p.noProfile),
|
|
91
|
+
},
|
|
92
|
+
]
|
|
93
|
+
: [];
|
|
94
|
+
return (_jsxs("aside", { className: "grid content-start gap-3 rounded-md border p-3", "aria-labelledby": headingId, children: [_jsxs("header", { className: "flex items-start justify-between gap-2", children: [_jsxs("div", { children: [_jsx("h3", { id: headingId, className: "font-medium", children: shift.title }), _jsxs("p", { className: "text-sm text-muted-foreground", children: [shiftTime(shift, zone, { withDate: true, locale }), shift.place ? ` · ${shift.place}` : ""] })] }), _jsx(Button, { type: "button", variant: "outline", onClick: onClose, "aria-label": "Close the shift", children: "Close" })] }), refusal ? (_jsxs("div", { role: "alert", className: "rounded-md border border-destructive p-2 text-sm", "data-refusal": refusal.kind, children: [_jsx("p", { children: refusal.message }), refusal.dates?.length ? _jsxs("p", { children: ["Dates: ", refusal.dates.join(", ")] }) : null, refusalNext(refusal.kind, true) ? _jsx("p", { children: refusalNext(refusal.kind, true) }) : null] })) : null, done ? (_jsx("p", { role: "status", className: "text-sm", children: done })) : null, candidates.isPending ? _jsx("p", { "aria-busy": "true", children: "Loading who could take it\u2026" }) : null, candidates.error ? (_jsx("p", { role: "alert", "data-refusal": rosterRefusal(candidates.error).kind, children: rosterRefusal(candidates.error).message })) : null, data ? (_jsxs(_Fragment, { children: [_jsxs("p", { className: "text-sm", children: ["On it now: ", _jsx("strong", { children: data.current.name ?? "nobody" })] }), data.pattern ? (_jsxs("div", { className: "grid gap-1 text-sm", children: [_jsxs("p", { children: ["Its regular person: ", data.pattern.name ?? "nobody", data.pattern.own ? " (this date keeps its own person)" : ""] }), data.pattern.own ? (_jsx(Button, { type: "button", variant: "outline", disabled: busy, onClick: () => act(() => follow.mutateAsync({ object: shift.object, id: shift.id }), "Back to the pattern."), children: "Back to the pattern" })) : null] })) : null, _jsxs("div", { className: "flex flex-wrap gap-2", children: [data.current.account ? (_jsxs(Button, { type: "button", variant: "outline", disabled: busy, onClick: () => act(() => assign.mutateAsync({ object: shift.object, id: shift.id, account: null }), "Nobody is on it now."), children: ["Take ", data.current.name ?? "them", " off it"] })) : null, shift.offer ? null : (_jsx(Button, { type: "button", variant: "outline", disabled: busy, onClick: () => act(() => offer.mutateAsync({ object: shift.object, id: shift.id }), "Offered to everyone who could take it."), children: "Offer to everyone" }))] }), data.truncated ? (_jsx("p", { className: "text-xs text-muted-foreground", children: "Only the first people are listed." })) : null, groups.map((group) => group.people.length ? (_jsxs("section", { className: "grid gap-1", "aria-label": group.title, children: [_jsx("h4", { className: "text-sm font-medium", children: group.title }), _jsx("ul", { className: "grid gap-1", children: group.people.map((p) => (_jsxs("li", { className: "flex flex-wrap items-center justify-between gap-2 rounded border p-1.5 text-sm", children: [_jsxs("span", { children: [p.name, p.account === data.current.account ? " (on it)" : "", p.warnings.map((w) => (_jsx("span", { className: "ml-1 rounded border px-1 text-xs", title: w.message, "data-warning": w.code, children: warningLabel(w.code) }, w.code))), p.clash ? (_jsxs("span", { className: "block text-xs text-muted-foreground", children: ["On ", p.clash.title, ", ", shiftTime(p.clash, zone, { locale })] })) : null, p.noProfile ? (_jsx("span", { className: "block text-xs text-muted-foreground", children: "No profile this shift can name" })) : null] }), p.account === data.current.account ? null : (_jsx(Button, { type: "button", size: "sm", variant: p.eligible ? "default" : "outline", disabled: busy || Boolean(p.clash) || p.noProfile, "aria-label": `Put ${p.name} on it`, onClick: () => act(() => assign.mutateAsync({
|
|
95
|
+
object: shift.object,
|
|
96
|
+
id: shift.id,
|
|
97
|
+
account: p.account,
|
|
98
|
+
}), `${p.name} is on it now.`), children: "Put on" }))] }, p.account))) })] }, group.title)) : null), dateIn(shift.startsAt, zone) <= today && !shift.uncovered ? (_jsxs("form", { className: "grid gap-1", onSubmit: markNotWorked, "aria-label": "Mark not worked", children: [_jsx("label", { htmlFor: reasonId, className: "text-sm font-medium", children: "Not worked? Say why (kept with the shift, for pay)" }), _jsx("input", { id: reasonId, className: "rounded-md border border-input px-2 py-1 text-sm", value: reason, maxLength: 500, autoComplete: "off", onChange: (e) => setReason(e.target.value) }), _jsx(Button, { type: "submit", variant: "outline", disabled: busy, children: "Mark not worked" })] })) : null] })) : null] }));
|
|
99
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type RosteringHooks, type RosterShift } from "@composable-os/pack-rostering/client";
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
import { type AssignHooks } from "./assign.tsx";
|
|
4
|
+
type Hooks = Pick<RosteringHooks, "useMe" | "useWeek"> & Partial<AssignHooks>;
|
|
5
|
+
export declare function RosterWeek({ rostering, from, locale, shiftExtra, }: {
|
|
6
|
+
rostering: Hooks;
|
|
7
|
+
/** The Monday (or any date) to open on; the week of today in the business's zone by default. */
|
|
8
|
+
from?: string;
|
|
9
|
+
locale?: string;
|
|
10
|
+
/** Something to show under a shift (a duty shift's checklist: rostering-checklist's ShiftChecklist). */
|
|
11
|
+
shiftExtra?: (shift: RosterShift) => ReactNode;
|
|
12
|
+
}): import("react").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// The roster week (stage 45 step 7): a week grid, days across on a wide screen and one under
|
|
3
|
+
// another on a phone, each day's shifts in order of start with the kind of work, the place and who
|
|
4
|
+
// is on it; shifts with nobody on them marked, my own highlighted, an open offer shown. For the
|
|
5
|
+
// team it is read only. For someone who rosters (the host's `me.rosters`, never guessed here) each
|
|
6
|
+
// shift opens the assign panel beside it, and the roster carries each shift's warnings, which the
|
|
7
|
+
// host gives to rosterers only.
|
|
8
|
+
//
|
|
9
|
+
// Times are the host's: each shift's start and end are shown in the business's zone (the roster's
|
|
10
|
+
// `zone`), never the device's, and each day's length comes from the host's `days` (a clock-change
|
|
11
|
+
// day says so). Nothing here works out who may be on a shift: the assign panel shows the host's
|
|
12
|
+
// answer. A duty shift with a checklist (step 4b) shows its name, and how it is going when the host
|
|
13
|
+
// says the reader may see it; `shiftExtra` takes the checklist itself (rostering-checklist).
|
|
14
|
+
import { addDays, checklistStateLabel, clockChange, dayLabel, personOn, rosterRefusal, shiftName, shiftsByDay, shiftTime, warningLabel, weekOf, } from "@composable-os/pack-rostering/client";
|
|
15
|
+
import { useId, useState } from "react";
|
|
16
|
+
import { Button } from "../ui-button/button.js";
|
|
17
|
+
import { Assign } from "./assign.js";
|
|
18
|
+
/** The hooks the assign panel calls, when the client holds every one of them. */
|
|
19
|
+
function assignHooks(h) {
|
|
20
|
+
const { useCandidates, useAssign, useFollow, useOffer, useMarkNotWorked } = h;
|
|
21
|
+
return useCandidates && useAssign && useFollow && useOffer && useMarkNotWorked
|
|
22
|
+
? { useCandidates, useAssign, useFollow, useOffer, useMarkNotWorked }
|
|
23
|
+
: null;
|
|
24
|
+
}
|
|
25
|
+
/** A stable colour per kind of work (display only): the same kind is always the same colour. */
|
|
26
|
+
const COLOURS = [
|
|
27
|
+
"border-l-sky-600",
|
|
28
|
+
"border-l-emerald-600",
|
|
29
|
+
"border-l-amber-600",
|
|
30
|
+
"border-l-violet-600",
|
|
31
|
+
"border-l-rose-600",
|
|
32
|
+
"border-l-teal-600",
|
|
33
|
+
"border-l-orange-600",
|
|
34
|
+
"border-l-indigo-600",
|
|
35
|
+
];
|
|
36
|
+
function colourOf(shift) {
|
|
37
|
+
const key = shift.kind?.id ?? shift.object;
|
|
38
|
+
let h = 0;
|
|
39
|
+
for (const c of key)
|
|
40
|
+
h = (h * 31 + c.charCodeAt(0)) % 9973;
|
|
41
|
+
return COLOURS[h % COLOURS.length];
|
|
42
|
+
}
|
|
43
|
+
export function RosterWeek({ rostering, from, locale = "en-AU", shiftExtra, }) {
|
|
44
|
+
const me = rostering.useMe();
|
|
45
|
+
const [start, setStart] = useState(from ? weekOf(from) : null);
|
|
46
|
+
const first = start ?? (me.data ? weekOf(me.data.today) : null);
|
|
47
|
+
const week = rostering.useWeek({ from: first ?? "", to: first ? addDays(first, 6) : "" }, first !== null);
|
|
48
|
+
const [open, setOpen] = useState(null);
|
|
49
|
+
const headingId = useId();
|
|
50
|
+
if (me.isPending)
|
|
51
|
+
return _jsx("p", { "aria-busy": "true", children: "Loading the roster\u2026" });
|
|
52
|
+
if (me.error || !me.data) {
|
|
53
|
+
return _jsx("p", { role: "alert", children: rosterRefusal(me.error).message });
|
|
54
|
+
}
|
|
55
|
+
const today = me.data.today;
|
|
56
|
+
const assigning = me.data.rosters ? assignHooks(rostering) : null;
|
|
57
|
+
const rosters = assigning !== null;
|
|
58
|
+
const zone = week.data?.zone ?? me.data.zone;
|
|
59
|
+
const go = (date) => {
|
|
60
|
+
setOpen(null);
|
|
61
|
+
setStart(weekOf(date));
|
|
62
|
+
};
|
|
63
|
+
return (_jsxs("section", { className: "grid gap-4", "aria-labelledby": headingId, children: [_jsxs("header", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsxs("h2", { id: headingId, className: "text-lg font-medium", children: ["Roster", first ? `: week of ${dayLabel(first, locale, true)}` : ""] }), _jsxs("nav", { "aria-label": "Weeks", className: "flex flex-wrap gap-2", children: [_jsx(Button, { type: "button", variant: "outline", onClick: () => first && go(addDays(first, -7)), "aria-label": "Previous week", children: "\u2039 Previous" }), _jsx(Button, { type: "button", variant: "outline", onClick: () => go(today), children: "This week" }), _jsx(Button, { type: "button", variant: "outline", onClick: () => first && go(addDays(first, 7)), "aria-label": "Next week", children: "Next \u203A" })] })] }), _jsxs("p", { className: "text-sm text-muted-foreground", children: ["Times are in ", zone, ".", rosters ? " Choose a shift to put someone on it." : ""] }), week.isPending ? _jsx("p", { "aria-busy": "true", children: "Loading the week\u2026" }) : null, week.error ? _jsx("p", { role: "alert", children: rosterRefusal(week.error).message }) : null, week.data?.truncated ? (_jsx("p", { role: "status", className: "rounded-md border p-2 text-sm", children: "This week has more shifts than one screen shows: the first ones are shown." })) : null, week.data ? (_jsxs("div", { className: "grid gap-4 lg:grid-cols-[1fr_minmax(18rem,22rem)]", children: [_jsx("ol", { className: "grid grid-cols-1 gap-3 md:grid-cols-7", "aria-label": "Days of the week", children: shiftsByDay(week.data).map(({ day, shifts }) => {
|
|
64
|
+
const change = clockChange(day);
|
|
65
|
+
return (_jsxs("li", { className: "min-w-0 rounded-md border p-2", "data-date": day.date, "data-today": day.date === today ? "true" : undefined, children: [_jsxs("h3", { className: "text-sm font-medium", children: [dayLabel(day.date, locale), day.date === today ? " (today)" : ""] }), change ? (_jsx("p", { className: "text-xs text-muted-foreground", "data-testid": "clock-change", children: change })) : null, shifts.length ? (_jsx("ul", { className: "mt-2 grid gap-2", "aria-label": `Shifts on ${dayLabel(day.date, locale, true)}`, children: shifts.map((shift) => (_jsxs("li", { children: [_jsx(ShiftCard, { shift: shift, zone: zone, locale: locale, selected: open?.id === shift.id, onOpen: rosters ? () => setOpen(shift) : undefined }), shiftExtra?.(shift)] }, `${shift.object}:${shift.id}`))) })) : (_jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: "No shifts" }))] }, day.date));
|
|
66
|
+
}) }), open && assigning ? (_jsx(Assign, { rostering: assigning, shift: open, zone: zone, today: today, locale: locale, onClose: () => setOpen(null), onChanged: () => week.refetch?.() })) : null] })) : null] }));
|
|
67
|
+
}
|
|
68
|
+
function ShiftCard({ shift, zone, locale, selected, onOpen, }) {
|
|
69
|
+
const body = (_jsxs(_Fragment, { children: [_jsx("span", { className: "block text-xs text-muted-foreground", children: shiftTime(shift, zone, { locale }) }), _jsx("span", { className: "block font-medium", children: shift.title }), shift.place ? _jsx("span", { className: "block text-xs", children: shift.place }) : null, _jsx("span", { className: `block text-xs ${shift.uncovered ? "font-semibold" : ""}`, children: personOn(shift) }), shift.offer ? (_jsx("span", { className: "mt-1 inline-block rounded border px-1 text-xs", children: "Offered" })) : null, shift.checklist ? (_jsxs("span", { className: "mt-1 mr-1 inline-block rounded border px-1 text-xs", "data-checklist": shift.checklist.state ?? "hidden", children: [shift.checklist.name, shift.checklist.state ? `: ${checklistStateLabel(shift.checklist.state)}` : ""] })) : null, (shift.warnings ?? []).map((w) => (_jsx("span", { className: "mt-1 mr-1 inline-block rounded border border-destructive px-1 text-xs text-destructive", title: w.message, "data-warning": w.code, children: warningLabel(w.code) }, `${w.code}:${w.account ?? ""}`)))] }));
|
|
70
|
+
const look = [
|
|
71
|
+
"block w-full rounded-md border border-l-4 p-2 text-left text-sm",
|
|
72
|
+
colourOf(shift),
|
|
73
|
+
shift.uncovered ? "border-dashed" : "",
|
|
74
|
+
shift.mine ? "bg-accent ring-2 ring-ring" : "",
|
|
75
|
+
selected ? "outline outline-2 outline-ring" : "",
|
|
76
|
+
].join(" ");
|
|
77
|
+
const name = shiftName(shift, zone, locale);
|
|
78
|
+
if (onOpen) {
|
|
79
|
+
return (_jsx("button", { type: "button", className: look, "aria-label": name, "aria-pressed": selected, "data-shift": shift.id, "data-mine": shift.mine ? "true" : undefined, "data-uncovered": shift.uncovered ? "true" : undefined, onClick: onOpen, children: body }));
|
|
80
|
+
}
|
|
81
|
+
return (_jsx("article", { className: look, "aria-label": name, "data-shift": shift.id, "data-mine": shift.mine ? "true" : undefined, "data-uncovered": shift.uncovered ? "true" : undefined, children: body }));
|
|
82
|
+
}
|