@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.
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const designSystem = require("@strapi/design-system");
5
+ const admin = require("@strapi/strapi/admin");
6
+ const format = require("./format-Dr6t_23v.js");
7
+ const react = require("react");
8
+ const icons = require("@strapi/icons");
9
+ const index = require("./index-Uv5-E0cg.js");
10
+ const FIELDS = [
11
+ {
12
+ key: "maxGroupsPerPerson",
13
+ label: "Groups per person",
14
+ hint: "Groups a person sits in, archived ones included."
15
+ },
16
+ { key: "maxMembersPerGroup", label: "Members per group", hint: "Seats of one group." },
17
+ {
18
+ key: "maxAmount",
19
+ label: "Largest amount",
20
+ hint: "One expense or one settlement, in the currency's smallest unit."
21
+ }
22
+ ];
23
+ const errorOf = (value, ceiling) => Number.isInteger(value) && value > 0 && value <= ceiling ? void 0 : `A whole number from 1 to ${ceiling.toLocaleString()}.`;
24
+ const LimitsForm = ({ limits = {}, ceilings = {}, canEdit }) => {
25
+ const { toggleNotification } = admin.useNotification();
26
+ const [save, { isLoading }] = format.useSetLimitsMutation();
27
+ const [draft, setDraft] = react.useState(limits);
28
+ const errors = Object.fromEntries(
29
+ FIELDS.map((f) => [f.key, errorOf(draft[f.key], ceilings[f.key])])
30
+ );
31
+ const changed = FIELDS.some((f) => draft[f.key] !== limits[f.key]);
32
+ const valid = FIELDS.every((f) => !errors[f.key]);
33
+ const onSave = async () => {
34
+ try {
35
+ setDraft(await save(draft).unwrap());
36
+ toggleNotification({ type: "success", message: "Limits saved. They apply from now on." });
37
+ } catch (err) {
38
+ toggleNotification({ type: "danger", message: format.errorMessage(err) });
39
+ }
40
+ };
41
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 5, children: [
42
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 5, children: FIELDS.map((f) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 4, s: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: f.key, hint: f.hint, error: canEdit ? errors[f.key] : void 0, children: [
43
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: f.label }),
44
+ /* @__PURE__ */ jsxRuntime.jsx(
45
+ designSystem.NumberInput,
46
+ {
47
+ value: draft[f.key],
48
+ disabled: !canEdit,
49
+ onValueChange: (value) => setDraft({ ...draft, [f.key]: value })
50
+ }
51
+ ),
52
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {}),
53
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
54
+ ] }) }, f.key)) }),
55
+ canEdit ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(
56
+ designSystem.Button,
57
+ {
58
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}),
59
+ loading: isLoading,
60
+ disabled: !changed || !valid,
61
+ onClick: onSave,
62
+ children: "Save the limits"
63
+ }
64
+ ) }) : null
65
+ ] });
66
+ };
67
+ const Row = ({ k, v, hint }) => /* @__PURE__ */ jsxRuntime.jsxs(
68
+ designSystem.Flex,
69
+ {
70
+ justifyContent: "space-between",
71
+ alignItems: "flex-start",
72
+ gap: 4,
73
+ paddingTop: 3,
74
+ paddingBottom: 3,
75
+ style: { borderBottom: "1px solid #eaeaef" },
76
+ children: [
77
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { flex: 1, minWidth: 0 }, children: [
78
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", tag: "p", children: k }),
79
+ hint ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: hint }) : null
80
+ ] }),
81
+ /* @__PURE__ */ jsxRuntime.jsx(format.Mono, { variant: "pi", fontWeight: "semiBold", children: String(v ?? "—") || "—" })
82
+ ]
83
+ }
84
+ );
85
+ const SettingsPage = () => {
86
+ const { data, isLoading, isError } = format.useGetSettingsQuery();
87
+ const { allowedActions, isLoading: checking } = admin.useRBAC({ write: index.PERMISSIONS.settingsWrite });
88
+ if (isLoading || checking) return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Loading, {});
89
+ if (isError) return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Error, {});
90
+ const s = data ?? {};
91
+ const methods = Object.entries(s.methods ?? {});
92
+ return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Protect, { permissions: index.PERMISSIONS.settingsRead, children: /* @__PURE__ */ jsxRuntime.jsxs(admin.Page.Main, { children: [
93
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Title, { children: "Split · Configuration" }),
94
+ /* @__PURE__ */ jsxRuntime.jsx(
95
+ admin.Layouts.Header,
96
+ {
97
+ title: "Split configuration",
98
+ subtitle: "Read from config/plugins.js and the server environment. Only the limits are changed here."
99
+ }
100
+ ),
101
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
102
+ /* @__PURE__ */ jsxRuntime.jsxs(
103
+ format.Section,
104
+ {
105
+ title: "Who is calling",
106
+ help: "The app routes under /api/split are protected by Strapi API tokens. The caller names the person with a header.",
107
+ children: [
108
+ /* @__PURE__ */ jsxRuntime.jsx(
109
+ Row,
110
+ {
111
+ k: "Person id header",
112
+ v: s.people?.idHeader,
113
+ hint: "Any stable id the host owns; a phone number is stored under one spelling."
114
+ }
115
+ ),
116
+ /* @__PURE__ */ jsxRuntime.jsx(
117
+ Row,
118
+ {
119
+ k: "Display name header",
120
+ v: s.people?.nameHeader,
121
+ hint: "Optional; refreshes the person's name."
122
+ }
123
+ ),
124
+ /* @__PURE__ */ jsxRuntime.jsx(Row, { k: "Create unknown people", v: s.people?.autoProvision ? "yes" : "no" }),
125
+ /* @__PURE__ */ jsxRuntime.jsx(
126
+ Row,
127
+ {
128
+ k: "Home country code",
129
+ v: s.countryCode,
130
+ hint: "Dropped from stored phone numbers."
131
+ }
132
+ )
133
+ ]
134
+ }
135
+ ),
136
+ /* @__PURE__ */ jsxRuntime.jsx(
137
+ format.Section,
138
+ {
139
+ title: "Limits",
140
+ help: "What is refused past these numbers. A change applies to what comes next: nothing that already exists is touched.",
141
+ index: 1,
142
+ children: /* @__PURE__ */ jsxRuntime.jsx(
143
+ LimitsForm,
144
+ {
145
+ limits: s.limits,
146
+ ceilings: s.limitCeilings,
147
+ canEdit: allowedActions.canWrite
148
+ }
149
+ )
150
+ }
151
+ ),
152
+ /* @__PURE__ */ jsxRuntime.jsx(format.Section, { title: "Groups", index: 2, children: /* @__PURE__ */ jsxRuntime.jsx(Row, { k: "Invite code prefix", v: s.inviteCodePrefix }) }),
153
+ /* @__PURE__ */ jsxRuntime.jsx(
154
+ format.Section,
155
+ {
156
+ title: "Settlement methods",
157
+ help: "An instant method is one the host pays itself: it is confirmed at once. The others wait for the receiver.",
158
+ index: 3,
159
+ children: methods.map(([name, m]) => /* @__PURE__ */ jsxRuntime.jsx(Row, { k: name, v: m.instant ? "instant" : "receiver confirms" }, name))
160
+ }
161
+ )
162
+ ] }) })
163
+ ] }) });
164
+ };
165
+ exports.SettingsPage = SettingsPage;
@@ -0,0 +1,165 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { Flex, Grid, Field, NumberInput, Button, Box, Typography } from "@strapi/design-system";
3
+ import { useNotification, useRBAC, Page, Layouts } from "@strapi/strapi/admin";
4
+ import { q as useSetLimitsMutation, j as errorMessage, r as useGetSettingsQuery, b as Section, M as Mono } from "./format-CNjIwTKo.mjs";
5
+ import { useState } from "react";
6
+ import { Check } from "@strapi/icons";
7
+ import { a as PERMISSIONS } from "./index-oF7vL92A.mjs";
8
+ const FIELDS = [
9
+ {
10
+ key: "maxGroupsPerPerson",
11
+ label: "Groups per person",
12
+ hint: "Groups a person sits in, archived ones included."
13
+ },
14
+ { key: "maxMembersPerGroup", label: "Members per group", hint: "Seats of one group." },
15
+ {
16
+ key: "maxAmount",
17
+ label: "Largest amount",
18
+ hint: "One expense or one settlement, in the currency's smallest unit."
19
+ }
20
+ ];
21
+ const errorOf = (value, ceiling) => Number.isInteger(value) && value > 0 && value <= ceiling ? void 0 : `A whole number from 1 to ${ceiling.toLocaleString()}.`;
22
+ const LimitsForm = ({ limits = {}, ceilings = {}, canEdit }) => {
23
+ const { toggleNotification } = useNotification();
24
+ const [save, { isLoading }] = useSetLimitsMutation();
25
+ const [draft, setDraft] = useState(limits);
26
+ const errors = Object.fromEntries(
27
+ FIELDS.map((f) => [f.key, errorOf(draft[f.key], ceilings[f.key])])
28
+ );
29
+ const changed = FIELDS.some((f) => draft[f.key] !== limits[f.key]);
30
+ const valid = FIELDS.every((f) => !errors[f.key]);
31
+ const onSave = async () => {
32
+ try {
33
+ setDraft(await save(draft).unwrap());
34
+ toggleNotification({ type: "success", message: "Limits saved. They apply from now on." });
35
+ } catch (err) {
36
+ toggleNotification({ type: "danger", message: errorMessage(err) });
37
+ }
38
+ };
39
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 5, children: [
40
+ /* @__PURE__ */ jsx(Grid.Root, { gap: 5, children: FIELDS.map((f) => /* @__PURE__ */ jsx(Grid.Item, { col: 4, s: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxs(Field.Root, { name: f.key, hint: f.hint, error: canEdit ? errors[f.key] : void 0, children: [
41
+ /* @__PURE__ */ jsx(Field.Label, { children: f.label }),
42
+ /* @__PURE__ */ jsx(
43
+ NumberInput,
44
+ {
45
+ value: draft[f.key],
46
+ disabled: !canEdit,
47
+ onValueChange: (value) => setDraft({ ...draft, [f.key]: value })
48
+ }
49
+ ),
50
+ /* @__PURE__ */ jsx(Field.Hint, {}),
51
+ /* @__PURE__ */ jsx(Field.Error, {})
52
+ ] }) }, f.key)) }),
53
+ canEdit ? /* @__PURE__ */ jsx(Flex, { justifyContent: "flex-end", children: /* @__PURE__ */ jsx(
54
+ Button,
55
+ {
56
+ startIcon: /* @__PURE__ */ jsx(Check, {}),
57
+ loading: isLoading,
58
+ disabled: !changed || !valid,
59
+ onClick: onSave,
60
+ children: "Save the limits"
61
+ }
62
+ ) }) : null
63
+ ] });
64
+ };
65
+ const Row = ({ k, v, hint }) => /* @__PURE__ */ jsxs(
66
+ Flex,
67
+ {
68
+ justifyContent: "space-between",
69
+ alignItems: "flex-start",
70
+ gap: 4,
71
+ paddingTop: 3,
72
+ paddingBottom: 3,
73
+ style: { borderBottom: "1px solid #eaeaef" },
74
+ children: [
75
+ /* @__PURE__ */ jsxs(Box, { style: { flex: 1, minWidth: 0 }, children: [
76
+ /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", tag: "p", children: k }),
77
+ hint ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: hint }) : null
78
+ ] }),
79
+ /* @__PURE__ */ jsx(Mono, { variant: "pi", fontWeight: "semiBold", children: String(v ?? "—") || "—" })
80
+ ]
81
+ }
82
+ );
83
+ const SettingsPage = () => {
84
+ const { data, isLoading, isError } = useGetSettingsQuery();
85
+ const { allowedActions, isLoading: checking } = useRBAC({ write: PERMISSIONS.settingsWrite });
86
+ if (isLoading || checking) return /* @__PURE__ */ jsx(Page.Loading, {});
87
+ if (isError) return /* @__PURE__ */ jsx(Page.Error, {});
88
+ const s = data ?? {};
89
+ const methods = Object.entries(s.methods ?? {});
90
+ return /* @__PURE__ */ jsx(Page.Protect, { permissions: PERMISSIONS.settingsRead, children: /* @__PURE__ */ jsxs(Page.Main, { children: [
91
+ /* @__PURE__ */ jsx(Page.Title, { children: "Split · Configuration" }),
92
+ /* @__PURE__ */ jsx(
93
+ Layouts.Header,
94
+ {
95
+ title: "Split configuration",
96
+ subtitle: "Read from config/plugins.js and the server environment. Only the limits are changed here."
97
+ }
98
+ ),
99
+ /* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
100
+ /* @__PURE__ */ jsxs(
101
+ Section,
102
+ {
103
+ title: "Who is calling",
104
+ help: "The app routes under /api/split are protected by Strapi API tokens. The caller names the person with a header.",
105
+ children: [
106
+ /* @__PURE__ */ jsx(
107
+ Row,
108
+ {
109
+ k: "Person id header",
110
+ v: s.people?.idHeader,
111
+ hint: "Any stable id the host owns; a phone number is stored under one spelling."
112
+ }
113
+ ),
114
+ /* @__PURE__ */ jsx(
115
+ Row,
116
+ {
117
+ k: "Display name header",
118
+ v: s.people?.nameHeader,
119
+ hint: "Optional; refreshes the person's name."
120
+ }
121
+ ),
122
+ /* @__PURE__ */ jsx(Row, { k: "Create unknown people", v: s.people?.autoProvision ? "yes" : "no" }),
123
+ /* @__PURE__ */ jsx(
124
+ Row,
125
+ {
126
+ k: "Home country code",
127
+ v: s.countryCode,
128
+ hint: "Dropped from stored phone numbers."
129
+ }
130
+ )
131
+ ]
132
+ }
133
+ ),
134
+ /* @__PURE__ */ jsx(
135
+ Section,
136
+ {
137
+ title: "Limits",
138
+ help: "What is refused past these numbers. A change applies to what comes next: nothing that already exists is touched.",
139
+ index: 1,
140
+ children: /* @__PURE__ */ jsx(
141
+ LimitsForm,
142
+ {
143
+ limits: s.limits,
144
+ ceilings: s.limitCeilings,
145
+ canEdit: allowedActions.canWrite
146
+ }
147
+ )
148
+ }
149
+ ),
150
+ /* @__PURE__ */ jsx(Section, { title: "Groups", index: 2, children: /* @__PURE__ */ jsx(Row, { k: "Invite code prefix", v: s.inviteCodePrefix }) }),
151
+ /* @__PURE__ */ jsx(
152
+ Section,
153
+ {
154
+ title: "Settlement methods",
155
+ help: "An instant method is one the host pays itself: it is confirmed at once. The others wait for the receiver.",
156
+ index: 3,
157
+ children: methods.map(([name, m]) => /* @__PURE__ */ jsx(Row, { k: name, v: m.instant ? "instant" : "receiver confirms" }, name))
158
+ }
159
+ )
160
+ ] }) })
161
+ ] }) });
162
+ };
163
+ export {
164
+ SettingsPage
165
+ };
@@ -6,7 +6,7 @@ import "@strapi/icons/symbols";
6
6
  import { useNavigate } from "react-router-dom";
