@composable-os/pack-rostering 0.0.0-stage → 0.1.0-beta.12
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,110 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// My availability in the app (stage 45 step 7): the times I said I cannot work, adding leave or
|
|
3
|
+
// another one-off time, or a regular time off (every week on chosen days), and ending one. Nobody
|
|
4
|
+
// approves it; only I and whoever rosters see it. When it covers shifts I am on, they stay mine
|
|
5
|
+
// and this offers them in one step. Dates and times are typed as the host takes them (a date
|
|
6
|
+
// YYYY-MM-DD, a time HH:MM, in the business's zone): no date picker module is needed, and the host
|
|
7
|
+
// says what is wrong with what was typed.
|
|
8
|
+
//
|
|
9
|
+
// What I write about my time off is forgotten once the call is over (`forgetAfter`) and when the
|
|
10
|
+
// screen closes; my list with its notes is kept in the app's cache no longer than it is shown.
|
|
11
|
+
import { awayKind, awayWhen, forgetAfter, rosterRefusal, shiftTime, WEEKDAYS, } from "@composable-os/pack-rostering/client";
|
|
12
|
+
import { useState } from "react";
|
|
13
|
+
import { View } from "react-native";
|
|
14
|
+
import { Button } from "../native-base/button.js";
|
|
15
|
+
import { Field } from "../native-base/field.js";
|
|
16
|
+
import { List } from "../native-base/list.js";
|
|
17
|
+
import { Row } from "../native-base/row.js";
|
|
18
|
+
import { Screen } from "../native-base/screen.js";
|
|
19
|
+
import { Text } from "../native-base/text.js";
|
|
20
|
+
const EMPTY = {
|
|
21
|
+
kind: "leave",
|
|
22
|
+
startDate: "",
|
|
23
|
+
startTime: "00:00",
|
|
24
|
+
endDate: "",
|
|
25
|
+
endTime: "23:59",
|
|
26
|
+
weekdays: [],
|
|
27
|
+
fromDate: "",
|
|
28
|
+
untilDate: "",
|
|
29
|
+
note: "",
|
|
30
|
+
};
|
|
31
|
+
function inputOf(form) {
|
|
32
|
+
const note = form.note.trim() ? { note: form.note.trim() } : {};
|
|
33
|
+
if (form.kind === "regular") {
|
|
34
|
+
return {
|
|
35
|
+
kind: "regular",
|
|
36
|
+
weekdays: form.weekdays,
|
|
37
|
+
startTime: form.startTime,
|
|
38
|
+
endTime: form.endTime,
|
|
39
|
+
fromDate: form.fromDate,
|
|
40
|
+
...(form.untilDate ? { untilDate: form.untilDate } : {}),
|
|
41
|
+
...note,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
kind: "leave",
|
|
46
|
+
startsAt: `${form.startDate}T${form.startTime}`,
|
|
47
|
+
endsAt: `${form.endDate}T${form.endTime}`,
|
|
48
|
+
...note,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export function MyAvailabilityScreen({ rostering, locale = "en-AU", }) {
|
|
52
|
+
const me = rostering.useMe();
|
|
53
|
+
const list = rostering.useMyAway({});
|
|
54
|
+
const away = rostering.useAway();
|
|
55
|
+
const back = rostering.useBack();
|
|
56
|
+
const offer = rostering.useOffer();
|
|
57
|
+
const [form, setForm] = useState(EMPTY);
|
|
58
|
+
const [answer, setAnswer] = useState(null);
|
|
59
|
+
const [offered, setOffered] = useState([]);
|
|
60
|
+
const [refusal, setRefusal] = useState(null);
|
|
61
|
+
const [said, setSaid] = useState(null);
|
|
62
|
+
const zone = me.data?.zone ?? "UTC";
|
|
63
|
+
const set = (patch) => setForm((f) => ({ ...f, ...patch }));
|
|
64
|
+
async function submit() {
|
|
65
|
+
setRefusal(null);
|
|
66
|
+
setSaid(null);
|
|
67
|
+
setAnswer(null);
|
|
68
|
+
setOffered([]);
|
|
69
|
+
try {
|
|
70
|
+
const made = await forgetAfter(away, inputOf(form));
|
|
71
|
+
setAnswer(made);
|
|
72
|
+
setForm(EMPTY);
|
|
73
|
+
setSaid("Saved. Only you and whoever rosters can see it.");
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
setRefusal(rosterRefusal(error));
|
|
77
|
+
}
|
|
78
|
+
await list.refetch?.();
|
|
79
|
+
}
|
|
80
|
+
async function remove(id) {
|
|
81
|
+
setRefusal(null);
|
|
82
|
+
try {
|
|
83
|
+
await back.mutateAsync({ id });
|
|
84
|
+
setSaid("Removed.");
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
setRefusal(rosterRefusal(error));
|
|
88
|
+
}
|
|
89
|
+
await list.refetch?.();
|
|
90
|
+
}
|
|
91
|
+
async function offerShift(object, id) {
|
|
92
|
+
setRefusal(null);
|
|
93
|
+
try {
|
|
94
|
+
await offer.mutateAsync({ object, id });
|
|
95
|
+
setOffered((o) => [...o, id]);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
setRefusal(rosterRefusal(error));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return (_jsxs(Screen, { title: "My availability", children: [me.isPending ? (_jsx(Text, { tone: "muted", accessibilityRole: "progressbar", children: "Loading\u2026" })) : null, me.error ? _jsx(Text, { accessibilityRole: "alert", children: rosterRefusal(me.error).message }) : null, _jsxs(Text, { children: ["Times are in ", zone, ". Only you and whoever rosters see this."] }), said ? _jsx(Text, { accessibilityRole: "alert", children: said }) : null, refusal ? _jsx(Text, { accessibilityRole: "alert", children: refusal.message }) : null, answer?.count ? (_jsxs(View, { children: [_jsxs(Text, { children: ["You are on ", answer.count, " shift", answer.count === 1 ? "" : "s", " then. They stay yours until someone takes them: offer them now?"] }), _jsx(List, { children: answer.shifts.map((s) => (_jsxs(View, { children: [_jsx(Row, { title: s.title, detail: shiftTime(s, zone, { withDate: true, locale }) }), offered.includes(s.id) ? (_jsx(Text, { children: "Offered" })) : (_jsx(Button, { label: `Offer ${s.title}`, quiet: true, busy: offer.isPending, onPress: () => offerShift(s.object, s.id) }))] }, s.id))) })] })) : null, _jsxs(View, { accessibilityLabel: "Add time off", children: [_jsx(Text, { accessibilityRole: "header", children: "Add time off" }), _jsxs(View, { accessibilityRole: "radiogroup", children: [_jsx(Button, { label: form.kind === "leave" ? "One-off time (chosen)" : "One-off time", quiet: form.kind !== "leave", onPress: () => set({ kind: "leave" }) }), _jsx(Button, { label: form.kind === "regular" ? "Every week (chosen)" : "Every week", quiet: form.kind !== "regular", onPress: () => set({ kind: "regular" }) })] }), form.kind === "regular" ? (_jsxs(_Fragment, { children: [_jsx(View, { children: WEEKDAYS.map(([value, name]) => {
|
|
102
|
+
const label = name.slice(0, 3);
|
|
103
|
+
const on = form.weekdays.includes(value);
|
|
104
|
+
return (_jsx(Button, { label: on ? `${label} (chosen)` : label, quiet: !on, onPress: () => set({
|
|
105
|
+
weekdays: on
|
|
106
|
+
? form.weekdays.filter((d) => d !== value)
|
|
107
|
+
: [...form.weekdays, value],
|
|
108
|
+
}) }, value));
|
|
109
|
+
}) }), _jsx(Field, { label: "From (time, HH:MM)", value: form.startTime, onChangeText: (v) => set({ startTime: v }) }), _jsx(Field, { label: "Until (time, HH:MM)", value: form.endTime, onChangeText: (v) => set({ endTime: v }) }), _jsx(Field, { label: "Starting on (YYYY-MM-DD)", value: form.fromDate, onChangeText: (v) => set({ fromDate: v }) }), _jsx(Field, { label: "Ending on (YYYY-MM-DD, optional)", value: form.untilDate, onChangeText: (v) => set({ untilDate: v }) })] })) : (_jsxs(_Fragment, { children: [_jsx(Field, { label: "From (date, YYYY-MM-DD)", value: form.startDate, onChangeText: (v) => set({ startDate: v }) }), _jsx(Field, { label: "From (time, HH:MM)", value: form.startTime, onChangeText: (v) => set({ startTime: v }) }), _jsx(Field, { label: "Until (date, YYYY-MM-DD)", value: form.endDate, onChangeText: (v) => set({ endDate: v }) }), _jsx(Field, { label: "Until (time, HH:MM)", value: form.endTime, onChangeText: (v) => set({ endTime: v }) })] })), _jsx(Field, { label: "Note (optional, seen by you and whoever rosters)", value: form.note, maxLength: 500, autoComplete: "off", onChangeText: (v) => set({ note: v }) }), _jsx(Button, { label: "Add time off", busy: away.isPending, onPress: submit })] }), _jsx(Text, { accessibilityRole: "header", children: "My time off" }), list.isPending ? (_jsx(Text, { tone: "muted", accessibilityRole: "progressbar", children: "Loading\u2026" })) : null, list.data ? (_jsx(List, { empty: "None from today on.", children: list.data.items.map((item) => (_jsxs(View, { children: [_jsx(Row, { title: `${awayKind(item.kind)} · ${awayWhen(item, locale)}`, detail: item.note }), _jsx(Button, { label: `End ${awayKind(item.kind).toLowerCase()}`, quiet: true, busy: back.isPending, onPress: () => remove(item.id) })] }, item.id))) })) : null] }));
|
|
110
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type RosteringHooks } from "@composable-os/pack-rostering/client";
|
|
2
|
+
type Hooks = Pick<RosteringHooks, "useFeed" | "useFeedRotate" | "useFeedRevoke">;
|
|
3
|
+
export declare function MyCalendarScreen({ rostering, openUrl, copy, }: {
|
|
4
|
+
rostering: Hooks;
|
|
5
|
+
/** Opens the webcal address in the phone's calendar (React Native's `Linking.openURL`). */
|
|
6
|
+
openUrl: (url: string) => Promise<unknown> | unknown;
|
|
7
|
+
/** The app's clipboard, if it has one (for example expo-clipboard's `setStringAsync`). */
|
|
8
|
+
copy?: (text: string) => Promise<unknown> | unknown;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// My calendar in the app (stage 45 step 7, over step 5's feed, ADR 0628): whether I have a private
|
|
3
|
+
// calendar address for my own shifts, making one (or a new one, which stops the old), and switching
|
|
4
|
+
// it off. The address is shown once, as the host gives it, then copied (the app's own clipboard,
|
|
5
|
+
// passed as `copy`) or opened in the phone's calendar (`openUrl`, React Native's Linking.openURL,
|
|
6
|
+
// with the webcal address); it is never stored, and is cleared when the screen closes. A lost
|
|
7
|
+
// address is never shown again: make a new one. The same headless entry as the web's screen.
|
|
8
|
+
import { forgetAfter, rosterRefusal, } from "@composable-os/pack-rostering/client";
|
|
9
|
+
import { useEffect, useState } from "react";
|
|
10
|
+
import { AppState, View } from "react-native";
|
|
11
|
+
import { Button } from "../native-base/button.js";
|
|
12
|
+
import { Screen } from "../native-base/screen.js";
|
|
13
|
+
import { Sheet } from "../native-base/sheet.js";
|
|
14
|
+
import { Text } from "../native-base/text.js";
|
|
15
|
+
export function MyCalendarScreen({ rostering, openUrl, copy, }) {
|
|
16
|
+
const feed = rostering.useFeed();
|
|
17
|
+
const rotate = rostering.useFeedRotate();
|
|
18
|
+
const revoke = rostering.useFeedRevoke();
|
|
19
|
+
const [address, setAddress] = useState(null);
|
|
20
|
+
const [confirm, setConfirm] = useState(null);
|
|
21
|
+
const [refusal, setRefusal] = useState(null);
|
|
22
|
+
const [said, setSaid] = useState(null);
|
|
23
|
+
useEffect(() => () => setAddress(null), []);
|
|
24
|
+
// Hidden when the app leaves the screen for the background, so the app switcher's snapshot never
|
|
25
|
+
// shows it.
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const listener = AppState.addEventListener("change", (state) => {
|
|
28
|
+
if (state !== "active")
|
|
29
|
+
setAddress(null);
|
|
30
|
+
});
|
|
31
|
+
return () => listener.remove();
|
|
32
|
+
}, []);
|
|
33
|
+
async function make() {
|
|
34
|
+
setConfirm(null);
|
|
35
|
+
setRefusal(null);
|
|
36
|
+
setSaid(null);
|
|
37
|
+
setAddress(null);
|
|
38
|
+
try {
|
|
39
|
+
const made = await forgetAfter(rotate, {});
|
|
40
|
+
setAddress({ https: made.https, webcal: made.webcal });
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
setRefusal(rosterRefusal(error));
|
|
44
|
+
}
|
|
45
|
+
await feed.refetch?.();
|
|
46
|
+
}
|
|
47
|
+
async function off() {
|
|
48
|
+
setConfirm(null);
|
|
49
|
+
setRefusal(null);
|
|
50
|
+
setAddress(null);
|
|
51
|
+
try {
|
|
52
|
+
await revoke.mutateAsync({});
|
|
53
|
+
setSaid("Switched off: the address no longer works.");
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
setRefusal(rosterRefusal(error));
|
|
57
|
+
}
|
|
58
|
+
await feed.refetch?.();
|
|
59
|
+
}
|
|
60
|
+
const busy = rotate.isPending || revoke.isPending;
|
|
61
|
+
return (_jsxs(Screen, { title: "My calendar", children: [_jsx(Text, { children: "A private address your phone's calendar subscribes to: your own shifts, kept up to date. Anyone with it sees your shifts, so do not share it. Calendars fetch it on their own schedule, often hours apart: this app is always the latest." }), feed.isPending ? (_jsx(Text, { tone: "muted", accessibilityRole: "progressbar", children: "Loading\u2026" })) : null, feed.error ? (_jsx(Text, { accessibilityRole: "alert", children: rosterRefusal(feed.error).message })) : null, refusal ? _jsx(Text, { accessibilityRole: "alert", children: refusal.message }) : null, said ? _jsx(Text, { accessibilityRole: "alert", children: said }) : null, address ? (_jsxs(View, { children: [_jsx(Text, { accessibilityRole: "header", children: "Your calendar address (shown this once)" }), _jsx(Text, { selectable: true, children: address.https }), _jsx(Button, { label: "Add to calendar", onPress: () => openUrl(address.webcal) }), copy ? (_jsx(Button, { label: "Copy the address", quiet: true, onPress: async () => {
|
|
62
|
+
try {
|
|
63
|
+
await copy(address.https);
|
|
64
|
+
setSaid("Copied.");
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
setSaid("It was not copied. Press and hold the address to copy it.");
|
|
68
|
+
}
|
|
69
|
+
} })) : null, _jsx(Button, { label: "Done", quiet: true, onPress: () => setAddress(null) }), _jsx(Text, { children: "It is not kept here. Lost it? Make a new address: the old one stops working." })] })) : null, feed.data && !address ? (_jsx(Text, { children: feed.data.active ? "You have a calendar address." : "You have no calendar address." })) : null, feed.data?.active ? (_jsxs(View, { children: [_jsx(Button, { label: "Make a new address", quiet: true, busy: busy, onPress: () => setConfirm("replace") }), _jsx(Button, { label: "Switch it off", quiet: true, busy: busy, onPress: () => setConfirm("off") })] })) : feed.data ? (_jsx(Button, { label: "Make my calendar address", busy: busy, onPress: make })) : null, _jsxs(Sheet, { open: confirm !== null, title: confirm === "replace" ? "Make a new address?" : "Switch it off?", onClose: () => setConfirm(null), children: [_jsx(Text, { children: confirm === "replace"
|
|
70
|
+
? "The address you have stops working, in every calendar that uses it."
|
|
71
|
+
: "The address stops working; your calendar keeps what it last fetched." }), _jsx(Button, { label: confirm === "replace" ? "Make a new address" : "Switch it off", busy: busy, onPress: confirm === "replace" ? make : off }), _jsx(Button, { label: "Keep it", quiet: true, onPress: () => setConfirm(null) })] })] }));
|
|
72
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type RosteringHooks } from "@composable-os/pack-rostering/client";
|
|
2
|
+
export type MyHoursHooks = Pick<RosteringHooks, "useMyPayPeriods" | "useMyPay">;
|
|
3
|
+
export declare function MyHoursNative({ rostering, locale, }: {
|
|
4
|
+
rostering: MyHoursHooks;
|
|
5
|
+
locale?: string;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// My hours in the app (stage 45, the owner's decision of 2026-11-24), a part of My shifts: my own
|
|
3
|
+
// hours and shifts for a pay period, as payroll is given them. Hours and counts only, no money.
|
|
4
|
+
// The shared logic is the pack's headless entry, as on the web; only the screen differs.
|
|
5
|
+
//
|
|
6
|
+
// The host answers everything: the periods (the current one and twelve before it), whether I am
|
|
7
|
+
// counted and how, my totals and each of my shifts (a locked period's locked figures, or a
|
|
8
|
+
// preview of an open one), and each refusal. Nothing about anyone else, and not why a shift was
|
|
9
|
+
// marked not worked, only that it was. The figures are fetched only when I pick a period, kept no
|
|
10
|
+
// longer than they are shown (`gcTime: 0`), hidden when the app goes to the background (read
|
|
11
|
+
// again when it comes back), and never stored.
|
|
12
|
+
import { basisLabel, dayLabel, payPeriodState, refusalNext, rosterRefusal, } from "@composable-os/pack-rostering/client";
|
|
13
|
+
import { useEffect, useState } from "react";
|
|
14
|
+
import { AppState, View } from "react-native";
|
|
15
|
+
import { Button } from "../native-base/button.js";
|
|
16
|
+
import { List } from "../native-base/list.js";
|
|
17
|
+
import { Row } from "../native-base/row.js";
|
|
18
|
+
import { Text } from "../native-base/text.js";
|
|
19
|
+
export function MyHoursNative({ rostering, locale = "en-AU", }) {
|
|
20
|
+
const [hidden, setHidden] = useState(false);
|
|
21
|
+
const periods = rostering.useMyPayPeriods(!hidden);
|
|
22
|
+
const [chosen, setChosen] = useState(null);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const listener = AppState.addEventListener("change", (state) => {
|
|
25
|
+
if (state !== "active") {
|
|
26
|
+
setChosen(null);
|
|
27
|
+
setHidden(true);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
setHidden(false);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return () => listener.remove();
|
|
34
|
+
}, []);
|
|
35
|
+
const period = periods.data?.periods.find((p) => p.start === chosen) ?? null;
|
|
36
|
+
const refusal = periods.error ? rosterRefusal(periods.error) : null;
|
|
37
|
+
return (_jsxs(View, { children: [_jsx(Text, { accessibilityRole: "header", children: "My hours" }), _jsx(Text, { children: "Your own hours and shifts for each pay period, as payroll is given them." }), hidden || periods.isPending ? (_jsx(Text, { tone: "muted", accessibilityRole: "progressbar", children: "Loading the pay periods\u2026" })) : null, !hidden && refusal ? (_jsxs(View, { children: [_jsx(Text, { accessibilityRole: "alert", children: refusal.kind === "human_only"
|
|
38
|
+
? "Your hours are shown to you only, at the screen."
|
|
39
|
+
: refusal.message }), refusal.kind === "network" || refusal.kind === "other" ? (_jsx(Button, { label: "Try again", quiet: true, onPress: () => periods.refetch?.() })) : null] })) : null, !hidden && periods.data && !periods.data.set ? (_jsx(Text, { children: "Pay periods are not set up yet, so there are no hours to show." })) : null, !hidden && periods.data?.set ? (_jsx(List, { children: periods.data.periods.map((p) => (_jsx(Row, { title: `${dayLabel(p.start, locale)} – ${dayLabel(p.end, locale)}${chosen === p.start ? " (shown)" : ""}`, detail: payPeriodState(p), onPress: () => setChosen(chosen === p.start ? null : p.start) }, p.start))) })) : null, !hidden && period ? (_jsx(PeriodHours, { rostering: rostering, period: period, locale: locale }, period.start)) : null] }));
|
|
40
|
+
}
|
|
41
|
+
function PeriodHours({ rostering, period, locale, }) {
|
|
42
|
+
const mine = rostering.useMyPay({ start: period.start });
|
|
43
|
+
const data = mine.data;
|
|
44
|
+
const refusal = mine.error ? rosterRefusal(mine.error) : null;
|
|
45
|
+
return (_jsxs(View, { children: [_jsxs(Text, { accessibilityRole: "header", children: [dayLabel(period.start, locale, true), " to ", dayLabel(period.end, locale, true)] }), mine.isPending ? (_jsx(Text, { tone: "muted", accessibilityRole: "progressbar", children: "Loading your hours\u2026" })) : null, refusal ? (_jsxs(View, { children: [_jsxs(Text, { accessibilityRole: "alert", children: [refusal.message, refusalNext(refusal.kind, false) ? ` ${refusalNext(refusal.kind, false)}` : ""] }), refusal.kind === "network" || refusal.kind === "other" ? (_jsx(Button, { label: "Try again", quiet: true, onPress: () => mine.refetch?.() })) : null] })) : null, data && !data.counted ? (_jsx(Text, { children: "You are not counted for pay in this period, so there are no hours to show. If you think you should be, ask whoever handles pay." })) : null, data?.counted ? (_jsxs(View, { children: [_jsx(Text, { children: data.period.preview
|
|
46
|
+
? "A preview from the roster as it stands: it can change until the period is locked."
|
|
47
|
+
: "Locked: these are the figures payroll was given." }), _jsxs(Text, { children: ["Counted: ", basisLabel(data.basis)] }), _jsx(List, { empty: "You have no counted shifts in this period.", children: data.totals.map((t) => (_jsx(Row, { title: t.kindName, detail: `${t.shifts} shifts · ${t.hours} hours${t.notWorked ? ` · ${t.notWorked} not worked` : ""}` }, `${t.basis}:${t.kind?.id ?? t.kindName}`))) }), _jsxs(Text, { children: ["All my hours: ", data.hours] }), data.lines.length ? (_jsx(List, { children: data.lines.map((l) => (_jsx(Row, { title: `${dayLabel(l.localDate, locale)} · ${l.title}`, detail: [
|
|
48
|
+
`${l.localStart.slice(11, 16)}–${l.localEnd.slice(11, 16)}`,
|
|
49
|
+
l.place,
|
|
50
|
+
l.notWorked
|
|
51
|
+
? "Marked not worked: counts for nothing. Ask whoever rosters why."
|
|
52
|
+
: `${l.countedMinutes} minutes`,
|
|
53
|
+
l.clockChange,
|
|
54
|
+
l.flagged
|
|
55
|
+
? "Its list was taken by someone else: whoever handles pay checks it."
|
|
56
|
+
: null,
|
|
57
|
+
]
|
|
58
|
+
.filter(Boolean)
|
|
59
|
+
.join(" · ") }, `${l.object}:${l.id}`))) })) : null] })) : null] }));
|
|
60
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type RosteringHooks, type RosterShift } from "@composable-os/pack-rostering/client";
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
import { type MyHoursHooks } from "./my-hours-screen.tsx";
|
|
4
|
+
type Hooks = Pick<RosteringHooks, "useMe" | "useMine" | "useOffers" | "useOffer" | "useWithdraw"> & MyHoursHooks;
|
|
5
|
+
export declare function MyShiftsScreen({ rostering, days, locale, calendar, shiftExtra, }: {
|
|
6
|
+
rostering: Hooks;
|
|
7
|
+
days?: number;
|
|
8
|
+
locale?: string;
|
|
9
|
+
calendar?: ReactNode;
|
|
10
|
+
shiftExtra?: (shift: RosterShift) => ReactNode;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// My shifts in the app (stage 45 step 7), for every rostered person: a cleaner with the
|
|
3
|
+
// `rostering.team` role (its role client), a coach whose role client was generated with the grant
|
|
4
|
+
// `rostering:roster`, or anyone else on the roster. The next weeks' shifts day by day, each with
|
|
5
|
+
// its time in the business's zone and its place, and offering one for someone else to take or
|
|
6
|
+
// withdrawing my offer. The shared logic is the pack's headless entry, as on the web; only the
|
|
7
|
+
// screen differs.
|
|
8
|
+
//
|
|
9
|
+
// The host decides and this shows: an offered shift stays mine until taken; an offer nobody could
|
|
10
|
+
// take, one past the cut-off, or one already made is refused with its own words. Room is left for
|
|
11
|
+
// a duty shift's checklist (`shiftExtra`: rostering-native-checklist's ShiftChecklistNative) and my
|
|
12
|
+
// calendar's address (`calendar`, step 5). Under the list, My hours (my-hours-screen.tsx, the
|
|
13
|
+
// owner's decision of 2026-11-24): my own hours for a pay period, fetched only when I pick one.
|
|
14
|
+
import { addDays, dateIn, dayLabel, refusalNext, rosterRefusal, shiftName, shiftTime, } from "@composable-os/pack-rostering/client";
|
|
15
|
+
import { useState } from "react";
|
|
16
|
+
import { View } from "react-native";
|
|
17
|
+
import { Button } from "../native-base/button.js";
|
|
18
|
+
import { List } from "../native-base/list.js";
|
|
19
|
+
import { Row } from "../native-base/row.js";
|
|
20
|
+
import { Screen } from "../native-base/screen.js";
|
|
21
|
+
import { Text } from "../native-base/text.js";
|
|
22
|
+
import { MyHoursNative } from "./my-hours-screen.js";
|
|
23
|
+
export function MyShiftsScreen({ rostering, days = 28, locale = "en-AU", calendar, shiftExtra, }) {
|
|
24
|
+
const me = rostering.useMe();
|
|
25
|
+
const first = me.data?.today ?? null;
|
|
26
|
+
const mine = rostering.useMine({ from: first ?? "", to: first ? addDays(first, Math.min(days, 62) - 1) : "" }, first !== null);
|
|
27
|
+
const offers = rostering.useOffers();
|
|
28
|
+
const offer = rostering.useOffer();
|
|
29
|
+
const withdraw = rostering.useWithdraw();
|
|
30
|
+
const [refusal, setRefusal] = useState(null);
|
|
31
|
+
const [said, setSaid] = useState(null);
|
|
32
|
+
const zone = mine.data?.zone ?? me.data?.zone ?? "UTC";
|
|
33
|
+
const busy = offer.isPending || withdraw.isPending;
|
|
34
|
+
async function act(id, what, done) {
|
|
35
|
+
setRefusal(null);
|
|
36
|
+
setSaid(null);
|
|
37
|
+
try {
|
|
38
|
+
await what();
|
|
39
|
+
setSaid(done);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
setRefusal({ id, refusal: rosterRefusal(error) });
|
|
43
|
+
}
|
|
44
|
+
await Promise.all([mine.refetch?.(), offers.refetch?.()]);
|
|
45
|
+
}
|
|
46
|
+
const shifts = mine.data?.shifts ?? [];
|
|
47
|
+
return (_jsxs(Screen, { title: "My shifts", children: [me.isPending || mine.isPending ? (_jsx(Text, { tone: "muted", accessibilityRole: "progressbar", children: "Loading your shifts\u2026" })) : null, me.error || mine.error ? (_jsx(Text, { accessibilityRole: "alert", children: rosterRefusal(me.error ?? mine.error).message })) : null, calendar, me.data ? (_jsxs(Text, { children: ["Times are in ", zone, ". Offers close ", me.data.cutoffMinutes, " minutes before a shift starts."] })) : null, said ? _jsx(Text, { accessibilityRole: "alert", children: said }) : null, mine.data?.truncated ? (_jsx(Text, { children: "You have more shifts than one screen shows: the first ones are shown." })) : null, mine.data ? (_jsx(List, { empty: `You have no shifts in the next ${days} days.`, children: shifts.map((shift) => (_jsxs(View, { accessible: true, accessibilityLabel: shiftName(shift, zone, locale), children: [_jsx(Row, { title: `${dayLabel(dateIn(shift.startsAt, zone), locale)} · ${shift.title}`, detail: [
|
|
48
|
+
shiftTime(shift, zone, { locale }),
|
|
49
|
+
shift.place,
|
|
50
|
+
shift.offer ? "Offered: still yours until someone takes it" : null,
|
|
51
|
+
]
|
|
52
|
+
.filter(Boolean)
|
|
53
|
+
.join(" · ") }), shift.offer ? (_jsx(Button, { label: `Withdraw the offer of ${shift.title}`, quiet: true, busy: busy, onPress: () => act(shift.id, () => withdraw.mutateAsync({ offer: shift.offer?.id ?? "" }), "Offer withdrawn: the shift is still yours.") })) : (_jsx(Button, { label: `Offer ${shift.title}`, quiet: true, busy: busy, onPress: () => act(shift.id, () => offer.mutateAsync({ object: shift.object, id: shift.id }), "Offered to everyone who could take it. It stays yours until someone does.") })), refusal?.id === shift.id ? (_jsxs(Text, { accessibilityRole: "alert", children: [refusal.refusal.message, refusalNext(refusal.refusal.kind, me.data?.rosters ?? false)
|
|
54
|
+
? ` ${refusalNext(refusal.refusal.kind, me.data?.rosters ?? false)}`
|
|
55
|
+
: ""] })) : null, shiftExtra?.(shift)] }, shift.id))) })) : null, offers.data?.mine.length ? (_jsxs(View, { children: [_jsx(Text, { accessibilityRole: "header", children: "My open offers" }), _jsx(List, { children: offers.data.mine.map((o) => (_jsx(Row, { title: o.shift.title, detail: shiftTime(o.shift, zone, { withDate: true, locale }) }, o.id))) })] })) : null, _jsx(MyHoursNative, { rostering: rostering, locale: locale })] }));
|
|
56
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type RosteringHooks } from "@composable-os/pack-rostering/client";
|
|
2
|
+
type Hooks = Pick<RosteringHooks, "useMe" | "useOffers" | "useTake">;
|
|
3
|
+
export declare function OffersScreen({ rostering, locale, }: {
|
|
4
|
+
rostering: Hooks;
|
|
5
|
+
locale?: string;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Offered to me, in the app (stage 45 step 7): the shifts the host says I could take now, soonest
|
|
3
|
+
// first, and taking one. Nobody approves a take. When I said I am away then, the host asks me to
|
|
4
|
+
// confirm and this asks the same in a sheet; when someone else took it first the host names them;
|
|
5
|
+
// a withdrawn or lapsed offer, one past the cut-off, a clash, a shift that changed hands, or a
|
|
6
|
+
// kind I am not qualified for each shows the host's words, and the list is read again.
|
|
7
|
+
import { refusalNext, rosterRefusal, shiftTime, } from "@composable-os/pack-rostering/client";
|
|
8
|
+
import { useState } from "react";
|
|
9
|
+
import { View } from "react-native";
|
|
10
|
+
import { Button } from "../native-base/button.js";
|
|
11
|
+
import { List } from "../native-base/list.js";
|
|
12
|
+
import { Row } from "../native-base/row.js";
|
|
13
|
+
import { Screen } from "../native-base/screen.js";
|
|
14
|
+
import { Sheet } from "../native-base/sheet.js";
|
|
15
|
+
import { Text } from "../native-base/text.js";
|
|
16
|
+
export function OffersScreen({ rostering, locale = "en-AU", }) {
|
|
17
|
+
const me = rostering.useMe();
|
|
18
|
+
const offers = rostering.useOffers();
|
|
19
|
+
const take = rostering.useTake();
|
|
20
|
+
const [confirming, setConfirming] = useState(null);
|
|
21
|
+
const [refusal, setRefusal] = useState(null);
|
|
22
|
+
const [taken, setTaken] = useState(null);
|
|
23
|
+
const zone = me.data?.zone ?? "UTC";
|
|
24
|
+
async function takeIt(o, confirmUnavailable) {
|
|
25
|
+
setRefusal(null);
|
|
26
|
+
setTaken(null);
|
|
27
|
+
try {
|
|
28
|
+
await take.mutateAsync({
|
|
29
|
+
offer: o.id,
|
|
30
|
+
...(confirmUnavailable ? { confirmUnavailable } : {}),
|
|
31
|
+
});
|
|
32
|
+
setConfirming(null);
|
|
33
|
+
setTaken(`${o.shift.title}, ${shiftTime(o.shift, zone, { withDate: true, locale })} is yours now.`);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
const r = rosterRefusal(error);
|
|
37
|
+
if (r.kind === "unavailable_confirm") {
|
|
38
|
+
setConfirming(o);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
setConfirming(null);
|
|
42
|
+
setRefusal(r);
|
|
43
|
+
}
|
|
44
|
+
await offers.refetch?.();
|
|
45
|
+
}
|
|
46
|
+
const open = offers.data?.open ?? [];
|
|
47
|
+
return (_jsxs(Screen, { title: "Offered to me", children: [me.isPending || offers.isPending ? (_jsx(Text, { tone: "muted", accessibilityRole: "progressbar", children: "Loading offers\u2026" })) : null, me.error || offers.error ? (_jsx(Text, { accessibilityRole: "alert", children: rosterRefusal(me.error ?? offers.error).message })) : null, taken ? _jsx(Text, { accessibilityRole: "alert", children: taken }) : null, refusal ? (_jsxs(Text, { accessibilityRole: "alert", children: [refusal.message, refusalNext(refusal.kind, me.data?.rosters ?? false)
|
|
48
|
+
? ` ${refusalNext(refusal.kind, me.data?.rosters ?? false)}`
|
|
49
|
+
: ""] })) : null, offers.data ? (_jsx(List, { empty: "No shifts are offered to you right now.", children: open.map((o) => (_jsxs(View, { children: [_jsx(Row, { title: o.shift.title, detail: [
|
|
50
|
+
shiftTime(o.shift, zone, { withDate: true, locale }),
|
|
51
|
+
`Offered by ${o.fromName ?? "whoever rosters"}${o.to ? " to you" : ""}`,
|
|
52
|
+
o.unavailable ? "You said you are away then" : null,
|
|
53
|
+
]
|
|
54
|
+
.filter(Boolean)
|
|
55
|
+
.join(" · ") }), _jsx(Button, { label: `Take ${o.shift.title}`, busy: take.isPending, onPress: () => takeIt(o, false) })] }, o.id))) })) : null, _jsxs(Sheet, { open: confirming !== null, title: "You said you are away then", onClose: () => setConfirming(null), children: [_jsx(Text, { children: "You said you are not available then. Take it anyway?" }), _jsx(Button, { label: "Take it anyway", busy: take.isPending, onPress: () => confirming && takeIt(confirming, true) }), _jsx(Button, { label: "Leave it", quiet: true, onPress: () => setConfirming(null) })] })] }));
|
|
56
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type RosteringHooks } from "@composable-os/pack-rostering/client";
|
|
2
|
+
type Hooks = Pick<RosteringHooks, "useMe" | "useWeek">;
|
|
3
|
+
export declare function RosterScreen({ rostering, locale, }: {
|
|
4
|
+
rostering: Hooks;
|
|
5
|
+
locale?: string;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// The roster in the app (stage 45 step 7), for every rostered person: the week as a day-by-day
|
|
3
|
+
// list 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 and my own marked as mine. Read only; a rosterer
|
|
5
|
+
// rosters on the web. Each shift's time is shown in the business's zone, and each day's length is
|
|
6
|
+
// the host's (a clock-change day says so), never worked out from the phone's own zone.
|
|
7
|
+
import { addDays, clockChange, dayLabel, personOn, rosterRefusal, shiftName, shiftsByDay, shiftTime, warningLabel, weekOf, } from "@composable-os/pack-rostering/client";
|
|
8
|
+
import { useState } from "react";
|
|
9
|
+
import { View } from "react-native";
|
|
10
|
+
import { Button } from "../native-base/button.js";
|
|
11
|
+
import { List } from "../native-base/list.js";
|
|
12
|
+
import { Row } from "../native-base/row.js";
|
|
13
|
+
import { Screen } from "../native-base/screen.js";
|
|
14
|
+
import { Text } from "../native-base/text.js";
|
|
15
|
+
export function RosterScreen({ rostering, locale = "en-AU", }) {
|
|
16
|
+
const me = rostering.useMe();
|
|
17
|
+
const [start, setStart] = useState(null);
|
|
18
|
+
const first = start ?? (me.data ? weekOf(me.data.today) : null);
|
|
19
|
+
const week = rostering.useWeek({ from: first ?? "", to: first ? addDays(first, 6) : "" }, first !== null);
|
|
20
|
+
const zone = week.data?.zone ?? me.data?.zone ?? "UTC";
|
|
21
|
+
return (_jsxs(Screen, { title: first ? `Roster: week of ${dayLabel(first, locale)}` : "Roster", children: [_jsxs(View, { children: [_jsx(Button, { label: "Previous week", quiet: true, disabled: !first, onPress: () => first && setStart(addDays(first, -7)) }), _jsx(Button, { label: "Next week", quiet: true, disabled: !first, onPress: () => first && setStart(addDays(first, 7)) })] }), me.isPending || week.isPending ? (_jsx(Text, { tone: "muted", accessibilityRole: "progressbar", children: "Loading the roster\u2026" })) : null, me.error || week.error ? (_jsx(Text, { accessibilityRole: "alert", children: rosterRefusal(me.error ?? week.error).message })) : null, week.data ? _jsxs(Text, { children: ["Times are in ", zone, "."] }) : null, week.data?.truncated ? (_jsx(Text, { children: "This week has more shifts than one screen shows: the first ones are shown." })) : null, week.data
|
|
22
|
+
? shiftsByDay(week.data).map(({ day, shifts }) => (_jsxs(View, { children: [_jsxs(Text, { accessibilityRole: "header", children: [dayLabel(day.date, locale), day.date === me.data?.today ? " (today)" : ""] }), clockChange(day) ? _jsx(Text, { children: clockChange(day) }) : null, _jsx(List, { empty: "No shifts", children: shifts.map((shift) => (_jsx(View, { accessible: true, accessibilityLabel: shiftName(shift, zone, locale), children: _jsx(Row, { title: `${shiftTime(shift, zone, { locale })} · ${shift.title}${shift.mine ? " (mine)" : ""}`, detail: [
|
|
23
|
+
shift.place,
|
|
24
|
+
personOn(shift),
|
|
25
|
+
shift.offer ? "Offered" : null,
|
|
26
|
+
...(shift.warnings ?? []).map((w) => warningLabel(w.code)),
|
|
27
|
+
]
|
|
28
|
+
.filter(Boolean)
|
|
29
|
+
.join(" · ") }) }, `${shift.object}:${shift.id}`))) })] }, day.date)))
|
|
30
|
+
: null] }));
|
|
31
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type RosteringHooks } from "@composable-os/pack-rostering/client";
|
|
2
|
+
type Hooks = Pick<RosteringHooks, "useMe" | "useOffers" | "useTake">;
|
|
3
|
+
export declare function OffersToMe({ rostering, locale }: {
|
|
4
|
+
rostering: Hooks;
|
|
5
|
+
locale?: string;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Offered to me (stage 45 step 7), for every rostered person: the shifts others offered that the
|
|
3
|
+
// host says I could take now (I am qualified for the kind of work, free then, and it is before the
|
|
4
|
+
// cut-off), soonest first, and a button to take each. Nobody approves a take; the person who
|
|
5
|
+
// offered it and whoever rosters are told.
|
|
6
|
+
//
|
|
7
|
+
// The host decides everything and this shows its answer: when I said I am away then, the host
|
|
8
|
+
// asks me to confirm (`unavailable_confirm`) and this asks the same; when someone else took it
|
|
9
|
+
// first, the host names them (`offer_taken`); a withdrawn or lapsed offer, one whose shift
|
|
10
|
+
// changed hands, one past the cut-off, a clash with a shift of mine, or a kind I am not qualified
|
|
11
|
+
// for each has its own state, and the list is refreshed.
|
|
12
|
+
import { refusalNext, rosterRefusal, shiftTime, } from "@composable-os/pack-rostering/client";
|
|
13
|
+
import { useId, useState } from "react";
|
|
14
|
+
import { Button } from "../ui-button/button.js";
|
|
15
|
+
export function OffersToMe({ rostering, locale = "en-AU" }) {
|
|
16
|
+
const me = rostering.useMe();
|
|
17
|
+
const offers = rostering.useOffers();
|
|
18
|
+
const take = rostering.useTake();
|
|
19
|
+
const [confirming, setConfirming] = useState(null);
|
|
20
|
+
const [refusal, setRefusal] = useState(null);
|
|
21
|
+
const [taken, setTaken] = useState(null);
|
|
22
|
+
const headingId = useId();
|
|
23
|
+
if (me.isPending || offers.isPending)
|
|
24
|
+
return _jsx("p", { "aria-busy": "true", children: "Loading offers\u2026" });
|
|
25
|
+
if (me.error || !me.data)
|
|
26
|
+
return _jsx("p", { role: "alert", children: rosterRefusal(me.error).message });
|
|
27
|
+
const zone = me.data.zone;
|
|
28
|
+
async function takeIt(o, confirmUnavailable) {
|
|
29
|
+
setRefusal(null);
|
|
30
|
+
setTaken(null);
|
|
31
|
+
try {
|
|
32
|
+
await take.mutateAsync({
|
|
33
|
+
offer: o.id,
|
|
34
|
+
...(confirmUnavailable ? { confirmUnavailable } : {}),
|
|
35
|
+
});
|
|
36
|
+
setConfirming(null);
|
|
37
|
+
setTaken(`${o.shift.title}, ${shiftTime(o.shift, zone, { withDate: true, locale })} is yours now.`);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
const r = rosterRefusal(error);
|
|
41
|
+
if (r.kind === "unavailable_confirm") {
|
|
42
|
+
setConfirming(o.id);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
setConfirming(null);
|
|
46
|
+
setRefusal({ id: o.id, refusal: r });
|
|
47
|
+
}
|
|
48
|
+
await offers.refetch?.();
|
|
49
|
+
}
|
|
50
|
+
const open = offers.data?.open ?? [];
|
|
51
|
+
return (_jsxs("section", { className: "grid gap-3", "aria-labelledby": headingId, children: [_jsx("h2", { id: headingId, className: "text-lg font-medium", children: "Offered to me" }), taken ? (_jsx("p", { role: "status", className: "text-sm", children: taken })) : null, refusal && !open.some((o) => o.id === refusal.id) ? (_jsxs("div", { role: "alert", className: "rounded-md border p-2 text-sm", "data-refusal": refusal.refusal.kind, children: [_jsx("p", { children: refusal.refusal.message }), refusalNext(refusal.refusal.kind, me.data.rosters) ? (_jsx("p", { children: refusalNext(refusal.refusal.kind, me.data.rosters) })) : null] })) : null, offers.error ? _jsx("p", { role: "alert", children: rosterRefusal(offers.error).message }) : null, offers.data && !open.length ? _jsx("p", { children: "No shifts are offered to you right now." }) : null, _jsx("ul", { className: "grid gap-2", children: open.map((o) => (_jsxs("li", { className: "grid gap-2 rounded-md border p-3", "data-offer": o.id, "aria-label": `${o.shift.title}, ${shiftTime(o.shift, zone, { withDate: true, locale })}, offered by ${o.fromName ?? "whoever rosters"}`, children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsxs("div", { children: [_jsx("p", { className: "font-medium", children: o.shift.title }), _jsx("p", { className: "text-sm text-muted-foreground", children: shiftTime(o.shift, zone, { withDate: true, locale }) }), _jsxs("p", { className: "text-sm", children: ["Offered by ", o.fromName ?? "whoever rosters", o.to ? " to you" : "", o.unavailable ? " · You said you are away then" : ""] })] }), confirming === o.id ? null : (_jsx(Button, { type: "button", disabled: take.isPending, "aria-label": `Take ${o.shift.title}`, onClick: () => takeIt(o, false), children: "Take it" }))] }), confirming === o.id ? (_jsxs("div", { role: "alertdialog", "aria-label": "You said you are away then", className: "grid gap-2 rounded-md border p-2", children: [_jsx("p", { className: "text-sm", children: "You said you are not available then. Take it anyway?" }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { type: "button", disabled: take.isPending, onClick: () => takeIt(o, true), children: "Take it anyway" }), _jsx(Button, { type: "button", variant: "outline", onClick: () => setConfirming(null), children: "Leave it" })] })] })) : null, refusal?.id === o.id ? (_jsxs("div", { role: "alert", className: "text-sm", "data-refusal": refusal.refusal.kind, children: [_jsx("p", { children: refusal.refusal.message }), refusalNext(refusal.refusal.kind, me.data?.rosters ?? false) ? (_jsx("p", { children: refusalNext(refusal.refusal.kind, me.data?.rosters ?? false) })) : null] })) : null] }, o.id))) })] }));
|
|
52
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type RosteringHooks } from "@composable-os/pack-rostering/client";
|
|
2
|
+
type Hooks = Pick<RosteringHooks, "useMe" | "usePatterns" | "usePeople" | "useSetPattern">;
|
|
3
|
+
export declare function Patterns({ rostering, locale }: {
|
|
4
|
+
rostering: Hooks;
|
|
5
|
+
locale?: string;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// The regular week (stage 45 step 7), for someone who rosters: every class series' coach and duty
|
|
3
|
+
// series' regular person, day by day, and changing who works one from a date. The shifts from
|
|
4
|
+
// that date follow, except those that keep their own person; a change that would put someone on
|
|
5
|
+
// two shifts at once on any date is refused whole by the host, naming the dates, and shown so.
|
|
6
|
+
//
|
|
7
|
+
// Shown only when the host says the reader rosters (`me.rosters`): nobody else's screen asks for
|
|
8
|
+
// the patterns. Everything shown is the host's answer.
|
|
9
|
+
import { dayLabel, patternWhen, refusalNext, rosterRefusal, WEEKDAYS, } from "@composable-os/pack-rostering/client";
|
|
10
|
+
import { useId, useState } from "react";
|
|
11
|
+
import { Button } from "../ui-button/button.js";
|
|
12
|
+
export function Patterns({ rostering, locale = "en-AU" }) {
|
|
13
|
+
const me = rostering.useMe();
|
|
14
|
+
const rosters = me.data?.rosters === true;
|
|
15
|
+
const patterns = rostering.usePatterns(rosters);
|
|
16
|
+
const people = rostering.usePeople(rosters);
|
|
17
|
+
const [editing, setEditing] = useState(null);
|
|
18
|
+
const headingId = useId();
|
|
19
|
+
if (me.isPending)
|
|
20
|
+
return _jsx("p", { "aria-busy": "true", children: "Loading\u2026" });
|
|
21
|
+
if (me.error || !me.data)
|
|
22
|
+
return _jsx("p", { role: "alert", children: rosterRefusal(me.error).message });
|
|
23
|
+
if (!rosters) {
|
|
24
|
+
return (_jsx("p", { role: "status", "data-refusal": "rostering", children: "The regular week is for whoever rosters. Your own shifts are on My shifts." }));
|
|
25
|
+
}
|
|
26
|
+
const all = patterns.data?.patterns ?? [];
|
|
27
|
+
return (_jsxs("section", { className: "grid gap-4", "aria-labelledby": headingId, children: [_jsx("h2", { id: headingId, className: "text-lg font-medium", children: "Regular week" }), patterns.isPending ? _jsx("p", { "aria-busy": "true", children: "Loading the regular week\u2026" }) : null, patterns.error ? _jsx("p", { role: "alert", children: rosterRefusal(patterns.error).message }) : null, patterns.data?.truncated ? (_jsx("p", { role: "status", className: "text-sm", children: "There are more patterns than one screen shows." })) : null, _jsx("ol", { className: "grid gap-3 md:grid-cols-7", "aria-label": "Days of the week", children: WEEKDAYS.map(([day, label]) => {
|
|
28
|
+
const on = all.filter((p) => p.weekdays.includes(day));
|
|
29
|
+
return (_jsxs("li", { className: "min-w-0 rounded-md border p-2", children: [_jsx("h3", { className: "text-sm font-medium", children: label }), on.length ? (_jsx("ul", { className: "mt-2 grid gap-2", children: on.map((p) => (_jsx("li", { children: _jsxs("button", { type: "button", className: "block w-full rounded-md border p-2 text-left text-sm", "aria-label": `${p.title}, ${label} ${p.time ?? ""}, ${p.name ?? "nobody"}. Change who works it`, "aria-pressed": editing?.id === p.id, onClick: () => setEditing(p), children: [_jsx("span", { className: "block text-xs text-muted-foreground", children: p.time }), _jsx("span", { className: "block font-medium", children: p.title }), _jsx("span", { className: "block text-xs", children: p.name ?? (p.noAccount ? "A coach with no account" : "Nobody") })] }) }, `${p.object}:${p.id}`))) })) : (_jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: "Nothing" }))] }, day));
|
|
30
|
+
}) }), editing ? (_jsx(ChangePattern, { rostering: rostering, pattern: editing, people: people.data?.people ?? [], today: me.data.today, locale: locale, onClose: () => setEditing(null), onChanged: () => patterns.refetch?.() })) : null] }));
|
|
31
|
+
}
|
|
32
|
+
function ChangePattern({ rostering, pattern, people, today, locale, onClose, onChanged, }) {
|
|
33
|
+
const setPattern = rostering.useSetPattern();
|
|
34
|
+
const [account, setAccount] = useState(pattern.account ?? "");
|
|
35
|
+
const [from, setFrom] = useState(today);
|
|
36
|
+
const [refusal, setRefusal] = useState(null);
|
|
37
|
+
const [said, setSaid] = useState(null);
|
|
38
|
+
const id = useId();
|
|
39
|
+
async function submit(event) {
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
setRefusal(null);
|
|
42
|
+
setSaid(null);
|
|
43
|
+
try {
|
|
44
|
+
const done = await setPattern.mutateAsync({
|
|
45
|
+
object: pattern.object,
|
|
46
|
+
id: pattern.id,
|
|
47
|
+
account: account || null,
|
|
48
|
+
from,
|
|
49
|
+
});
|
|
50
|
+
setSaid(`From ${dayLabel(done.from, locale, true)}, ${people.find((p) => p.account === done.account)?.name ?? "nobody"} works ${pattern.title}.`);
|
|
51
|
+
onChanged();
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
setRefusal(rosterRefusal(error));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return (_jsxs("form", { className: "grid gap-3 rounded-md border p-3", onSubmit: submit, "aria-label": `Change who works ${pattern.title}`, children: [_jsxs("div", { className: "flex items-start justify-between gap-2", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: pattern.title }), _jsxs("p", { className: "text-sm text-muted-foreground", children: [pattern.objectLabel, " \u00B7 ", patternWhen(pattern), " \u00B7 ", pattern.zone] })] }), _jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: "Close" })] }), _jsxs("div", { className: "grid gap-1", children: [_jsx("label", { htmlFor: `${id}-who`, className: "text-sm", children: "Regular person" }), _jsxs("select", { id: `${id}-who`, className: "rounded-md border border-input px-2 py-1 text-sm", value: account, onChange: (e) => setAccount(e.target.value), children: [_jsx("option", { value: "", children: "Nobody" }), people.map((p) => (_jsx("option", { value: p.account, children: p.name }, p.account)))] })] }), _jsxs("div", { className: "grid gap-1", children: [_jsx("label", { htmlFor: `${id}-from`, className: "text-sm", children: "From" }), _jsx("input", { id: `${id}-from`, type: "date", className: "rounded-md border border-input px-2 py-1 text-sm", value: from, onChange: (e) => setFrom(e.target.value) })] }), refusal ? (_jsxs("div", { role: "alert", className: "text-sm", "data-refusal": refusal.kind, children: [_jsx("p", { children: refusal.message }), refusal.dates?.length ? (_jsxs("p", { children: ["On: ", refusal.dates.map((d) => dayLabel(d, locale)).join(", ")] })) : null, refusalNext(refusal.kind, true) ? _jsx("p", { children: refusalNext(refusal.kind, true) }) : null] })) : null, said ? (_jsx("p", { role: "status", className: "text-sm", children: said })) : null, _jsx(Button, { type: "submit", disabled: setPattern.isPending, children: "Save from this date" })] }));
|
|
58
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type RosteringHooks } from "@composable-os/pack-rostering/client";
|
|
2
|
+
type Hooks = Pick<RosteringHooks, "useMe" | "usePeriods" | "usePeriodTotals" | "useLock" | "useReopen" | "useExport" | "usePayBases" | "usePayBasis">;
|
|
3
|
+
export declare function Pay({ rostering, locale }: {
|
|
4
|
+
rostering: Hooks;
|
|
5
|
+
locale?: string;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
7
|
+
export {};
|