@sonatel-os/strapi-plugin-split 0.5.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 +3 -1
- package/dist/_chunks/{App-CLfoPnvq.js → App-CYAjChoJ.js} +52 -70
- package/dist/_chunks/{App-8QwzQSyg.mjs → App-CyHrReR9.mjs} +2 -20
- package/dist/_chunks/SettingsPage-BqEpGpCs.js +165 -0
- package/dist/_chunks/SettingsPage-By2SGFAk.mjs +165 -0
- package/dist/_chunks/{api-BCYZ56eI.mjs → format-CNjIwTKo.mjs} +55 -13
- package/dist/_chunks/{api-cwZGoKZx.js → format-Dr6t_23v.js} +46 -4
- package/dist/_chunks/{index-oyRhs5fN.js → index-Uv5-E0cg.js} +4 -3
- package/dist/_chunks/{index-PFbwTznf.mjs → index-oF7vL92A.mjs} +4 -3
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +75 -19
- package/dist/server/index.mjs +75 -19
- package/package.json +1 -1
- package/dist/_chunks/SettingsPage-B746YfAA.js +0 -101
- package/dist/_chunks/SettingsPage-CH92IYGk.mjs +0 -101
package/dist/server/index.mjs
CHANGED
|
@@ -24,7 +24,8 @@ const RBAC = Object.freeze({
|
|
|
24
24
|
PEOPLE_WRITE: "people.write",
|
|
25
25
|
SETTLEMENTS_READ: "settlements.read",
|
|
26
26
|
AUDIT_READ: "audit.read",
|
|
27
|
-
SETTINGS_READ: "settings.read"
|
|
27
|
+
SETTINGS_READ: "settings.read",
|
|
28
|
+
SETTINGS_WRITE: "settings.write"
|
|
28
29
|
});
|
|
29
30
|
const SPLIT_MODE = Object.freeze({ EQUAL: "equal", WEIGHTED: "weighted", FREE: "free" });
|
|
30
31
|
const ROLE = Object.freeze({ OWNER: "owner", MEMBER: "member" });
|
|
@@ -83,11 +84,17 @@ const ORDER_LIST_SIZE = 20;
|
|
|
83
84
|
const ORDER_NOTE_MAX = 80;
|
|
84
85
|
const ORDER_RECENT_MS = 24 * 60 * 60 * 1e3;
|
|
85
86
|
const DEFAULT_LIMITS = Object.freeze({
|
|
86
|
-
maxGroupsPerPerson:
|
|
87
|
-
maxMembersPerGroup:
|
|
87
|
+
maxGroupsPerPerson: 150,
|
|
88
|
+
maxMembersPerGroup: 150,
|
|
88
89
|
/** Largest single expense or settlement, in the currency's smallest unit. */
|
|
89
|
-
maxAmount:
|
|
90
|
+
maxAmount: 15e7
|
|
90
91
|
});
|
|
92
|
+
const LIMIT_CEILINGS = Object.freeze({
|
|
93
|
+
maxGroupsPerPerson: 1e3,
|
|
94
|
+
maxMembersPerGroup: 500,
|
|
95
|
+
maxAmount: 2e9
|
|
96
|
+
});
|
|
97
|
+
const LIMITS_STORE_KEY = "limits";
|
|
91
98
|
const DEFAULT_INVITE_PREFIX = "SPL";
|
|
92
99
|
const DEFAULT_COUNTRY_CODE = "";
|
|
93
100
|
const CODE_CHARSET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
|
@@ -144,6 +151,12 @@ const ACTIONS = [
|
|
|
144
151
|
category: PLUGIN_DISPLAY_NAME,
|
|
145
152
|
uid: RBAC.SETTINGS_READ,
|
|
146
153
|
displayName: "Read settings"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
section: "settings",
|
|
157
|
+
category: PLUGIN_DISPLAY_NAME,
|
|
158
|
+
uid: RBAC.SETTINGS_WRITE,
|
|
159
|
+
displayName: "Change the limits"
|
|
147
160
|
}
|
|
148
161
|
].map((a) => ({ ...a, pluginName: PLUGIN_ID }));
|
|
149
162
|
const UNIQUE_COLUMNS = [
|
|
@@ -1405,8 +1418,16 @@ const admin$1 = ({ strapi }) => {
|
|
|
1405
1418
|
countryCode: settings2.countryCode(),
|
|
1406
1419
|
people: settings2.people(),
|
|
1407
1420
|
methods: settings2.methods(),
|
|
1408
|
-
limits: settings2.limits()
|
|
1421
|
+
limits: await settings2.limits(),
|
|
1422
|
+
limitCeilings: LIMIT_CEILINGS
|
|
1409
1423
|
});
|
|
1424
|
+
}),
|
|
1425
|
+
setLimits: handle(strapi, async (ctx) => {
|
|
1426
|
+
const limits = await svc("settings").setLimits(body(ctx));
|
|
1427
|
+
strapi.log.info(
|
|
1428
|
+
`${LOG_PREFIX} limits set to ${JSON.stringify(limits)} by admin ${ctx.state.user?.id}`
|
|
1429
|
+
);
|
|
1430
|
+
ok(ctx, limits);
|
|
1410
1431
|
})
|
|
1411
1432
|
};
|
|
1412
1433
|
};
|
|
@@ -1523,14 +1544,23 @@ const admin = [
|
|
|
1523
1544
|
route("PUT", "/people/:id/active", "setPersonActive", RBAC.PEOPLE_WRITE),
|
|
1524
1545
|
route("GET", "/settlements", "settlements", RBAC.SETTLEMENTS_READ),
|
|
1525
1546
|
route("GET", "/events", "events", RBAC.AUDIT_READ),
|
|
1526
|
-
route("GET", "/settings", "settings", RBAC.SETTINGS_READ)
|
|
1547
|
+
route("GET", "/settings", "settings", RBAC.SETTINGS_READ),
|
|
1548
|
+
route("PUT", "/settings/limits", "setLimits", RBAC.SETTINGS_WRITE)
|
|
1527
1549
|
];
|
|
1528
1550
|
const routes = {
|
|
1529
1551
|
"content-api": { type: "content-api", routes: contentApi },
|
|
1530
1552
|
admin: { type: "admin", routes: admin }
|
|
1531
1553
|
};
|
|
1532
1554
|
const DEFAULT_PEOPLE = Object.freeze({ idHeader: "x-person-id", nameHeader: "x-person-name" });
|
|
1555
|
+
const LIMIT_KEYS = Object.keys(DEFAULT_LIMITS);
|
|
1556
|
+
const withinCeiling = (key, value) => Number.isInteger(value) && value > 0 && value <= LIMIT_CEILINGS[key];
|
|
1557
|
+
const usable = (limits) => Object.fromEntries(
|
|
1558
|
+
LIMIT_KEYS.filter((key) => withinCeiling(key, limits?.[key])).map((key) => [key, limits[key]])
|
|
1559
|
+
);
|
|
1533
1560
|
const settings = ({ strapi }) => ({
|
|
1561
|
+
store() {
|
|
1562
|
+
return strapi.store({ type: "plugin", name: PLUGIN_ID });
|
|
1563
|
+
},
|
|
1534
1564
|
/** @returns {Object} the full plugin config */
|
|
1535
1565
|
all() {
|
|
1536
1566
|
return strapi.config.get(`plugin::${PLUGIN_ID}`) ?? {};
|
|
@@ -1557,8 +1587,34 @@ const settings = ({ strapi }) => ({
|
|
|
1557
1587
|
Object.entries(methods).map(([name, m]) => [name, { instant: Boolean(m?.instant) }])
|
|
1558
1588
|
);
|
|
1559
1589
|
},
|
|
1560
|
-
limits
|
|
1590
|
+
/** The limits from the configuration file, before anything set in the back office. */
|
|
1591
|
+
configuredLimits() {
|
|
1561
1592
|
return { ...DEFAULT_LIMITS, ...this.all().limits ?? {} };
|
|
1593
|
+
},
|
|
1594
|
+
/**
|
|
1595
|
+
* The limits in force: what an administrator set, else the configuration file, else the defaults.
|
|
1596
|
+
* @returns {Promise<{ maxGroupsPerPerson: number, maxMembersPerGroup: number, maxAmount: number }>}
|
|
1597
|
+
*/
|
|
1598
|
+
async limits() {
|
|
1599
|
+
const saved = await this.store().get({ key: LIMITS_STORE_KEY });
|
|
1600
|
+
return { ...this.configuredLimits(), ...usable(saved) };
|
|
1601
|
+
},
|
|
1602
|
+
/**
|
|
1603
|
+
* Sets the limits from the back office. Every limit is given, each a whole number from 1 to its
|
|
1604
|
+
* ceiling. Lowering one never touches what already exists: it only refuses what comes next.
|
|
1605
|
+
* @param {Object} input
|
|
1606
|
+
* @returns {Promise<Object>} the limits now in force
|
|
1607
|
+
*/
|
|
1608
|
+
async setLimits(input) {
|
|
1609
|
+
const refused = LIMIT_KEYS.filter((key) => !withinCeiling(key, input?.[key]));
|
|
1610
|
+
if (refused.length > 0)
|
|
1611
|
+
throw badRequest(
|
|
1612
|
+
ERROR_CODES.VALIDATION,
|
|
1613
|
+
"Chaque limite est un entier entre 1 et son plafond.",
|
|
1614
|
+
{ fields: refused, ceilings: LIMIT_CEILINGS }
|
|
1615
|
+
);
|
|
1616
|
+
await this.store().set({ key: LIMITS_STORE_KEY, value: usable(input) });
|
|
1617
|
+
return this.limits();
|
|
1562
1618
|
}
|
|
1563
1619
|
});
|
|
1564
1620
|
const audit = ({ strapi }) => ({
|
|
@@ -2006,7 +2062,7 @@ const group = ({ strapi }) => {
|
|
|
2006
2062
|
async create(person2, input) {
|
|
2007
2063
|
const name = cleanName(input.name);
|
|
2008
2064
|
if (!name) throw badRequest(ERROR_CODES.VALIDATION, "Donne un nom au groupe.");
|
|
2009
|
-
const limits = svc("settings").limits();
|
|
2065
|
+
const limits = await svc("settings").limits();
|
|
2010
2066
|
const held = await members().count({ where: { person: person2.id, ...HELD } });
|
|
2011
2067
|
if (held >= limits.maxGroupsPerPerson)
|
|
2012
2068
|
throw unprocessable(
|
|
@@ -2083,7 +2139,7 @@ const group = ({ strapi }) => {
|
|
|
2083
2139
|
});
|
|
2084
2140
|
if (existing && !existing.joinedAt) await svc("member").take({ ...existing, group: group2 }, person2);
|
|
2085
2141
|
if (existing) return group2;
|
|
2086
|
-
const limits = svc("settings").limits();
|
|
2142
|
+
const limits = await svc("settings").limits();
|
|
2087
2143
|
const count = await members().count({ where: { group: group2.id, leftAt: { $null: true } } });
|
|
2088
2144
|
if (count >= limits.maxMembersPerGroup)
|
|
2089
2145
|
throw unprocessable(ERROR_CODES.MEMBER_LIMIT, "Ce groupe est complet.");
|
|
@@ -2191,7 +2247,7 @@ const member = ({ strapi }) => {
|
|
|
2191
2247
|
*/
|
|
2192
2248
|
async add({ group: group2, me }, raw) {
|
|
2193
2249
|
const input = this.parse(raw);
|
|
2194
|
-
const limits = svc("settings").limits();
|
|
2250
|
+
const limits = await svc("settings").limits();
|
|
2195
2251
|
const seats = await members().findMany({
|
|
2196
2252
|
where: { group: group2.id, leftAt: { $null: true } },
|
|
2197
2253
|
populate: { person: true }
|
|
@@ -2406,10 +2462,10 @@ const expense = ({ strapi }) => {
|
|
|
2406
2462
|
* @returns {{ label: string, category: string|null, amount: number, mode: string, spentAt: Date,
|
|
2407
2463
|
* paidBy: number, shares: Array<{ member: number, amount: number, weight: number }> }}
|
|
2408
2464
|
*/
|
|
2409
|
-
parse(input, active) {
|
|
2465
|
+
async parse(input, active) {
|
|
2410
2466
|
const label2 = String(input?.label ?? "").trim().slice(0, LABEL_MAX);
|
|
2411
2467
|
if (!label2) throw badRequest(ERROR_CODES.VALIDATION, "Dis ce que tu as payé.");
|
|
2412
|
-
const { maxAmount } = svc("settings").limits();
|
|
2468
|
+
const { maxAmount } = await svc("settings").limits();
|
|
2413
2469
|
const amount = input?.amount;
|
|
2414
2470
|
if (!Number.isInteger(amount) || amount <= 0 || amount > maxAmount)
|
|
2415
2471
|
throw badRequest(ERROR_CODES.VALIDATION, "Montant invalide.", { maxAmount });
|
|
@@ -2465,7 +2521,7 @@ const expense = ({ strapi }) => {
|
|
|
2465
2521
|
const earlier = await this.replayed(group2, clientRef);
|
|
2466
2522
|
if (earlier) return { expense: earlier, replayed: true };
|
|
2467
2523
|
const { active } = await svc("ledger").of(group2);
|
|
2468
|
-
const { shares: list, ...data } = this.parse(input, active);
|
|
2524
|
+
const { shares: list, ...data } = await this.parse(input, active);
|
|
2469
2525
|
try {
|
|
2470
2526
|
const created = await strapi.db.transaction(async () => {
|
|
2471
2527
|
await svc("group").lock(group2);
|
|
@@ -2508,7 +2564,7 @@ const expense = ({ strapi }) => {
|
|
|
2508
2564
|
const { group: group2, me } = seat;
|
|
2509
2565
|
const expense2 = await this.editable(seat, documentId);
|
|
2510
2566
|
const { active } = await svc("ledger").of(group2);
|
|
2511
|
-
const { shares: list, ...data } = this.parse(input, active);
|
|
2567
|
+
const { shares: list, ...data } = await this.parse(input, active);
|
|
2512
2568
|
await strapi.db.transaction(async () => {
|
|
2513
2569
|
await svc("group").lock(group2);
|
|
2514
2570
|
await expenses().update({ where: { id: expense2.id }, data });
|
|
@@ -2571,7 +2627,7 @@ const settlement = ({ strapi }) => {
|
|
|
2571
2627
|
* (`to`) when the caller pays, the one who paid (`from`) when the caller received.
|
|
2572
2628
|
*/
|
|
2573
2629
|
async parse({ group: group2, me }, input) {
|
|
2574
|
-
const { maxAmount } = svc("settings").limits();
|
|
2630
|
+
const { maxAmount } = await svc("settings").limits();
|
|
2575
2631
|
const amount = input?.amount;
|
|
2576
2632
|
if (!Number.isInteger(amount) || amount <= 0 || amount > maxAmount)
|
|
2577
2633
|
throw badRequest(ERROR_CODES.VALIDATION, "Montant invalide.", { maxAmount });
|
|
@@ -2808,10 +2864,10 @@ const order = ({ strapi }) => {
|
|
|
2808
2864
|
return date;
|
|
2809
2865
|
},
|
|
2810
2866
|
/** What the organiser sent, checked. */
|
|
2811
|
-
parse(input) {
|
|
2867
|
+
async parse(input) {
|
|
2812
2868
|
const title = label(input?.title);
|
|
2813
2869
|
if (!title) throw invalid("Donne un nom à la commande.");
|
|
2814
|
-
const { maxAmount } = svc("settings").limits();
|
|
2870
|
+
const { maxAmount } = await svc("settings").limits();
|
|
2815
2871
|
const list = Array.isArray(input?.items) ? input.items : [];
|
|
2816
2872
|
if (list.length === 0 || list.length > ORDER_MAX_ITEMS)
|
|
2817
2873
|
throw invalid(`Entre 1 et ${ORDER_MAX_ITEMS} articles.`, { max: ORDER_MAX_ITEMS });
|
|
@@ -2826,7 +2882,7 @@ const order = ({ strapi }) => {
|
|
|
2826
2882
|
* @param {{ title: string, closesAt?: string, items: Array<{ label: string, price: number }> }} input
|
|
2827
2883
|
*/
|
|
2828
2884
|
async create({ group: group2, me }, input) {
|
|
2829
|
-
const data = this.parse(input);
|
|
2885
|
+
const data = await this.parse(input);
|
|
2830
2886
|
const order2 = await strapi.db.transaction(async () => {
|
|
2831
2887
|
const created = await orders().create({
|
|
2832
2888
|
data: {
|
|
@@ -2955,7 +3011,7 @@ const order = ({ strapi }) => {
|
|
|
2955
3011
|
this.assertOrganizer(order2, me);
|
|
2956
3012
|
if (order2.status === ORDER_STATUS.CLOSED) return order2;
|
|
2957
3013
|
this.assertOpen(order2);
|
|
2958
|
-
const { maxAmount } = svc("settings").limits();
|
|
3014
|
+
const { maxAmount } = await svc("settings").limits();
|
|
2959
3015
|
const deliveryFee = input?.deliveryFee ?? 0;
|
|
2960
3016
|
if (!Number.isInteger(deliveryFee) || deliveryFee < 0 || deliveryFee > maxAmount)
|
|
2961
3017
|
throw invalid("Frais de livraison invalides.", { maxAmount });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonatel-os/strapi-plugin-split",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "A shared-expenses ledger for Strapi v5: groups, members, expenses split three ways, balances, settlements with idempotent writes — with admin screens and RBAC.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "LPIX-11 <mohamed.johnson@orange-sonatel.com>",
|
|
@@ -1,101 +0,0 @@
|
|
|
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 api = require("./api-cwZGoKZx.js");
|
|
7
|
-
const index = require("./index-oyRhs5fN.js");
|
|
8
|
-
const Row = ({ k, v, hint }) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9
|
-
designSystem.Flex,
|
|
10
|
-
{
|
|
11
|
-
justifyContent: "space-between",
|
|
12
|
-
alignItems: "flex-start",
|
|
13
|
-
gap: 4,
|
|
14
|
-
paddingTop: 3,
|
|
15
|
-
paddingBottom: 3,
|
|
16
|
-
style: { borderBottom: "1px solid #eaeaef" },
|
|
17
|
-
children: [
|
|
18
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { flex: 1, minWidth: 0 }, children: [
|
|
19
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", tag: "p", children: k }),
|
|
20
|
-
hint ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: hint }) : null
|
|
21
|
-
] }),
|
|
22
|
-
/* @__PURE__ */ jsxRuntime.jsx(api.Mono, { variant: "pi", fontWeight: "semiBold", children: String(v ?? "—") || "—" })
|
|
23
|
-
]
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
const SettingsPage = () => {
|
|
27
|
-
const { data, isLoading, isError } = api.useGetSettingsQuery();
|
|
28
|
-
if (isLoading) return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Loading, {});
|
|
29
|
-
if (isError) return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Error, {});
|
|
30
|
-
const s = data ?? {};
|
|
31
|
-
const methods = Object.entries(s.methods ?? {});
|
|
32
|
-
return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Protect, { permissions: index.PERMISSIONS.settingsRead, children: /* @__PURE__ */ jsxRuntime.jsxs(admin.Page.Main, { children: [
|
|
33
|
-
/* @__PURE__ */ jsxRuntime.jsx(admin.Page.Title, { children: "Split · Configuration" }),
|
|
34
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
35
|
-
admin.Layouts.Header,
|
|
36
|
-
{
|
|
37
|
-
title: "Split configuration",
|
|
38
|
-
subtitle: "Read from config/plugins.js and the server environment. Nothing here is edited in the admin."
|
|
39
|
-
}
|
|
40
|
-
),
|
|
41
|
-
/* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
42
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
43
|
-
api.Section,
|
|
44
|
-
{
|
|
45
|
-
title: "Who is calling",
|
|
46
|
-
help: "The app routes under /api/split are protected by Strapi API tokens. The caller names the person with a header.",
|
|
47
|
-
children: [
|
|
48
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
49
|
-
Row,
|
|
50
|
-
{
|
|
51
|
-
k: "Person id header",
|
|
52
|
-
v: s.people?.idHeader,
|
|
53
|
-
hint: "Any stable id the host owns; a phone number is stored under one spelling."
|
|
54
|
-
}
|
|
55
|
-
),
|
|
56
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
57
|
-
Row,
|
|
58
|
-
{
|
|
59
|
-
k: "Display name header",
|
|
60
|
-
v: s.people?.nameHeader,
|
|
61
|
-
hint: "Optional; refreshes the person's name."
|
|
62
|
-
}
|
|
63
|
-
),
|
|
64
|
-
/* @__PURE__ */ jsxRuntime.jsx(Row, { k: "Create unknown people", v: s.people?.autoProvision ? "yes" : "no" }),
|
|
65
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
66
|
-
Row,
|
|
67
|
-
{
|
|
68
|
-
k: "Home country code",
|
|
69
|
-
v: s.countryCode,
|
|
70
|
-
hint: "Dropped from stored phone numbers."
|
|
71
|
-
}
|
|
72
|
-
)
|
|
73
|
-
]
|
|
74
|
-
}
|
|
75
|
-
),
|
|
76
|
-
/* @__PURE__ */ jsxRuntime.jsxs(api.Section, { title: "Groups and amounts", index: 1, children: [
|
|
77
|
-
/* @__PURE__ */ jsxRuntime.jsx(Row, { k: "Invite code prefix", v: s.inviteCodePrefix }),
|
|
78
|
-
/* @__PURE__ */ jsxRuntime.jsx(Row, { k: "Groups per person", v: s.limits?.maxGroupsPerPerson }),
|
|
79
|
-
/* @__PURE__ */ jsxRuntime.jsx(Row, { k: "Members per group", v: s.limits?.maxMembersPerGroup }),
|
|
80
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
81
|
-
Row,
|
|
82
|
-
{
|
|
83
|
-
k: "Largest amount",
|
|
84
|
-
v: s.limits?.maxAmount,
|
|
85
|
-
hint: "One expense or one settlement, in the currency's smallest unit."
|
|
86
|
-
}
|
|
87
|
-
)
|
|
88
|
-
] }),
|
|
89
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
90
|
-
api.Section,
|
|
91
|
-
{
|
|
92
|
-
title: "Settlement methods",
|
|
93
|
-
help: "An instant method is one the host pays itself: it is confirmed at once. The others wait for the receiver.",
|
|
94
|
-
index: 2,
|
|
95
|
-
children: methods.map(([name, m]) => /* @__PURE__ */ jsxRuntime.jsx(Row, { k: name, v: m.instant ? "instant" : "receiver confirms" }, name))
|
|
96
|
-
}
|
|
97
|
-
)
|
|
98
|
-
] }) })
|
|
99
|
-
] }) });
|
|
100
|
-
};
|
|
101
|
-
exports.SettingsPage = SettingsPage;
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Flex, Box, Typography } from "@strapi/design-system";
|
|
3
|
-
import { Page, Layouts } from "@strapi/strapi/admin";
|
|
4
|
-
import { m as useGetSettingsQuery, b as Section, M as Mono } from "./api-BCYZ56eI.mjs";
|
|
5
|
-
import { a as PERMISSIONS } from "./index-PFbwTznf.mjs";
|
|
6
|
-
const Row = ({ k, v, hint }) => /* @__PURE__ */ jsxs(
|
|
7
|
-
Flex,
|
|
8
|
-
{
|
|
9
|
-
justifyContent: "space-between",
|
|
10
|
-
alignItems: "flex-start",
|
|
11
|
-
gap: 4,
|
|
12
|
-
paddingTop: 3,
|
|
13
|
-
paddingBottom: 3,
|
|
14
|
-
style: { borderBottom: "1px solid #eaeaef" },
|
|
15
|
-
children: [
|
|
16
|
-
/* @__PURE__ */ jsxs(Box, { style: { flex: 1, minWidth: 0 }, children: [
|
|
17
|
-
/* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", tag: "p", children: k }),
|
|
18
|
-
hint ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: hint }) : null
|
|
19
|
-
] }),
|
|
20
|
-
/* @__PURE__ */ jsx(Mono, { variant: "pi", fontWeight: "semiBold", children: String(v ?? "—") || "—" })
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
);
|
|
24
|
-
const SettingsPage = () => {
|
|
25
|
-
const { data, isLoading, isError } = useGetSettingsQuery();
|
|
26
|
-
if (isLoading) return /* @__PURE__ */ jsx(Page.Loading, {});
|
|
27
|
-
if (isError) return /* @__PURE__ */ jsx(Page.Error, {});
|
|
28
|
-
const s = data ?? {};
|
|
29
|
-
const methods = Object.entries(s.methods ?? {});
|
|
30
|
-
return /* @__PURE__ */ jsx(Page.Protect, { permissions: PERMISSIONS.settingsRead, children: /* @__PURE__ */ jsxs(Page.Main, { children: [
|
|
31
|
-
/* @__PURE__ */ jsx(Page.Title, { children: "Split · Configuration" }),
|
|
32
|
-
/* @__PURE__ */ jsx(
|
|
33
|
-
Layouts.Header,
|
|
34
|
-
{
|
|
35
|
-
title: "Split configuration",
|
|
36
|
-
subtitle: "Read from config/plugins.js and the server environment. Nothing here is edited in the admin."
|
|
37
|
-
}
|
|
38
|
-
),
|
|
39
|
-
/* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
40
|
-
/* @__PURE__ */ jsxs(
|
|
41
|
-
Section,
|
|
42
|
-
{
|
|
43
|
-
title: "Who is calling",
|
|
44
|
-
help: "The app routes under /api/split are protected by Strapi API tokens. The caller names the person with a header.",
|
|
45
|
-
children: [
|
|
46
|
-
/* @__PURE__ */ jsx(
|
|
47
|
-
Row,
|
|
48
|
-
{
|
|
49
|
-
k: "Person id header",
|
|
50
|
-
v: s.people?.idHeader,
|
|
51
|
-
hint: "Any stable id the host owns; a phone number is stored under one spelling."
|
|
52
|
-
}
|
|
53
|
-
),
|
|
54
|
-
/* @__PURE__ */ jsx(
|
|
55
|
-
Row,
|
|
56
|
-
{
|
|
57
|
-
k: "Display name header",
|
|
58
|
-
v: s.people?.nameHeader,
|
|
59
|
-
hint: "Optional; refreshes the person's name."
|
|
60
|
-
}
|
|
61
|
-
),
|
|
62
|
-
/* @__PURE__ */ jsx(Row, { k: "Create unknown people", v: s.people?.autoProvision ? "yes" : "no" }),
|
|
63
|
-
/* @__PURE__ */ jsx(
|
|
64
|
-
Row,
|
|
65
|
-
{
|
|
66
|
-
k: "Home country code",
|
|
67
|
-
v: s.countryCode,
|
|
68
|
-
hint: "Dropped from stored phone numbers."
|
|
69
|
-
}
|
|
70
|
-
)
|
|
71
|
-
]
|
|
72
|
-
}
|
|
73
|
-
),
|
|
74
|
-
/* @__PURE__ */ jsxs(Section, { title: "Groups and amounts", index: 1, children: [
|
|
75
|
-
/* @__PURE__ */ jsx(Row, { k: "Invite code prefix", v: s.inviteCodePrefix }),
|
|
76
|
-
/* @__PURE__ */ jsx(Row, { k: "Groups per person", v: s.limits?.maxGroupsPerPerson }),
|
|
77
|
-
/* @__PURE__ */ jsx(Row, { k: "Members per group", v: s.limits?.maxMembersPerGroup }),
|
|
78
|
-
/* @__PURE__ */ jsx(
|
|
79
|
-
Row,
|
|
80
|
-
{
|
|
81
|
-
k: "Largest amount",
|
|
82
|
-
v: s.limits?.maxAmount,
|
|
83
|
-
hint: "One expense or one settlement, in the currency's smallest unit."
|
|
84
|
-
}
|
|
85
|
-
)
|
|
86
|
-
] }),
|
|
87
|
-
/* @__PURE__ */ jsx(
|
|
88
|
-
Section,
|
|
89
|
-
{
|
|
90
|
-
title: "Settlement methods",
|
|
91
|
-
help: "An instant method is one the host pays itself: it is confirmed at once. The others wait for the receiver.",
|
|
92
|
-
index: 2,
|
|
93
|
-
children: methods.map(([name, m]) => /* @__PURE__ */ jsx(Row, { k: name, v: m.instant ? "instant" : "receiver confirms" }, name))
|
|
94
|
-
}
|
|
95
|
-
)
|
|
96
|
-
] }) })
|
|
97
|
-
] }) });
|
|
98
|
-
};
|
|
99
|
-
export {
|
|
100
|
-
SettingsPage
|
|
101
|
-
};
|