7
7
  import { styled, css, keyframes } from "styled-components";
8
8
  import { adminApi } from "@strapi/strapi/admin";
9
- import { P as PLUGIN_ID } from "./index-PFbwTznf.mjs";
9
+ import { P as PLUGIN_ID } from "./index-oF7vL92A.mjs";
10
10
  const SPRING = "cubic-bezier(0.32, 0.72, 0, 1)";
11
11
  const rise = keyframes`
12
12
  from { opacity: 0; transform: translateY(14px); filter: blur(6px); }
@@ -379,7 +379,12 @@ styled.span`
379
379
  flex-shrink: 0;
380
380
  `;
381
381
  const BASE = `/${PLUGIN_ID}`;
382
- const TAG = Object.freeze({ DASH: "SplitDashboard", GROUP: "SplitGroup", PERSON: "SplitPerson" });
382
+ const TAG = Object.freeze({
383
+ DASH: "SplitDashboard",
384
+ GROUP: "SplitGroup",
385
+ PERSON: "SplitPerson",
386
+ SETTINGS: "SplitSettings"
387
+ });
383
388
  const unwrap = (res) => res && typeof res === "object" && "data" in res ? res.data : res;
384
389
  const qs = (params = {}) => {
385
390
  const clean = Object.fromEntries(
@@ -426,7 +431,20 @@ const api = adminApi.enhanceEndpoints({ addTagTypes: Object.values(TAG) }).injec
426
431
  }),
427
432
  getSettlements: b.query({ query: (p) => `${BASE}/settlements${qs(p)}` }),
428
433
  getEvents: b.query({ query: (p) => `${BASE}/events${qs(p)}` }),
429
- getSettings: b.query({ query: () => `${BASE}/settings`, transformResponse: unwrap })
434
+ getSettings: b.query({
435
+ query: () => `${BASE}/settings`,
436
+ transformResponse: unwrap,
437
+ providesTags: [TAG.SETTINGS]
438
+ }),
439
+ setLimits: b.mutation({
440
+ query: (limits) => ({
441
+ url: `${BASE}/settings/limits`,
442
+ method: "PUT",
443
+ data: { data: limits }
444
+ }),
445
+ transformResponse: unwrap,
446
+ invalidatesTags: [TAG.SETTINGS]
447
+ })
430
448
  }),
431
449
  overrideExisting: true
432
450
  });
@@ -441,8 +459,27 @@ const {
441
459
  useSetPersonActiveMutation,
442
460
  useGetSettlementsQuery,
443
461
  useGetEventsQuery,
444
- useGetSettingsQuery
462
+ useGetSettingsQuery,
463
+ useSetLimitsMutation
445
464
  } = api;
465
+ const fmtDateTime = (value, locale) => {
466
+ if (!value) return "—";
467
+ try {
468
+ return new Intl.DateTimeFormat(locale ?? void 0, {
469
+ dateStyle: "medium",
470
+ timeStyle: "short"
471
+ }).format(new Date(value));
472
+ } catch {
473
+ return String(value);
474
+ }
475
+ };
476
+ const fmtNumber = (value, locale) => new Intl.NumberFormat(locale ?? void 0).format(Number(value ?? 0));
477
+ const fmtSigned = (value, locale) => {
478
+ const n = Number(value ?? 0);
479
+ const digits = fmtNumber(Math.abs(n), locale);
480
+ return n > 0 ? `+${digits}` : n < 0 ? `−${digits}` : digits;
481
+ };
482
+ const errorMessage = (err) => err?.data?.error?.message ?? err?.response?.data?.error?.message ?? err?.error?.message ?? err?.message ?? "Une erreur est survenue.";
446
483
  export {
447
484
  Bar as B,
448
485
  Eyebrow as E,
@@ -453,14 +490,19 @@ export {
453
490
  Section as b,
454
491
  useGetGroupsQuery as c,
455
492
  StatusBadge as d,
456
- useGetGroupQuery as e,
457
- useArchiveGroupMutation as f,
458
- useGetPeopleQuery as g,
459
- useGetPersonQuery as h,
460
- useRevealPhoneMutation as i,
461
- useSetPersonActiveMutation as j,
462
- useGetSettlementsQuery as k,
463
- useGetEventsQuery as l,
464
- useGetSettingsQuery as m,
493
+ fmtDateTime as e,
494
+ fmtNumber as f,
495
+ useGetGroupQuery as g,
496
+ useArchiveGroupMutation as h,
497
+ fmtSigned as i,
498
+ errorMessage as j,
499
+ useGetPeopleQuery as k,
500
+ useGetPersonQuery as l,
501
+ useRevealPhoneMutation as m,
502
+ useSetPersonActiveMutation as n,
503
+ useGetSettlementsQuery as o,
504
+ useGetEventsQuery as p,
505
+ useSetLimitsMutation as q,
506
+ useGetSettingsQuery as r,
465
507
  useGetDashboardQuery as u
466
508
  };
@@ -7,7 +7,7 @@ require("@strapi/icons/symbols");
7
7
  const reactRouterDom = require("react-router-dom");
8
8
  const styledComponents = require("styled-components");
9
9
  const admin = require("@strapi/strapi/admin");
10
- const index = require("./index-oyRhs5fN.js");
10
+ const index = require("./index-Uv5-E0cg.js");
11
11
  const SPRING = "cubic-bezier(0.32, 0.72, 0, 1)";
12
12
  const rise = styledComponents.keyframes`
