@sonatel-os/strapi-plugin-split 0.4.0 → 0.6.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 CHANGED
@@ -8,17 +8,17 @@ It assumes nothing about its host. Who the people are (a header your gateway set
8
8
 
9
9
  ## What you get
10
10
 
11
- | Area | In the admin | For the app (`/api/split`) |
12
- | --------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
13
- | **People** | Search by name or phone (masked), reveal a full number (permission, logged), deactivate. | `GET /me`, `PUT /me` (`{ autoAcceptInvites }`) |
14
- | **Home** | Dashboard: people, groups, amount spent together, amount settled, by method. | `GET /overview` (what to pay, who owes you, every group), `GET /activity` |
15
- | **Groups** | Search by name or invite code; one group's books: seats, balances, payments, history. Archive. | `POST /groups`, `POST /groups/join`, `GET/PATCH/PUT /groups/:group`, `…/archive`, `…/leave` |
16
- | **Invitations** | — | `GET /invitations`, `POST /invitations/:invitation/accept`, `…/decline` |
17
- | **Members** | Seats with their state: uses the app, added by name, left. | `POST /groups/:group/members`, `DELETE /groups/:group/members/:member` |
18
- | **Expenses** | The most recent fifty of a group. | `GET/POST /groups/:group/expenses`, `PUT/DELETE …/expenses/:expense` |
19
- | **Settlements** | Look a payment up by the reference the customer has. | `GET/POST /groups/:group/settlements`, `POST …/settlements/:settlement/confirm`, `…/reject`, `…/cancel` |
20
- | **Orders** | — (each one is in the audit trail; a closed one is an expense). | `GET/POST /groups/:group/orders`, `GET …/orders/:order`, `PUT …/orders/:order/lines`, `POST …/orders/:order/close`, `…/cancel` |
21
- | **Audit** | Who did what in which group, newest first. | — |
11
+ | Area | In the admin | For the app (`/api/split`) |
12
+ | --------------- | ---------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
13
+ | **People** | Search by name or phone (masked), reveal a full number (permission, logged), deactivate. | `GET /me`, `PUT /me` (`{ autoAcceptInvites }`) |
14
+ | **Home** | Dashboard: people, groups, amount spent together, amount settled, by method. | `GET /overview` (what to pay, who owes you, every group), `GET /activity` |
15
+ | **Groups** | Search by name or invite code; one group's books: seats, balances, payments, history. Archive. | `POST /groups`, `POST /groups/join`, `GET/PATCH/PUT /groups/:group`, `…/archive`, `…/leave` |
16
+ | **Invitations** | — | `GET /invitations`, `POST /invitations/:invitation/accept`, `…/decline` |
17
+ | **Members** | Seats with their state: uses the app, added by name, left. | `POST /groups/:group/members`, `DELETE /groups/:group/members/:member` |
18
+ | **Expenses** | The most recent fifty of a group. | `GET/POST /groups/:group/expenses`, `PUT/DELETE …/expenses/:expense` |
19
+ | **Settlements** | Look a payment up by the reference the customer has. | `GET/POST /groups/:group/settlements`, `POST …/settlements/:settlement/confirm`, `…/reject`, `…/cancel` |
20
+ | **Orders** | — (each one is in the audit trail; a closed one is an expense). | `GET /orders`, `GET/POST /groups/:group/orders`, `GET …/orders/:order`, `PUT …/orders/:order/lines`, `POST …/orders/:order/close`, `…/cancel` |
21
+ | **Audit** | Who did what in which group, newest first. | — |
22
22
 
23
23
  All plugin tables are prefixed `split_` and hidden from the Content Manager: a ledger is not edited by hand, and the admin screens are read-mostly on purpose.
24
24
 
@@ -31,7 +31,7 @@ All plugin tables are prefixed `split_` and hidden from the Content Manager: a l
31
31
  - **Seats before people.** A member can be added by name and phone before they ever open the app. A member added by name only can owe and be owed, and what they are paid needs nobody's confirmation.
32
32
  - **Being added is an offer.** A seat added with the phone of someone who uses the app (or who opens it later) is an invitation: they see it in `GET /invitations` and in `GET /overview` (`invitations`), and the group stays closed to them until they accept. Entering the group's invite code accepts it too. Someone who set `autoAcceptInvites` is in at once. Until the answer, the seat counts like a name: the group can include it in expenses (`invite: "pending"` on the member), and what it is paid needs nobody's confirmation. Declining frees the seat when nothing is on the books for it; otherwise the seat stays as a name nobody holds (`invite: "declined"`), so the books still add up.
33
33
  - **Nobody leaves with an open account.** Leaving a group, or being removed from it, is refused (`MEMBER_NOT_SETTLED`, with `details.balance`) while the seat owes, is owed, or has a payment awaiting confirmation.
34
- - **An order is not money until it closes.** Someone lists items with a unit price and, if they want, a closing time; members say how many of each they take (`PUT …/lines` replaces what one member takes; the organiser can set anyone's, also after the closing time). Closing writes one `free` expense paid by the organiser: each member owes what they took plus an equal part of the delivery fee given at closing. The expense carries the order's reference, so closing twice writes once.
34
+ - **An order is not money until it closes.** Someone lists items with a unit price and, if they want, a closing time; members say how many of each they take (`PUT …/lines` replaces what one member takes; the organiser can set anyone's, also after the closing time). Closing writes one `free` expense paid by the organiser: each member owes what they took plus an equal part of the delivery fee given at closing. The expense carries the order's reference, so closing twice writes once. A line can carry a short precision (`note`, 80 characters: "sans piment"), read by everyone on the order and gone when the member sends their basket again without it. `GET /orders` gives a person the orders worth knowing about across their groups — the open ones, and those closed or dropped within the last day — each with its group, its organiser and what the person took; the overview carries the same list as `orders`. It reads no books, so a host can ask it often to tell people an order was launched or closed.
35
35
  - **No seat, no group.** Asking for a group you are not in answers the same `404` as a group that does not exist.
36
36
 
37
37
  ## Install
@@ -57,7 +57,8 @@ split: {
57
57
  cash: { instant: false },
58
58
  other: { instant: false },
59
59
  },
60
- limits: { maxGroupsPerPerson: 50, maxMembersPerGroup: 50, maxAmount: 50000000 },
60
+ // starting values: an administrator can change them in Settings → Split, and that wins
61
+ limits: { maxGroupsPerPerson: 150, maxMembersPerGroup: 150, maxAmount: 150000000 },
61
62
  },
62
63
  },
63
64
  ```
@@ -119,6 +120,7 @@ Clients branch on `code` (see `server/src/constants.js`), never on the French me
119
120
  | `people.write` | deactivate and reactivate people |
120
121
  | `settlements.read` | look settlements up |
121
122
  | `settings.read` | see the configuration page |
123
+ | `settings.write` | change the limits (logged) |
122
124
 
123
125
  ## Development
124
126
 
@@ -7,8 +7,8 @@ const admin = require("@strapi/strapi/admin");
7
7
  const reactRouterDom = require("react-router-dom");
8
8
  const reactIntl = require("react-intl");
9
9
  const styledComponents = require("styled-components");
10
- const index = require("./index-oyRhs5fN.js");
11
- const api = require("./api-cwZGoKZx.js");
10
+ const index = require("./index-Uv5-E0cg.js");
11
+ const format = require("./format-Dr6t_23v.js");
12
12
  const react = require("react");
13
13
  const getTranslation = (id) => `${index.PLUGIN_ID}.${id}`;
14
14
  const Head = styledComponents.styled.header`
@@ -34,7 +34,7 @@ const Title = styledComponents.styled(designSystem.Typography)`
34
34
  const Content = styledComponents.styled(designSystem.Box)`
35
35
  padding: 0 5.6rem 8rem;
36
36
  > * {
37
- transition: opacity 320ms ${api.SPRING};
37
+ transition: opacity 320ms ${format.SPRING};
38
38
  }
39
39
  `;
40
40
  const PageShell = ({
@@ -53,7 +53,7 @@ const PageShell = ({
53
53
  navigationAction ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingBottom: 4, children: navigationAction }) : null,
54
54
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "flex-end", gap: 6, wrap: "wrap", children: [
55
55
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { minWidth: 0 }, children: [
56
- /* @__PURE__ */ jsxRuntime.jsx(api.Eyebrow, { paddingBottom: 2, children: eyebrow }),
56
+ /* @__PURE__ */ jsxRuntime.jsx(format.Eyebrow, { paddingBottom: 2, children: eyebrow }),
57
57
  /* @__PURE__ */ jsxRuntime.jsx(Title, { tag: "h1", children: title }),
58
58
  subtitle ? /* @__PURE__ */ jsxRuntime.jsx(
59
59
  designSystem.Typography,
@@ -74,7 +74,7 @@ const PageShell = ({
74
74
  ] })
75
75
  ] }),
76
76
  /* @__PURE__ */ jsxRuntime.jsxs(Content, { children: [
77
- intro ? /* @__PURE__ */ jsxRuntime.jsx(api.Intro, { ...intro }) : null,
77
+ intro ? /* @__PURE__ */ jsxRuntime.jsx(format.Intro, { ...intro }) : null,
78
78
  children
79
79
  ] })
80
80
  ] });
@@ -98,34 +98,16 @@ const Cell = ({ main, sub, strong, tone }) => /* @__PURE__ */ jsxRuntime.jsxs(js
98
98
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: strong ? "semiBold" : void 0, textColor: tone, children: main ?? "—" }),
99
99
  sub ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: sub }) : null
100
100
  ] });
101
- const fmtDateTime = (value, locale) => {
102
- if (!value) return "—";
103
- try {
104
- return new Intl.DateTimeFormat(locale ?? void 0, {
105
- dateStyle: "medium",
106
- timeStyle: "short"
107
- }).format(new Date(value));
108
- } catch {
109
- return String(value);
110
- }
111
- };
112
- const fmtNumber = (value, locale) => new Intl.NumberFormat(locale ?? void 0).format(Number(value ?? 0));
113
- const fmtSigned = (value, locale) => {
114
- const n = Number(value ?? 0);
115
- const digits = fmtNumber(Math.abs(n), locale);
116
- return n > 0 ? `+${digits}` : n < 0 ? `−${digits}` : digits;
117
- };
118
- const errorMessage = (err) => err?.data?.error?.message ?? err?.response?.data?.error?.message ?? err?.error?.message ?? err?.message ?? "Une erreur est survenue.";
119
101
  const ACCENT = "#FF7900";
120
102
  const GREEN = "#328048";
121
103
  const BLUE = "#4945FF";
122
104
  const AMBER = "#D9822F";
123
105
  const Dashboard = () => {
124
106
  const { locale } = reactIntl.useIntl();
125
- const { data, isLoading, isError } = api.useGetDashboardQuery();
107
+ const { data, isLoading, isError } = format.useGetDashboardQuery();
126
108
  if (isLoading) return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Loading, {});
127
109
  if (isError || !data) return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Error, {});
128
- const n = (value) => fmtNumber(value, locale);
110
+ const n = (value) => format.fmtNumber(value, locale);
129
111
  const { people, groups, expenses, settlements, days } = data;
130
112
  const settledMax = Math.max(1, ...settlements.byMethod.map((m) => m.total));
131
113
  const tiles = [
@@ -172,11 +154,11 @@ const Dashboard = () => {
172
154
  xs: 12,
173
155
  direction: "column",
174
156
  alignItems: "stretch",
175
- children: /* @__PURE__ */ jsxRuntime.jsx(api.StatTile, { ...tile, index: i })
157
+ children: /* @__PURE__ */ jsxRuntime.jsx(format.StatTile, { ...tile, index: i })
176
158
  },
177
159
  tile.label
178
160
  )) }),
179
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 6, children: /* @__PURE__ */ jsxRuntime.jsxs(api.Section, { title: "How debts get settled", help: "Confirmed settlements, by method.", index: 4, children: [
161
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 6, children: /* @__PURE__ */ jsxRuntime.jsxs(format.Section, { title: "How debts get settled", help: "Confirmed settlements, by method.", index: 4, children: [
180
162
  /* @__PURE__ */ jsxRuntime.jsx(
181
163
  DataTable,
182
164
  {
@@ -189,7 +171,7 @@ const Dashboard = () => {
189
171
  {
190
172
  key: "share",
191
173
  label: "Share",
192
- render: (m) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { minWidth: 160 }, children: /* @__PURE__ */ jsxRuntime.jsx(api.Bar, { value: m.total, max: settledMax }) })
174
+ render: (m) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { minWidth: 160 }, children: /* @__PURE__ */ jsxRuntime.jsx(format.Bar, { value: m.total, max: settledMax }) })
193
175
  }
194
176
  ]
195
177
  }
@@ -288,7 +270,7 @@ const ListPage = ({
288
270
  ) }) : null,
289
271
  filters ? filters(extra, set) : null
290
272
  ] }),
291
- /* @__PURE__ */ jsxRuntime.jsxs(api.Section, { children: [
273
+ /* @__PURE__ */ jsxRuntime.jsxs(format.Section, { children: [
292
274
  isLoading ? /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Loading, {}) : /* @__PURE__ */ jsxRuntime.jsx(DataTable, { columns, rows: data?.data ?? [], onRow, empty }),
293
275
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 4, children: /* @__PURE__ */ jsxRuntime.jsx(Pager, { meta: data?.meta?.pagination, onPage: setPage }) })
294
276
  ] })
@@ -303,7 +285,7 @@ const GroupsPage = () => {
303
285
  title: "Groups",
304
286
  subtitle: "Find a group by its name or its invite code, then open its books.",
305
287
  permissions: index.PERMISSIONS.groupsRead,
306
- useQuery: api.useGetGroupsQuery,
288
+ useQuery: format.useGetGroupsQuery,
307
289
  searchLabel: "Name or invite code",
308
290
  empty: "No group matches.",
309
291
  onRow: (g) => navigate(g.id),
@@ -312,17 +294,17 @@ const GroupsPage = () => {
312
294
  {
313
295
  key: "code",
314
296
  label: "Invite code",
315
- render: (g) => /* @__PURE__ */ jsxRuntime.jsx(api.Mono, { variant: "pi", children: g.inviteCode })
297
+ render: (g) => /* @__PURE__ */ jsxRuntime.jsx(format.Mono, { variant: "pi", children: g.inviteCode })
316
298
  },
317
299
  {
318
300
  key: "status",
319
301
  label: "Status",
320
- render: (g) => /* @__PURE__ */ jsxRuntime.jsx(api.StatusBadge, { status: g.isArchived ? "archived" : "active" })
302
+ render: (g) => /* @__PURE__ */ jsxRuntime.jsx(format.StatusBadge, { status: g.isArchived ? "archived" : "active" })
321
303
  },
322
304
  {
323
305
  key: "last",
324
306
  label: "Last activity",
325
- render: (g) => /* @__PURE__ */ jsxRuntime.jsx(Cell, { main: fmtDateTime(g.lastActivityAt, locale), tone: "neutral600" })
307
+ render: (g) => /* @__PURE__ */ jsxRuntime.jsx(Cell, { main: format.fmtDateTime(g.lastActivityAt, locale), tone: "neutral600" })
326
308
  }
327
309
  ]
328
310
  }
@@ -335,12 +317,12 @@ const GroupDetailPage = () => {
335
317
  const navigate = reactRouterDom.useNavigate();
336
318
  const { toggleNotification } = admin.useNotification();
337
319
  const { allowedActions } = admin.useRBAC({ archive: index.PERMISSIONS.groupsWrite });
338
- const { data: group, isLoading, isError } = api.useGetGroupQuery(id);
339
- const [archive, { isLoading: archiving }] = api.useArchiveGroupMutation();
320
+ const { data: group, isLoading, isError } = format.useGetGroupQuery(id);
321
+ const [archive, { isLoading: archiving }] = format.useArchiveGroupMutation();
340
322
  if (isLoading) return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Loading, {});
341
323
  if (isError || !group) return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Error, {});
342
- const n = (value) => fmtNumber(value, locale);
343
- const when = (value) => fmtDateTime(value, locale);
324
+ const n = (value) => format.fmtNumber(value, locale);
325
+ const when = (value) => format.fmtDateTime(value, locale);
344
326
  const onArchive = async () => {
345
327
  try {
346
328
  await archive(id).unwrap();
@@ -349,7 +331,7 @@ const GroupDetailPage = () => {
349
331
  message: "Group archived. Nothing can be written in it any more."
350
332
  });
351
333
  } catch (err) {
352
- toggleNotification({ type: "danger", message: errorMessage(err) });
334
+ toggleNotification({ type: "danger", message: format.errorMessage(err) });
353
335
  }
354
336
  };
355
337
  return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Protect, { permissions: index.PERMISSIONS.groupsRead, children: /* @__PURE__ */ jsxRuntime.jsxs(
@@ -368,7 +350,7 @@ const GroupDetailPage = () => {
368
350
  children: "Groups"
369
351
  }
370
352
  ),
371
- primaryAction: group.isArchived ? /* @__PURE__ */ jsxRuntime.jsx(api.StatusBadge, { status: "archived" }) : allowedActions.canArchive ? /* @__PURE__ */ jsxRuntime.jsx(
353
+ primaryAction: group.isArchived ? /* @__PURE__ */ jsxRuntime.jsx(format.StatusBadge, { status: "archived" }) : allowedActions.canArchive ? /* @__PURE__ */ jsxRuntime.jsx(
372
354
  designSystem.Button,
373
355
  {
374
356
  variant: "danger-light",
@@ -383,10 +365,10 @@ const GroupDetailPage = () => {
383
365
  { label: "Members", value: n(group.memberCount) },
384
366
  { label: "Expenses", value: n(group.expenseCount) },
385
367
  { label: "Spent together", value: n(group.total) }
386
- ].map((tile, i) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 4, s: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsx(api.StatTile, { ...tile, index: i }) }, tile.label)) }),
368
+ ].map((tile, i) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 4, s: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsx(format.StatTile, { ...tile, index: i }) }, tile.label)) }),
387
369
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, paddingTop: 6, children: [
388
370
  /* @__PURE__ */ jsxRuntime.jsx(
389
- api.Section,
371
+ format.Section,
390
372
  {
391
373
  title: "Members and balances",
392
374
  help: "Above zero is owed money, below zero owes money. Phone numbers are masked.",
@@ -412,7 +394,7 @@ const GroupDetailPage = () => {
412
394
  {
413
395
  key: "phone",
414
396
  label: "Phone",
415
- render: (m) => /* @__PURE__ */ jsxRuntime.jsx(api.Mono, { variant: "pi", children: m.phone ?? "—" })
397
+ render: (m) => /* @__PURE__ */ jsxRuntime.jsx(format.Mono, { variant: "pi", children: m.phone ?? "—" })
416
398
  },
417
399
  {
418
400
  key: "state",
@@ -428,7 +410,7 @@ const GroupDetailPage = () => {
428
410
  {
429
411
  key: "balance",
430
412
  label: "Balance",
431
- render: (m) => /* @__PURE__ */ jsxRuntime.jsx(Cell, { main: fmtSigned(m.balance, locale), tone: toneOf(m.balance), strong: true })
413
+ render: (m) => /* @__PURE__ */ jsxRuntime.jsx(Cell, { main: format.fmtSigned(m.balance, locale), tone: toneOf(m.balance), strong: true })
432
414
  }
433
415
  ]
434
416
  }
@@ -436,7 +418,7 @@ const GroupDetailPage = () => {
436
418
  }
437
419
  ),
438
420
  /* @__PURE__ */ jsxRuntime.jsx(
439
- api.Section,
421
+ format.Section,
440
422
  {
441
423
  title: "What would settle it",
442
424
  help: "The fewest payments that bring everyone to zero.",
@@ -459,7 +441,7 @@ const GroupDetailPage = () => {
459
441
  )
460
442
  }
461
443
  ),
462
- /* @__PURE__ */ jsxRuntime.jsx(api.Section, { title: "Settlements", help: "The most recent fifty.", index: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
444
+ /* @__PURE__ */ jsxRuntime.jsx(format.Section, { title: "Settlements", help: "The most recent fifty.", index: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
463
445
  DataTable,
464
446
  {
465
447
  empty: "No settlement yet.",
@@ -483,17 +465,17 @@ const GroupDetailPage = () => {
483
465
  {
484
466
  key: "status",
485
467
  label: "Status",
486
- render: (s) => /* @__PURE__ */ jsxRuntime.jsx(api.StatusBadge, { status: s.status })
468
+ render: (s) => /* @__PURE__ */ jsxRuntime.jsx(format.StatusBadge, { status: s.status })
487
469
  },
488
470
  {
489
471
  key: "ref",
490
472
  label: "Reference",
491
- render: (s) => /* @__PURE__ */ jsxRuntime.jsx(api.Mono, { variant: "pi", children: s.reference ?? "—" })
473
+ render: (s) => /* @__PURE__ */ jsxRuntime.jsx(format.Mono, { variant: "pi", children: s.reference ?? "—" })
492
474
  }
493
475
  ]
494
476
  }
495
477
  ) }),
496
- /* @__PURE__ */ jsxRuntime.jsx(api.Section, { title: "Expenses", help: "The most recent fifty.", index: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
478
+ /* @__PURE__ */ jsxRuntime.jsx(format.Section, { title: "Expenses", help: "The most recent fifty.", index: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
497
479
  DataTable,
498
480
  {
499
481
  empty: "No expense yet.",
@@ -544,7 +526,7 @@ const PeoplePage = () => {
544
526
  title: "People",
545
527
  subtitle: "Find someone by name or by phone number. Numbers stay masked in lists.",
546
528
  permissions: index.PERMISSIONS.peopleRead,
547
- useQuery: api.useGetPeopleQuery,
529
+ useQuery: format.useGetPeopleQuery,
548
530
  searchLabel: "Name or phone",
549
531
  empty: "Nobody matches.",
550
532
  onRow: (p) => navigate(p.id),
@@ -554,16 +536,16 @@ const PeoplePage = () => {
554
536
  label: "Person",
555
537
  render: (p) => /* @__PURE__ */ jsxRuntime.jsx(Cell, { main: p.displayName ?? "No name yet", strong: true })
556
538
  },
557
- { key: "phone", label: "Phone", render: (p) => /* @__PURE__ */ jsxRuntime.jsx(api.Mono, { variant: "pi", children: p.phone ?? "—" }) },
539
+ { key: "phone", label: "Phone", render: (p) => /* @__PURE__ */ jsxRuntime.jsx(format.Mono, { variant: "pi", children: p.phone ?? "—" }) },
558
540
  {
559
541
  key: "status",
560
542
  label: "Status",
561
- render: (p) => /* @__PURE__ */ jsxRuntime.jsx(api.StatusBadge, { status: p.isActive ? "active" : "inactive" })
543
+ render: (p) => /* @__PURE__ */ jsxRuntime.jsx(format.StatusBadge, { status: p.isActive ? "active" : "inactive" })
562
544
  },
563
545
  {
564
546
  key: "seen",
565
547
  label: "Last seen",
566
- render: (p) => /* @__PURE__ */ jsxRuntime.jsx(Cell, { main: fmtDateTime(p.lastActiveAt, locale), tone: "neutral600" })
548
+ render: (p) => /* @__PURE__ */ jsxRuntime.jsx(Cell, { main: format.fmtDateTime(p.lastActiveAt, locale), tone: "neutral600" })
567
549
  }
568
550
  ]
569
551
  }
@@ -578,9 +560,9 @@ const PersonDetailPage = () => {
578
560
  reveal: index.PERMISSIONS.peoplePhone,
579
561
  write: index.PERMISSIONS.peopleWrite
580
562
  });
581
- const { data: person, isLoading, isError } = api.useGetPersonQuery(id);
582
- const [reveal, { isLoading: revealing }] = api.useRevealPhoneMutation();
583
- const [setActive, { isLoading: saving }] = api.useSetPersonActiveMutation();
563
+ const { data: person, isLoading, isError } = format.useGetPersonQuery(id);
564
+ const [reveal, { isLoading: revealing }] = format.useRevealPhoneMutation();
565
+ const [setActive, { isLoading: saving }] = format.useSetPersonActiveMutation();
584
566
  const [fullPhone, setFullPhone] = react.useState(null);
585
567
  if (isLoading) return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Loading, {});
586
568
  if (isError || !person) return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Error, {});
@@ -590,7 +572,7 @@ const PersonDetailPage = () => {
590
572
  if (done) toggleNotification({ type: "success", message: done });
591
573
  return result;
592
574
  } catch (err) {
593
- toggleNotification({ type: "danger", message: errorMessage(err) });
575
+ toggleNotification({ type: "danger", message: format.errorMessage(err) });
594
576
  return null;
595
577
  }
596
578
  };
@@ -604,7 +586,7 @@ const PersonDetailPage = () => {
604
586
  {
605
587
  title: person.displayName ?? "No name yet",
606
588
  eyebrow: "Person",
607
- subtitle: `First seen ${fmtDateTime(person.createdAt, locale)} · last seen ${fmtDateTime(person.lastActiveAt, locale)}`,
589
+ subtitle: `First seen ${format.fmtDateTime(person.createdAt, locale)} · last seen ${format.fmtDateTime(person.lastActiveAt, locale)}`,
608
590
  navigationAction: /* @__PURE__ */ jsxRuntime.jsx(
609
591
  designSystem.Button,
610
592
  {
@@ -624,15 +606,15 @@ const PersonDetailPage = () => {
624
606
  children: person.isActive ? "Deactivate" : "Reactivate"
625
607
  }
626
608
  ) : null,
627
- secondaryAction: /* @__PURE__ */ jsxRuntime.jsx(api.StatusBadge, { status: person.isActive ? "active" : "inactive" }),
609
+ secondaryAction: /* @__PURE__ */ jsxRuntime.jsx(format.StatusBadge, { status: person.isActive ? "active" : "inactive" }),
628
610
  children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
629
611
  /* @__PURE__ */ jsxRuntime.jsx(
630
- api.Section,
612
+ format.Section,
631
613
  {
632
614
  title: "Phone number",
633
615
  help: "Masked by default. Revealing it is written in the server log with your account.",
634
616
  children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, alignItems: "center", children: [
635
- /* @__PURE__ */ jsxRuntime.jsx(api.Mono, { variant: "delta", fontWeight: "bold", children: fullPhone ?? person.phone ?? "—" }),
617
+ /* @__PURE__ */ jsxRuntime.jsx(format.Mono, { variant: "delta", fontWeight: "bold", children: fullPhone ?? person.phone ?? "—" }),
636
618
  allowedActions.canReveal && person.phone && !fullPhone ? /* @__PURE__ */ jsxRuntime.jsx(
637
619
  designSystem.Button,
638
620
  {
@@ -647,7 +629,7 @@ const PersonDetailPage = () => {
647
629
  ] })
648
630
  }
649
631
  ),
650
- /* @__PURE__ */ jsxRuntime.jsx(api.Section, { title: "Groups", index: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
632
+ /* @__PURE__ */ jsxRuntime.jsx(format.Section, { title: "Groups", index: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
651
633
  DataTable,
652
634
  {
653
635
  empty: "Not in any group.",
@@ -663,7 +645,7 @@ const PersonDetailPage = () => {
663
645
  {
664
646
  key: "status",
665
647
  label: "Status",
666
- render: (g) => /* @__PURE__ */ jsxRuntime.jsx(api.StatusBadge, { status: g.isArchived ? "archived" : "active" })
648
+ render: (g) => /* @__PURE__ */ jsxRuntime.jsx(format.StatusBadge, { status: g.isArchived ? "archived" : "active" })
667
649
  }
668
650
  ]
669
651
  }
@@ -682,7 +664,7 @@ const SettlementsPage = () => {
682
664
  title: "Settlements",
683
665
  subtitle: "Look a payment up by the reference the customer has: a mobile-money transaction id, for instance.",
684
666
  permissions: index.PERMISSIONS.settlementsRead,
685
- useQuery: api.useGetSettlementsQuery,
667
+ useQuery: format.useGetSettlementsQuery,
686
668
  searchLabel: "Payment reference",
687
669
  searchParam: "reference",
688
670
  empty: "No settlement matches.",
@@ -704,7 +686,7 @@ const SettlementsPage = () => {
704
686
  {
705
687
  key: "when",
706
688
  label: "Declared",
707
- render: (s) => /* @__PURE__ */ jsxRuntime.jsx(Cell, { main: fmtDateTime(s.declaredAt, locale), tone: "neutral600" })
689
+ render: (s) => /* @__PURE__ */ jsxRuntime.jsx(Cell, { main: format.fmtDateTime(s.declaredAt, locale), tone: "neutral600" })
708
690
  },
709
691
  { key: "group", label: "Group", render: (s) => /* @__PURE__ */ jsxRuntime.jsx(Cell, { main: s.group?.name }) },
710
692
  {
@@ -715,13 +697,13 @@ const SettlementsPage = () => {
715
697
  {
716
698
  key: "amount",
717
699
  label: "Amount",
718
- render: (s) => /* @__PURE__ */ jsxRuntime.jsx(Cell, { main: fmtNumber(s.amount, locale), sub: s.method, strong: true })
700
+ render: (s) => /* @__PURE__ */ jsxRuntime.jsx(Cell, { main: format.fmtNumber(s.amount, locale), sub: s.method, strong: true })
719
701
  },
720
- { key: "status", label: "Status", render: (s) => /* @__PURE__ */ jsxRuntime.jsx(api.StatusBadge, { status: s.status }) },
702
+ { key: "status", label: "Status", render: (s) => /* @__PURE__ */ jsxRuntime.jsx(format.StatusBadge, { status: s.status }) },
721
703
  {
722
704
  key: "ref",
723
705
  label: "Reference",
724
- render: (s) => /* @__PURE__ */ jsxRuntime.jsx(api.Mono, { variant: "pi", children: s.reference ?? "—" })
706
+ render: (s) => /* @__PURE__ */ jsxRuntime.jsx(format.Mono, { variant: "pi", children: s.reference ?? "—" })
725
707
  }
726
708
  ]
727
709
  }
@@ -736,7 +718,7 @@ const AuditPage = () => {
736
718
  title: "Audit trail",
737
719
  subtitle: "Who did what, in which group, newest first. Written by the server, never edited.",
738
720
  permissions: index.PERMISSIONS.auditRead,
739
- useQuery: api.useGetEventsQuery,
721
+ useQuery: format.useGetEventsQuery,
740
722
  searchLabel: "Action, e.g. settlement.created",
741
723
  searchParam: "action",
742
724
  empty: "Nothing recorded.",
@@ -744,12 +726,12 @@ const AuditPage = () => {
744
726
  {
745
727
  key: "when",
746
728
  label: "When",
747
- render: (e) => /* @__PURE__ */ jsxRuntime.jsx(Cell, { main: fmtDateTime(e.at, locale), tone: "neutral600" })
729
+ render: (e) => /* @__PURE__ */ jsxRuntime.jsx(Cell, { main: format.fmtDateTime(e.at, locale), tone: "neutral600" })
748
730
  },
749
731
  {
750
732
  key: "action",
751
733
  label: "Action",
752
- render: (e) => /* @__PURE__ */ jsxRuntime.jsx(api.Mono, { variant: "pi", fontWeight: "semiBold", children: e.action })
734
+ render: (e) => /* @__PURE__ */ jsxRuntime.jsx(format.Mono, { variant: "pi", fontWeight: "semiBold", children: e.action })
753
735
  },
754
736
  {
755
737
  key: "actor",
@@ -5,8 +5,8 @@ import { Page, useNotification, useRBAC } from "@strapi/strapi/admin";
5
5
  import { useNavigate, useParams, Routes, Route, NavLink } from "react-router-dom";
6
6
  import { useIntl } from "react-intl";
7
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";
8
+ import { P as PLUGIN_ID, a as PERMISSIONS } from "./index-oF7vL92A.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, f as fmtNumber, c as useGetGroupsQuery, M as Mono, d as StatusBadge, e as fmtDateTime, g as useGetGroupQuery, h as useArchiveGroupMutation, i as fmtSigned, j as errorMessage, k as useGetPeopleQuery, l as useGetPersonQuery, m as useRevealPhoneMutation, n as useSetPersonActiveMutation, o as useGetSettlementsQuery, p as useGetEventsQuery } from "./format-CNjIwTKo.mjs";
10
10
  import { useState } from "react";
11
11
  const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
12
12
  const Head = styled.header`
@@ -96,24 +96,6 @@ const Cell = ({ main, sub, strong, tone }) => /* @__PURE__ */ jsxs(Fragment, { c
96
96
  /* @__PURE__ */ jsx(Typography, { fontWeight: strong ? "semiBold" : void 0, textColor: tone, children: main ?? "—" }),
97
97
  sub ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: sub }) : null
98
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
99
  const ACCENT = "#FF7900";
118
100
  const GREEN = "#328048";
119
101
  const BLUE = "#4945FF";