@sonatel-os/strapi-plugin-split 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -2
- package/dist/_chunks/App-8QwzQSyg.mjs +937 -0
- package/dist/_chunks/App-CLfoPnvq.js +937 -0
- package/dist/_chunks/SettingsPage-B746YfAA.js +101 -0
- package/dist/_chunks/SettingsPage-CH92IYGk.mjs +101 -0
- package/dist/_chunks/api-BCYZ56eI.mjs +466 -0
- package/dist/_chunks/api-cwZGoKZx.js +465 -0
- package/dist/_chunks/en-2Jxpmk_V.js +13 -0
- package/dist/_chunks/en-BB-FKqG6.mjs +13 -0
- package/dist/_chunks/fr-CKuK9t8l.mjs +13 -0
- package/dist/_chunks/fr-FgrMO3p9.js +13 -0
- package/dist/_chunks/index-PFbwTznf.mjs +98 -0
- package/dist/_chunks/index-oyRhs5fN.js +97 -0
- package/dist/admin/index.js +3 -0
- package/dist/admin/index.mjs +4 -0
- package/dist/server/index.js +2447 -0
- package/dist/server/index.mjs +2448 -0
- package/package.json +81 -4
|
@@ -0,0 +1,937 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Flex, Typography, Table, Thead, Tr, Th, Tbody, Td, Grid, Button, SearchForm, Searchbar, SingleSelect, SingleSelectOption } from "@strapi/design-system";
|
|
3
|
+
import { User, Stack, PriceTag, ArrowsCounterClockwise, Archive, ArrowLeft, Eye, PresentationChart, ListSearch } from "@strapi/icons";
|
|
4
|
+
import { Page, useNotification, useRBAC } from "@strapi/strapi/admin";
|
|
5
|
+
import { useNavigate, useParams, Routes, Route, NavLink } from "react-router-dom";
|
|
6
|
+
import { useIntl } from "react-intl";
|
|
7
|
+
import { styled } from "styled-components";
|
|
8
|
+
import { P as PLUGIN_ID, a as PERMISSIONS } from "./index-PFbwTznf.mjs";
|
|
9
|
+
import { E as Eyebrow, I as Intro, S as SPRING$1, u as useGetDashboardQuery, a as StatTile, b as Section, B as Bar, c as useGetGroupsQuery, M as Mono, d as StatusBadge, e as useGetGroupQuery, f as useArchiveGroupMutation, g as useGetPeopleQuery, h as useGetPersonQuery, i as useRevealPhoneMutation, j as useSetPersonActiveMutation, k as useGetSettlementsQuery, l as useGetEventsQuery } from "./api-BCYZ56eI.mjs";
|
|
10
|
+
import { useState } from "react";
|
|
11
|
+
const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
|
|
12
|
+
const Head = styled.header`
|
|
13
|
+
position: relative;
|
|
14
|
+
padding: 4.8rem 5.6rem 3.2rem;
|
|
15
|
+
&::before {
|
|
16
|
+
content: '';
|
|
17
|
+
position: absolute;
|
|
18
|
+
inset: -20% -10% auto auto;
|
|
19
|
+
width: 46rem;
|
|
20
|
+
height: 46rem;
|
|
21
|
+
border-radius: 50%;
|
|
22
|
+
background: radial-gradient(circle, rgba(255, 121, 0, 0.1) 0%, rgba(255, 121, 0, 0) 65%);
|
|
23
|
+
pointer-events: none;
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
const Title = styled(Typography)`
|
|
27
|
+
font-size: 3.2rem;
|
|
28
|
+
line-height: 1.1;
|
|
29
|
+
font-weight: 700;
|
|
30
|
+
letter-spacing: -0.03em;
|
|
31
|
+
`;
|
|
32
|
+
const Content = styled(Box)`
|
|
33
|
+
padding: 0 5.6rem 8rem;
|
|
34
|
+
> * {
|
|
35
|
+
transition: opacity 320ms ${SPRING$1};
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
const PageShell = ({
|
|
39
|
+
title,
|
|
40
|
+
subtitle,
|
|
41
|
+
primaryAction,
|
|
42
|
+
secondaryAction,
|
|
43
|
+
navigationAction,
|
|
44
|
+
eyebrow = "Split",
|
|
45
|
+
intro,
|
|
46
|
+
children
|
|
47
|
+
}) => {
|
|
48
|
+
return /* @__PURE__ */ jsxs(Page.Main, { children: [
|
|
49
|
+
/* @__PURE__ */ jsx(Page.Title, { children: `Split · ${title}` }),
|
|
50
|
+
/* @__PURE__ */ jsxs(Head, { children: [
|
|
51
|
+
navigationAction ? /* @__PURE__ */ jsx(Box, { paddingBottom: 4, children: navigationAction }) : null,
|
|
52
|
+
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "flex-end", gap: 6, wrap: "wrap", children: [
|
|
53
|
+
/* @__PURE__ */ jsxs(Box, { style: { minWidth: 0 }, children: [
|
|
54
|
+
/* @__PURE__ */ jsx(Eyebrow, { paddingBottom: 2, children: eyebrow }),
|
|
55
|
+
/* @__PURE__ */ jsx(Title, { tag: "h1", children: title }),
|
|
56
|
+
subtitle ? /* @__PURE__ */ jsx(
|
|
57
|
+
Typography,
|
|
58
|
+
{
|
|
59
|
+
variant: "omega",
|
|
60
|
+
textColor: "neutral600",
|
|
61
|
+
tag: "p",
|
|
62
|
+
paddingTop: 2,
|
|
63
|
+
style: { maxWidth: "70ch" },
|
|
64
|
+
children: subtitle
|
|
65
|
+
}
|
|
66
|
+
) : null
|
|
67
|
+
] }),
|
|
68
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", wrap: "wrap", children: [
|
|
69
|
+
secondaryAction,
|
|
70
|
+
primaryAction
|
|
71
|
+
] })
|
|
72
|
+
] })
|
|
73
|
+
] }),
|
|
74
|
+
/* @__PURE__ */ jsxs(Content, { children: [
|
|
75
|
+
intro ? /* @__PURE__ */ jsx(Intro, { ...intro }) : null,
|
|
76
|
+
children
|
|
77
|
+
] })
|
|
78
|
+
] });
|
|
79
|
+
};
|
|
80
|
+
const DataTable = ({ columns, rows, onRow, empty }) => {
|
|
81
|
+
if (rows.length === 0) return /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: empty });
|
|
82
|
+
return /* @__PURE__ */ jsxs(Table, { colCount: columns.length, rowCount: rows.length, children: [
|
|
83
|
+
/* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsx(Tr, { children: columns.map((c) => /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: c.label }) }, c.key)) }) }),
|
|
84
|
+
/* @__PURE__ */ jsx(Tbody, { children: rows.map((row, i) => /* @__PURE__ */ jsx(
|
|
85
|
+
Tr,
|
|
86
|
+
{
|
|
87
|
+
onClick: onRow ? () => onRow(row) : void 0,
|
|
88
|
+
style: onRow ? { cursor: "pointer" } : void 0,
|
|
89
|
+
children: columns.map((c) => /* @__PURE__ */ jsx(Td, { children: c.render(row) }, c.key))
|
|
90
|
+
},
|
|
91
|
+
row.id ?? i
|
|
92
|
+
)) })
|
|
93
|
+
] });
|
|
94
|
+
};
|
|
95
|
+
const Cell = ({ main, sub, strong, tone }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
96
|
+
/* @__PURE__ */ jsx(Typography, { fontWeight: strong ? "semiBold" : void 0, textColor: tone, children: main ?? "—" }),
|
|
97
|
+
sub ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: sub }) : null
|
|
98
|
+
] });
|
|
99
|
+
const fmtDateTime = (value, locale) => {
|
|
100
|
+
if (!value) return "—";
|
|
101
|
+
try {
|
|
102
|
+
return new Intl.DateTimeFormat(locale ?? void 0, {
|
|
103
|
+
dateStyle: "medium",
|
|
104
|
+
timeStyle: "short"
|
|
105
|
+
}).format(new Date(value));
|
|
106
|
+
} catch {
|
|
107
|
+
return String(value);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const fmtNumber = (value, locale) => new Intl.NumberFormat(locale ?? void 0).format(Number(value ?? 0));
|
|
111
|
+
const fmtSigned = (value, locale) => {
|
|
112
|
+
const n = Number(value ?? 0);
|
|
113
|
+
const digits = fmtNumber(Math.abs(n), locale);
|
|
114
|
+
return n > 0 ? `+${digits}` : n < 0 ? `−${digits}` : digits;
|
|
115
|
+
};
|
|
116
|
+
const errorMessage = (err) => err?.data?.error?.message ?? err?.response?.data?.error?.message ?? err?.error?.message ?? err?.message ?? "Une erreur est survenue.";
|
|
117
|
+
const ACCENT = "#FF7900";
|
|
118
|
+
const GREEN = "#328048";
|
|
119
|
+
const BLUE = "#4945FF";
|
|
120
|
+
const AMBER = "#D9822F";
|
|
121
|
+
const Dashboard = () => {
|
|
122
|
+
const { locale } = useIntl();
|
|
123
|
+
const { data, isLoading, isError } = useGetDashboardQuery();
|
|
124
|
+
if (isLoading) return /* @__PURE__ */ jsx(Page.Loading, {});
|
|
125
|
+
if (isError || !data) return /* @__PURE__ */ jsx(Page.Error, {});
|
|
126
|
+
const n = (value) => fmtNumber(value, locale);
|
|
127
|
+
const { people, groups, expenses, settlements, days } = data;
|
|
128
|
+
const settledMax = Math.max(1, ...settlements.byMethod.map((m) => m.total));
|
|
129
|
+
const tiles = [
|
|
130
|
+
{
|
|
131
|
+
label: "People",
|
|
132
|
+
value: n(people.total),
|
|
133
|
+
hint: `${n(people.active)} active, ${n(people.new)} new in ${days} days`,
|
|
134
|
+
accent: BLUE,
|
|
135
|
+
icon: /* @__PURE__ */ jsx(User, {})
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
label: "Groups",
|
|
139
|
+
value: n(groups.total),
|
|
140
|
+
hint: `${n(groups.new)} new in ${days} days, ${n(groups.archived)} archived`,
|
|
141
|
+
accent: ACCENT,
|
|
142
|
+
icon: /* @__PURE__ */ jsx(Stack, {})
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
label: "Spent together",
|
|
146
|
+
value: n(expenses.total),
|
|
147
|
+
hint: `${n(expenses.count)} expenses, ${n(expenses.recent.total)} in ${days} days`,
|
|
148
|
+
accent: AMBER,
|
|
149
|
+
icon: /* @__PURE__ */ jsx(PriceTag, {})
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
label: "Settled",
|
|
153
|
+
value: n(settlements.confirmed.total),
|
|
154
|
+
hint: `${n(settlements.confirmed.count)} confirmed, ${n(settlements.pending.count)} awaiting confirmation`,
|
|
155
|
+
accent: GREEN,
|
|
156
|
+
icon: /* @__PURE__ */ jsx(ArrowsCounterClockwise, {})
|
|
157
|
+
}
|
|
158
|
+
];
|
|
159
|
+
return /* @__PURE__ */ jsx(Page.Protect, { permissions: PERMISSIONS.dashboardRead, children: /* @__PURE__ */ jsxs(
|
|
160
|
+
PageShell,
|
|
161
|
+
{
|
|
162
|
+
title: "Dashboard",
|
|
163
|
+
subtitle: "Amounts are in the currency's smallest unit, as the ledger stores them.",
|
|
164
|
+
children: [
|
|
165
|
+
/* @__PURE__ */ jsx(Grid.Root, { gap: 5, children: tiles.map((tile, i) => /* @__PURE__ */ jsx(
|
|
166
|
+
Grid.Item,
|
|
167
|
+
{
|
|
168
|
+
col: 3,
|
|
169
|
+
s: 6,
|
|
170
|
+
xs: 12,
|
|
171
|
+
direction: "column",
|
|
172
|
+
alignItems: "stretch",
|
|
173
|
+
children: /* @__PURE__ */ jsx(StatTile, { ...tile, index: i })
|
|
174
|
+
},
|
|
175
|
+
tile.label
|
|
176
|
+
)) }),
|
|
177
|
+
/* @__PURE__ */ jsx(Box, { paddingTop: 6, children: /* @__PURE__ */ jsxs(Section, { title: "How debts get settled", help: "Confirmed settlements, by method.", index: 4, children: [
|
|
178
|
+
/* @__PURE__ */ jsx(
|
|
179
|
+
DataTable,
|
|
180
|
+
{
|
|
181
|
+
empty: "Nothing has been settled yet.",
|
|
182
|
+
rows: settlements.byMethod.map((m) => ({ ...m, id: m.method })),
|
|
183
|
+
columns: [
|
|
184
|
+
{ key: "method", label: "Method", render: (m) => /* @__PURE__ */ jsx(Cell, { main: m.method, strong: true }) },
|
|
185
|
+
{ key: "count", label: "Settlements", render: (m) => /* @__PURE__ */ jsx(Cell, { main: n(m.count) }) },
|
|
186
|
+
{ key: "total", label: "Amount", render: (m) => /* @__PURE__ */ jsx(Cell, { main: n(m.total), strong: true }) },
|
|
187
|
+
{
|
|
188
|
+
key: "share",
|
|
189
|
+
label: "Share",
|
|
190
|
+
render: (m) => /* @__PURE__ */ jsx(Box, { style: { minWidth: 160 }, children: /* @__PURE__ */ jsx(Bar, { value: m.total, max: settledMax }) })
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
),
|
|
195
|
+
settlements.pending.count > 0 ? /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", tag: "p", paddingTop: 4, children: [
|
|
196
|
+
n(settlements.pending.total),
|
|
197
|
+
" declared in ",
|
|
198
|
+
n(settlements.pending.count),
|
|
199
|
+
" ",
|
|
200
|
+
"settlements still wait for the receiver to confirm."
|
|
201
|
+
] }) : null
|
|
202
|
+
] }) })
|
|
203
|
+
]
|
|
204
|
+
}
|
|
205
|
+
) });
|
|
206
|
+
};
|
|
207
|
+
const Pager = ({ meta, onPage }) => {
|
|
208
|
+
if (!meta || meta.pageCount <= 1) return null;
|
|
209
|
+
return /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", children: [
|
|
210
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", children: [
|
|
211
|
+
"Page ",
|
|
212
|
+
meta.page,
|
|
213
|
+
" / ",
|
|
214
|
+
meta.pageCount,
|
|
215
|
+
" · ",
|
|
216
|
+
meta.total,
|
|
217
|
+
" items"
|
|
218
|
+
] }),
|
|
219
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
220
|
+
/* @__PURE__ */ jsx(
|
|
221
|
+
Button,
|
|
222
|
+
{
|
|
223
|
+
size: "S",
|
|
224
|
+
variant: "tertiary",
|
|
225
|
+
disabled: meta.page <= 1,
|
|
226
|
+
onClick: () => onPage(meta.page - 1),
|
|
227
|
+
children: "Previous"
|
|
228
|
+
}
|
|
229
|
+
),
|
|
230
|
+
/* @__PURE__ */ jsx(
|
|
231
|
+
Button,
|
|
232
|
+
{
|
|
233
|
+
size: "S",
|
|
234
|
+
variant: "tertiary",
|
|
235
|
+
disabled: meta.page >= meta.pageCount,
|
|
236
|
+
onClick: () => onPage(meta.page + 1),
|
|
237
|
+
children: "Next"
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
] })
|
|
241
|
+
] });
|
|
242
|
+
};
|
|
243
|
+
const PAGE_SIZE = 25;
|
|
244
|
+
const ListPage = ({
|
|
245
|
+
title,
|
|
246
|
+
subtitle,
|
|
247
|
+
permissions,
|
|
248
|
+
useQuery,
|
|
249
|
+
searchLabel,
|
|
250
|
+
searchParam = "q",
|
|
251
|
+
filters,
|
|
252
|
+
columns,
|
|
253
|
+
onRow,
|
|
254
|
+
empty
|
|
255
|
+
}) => {
|
|
256
|
+
const [q, setQ] = useState("");
|
|
257
|
+
const [extra, setExtra] = useState({});
|
|
258
|
+
const [page, setPage] = useState(1);
|
|
259
|
+
const { data, isLoading, isError } = useQuery({
|
|
260
|
+
[searchParam]: q || void 0,
|
|
261
|
+
...extra,
|
|
262
|
+
page,
|
|
263
|
+
pageSize: PAGE_SIZE
|
|
264
|
+
});
|
|
265
|
+
const set = (patch) => {
|
|
266
|
+
setExtra((current) => ({ ...current, ...patch }));
|
|
267
|
+
setPage(1);
|
|
268
|
+
};
|
|
269
|
+
if (isError) return /* @__PURE__ */ jsx(Page.Error, {});
|
|
270
|
+
return /* @__PURE__ */ jsx(Page.Protect, { permissions, children: /* @__PURE__ */ jsxs(PageShell, { title, subtitle, children: [
|
|
271
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 3, paddingBottom: 4, wrap: "wrap", children: [
|
|
272
|
+
searchLabel ? /* @__PURE__ */ jsx(SearchForm, { onSubmit: (e) => e.preventDefault(), children: /* @__PURE__ */ jsx(
|
|
273
|
+
Searchbar,
|
|
274
|
+
{
|
|
275
|
+
name: "q",
|
|
276
|
+
value: q,
|
|
277
|
+
onChange: (e) => {
|
|
278
|
+
setQ(e.target.value);
|
|
279
|
+
setPage(1);
|
|
280
|
+
},
|
|
281
|
+
onClear: () => setQ(""),
|
|
282
|
+
clearLabel: "Clear",
|
|
283
|
+
placeholder: searchLabel,
|
|
284
|
+
children: searchLabel
|
|
285
|
+
}
|
|
286
|
+
) }) : null,
|
|
287
|
+
filters ? filters(extra, set) : null
|
|
288
|
+
] }),
|
|
289
|
+
/* @__PURE__ */ jsxs(Section, { children: [
|
|
290
|
+
isLoading ? /* @__PURE__ */ jsx(Page.Loading, {}) : /* @__PURE__ */ jsx(DataTable, { columns, rows: data?.data ?? [], onRow, empty }),
|
|
291
|
+
/* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(Pager, { meta: data?.meta?.pagination, onPage: setPage }) })
|
|
292
|
+
] })
|
|
293
|
+
] }) });
|
|
294
|
+
};
|
|
295
|
+
const GroupsPage = () => {
|
|
296
|
+
const { locale } = useIntl();
|
|
297
|
+
const navigate = useNavigate();
|
|
298
|
+
return /* @__PURE__ */ jsx(
|
|
299
|
+
ListPage,
|
|
300
|
+
{
|
|
301
|
+
title: "Groups",
|
|
302
|
+
subtitle: "Find a group by its name or its invite code, then open its books.",
|
|
303
|
+
permissions: PERMISSIONS.groupsRead,
|
|
304
|
+
useQuery: useGetGroupsQuery,
|
|
305
|
+
searchLabel: "Name or invite code",
|
|
306
|
+
empty: "No group matches.",
|
|
307
|
+
onRow: (g) => navigate(g.id),
|
|
308
|
+
columns: [
|
|
309
|
+
{ key: "name", label: "Group", render: (g) => /* @__PURE__ */ jsx(Cell, { main: g.name, strong: true }) },
|
|
310
|
+
{
|
|
311
|
+
key: "code",
|
|
312
|
+
label: "Invite code",
|
|
313
|
+
render: (g) => /* @__PURE__ */ jsx(Mono, { variant: "pi", children: g.inviteCode })
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
key: "status",
|
|
317
|
+
label: "Status",
|
|
318
|
+
render: (g) => /* @__PURE__ */ jsx(StatusBadge, { status: g.isArchived ? "archived" : "active" })
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
key: "last",
|
|
322
|
+
label: "Last activity",
|
|
323
|
+
render: (g) => /* @__PURE__ */ jsx(Cell, { main: fmtDateTime(g.lastActivityAt, locale), tone: "neutral600" })
|
|
324
|
+
}
|
|
325
|
+
]
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
};
|
|
329
|
+
const toneOf = (balance) => balance > 0 ? "success600" : balance < 0 ? "warning600" : "neutral600";
|
|
330
|
+
const GroupDetailPage = () => {
|
|
331
|
+
const { id } = useParams();
|
|
332
|
+
const { locale } = useIntl();
|
|
333
|
+
const navigate = useNavigate();
|
|
334
|
+
const { toggleNotification } = useNotification();
|
|
335
|
+
const { allowedActions } = useRBAC({ archive: PERMISSIONS.groupsWrite });
|
|
336
|
+
const { data: group, isLoading, isError } = useGetGroupQuery(id);
|
|
337
|
+
const [archive, { isLoading: archiving }] = useArchiveGroupMutation();
|
|
338
|
+
if (isLoading) return /* @__PURE__ */ jsx(Page.Loading, {});
|
|
339
|
+
if (isError || !group) return /* @__PURE__ */ jsx(Page.Error, {});
|
|
340
|
+
const n = (value) => fmtNumber(value, locale);
|
|
341
|
+
const when = (value) => fmtDateTime(value, locale);
|
|
342
|
+
const onArchive = async () => {
|
|
343
|
+
try {
|
|
344
|
+
await archive(id).unwrap();
|
|
345
|
+
toggleNotification({
|
|
346
|
+
type: "success",
|
|
347
|
+
message: "Group archived. Nothing can be written in it any more."
|
|
348
|
+
});
|
|
349
|
+
} catch (err) {
|
|
350
|
+
toggleNotification({ type: "danger", message: errorMessage(err) });
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
return /* @__PURE__ */ jsx(Page.Protect, { permissions: PERMISSIONS.groupsRead, children: /* @__PURE__ */ jsxs(
|
|
354
|
+
PageShell,
|
|
355
|
+
{
|
|
356
|
+
title: group.name,
|
|
357
|
+
eyebrow: `Group · ${group.inviteCode}`,
|
|
358
|
+
subtitle: `Created ${when(group.createdAt)} · last activity ${when(group.lastActivityAt)}`,
|
|
359
|
+
navigationAction: /* @__PURE__ */ jsx(
|
|
360
|
+
Button,
|
|
361
|
+
{
|
|
362
|
+
variant: "ghost",
|
|
363
|
+
size: "S",
|
|
364
|
+
startIcon: /* @__PURE__ */ jsx(ArrowLeft, {}),
|
|
365
|
+
onClick: () => navigate("..", { relative: "path" }),
|
|
366
|
+
children: "Groups"
|
|
367
|
+
}
|
|
368
|
+
),
|
|
369
|
+
primaryAction: group.isArchived ? /* @__PURE__ */ jsx(StatusBadge, { status: "archived" }) : allowedActions.canArchive ? /* @__PURE__ */ jsx(
|
|
370
|
+
Button,
|
|
371
|
+
{
|
|
372
|
+
variant: "danger-light",
|
|
373
|
+
startIcon: /* @__PURE__ */ jsx(Archive, {}),
|
|
374
|
+
loading: archiving,
|
|
375
|
+
onClick: onArchive,
|
|
376
|
+
children: "Archive"
|
|
377
|
+
}
|
|
378
|
+
) : null,
|
|
379
|
+
children: [
|
|
380
|
+
/* @__PURE__ */ jsx(Grid.Root, { gap: 5, children: [
|
|
381
|
+
{ label: "Members", value: n(group.memberCount) },
|
|
382
|
+
{ label: "Expenses", value: n(group.expenseCount) },
|
|
383
|
+
{ label: "Spent together", value: n(group.total) }
|
|
384
|
+
].map((tile, i) => /* @__PURE__ */ jsx(Grid.Item, { col: 4, s: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsx(StatTile, { ...tile, index: i }) }, tile.label)) }),
|
|
385
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, paddingTop: 6, children: [
|
|
386
|
+
/* @__PURE__ */ jsx(
|
|
387
|
+
Section,
|
|
388
|
+
{
|
|
389
|
+
title: "Members and balances",
|
|
390
|
+
help: "Above zero is owed money, below zero owes money. Phone numbers are masked.",
|
|
391
|
+
index: 3,
|
|
392
|
+
children: /* @__PURE__ */ jsx(
|
|
393
|
+
DataTable,
|
|
394
|
+
{
|
|
395
|
+
empty: "Nobody.",
|
|
396
|
+
rows: group.members,
|
|
397
|
+
columns: [
|
|
398
|
+
{
|
|
399
|
+
key: "name",
|
|
400
|
+
label: "Member",
|
|
401
|
+
render: (m) => /* @__PURE__ */ jsx(
|
|
402
|
+
Cell,
|
|
403
|
+
{
|
|
404
|
+
main: m.displayName,
|
|
405
|
+
sub: m.role === "owner" ? "Created the group" : null,
|
|
406
|
+
strong: true
|
|
407
|
+
}
|
|
408
|
+
)
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
key: "phone",
|
|
412
|
+
label: "Phone",
|
|
413
|
+
render: (m) => /* @__PURE__ */ jsx(Mono, { variant: "pi", children: m.phone ?? "—" })
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
key: "state",
|
|
417
|
+
label: "State",
|
|
418
|
+
render: (m) => /* @__PURE__ */ jsx(
|
|
419
|
+
Cell,
|
|
420
|
+
{
|
|
421
|
+
main: m.hasLeft ? "Left" : m.isRegistered ? "Uses the app" : "Added by name",
|
|
422
|
+
tone: "neutral600"
|
|
423
|
+
}
|
|
424
|
+
)
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
key: "balance",
|
|
428
|
+
label: "Balance",
|
|
429
|
+
render: (m) => /* @__PURE__ */ jsx(Cell, { main: fmtSigned(m.balance, locale), tone: toneOf(m.balance), strong: true })
|
|
430
|
+
}
|
|
431
|
+
]
|
|
432
|
+
}
|
|
433
|
+
)
|
|
434
|
+
}
|
|
435
|
+
),
|
|
436
|
+
/* @__PURE__ */ jsx(
|
|
437
|
+
Section,
|
|
438
|
+
{
|
|
439
|
+
title: "What would settle it",
|
|
440
|
+
help: "The fewest payments that bring everyone to zero.",
|
|
441
|
+
index: 4,
|
|
442
|
+
children: /* @__PURE__ */ jsx(
|
|
443
|
+
DataTable,
|
|
444
|
+
{
|
|
445
|
+
empty: "Everyone is even.",
|
|
446
|
+
rows: group.payments.map((p, i) => ({ ...p, id: i })),
|
|
447
|
+
columns: [
|
|
448
|
+
{ key: "from", label: "Pays", render: (p) => /* @__PURE__ */ jsx(Cell, { main: p.from.displayName }) },
|
|
449
|
+
{ key: "to", label: "To", render: (p) => /* @__PURE__ */ jsx(Cell, { main: p.to.displayName }) },
|
|
450
|
+
{
|
|
451
|
+
key: "amount",
|
|
452
|
+
label: "Amount",
|
|
453
|
+
render: (p) => /* @__PURE__ */ jsx(Cell, { main: n(p.amount), strong: true })
|
|
454
|
+
}
|
|
455
|
+
]
|
|
456
|
+
}
|
|
457
|
+
)
|
|
458
|
+
}
|
|
459
|
+
),
|
|
460
|
+
/* @__PURE__ */ jsx(Section, { title: "Settlements", help: "The most recent fifty.", index: 5, children: /* @__PURE__ */ jsx(
|
|
461
|
+
DataTable,
|
|
462
|
+
{
|
|
463
|
+
empty: "No settlement yet.",
|
|
464
|
+
rows: group.settlements,
|
|
465
|
+
columns: [
|
|
466
|
+
{
|
|
467
|
+
key: "when",
|
|
468
|
+
label: "Declared",
|
|
469
|
+
render: (s) => /* @__PURE__ */ jsx(Cell, { main: when(s.declaredAt), tone: "neutral600" })
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
key: "who",
|
|
473
|
+
label: "From → to",
|
|
474
|
+
render: (s) => /* @__PURE__ */ jsx(Cell, { main: `${s.from.displayName} → ${s.to.displayName}` })
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
key: "amount",
|
|
478
|
+
label: "Amount",
|
|
479
|
+
render: (s) => /* @__PURE__ */ jsx(Cell, { main: n(s.amount), sub: s.method, strong: true })
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
key: "status",
|
|
483
|
+
label: "Status",
|
|
484
|
+
render: (s) => /* @__PURE__ */ jsx(StatusBadge, { status: s.status })
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
key: "ref",
|
|
488
|
+
label: "Reference",
|
|
489
|
+
render: (s) => /* @__PURE__ */ jsx(Mono, { variant: "pi", children: s.reference ?? "—" })
|
|
490
|
+
}
|
|
491
|
+
]
|
|
492
|
+
}
|
|
493
|
+
) }),
|
|
494
|
+
/* @__PURE__ */ jsx(Section, { title: "Expenses", help: "The most recent fifty.", index: 6, children: /* @__PURE__ */ jsx(
|
|
495
|
+
DataTable,
|
|
496
|
+
{
|
|
497
|
+
empty: "No expense yet.",
|
|
498
|
+
rows: group.expenses,
|
|
499
|
+
columns: [
|
|
500
|
+
{
|
|
501
|
+
key: "when",
|
|
502
|
+
label: "Spent",
|
|
503
|
+
render: (e) => /* @__PURE__ */ jsx(Cell, { main: when(e.spentAt), tone: "neutral600" })
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
key: "label",
|
|
507
|
+
label: "What",
|
|
508
|
+
render: (e) => /* @__PURE__ */ jsx(Cell, { main: e.label, sub: e.category, strong: true })
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
key: "payer",
|
|
512
|
+
label: "Paid by",
|
|
513
|
+
render: (e) => /* @__PURE__ */ jsx(Cell, { main: e.paidBy.displayName })
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
key: "amount",
|
|
517
|
+
label: "Amount",
|
|
518
|
+
render: (e) => /* @__PURE__ */ jsx(
|
|
519
|
+
Cell,
|
|
520
|
+
{
|
|
521
|
+
main: n(e.amount),
|
|
522
|
+
sub: `${e.mode}, ${e.shares.length} taking part`,
|
|
523
|
+
strong: true
|
|
524
|
+
}
|
|
525
|
+
)
|
|
526
|
+
}
|
|
527
|
+
]
|
|
528
|
+
}
|
|
529
|
+
) }),
|
|
530
|
+
/* @__PURE__ */ jsx(Box, {})
|
|
531
|
+
] })
|
|
532
|
+
]
|
|
533
|
+
}
|
|
534
|
+
) });
|
|
535
|
+
};
|
|
536
|
+
const PeoplePage = () => {
|
|
537
|
+
const { locale } = useIntl();
|
|
538
|
+
const navigate = useNavigate();
|
|
539
|
+
return /* @__PURE__ */ jsx(
|
|
540
|
+
ListPage,
|
|
541
|
+
{
|
|
542
|
+
title: "People",
|
|
543
|
+
subtitle: "Find someone by name or by phone number. Numbers stay masked in lists.",
|
|
544
|
+
permissions: PERMISSIONS.peopleRead,
|
|
545
|
+
useQuery: useGetPeopleQuery,
|
|
546
|
+
searchLabel: "Name or phone",
|
|
547
|
+
empty: "Nobody matches.",
|
|
548
|
+
onRow: (p) => navigate(p.id),
|
|
549
|
+
columns: [
|
|
550
|
+
{
|
|
551
|
+
key: "name",
|
|
552
|
+
label: "Person",
|
|
553
|
+
render: (p) => /* @__PURE__ */ jsx(Cell, { main: p.displayName ?? "No name yet", strong: true })
|
|
554
|
+
},
|
|
555
|
+
{ key: "phone", label: "Phone", render: (p) => /* @__PURE__ */ jsx(Mono, { variant: "pi", children: p.phone ?? "—" }) },
|
|
556
|
+
{
|
|
557
|
+
key: "status",
|
|
558
|
+
label: "Status",
|
|
559
|
+
render: (p) => /* @__PURE__ */ jsx(StatusBadge, { status: p.isActive ? "active" : "inactive" })
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
key: "seen",
|
|
563
|
+
label: "Last seen",
|
|
564
|
+
render: (p) => /* @__PURE__ */ jsx(Cell, { main: fmtDateTime(p.lastActiveAt, locale), tone: "neutral600" })
|
|
565
|
+
}
|
|
566
|
+
]
|
|
567
|
+
}
|
|
568
|
+
);
|
|
569
|
+
};
|
|
570
|
+
const PersonDetailPage = () => {
|
|
571
|
+
const { id } = useParams();
|
|
572
|
+
const { locale } = useIntl();
|
|
573
|
+
const navigate = useNavigate();
|
|
574
|
+
const { toggleNotification } = useNotification();
|
|
575
|
+
const { allowedActions } = useRBAC({
|
|
576
|
+
reveal: PERMISSIONS.peoplePhone,
|
|
577
|
+
write: PERMISSIONS.peopleWrite
|
|
578
|
+
});
|
|
579
|
+
const { data: person, isLoading, isError } = useGetPersonQuery(id);
|
|
580
|
+
const [reveal, { isLoading: revealing }] = useRevealPhoneMutation();
|
|
581
|
+
const [setActive, { isLoading: saving }] = useSetPersonActiveMutation();
|
|
582
|
+
const [fullPhone, setFullPhone] = useState(null);
|
|
583
|
+
if (isLoading) return /* @__PURE__ */ jsx(Page.Loading, {});
|
|
584
|
+
if (isError || !person) return /* @__PURE__ */ jsx(Page.Error, {});
|
|
585
|
+
const attempt = async (work, done) => {
|
|
586
|
+
try {
|
|
587
|
+
const result = await work().unwrap();
|
|
588
|
+
if (done) toggleNotification({ type: "success", message: done });
|
|
589
|
+
return result;
|
|
590
|
+
} catch (err) {
|
|
591
|
+
toggleNotification({ type: "danger", message: errorMessage(err) });
|
|
592
|
+
return null;
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
const onReveal = async () => setFullPhone((await attempt(() => reveal(id)))?.phone ?? null);
|
|
596
|
+
const onToggle = () => attempt(
|
|
597
|
+
() => setActive({ id, isActive: !person.isActive }),
|
|
598
|
+
person.isActive ? "Deactivated: this person can no longer use the ledger." : "Reactivated."
|
|
599
|
+
);
|
|
600
|
+
return /* @__PURE__ */ jsx(Page.Protect, { permissions: PERMISSIONS.peopleRead, children: /* @__PURE__ */ jsx(
|
|
601
|
+
PageShell,
|
|
602
|
+
{
|
|
603
|
+
title: person.displayName ?? "No name yet",
|
|
604
|
+
eyebrow: "Person",
|
|
605
|
+
subtitle: `First seen ${fmtDateTime(person.createdAt, locale)} · last seen ${fmtDateTime(person.lastActiveAt, locale)}`,
|
|
606
|
+
navigationAction: /* @__PURE__ */ jsx(
|
|
607
|
+
Button,
|
|
608
|
+
{
|
|
609
|
+
variant: "ghost",
|
|
610
|
+
size: "S",
|
|
611
|
+
startIcon: /* @__PURE__ */ jsx(ArrowLeft, {}),
|
|
612
|
+
onClick: () => navigate("..", { relative: "path" }),
|
|
613
|
+
children: "People"
|
|
614
|
+
}
|
|
615
|
+
),
|
|
616
|
+
primaryAction: allowedActions.canWrite ? /* @__PURE__ */ jsx(
|
|
617
|
+
Button,
|
|
618
|
+
{
|
|
619
|
+
variant: person.isActive ? "danger-light" : "secondary",
|
|
620
|
+
loading: saving,
|
|
621
|
+
onClick: onToggle,
|
|
622
|
+
children: person.isActive ? "Deactivate" : "Reactivate"
|
|
623
|
+
}
|
|
624
|
+
) : null,
|
|
625
|
+
secondaryAction: /* @__PURE__ */ jsx(StatusBadge, { status: person.isActive ? "active" : "inactive" }),
|
|
626
|
+
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
627
|
+
/* @__PURE__ */ jsx(
|
|
628
|
+
Section,
|
|
629
|
+
{
|
|
630
|
+
title: "Phone number",
|
|
631
|
+
help: "Masked by default. Revealing it is written in the server log with your account.",
|
|
632
|
+
children: /* @__PURE__ */ jsxs(Flex, { gap: 4, alignItems: "center", children: [
|
|
633
|
+
/* @__PURE__ */ jsx(Mono, { variant: "delta", fontWeight: "bold", children: fullPhone ?? person.phone ?? "—" }),
|
|
634
|
+
allowedActions.canReveal && person.phone && !fullPhone ? /* @__PURE__ */ jsx(
|
|
635
|
+
Button,
|
|
636
|
+
{
|
|
637
|
+
variant: "tertiary",
|
|
638
|
+
size: "S",
|
|
639
|
+
startIcon: /* @__PURE__ */ jsx(Eye, {}),
|
|
640
|
+
loading: revealing,
|
|
641
|
+
onClick: onReveal,
|
|
642
|
+
children: "Reveal"
|
|
643
|
+
}
|
|
644
|
+
) : null
|
|
645
|
+
] })
|
|
646
|
+
}
|
|
647
|
+
),
|
|
648
|
+
/* @__PURE__ */ jsx(Section, { title: "Groups", index: 1, children: /* @__PURE__ */ jsx(
|
|
649
|
+
DataTable,
|
|
650
|
+
{
|
|
651
|
+
empty: "Not in any group.",
|
|
652
|
+
rows: person.groups,
|
|
653
|
+
onRow: (g) => navigate(`../../groups/${g.id}`, { relative: "path" }),
|
|
654
|
+
columns: [
|
|
655
|
+
{ key: "name", label: "Group", render: (g) => /* @__PURE__ */ jsx(Cell, { main: g.name, strong: true }) },
|
|
656
|
+
{
|
|
657
|
+
key: "role",
|
|
658
|
+
label: "Seat",
|
|
659
|
+
render: (g) => /* @__PURE__ */ jsx(Typography, { children: g.hasLeft ? "Left" : g.role === "owner" ? "Created it" : "Member" })
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
key: "status",
|
|
663
|
+
label: "Status",
|
|
664
|
+
render: (g) => /* @__PURE__ */ jsx(StatusBadge, { status: g.isArchived ? "archived" : "active" })
|
|
665
|
+
}
|
|
666
|
+
]
|
|
667
|
+
}
|
|
668
|
+
) })
|
|
669
|
+
] })
|
|
670
|
+
}
|
|
671
|
+
) });
|
|
672
|
+
};
|
|
673
|
+
const STATUSES = ["pending", "confirmed", "rejected", "cancelled"];
|
|
674
|
+
const SettlementsPage = () => {
|
|
675
|
+
const { locale } = useIntl();
|
|
676
|
+
const navigate = useNavigate();
|
|
677
|
+
return /* @__PURE__ */ jsx(
|
|
678
|
+
ListPage,
|
|
679
|
+
{
|
|
680
|
+
title: "Settlements",
|
|
681
|
+
subtitle: "Look a payment up by the reference the customer has: a mobile-money transaction id, for instance.",
|
|
682
|
+
permissions: PERMISSIONS.settlementsRead,
|
|
683
|
+
useQuery: useGetSettlementsQuery,
|
|
684
|
+
searchLabel: "Payment reference",
|
|
685
|
+
searchParam: "reference",
|
|
686
|
+
empty: "No settlement matches.",
|
|
687
|
+
onRow: (s) => s.group ? navigate(`../groups/${s.group.id}`, { relative: "path" }) : null,
|
|
688
|
+
filters: (state, set) => /* @__PURE__ */ jsxs(
|
|
689
|
+
SingleSelect,
|
|
690
|
+
{
|
|
691
|
+
size: "S",
|
|
692
|
+
"aria-label": "Status",
|
|
693
|
+
value: state.status ?? "",
|
|
694
|
+
onChange: (status) => set({ status }),
|
|
695
|
+
children: [
|
|
696
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "", children: "All statuses" }),
|
|
697
|
+
STATUSES.map((status) => /* @__PURE__ */ jsx(SingleSelectOption, { value: status, children: status }, status))
|
|
698
|
+
]
|
|
699
|
+
}
|
|
700
|
+
),
|
|
701
|
+
columns: [
|
|
702
|
+
{
|
|
703
|
+
key: "when",
|
|
704
|
+
label: "Declared",
|
|
705
|
+
render: (s) => /* @__PURE__ */ jsx(Cell, { main: fmtDateTime(s.declaredAt, locale), tone: "neutral600" })
|
|
706
|
+
},
|
|
707
|
+
{ key: "group", label: "Group", render: (s) => /* @__PURE__ */ jsx(Cell, { main: s.group?.name }) },
|
|
708
|
+
{
|
|
709
|
+
key: "who",
|
|
710
|
+
label: "From → to",
|
|
711
|
+
render: (s) => /* @__PURE__ */ jsx(Cell, { main: `${s.from.displayName} → ${s.to.displayName}` })
|
|
712
|
+
},
|
|
713
|
+
{
|
|
714
|
+
key: "amount",
|
|
715
|
+
label: "Amount",
|
|
716
|
+
render: (s) => /* @__PURE__ */ jsx(Cell, { main: fmtNumber(s.amount, locale), sub: s.method, strong: true })
|
|
717
|
+
},
|
|
718
|
+
{ key: "status", label: "Status", render: (s) => /* @__PURE__ */ jsx(StatusBadge, { status: s.status }) },
|
|
719
|
+
{
|
|
720
|
+
key: "ref",
|
|
721
|
+
label: "Reference",
|
|
722
|
+
render: (s) => /* @__PURE__ */ jsx(Mono, { variant: "pi", children: s.reference ?? "—" })
|
|
723
|
+
}
|
|
724
|
+
]
|
|
725
|
+
}
|
|
726
|
+
);
|
|
727
|
+
};
|
|
728
|
+
const summary = (data) => data ? Object.entries(data).filter(([, value]) => value !== null && value !== void 0).map(([key, value]) => `${key}: ${value}`).join(" · ") : "—";
|
|
729
|
+
const AuditPage = () => {
|
|
730
|
+
const { locale } = useIntl();
|
|
731
|
+
return /* @__PURE__ */ jsx(
|
|
732
|
+
ListPage,
|
|
733
|
+
{
|
|
734
|
+
title: "Audit trail",
|
|
735
|
+
subtitle: "Who did what, in which group, newest first. Written by the server, never edited.",
|
|
736
|
+
permissions: PERMISSIONS.auditRead,
|
|
737
|
+
useQuery: useGetEventsQuery,
|
|
738
|
+
searchLabel: "Action, e.g. settlement.created",
|
|
739
|
+
searchParam: "action",
|
|
740
|
+
empty: "Nothing recorded.",
|
|
741
|
+
columns: [
|
|
742
|
+
{
|
|
743
|
+
key: "when",
|
|
744
|
+
label: "When",
|
|
745
|
+
render: (e) => /* @__PURE__ */ jsx(Cell, { main: fmtDateTime(e.at, locale), tone: "neutral600" })
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
key: "action",
|
|
749
|
+
label: "Action",
|
|
750
|
+
render: (e) => /* @__PURE__ */ jsx(Mono, { variant: "pi", fontWeight: "semiBold", children: e.action })
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
key: "actor",
|
|
754
|
+
label: "By",
|
|
755
|
+
render: (e) => /* @__PURE__ */ jsx(Cell, { main: e.actor?.displayName ?? "An administrator" })
|
|
756
|
+
},
|
|
757
|
+
{ key: "group", label: "Group", render: (e) => /* @__PURE__ */ jsx(Cell, { main: e.group?.name }) },
|
|
758
|
+
{
|
|
759
|
+
key: "data",
|
|
760
|
+
label: "Details",
|
|
761
|
+
render: (e) => /* @__PURE__ */ jsx(Cell, { main: summary(e.data), tone: "neutral600" })
|
|
762
|
+
}
|
|
763
|
+
]
|
|
764
|
+
}
|
|
765
|
+
);
|
|
766
|
+
};
|
|
767
|
+
const SPRING = "cubic-bezier(0.32, 0.72, 0, 1)";
|
|
768
|
+
const Canvas = styled(Flex)`
|
|
769
|
+
min-height: 100vh;
|
|
770
|
+
background: ${({ theme }) => theme.colors.neutral100};
|
|
771
|
+
`;
|
|
772
|
+
const Rail = styled.aside`
|
|
773
|
+
width: 272px;
|
|
774
|
+
flex-shrink: 0;
|
|
775
|
+
padding: 1.6rem 0 1.6rem 1.6rem;
|
|
776
|
+
`;
|
|
777
|
+
const Side = styled.nav`
|
|
778
|
+
position: sticky;
|
|
779
|
+
top: 1.6rem;
|
|
780
|
+
display: flex;
|
|
781
|
+
flex-direction: column;
|
|
782
|
+
height: calc(100vh - 3.2rem);
|
|
783
|
+
overflow: auto;
|
|
784
|
+
border-radius: 2rem;
|
|
785
|
+
padding: 0.5rem;
|
|
786
|
+
background: ${({ theme }) => theme.colors.neutral150};
|
|
787
|
+
box-shadow:
|
|
788
|
+
0 1px 2px rgba(33, 33, 52, 0.04),
|
|
789
|
+
0 24px 48px -28px rgba(33, 33, 52, 0.3);
|
|
790
|
+
`;
|
|
791
|
+
const SideCore = styled.div`
|
|
792
|
+
flex: 1;
|
|
793
|
+
border-radius: calc(2rem - 0.5rem);
|
|
794
|
+
background: ${({ theme }) => theme.colors.neutral0};
|
|
795
|
+
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
|
|
796
|
+
padding: 2rem 1.2rem;
|
|
797
|
+
display: flex;
|
|
798
|
+
flex-direction: column;
|
|
799
|
+
`;
|
|
800
|
+
const Brand = styled(Flex)`
|
|
801
|
+
padding: 0 ${({ theme }) => theme.spaces[3]} ${({ theme }) => theme.spaces[5]};
|
|
802
|
+
`;
|
|
803
|
+
const Logo = styled.span`
|
|
804
|
+
display: inline-flex;
|
|
805
|
+
align-items: center;
|
|
806
|
+
justify-content: center;
|
|
807
|
+
width: 3.6rem;
|
|
808
|
+
height: 3.6rem;
|
|
809
|
+
border-radius: 1rem;
|
|
810
|
+
background: linear-gradient(135deg, #ff7900, #facc15);
|
|
811
|
+
color: #fff;
|
|
812
|
+
font-weight: 800;
|
|
813
|
+
font-size: 1.6rem;
|
|
814
|
+
letter-spacing: -0.04em;
|
|
815
|
+
box-shadow: 0 6px 14px -6px rgba(255, 121, 0, 0.6);
|
|
816
|
+
`;
|
|
817
|
+
const GroupTitle = styled(Typography)`
|
|
818
|
+
display: block;
|
|
819
|
+
padding: ${({ theme }) => theme.spaces[5]} ${({ theme }) => theme.spaces[3]}
|
|
820
|
+
${({ theme }) => theme.spaces[2]};
|
|
821
|
+
letter-spacing: 0.18em;
|
|
822
|
+
text-transform: uppercase;
|
|
823
|
+
font-size: 1rem;
|
|
824
|
+
`;
|
|
825
|
+
const Item = styled(NavLink)`
|
|
826
|
+
position: relative;
|
|
827
|
+
display: flex;
|
|
828
|
+
align-items: center;
|
|
829
|
+
gap: ${({ theme }) => theme.spaces[3]};
|
|
830
|
+
padding: 0.8rem 1.2rem 0.8rem 1.4rem;
|
|
831
|
+
border-radius: 1.2rem;
|
|
832
|
+
color: ${({ theme }) => theme.colors.neutral700};
|
|
833
|
+
text-decoration: none;
|
|
834
|
+
font-size: 1.4rem;
|
|
835
|
+
line-height: 2.2rem;
|
|
836
|
+
transition:
|
|
837
|
+
background 360ms ${SPRING},
|
|
838
|
+
color 360ms ${SPRING},
|
|
839
|
+
transform 360ms ${SPRING};
|
|
840
|
+
svg {
|
|
841
|
+
width: 1.6rem;
|
|
842
|
+
height: 1.6rem;
|
|
843
|
+
flex-shrink: 0;
|
|
844
|
+
color: ${({ theme }) => theme.colors.neutral500};
|
|
845
|
+
transition: color 360ms ${SPRING};
|
|
846
|
+
}
|
|
847
|
+
&::before {
|
|
848
|
+
content: '';
|
|
849
|
+
position: absolute;
|
|
850
|
+
left: 0.2rem;
|
|
851
|
+
top: 50%;
|
|
852
|
+
width: 0.4rem;
|
|
853
|
+
height: 0;
|
|
854
|
+
border-radius: 999px;
|
|
855
|
+
background: #ff7900;
|
|
856
|
+
transform: translateY(-50%);
|
|
857
|
+
transition: height 360ms ${SPRING};
|
|
858
|
+
}
|
|
859
|
+
&:hover {
|
|
860
|
+
background: ${({ theme }) => theme.colors.neutral100};
|
|
861
|
+
color: ${({ theme }) => theme.colors.neutral800};
|
|
862
|
+
transform: translateX(2px);
|
|
863
|
+
}
|
|
864
|
+
&:active {
|
|
865
|
+
transform: scale(0.98);
|
|
866
|
+
}
|
|
867
|
+
&.active {
|
|
868
|
+
background: ${({ theme }) => theme.colors.neutral100};
|
|
869
|
+
color: ${({ theme }) => theme.colors.neutral800};
|
|
870
|
+
font-weight: 600;
|
|
871
|
+
}
|
|
872
|
+
&.active::before {
|
|
873
|
+
height: 1.6rem;
|
|
874
|
+
}
|
|
875
|
+
&.active svg {
|
|
876
|
+
color: #ff7900;
|
|
877
|
+
}
|
|
878
|
+
`;
|
|
879
|
+
const GROUPS = [
|
|
880
|
+
{
|
|
881
|
+
title: "Overview",
|
|
882
|
+
items: [
|
|
883
|
+
{ to: "", end: true, key: "nav.dashboard", label: "Dashboard", Icon: PresentationChart }
|
|
884
|
+
]
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
title: "Look up",
|
|
888
|
+
items: [
|
|
889
|
+
{ to: "groups", key: "nav.groups", label: "Groups", Icon: Stack },
|
|
890
|
+
{ to: "people", key: "nav.people", label: "People", Icon: User },
|
|
891
|
+
{
|
|
892
|
+
to: "settlements",
|
|
893
|
+
key: "nav.settlements",
|
|
894
|
+
label: "Settlements",
|
|
895
|
+
Icon: ArrowsCounterClockwise
|
|
896
|
+
}
|
|
897
|
+
]
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
title: "Verify",
|
|
901
|
+
items: [{ to: "audit", key: "nav.audit", label: "Audit trail", Icon: ListSearch }]
|
|
902
|
+
}
|
|
903
|
+
];
|
|
904
|
+
const App = () => {
|
|
905
|
+
const { formatMessage } = useIntl();
|
|
906
|
+
return /* @__PURE__ */ jsx(Page.Protect, { permissions: PERMISSIONS.access, children: /* @__PURE__ */ jsxs(Canvas, { alignItems: "stretch", children: [
|
|
907
|
+
/* @__PURE__ */ jsx(Rail, { children: /* @__PURE__ */ jsx(Side, { "aria-label": "Split", children: /* @__PURE__ */ jsxs(SideCore, { children: [
|
|
908
|
+
/* @__PURE__ */ jsxs(Brand, { gap: 3, alignItems: "center", children: [
|
|
909
|
+
/* @__PURE__ */ jsx(Logo, { "aria-hidden": true, children: "÷" }),
|
|
910
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
911
|
+
/* @__PURE__ */ jsx(Typography, { variant: "beta", tag: "p", children: "Split" }),
|
|
912
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: "Shared expenses" })
|
|
913
|
+
] })
|
|
914
|
+
] }),
|
|
915
|
+
GROUPS.map((g) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
916
|
+
/* @__PURE__ */ jsx(GroupTitle, { variant: "sigma", textColor: "neutral500", children: g.title }),
|
|
917
|
+
/* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: g.items.map((n) => /* @__PURE__ */ jsxs(Item, { to: n.to, end: n.end, children: [
|
|
918
|
+
/* @__PURE__ */ jsx(n.Icon, { "aria-hidden": true }),
|
|
919
|
+
formatMessage({ id: getTranslation(n.key), defaultMessage: n.label })
|
|
920
|
+
] }, n.key)) })
|
|
921
|
+
] }, g.title))
|
|
922
|
+
] }) }) }),
|
|
923
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1, minWidth: 0 }, children: /* @__PURE__ */ jsxs(Routes, { children: [
|
|
924
|
+
/* @__PURE__ */ jsx(Route, { index: true, element: /* @__PURE__ */ jsx(Dashboard, {}) }),
|
|
925
|
+
/* @__PURE__ */ jsx(Route, { path: "groups", element: /* @__PURE__ */ jsx(GroupsPage, {}) }),
|
|
926
|
+
/* @__PURE__ */ jsx(Route, { path: "groups/:id", element: /* @__PURE__ */ jsx(GroupDetailPage, {}) }),
|
|
927
|
+
/* @__PURE__ */ jsx(Route, { path: "people", element: /* @__PURE__ */ jsx(PeoplePage, {}) }),
|
|
928
|
+
/* @__PURE__ */ jsx(Route, { path: "people/:id", element: /* @__PURE__ */ jsx(PersonDetailPage, {}) }),
|
|
929
|
+
/* @__PURE__ */ jsx(Route, { path: "settlements", element: /* @__PURE__ */ jsx(SettlementsPage, {}) }),
|
|
930
|
+
/* @__PURE__ */ jsx(Route, { path: "audit", element: /* @__PURE__ */ jsx(AuditPage, {}) }),
|
|
931
|
+
/* @__PURE__ */ jsx(Route, { path: "*", element: /* @__PURE__ */ jsx(Page.Error, {}) })
|
|
932
|
+
] }) })
|
|
933
|
+
] }) });
|
|
934
|
+
};
|
|
935
|
+
export {
|
|
936
|
+
App
|
|
937
|
+
};
|