13
13
  from { opacity: 0; transform: translateY(14px); filter: blur(6px); }
@@ -380,7 +380,12 @@ styledComponents.styled.span`
380
380
  flex-shrink: 0;
381
381
  `;
382
382
  const BASE = `/${index.PLUGIN_ID}`;
383
- const TAG = Object.freeze({ DASH: "SplitDashboard", GROUP: "SplitGroup", PERSON: "SplitPerson" });
383
+ const TAG = Object.freeze({
384
+ DASH: "SplitDashboard",
385
+ GROUP: "SplitGroup",
386
+ PERSON: "SplitPerson",
387
+ SETTINGS: "SplitSettings"
388
+ });
384
389
  const unwrap = (res) => res && typeof res === "object" && "data" in res ? res.data : res;
385
390
  const qs = (params = {}) => {
386
391
  const clean = Object.fromEntries(
@@ -427,7 +432,20 @@ const api = admin.adminApi.enhanceEndpoints({ addTagTypes: Object.values(TAG) })
427
432
  }),
428
433
  getSettlements: b.query({ query: (p) => `${BASE}/settlements${qs(p)}` }),
429
434
  getEvents: b.query({ query: (p) => `${BASE}/events${qs(p)}` }),
430
- getSettings: b.query({ query: () => `${BASE}/settings`, transformResponse: unwrap })
435
+ getSettings: b.query({
436
+ query: () => `${BASE}/settings`,
437
+ transformResponse: unwrap,
438
+ providesTags: [TAG.SETTINGS]
439
+ }),
440
+ setLimits: b.mutation({
441
+ query: (limits) => ({
442
+ url: `${BASE}/settings/limits`,
443
+ method: "PUT",
444
+ data: { data: limits }
445
+ }),
446
+ transformResponse: unwrap,
447
+ invalidatesTags: [TAG.SETTINGS]
448
+ })
431
449
  }),
432
450
  overrideExisting: true
433
451
  });
@@ -442,8 +460,27 @@ const {
442
460
  useSetPersonActiveMutation,
443
461
  useGetSettlementsQuery,
444
462
  useGetEventsQuery,
445
- useGetSettingsQuery
463
+ useGetSettingsQuery,
464
+ useSetLimitsMutation
446
465
  } = api;
466
+ const fmtDateTime = (value, locale) => {
467
+ if (!value) return "—";
468
+ try {
469
+ return new Intl.DateTimeFormat(locale ?? void 0, {
470
+ dateStyle: "medium",
471
+ timeStyle: "short"
472
+ }).format(new Date(value));
473
+ } catch {
474
+ return String(value);
475
+ }
476
+ };
477
+ const fmtNumber = (value, locale) => new Intl.NumberFormat(locale ?? void 0).format(Number(value ?? 0));
478
+ const fmtSigned = (value, locale) => {
479
+ const n = Number(value ?? 0);
480
+ const digits = fmtNumber(Math.abs(n), locale);
481
+ return n > 0 ? `+${digits}` : n < 0 ? `−${digits}` : digits;
482
+ };
483
+ const errorMessage = (err) => err?.data?.error?.message ?? err?.response?.data?.error?.message ?? err?.error?.message ?? err?.message ?? "Une erreur est survenue.";
447
484
  exports.Bar = Bar;
448
485
  exports.Eyebrow = Eyebrow;
449
486
  exports.Intro = Intro;
@@ -452,6 +489,10 @@ exports.SPRING = SPRING;
452
489
  exports.Section = Section;
453
490
  exports.StatTile = StatTile;
454
491
  exports.StatusBadge = StatusBadge;
492
+ exports.errorMessage = errorMessage;
493
+ exports.fmtDateTime = fmtDateTime;
494
+ exports.fmtNumber = fmtNumber;
495
+ exports.fmtSigned = fmtSigned;
455
496
  exports.useArchiveGroupMutation = useArchiveGroupMutation;
456
497
  exports.useGetDashboardQuery = useGetDashboardQuery;
457
498
  exports.useGetEventsQuery = useGetEventsQuery;
@@ -462,4 +503,5 @@ exports.useGetPersonQuery = useGetPersonQuery;
462
503
  exports.useGetSettingsQuery = useGetSettingsQuery;
463
504
  exports.useGetSettlementsQuery = useGetSettlementsQuery;
464
505
  exports.useRevealPhoneMutation = useRevealPhoneMutation;
506
+ exports.useSetLimitsMutation = useSetLimitsMutation;
465
507
  exports.useSetPersonActiveMutation = useSetPersonActiveMutation;
@@ -39,7 +39,8 @@ const PERMISSIONS = Object.freeze({
39
39
  peopleWrite: one("people.write"),
40
40
  settlementsRead: one("settlements.read"),
41
41
  auditRead: one("audit.read"),
42
- settingsRead: one("settings.read")
42
+ settingsRead: one("settings.read"),
43
+ settingsWrite: one("settings.write")
43
44
  });
44
45
  const prefixPluginTranslations = (dictionary, pluginId) => Object.keys(dictionary).reduce((acc, key) => {
45
46
  acc[`${pluginId}.${key}`] = dictionary[key];
@@ -53,7 +54,7 @@ const index = {
53
54
  intlLabel: { id: `${PLUGIN_ID}.menu.label`, defaultMessage: "Split" },
54
55
  permissions: PERMISSIONS.access,
55
56
  Component: async () => {
56
- const { App } = await Promise.resolve().then(() => require("./App-CLfoPnvq.js"));
57
+ const { App } = await Promise.resolve().then(() => require("./App-CYAjChoJ.js"));
57
58
  return App;
58
59
  }
59
60
  });
@@ -66,7 +67,7 @@ const index = {
66
67
  intlLabel: { id: `${PLUGIN_ID}.settings.link`, defaultMessage: "Configuration" },
67
68
  permissions: PERMISSIONS.settingsRead,
68
69
  Component: async () => {
69
- const { SettingsPage } = await Promise.resolve().then(() => require("./SettingsPage-B746YfAA.js"));
70
+ const { SettingsPage } = await Promise.resolve().then(() => require("./SettingsPage-BqEpGpCs.js"));
70
71
  return SettingsPage;
71
72
  }
72
73
  }
@@ -38,7 +38,8 @@ const PERMISSIONS = Object.freeze({
38
38
  peopleWrite: one("people.write"),
39
39
  settlementsRead: one("settlements.read"),
40
40
  auditRead: one("audit.read"),
41
- settingsRead: one("settings.read")
41
+ settingsRead: one("settings.read"),
42
+ settingsWrite: one("settings.write")
42
43
  });
43
44
  const prefixPluginTranslations = (dictionary, pluginId) => Object.keys(dictionary).reduce((acc, key) => {
44
45
  acc[`${pluginId}.${key}`] = dictionary[key];
@@ -52,7 +53,7 @@ const index = {
52
53
  intlLabel: { id: `${PLUGIN_ID}.menu.label`, defaultMessage: "Split" },
53
54
  permissions: PERMISSIONS.access,
54
55
  Component: async () => {
55
- const { App } = await import("./App-8QwzQSyg.mjs");
56
+ const { App } = await import("./App-CyHrReR9.mjs");
56
57
  return App;
57
58
  }
58
59
  });
@@ -65,7 +66,7 @@ const index = {
65
66
  intlLabel: { id: `${PLUGIN_ID}.settings.link`, defaultMessage: "Configuration" },
66
67
  permissions: PERMISSIONS.settingsRead,
67
68
  Component: async () => {
68
- const { SettingsPage } = await import("./SettingsPage-CH92IYGk.mjs");
69
+ const { SettingsPage } = await import("./SettingsPage-By2SGFAk.mjs");
69
70
  return SettingsPage;
70
71
  }
71
72
  }
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
- const index = require("../_chunks/index-oyRhs5fN.js");
2
+ const index = require("../_chunks/index-Uv5-E0cg.js");
3
3
  module.exports = index.index;
@@ -1,4 +1,4 @@
1
- import { i } from "../_chunks/index-PFbwTznf.mjs";
1
+ import { i } from "../_chunks/index-oF7vL92A.mjs";
2
2
  export {
3
3
  i as default
4
4
  };