@burdenoff/microfe-mybodyshield 2026.821.2 → 2026.830.1
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/dist/mybodyshield/MyBodyShieldRoot.d.ts.map +1 -1
- package/dist/mybodyshield/MyBodyShieldRoot.js +54 -56
- package/dist/mybodyshield/MyBodyShieldRoot.js.map +1 -1
- package/dist/mybodyshield/MyBodyShieldRoutes.d.ts.map +1 -1
- package/dist/mybodyshield/MyBodyShieldRoutes.js +121 -62
- package/dist/mybodyshield/MyBodyShieldRoutes.js.map +1 -1
- package/dist/mybodyshield/components/EvidenceUpload.d.ts.map +1 -1
- package/dist/mybodyshield/components/EvidenceUpload.js +46 -45
- package/dist/mybodyshield/components/EvidenceUpload.js.map +1 -1
- package/dist/mybodyshield/components/FileLink.d.ts.map +1 -1
- package/dist/mybodyshield/components/FileLink.js +27 -18
- package/dist/mybodyshield/components/FileLink.js.map +1 -1
- package/dist/mybodyshield/components/MybDiscussion.d.ts +1 -1
- package/dist/mybodyshield/components/MybDiscussion.d.ts.map +1 -1
- package/dist/mybodyshield/components/MybDiscussion.js +59 -58
- package/dist/mybodyshield/components/MybDiscussion.js.map +1 -1
- package/dist/mybodyshield/components/MybTags.d.ts +1 -1
- package/dist/mybodyshield/components/MybTags.d.ts.map +1 -1
- package/dist/mybodyshield/components/MybTags.js +83 -74
- package/dist/mybodyshield/components/MybTags.js.map +1 -1
- package/dist/mybodyshield/components/PageDisabled.d.ts.map +1 -1
- package/dist/mybodyshield/components/PageDisabled.js +16 -11
- package/dist/mybodyshield/components/PageDisabled.js.map +1 -1
- package/dist/mybodyshield/components/Pagination.d.ts.map +1 -1
- package/dist/mybodyshield/components/Pagination.js +36 -27
- package/dist/mybodyshield/components/Pagination.js.map +1 -1
- package/dist/mybodyshield/components/StateViews.d.ts.map +1 -1
- package/dist/mybodyshield/components/StateViews.js +42 -34
- package/dist/mybodyshield/components/StateViews.js.map +1 -1
- package/dist/mybodyshield/components/UserSearchSelect.d.ts.map +1 -1
- package/dist/mybodyshield/components/UserSearchSelect.js +66 -68
- package/dist/mybodyshield/components/UserSearchSelect.js.map +1 -1
- package/dist/mybodyshield/hooks/index.d.ts +1 -0
- package/dist/mybodyshield/hooks/index.d.ts.map +1 -1
- package/dist/mybodyshield/hooks/index.js +1 -0
- package/dist/mybodyshield/hooks/useTr.d.ts +5 -0
- package/dist/mybodyshield/hooks/useTr.d.ts.map +1 -0
- package/dist/mybodyshield/hooks/useTr.js +12 -0
- package/dist/mybodyshield/hooks/useTr.js.map +1 -0
- package/dist/mybodyshield/pages/DashboardPage.d.ts.map +1 -1
- package/dist/mybodyshield/pages/DashboardPage.js +157 -136
- package/dist/mybodyshield/pages/DashboardPage.js.map +1 -1
- package/dist/mybodyshield/pages/SettingsPage.d.ts.map +1 -1
- package/dist/mybodyshield/pages/SettingsPage.js +50 -59
- package/dist/mybodyshield/pages/SettingsPage.js.map +1 -1
- package/dist/mybodyshield/pages/_shared/visuals.d.ts +2 -1
- package/dist/mybodyshield/pages/_shared/visuals.d.ts.map +1 -1
- package/dist/mybodyshield/pages/_shared/visuals.js +91 -81
- package/dist/mybodyshield/pages/_shared/visuals.js.map +1 -1
- package/dist/mybodyshield/pages/ai/AiControlsPage.d.ts.map +1 -1
- package/dist/mybodyshield/pages/ai/AiControlsPage.js +279 -231
- package/dist/mybodyshield/pages/ai/AiControlsPage.js.map +1 -1
- package/dist/mybodyshield/pages/coaching/CoachingPage.d.ts.map +1 -1
- package/dist/mybodyshield/pages/coaching/CoachingPage.js +349 -258
- package/dist/mybodyshield/pages/coaching/CoachingPage.js.map +1 -1
- package/dist/mybodyshield/pages/goals/GoalsPage.d.ts.map +1 -1
- package/dist/mybodyshield/pages/goals/GoalsPage.js +247 -251
- package/dist/mybodyshield/pages/goals/GoalsPage.js.map +1 -1
- package/dist/mybodyshield/pages/insights/InsightsCharts.d.ts.map +1 -1
- package/dist/mybodyshield/pages/insights/InsightsCharts.js +216 -213
- package/dist/mybodyshield/pages/insights/InsightsCharts.js.map +1 -1
- package/dist/mybodyshield/pages/insights/InsightsPage.d.ts.map +1 -1
- package/dist/mybodyshield/pages/insights/InsightsPage.js +327 -220
- package/dist/mybodyshield/pages/insights/InsightsPage.js.map +1 -1
- package/dist/mybodyshield/pages/nutrition/NutritionPage.d.ts.map +1 -1
- package/dist/mybodyshield/pages/nutrition/NutritionPage.js +575 -529
- package/dist/mybodyshield/pages/nutrition/NutritionPage.js.map +1 -1
- package/dist/mybodyshield/pages/programs/ProgramDetailPage.d.ts.map +1 -1
- package/dist/mybodyshield/pages/programs/ProgramDetailPage.js +333 -275
- package/dist/mybodyshield/pages/programs/ProgramDetailPage.js.map +1 -1
- package/dist/mybodyshield/pages/programs/ProgramsPage.d.ts.map +1 -1
- package/dist/mybodyshield/pages/programs/ProgramsPage.js +258 -253
- package/dist/mybodyshield/pages/programs/ProgramsPage.js.map +1 -1
- package/dist/mybodyshield/pages/progress/ProgressPage.d.ts.map +1 -1
- package/dist/mybodyshield/pages/progress/ProgressPage.js +271 -254
- package/dist/mybodyshield/pages/progress/ProgressPage.js.map +1 -1
- package/dist/mybodyshield/pages/recovery/RecoveryPage.d.ts.map +1 -1
- package/dist/mybodyshield/pages/recovery/RecoveryPage.js +206 -200
- package/dist/mybodyshield/pages/recovery/RecoveryPage.js.map +1 -1
- package/dist/mybodyshield/pages/train/SessionDetailPage.d.ts.map +1 -1
- package/dist/mybodyshield/pages/train/SessionDetailPage.js +327 -294
- package/dist/mybodyshield/pages/train/SessionDetailPage.js.map +1 -1
- package/dist/mybodyshield/pages/train/SessionsPage.d.ts.map +1 -1
- package/dist/mybodyshield/pages/train/SessionsPage.js +180 -163
- package/dist/mybodyshield/pages/train/SessionsPage.js.map +1 -1
- package/dist/mybodyshield/utils/i18n.d.ts +1 -2
- package/dist/mybodyshield/utils/i18n.d.ts.map +1 -1
- package/dist/mybodyshield/utils/i18n.js +15 -0
- package/dist/mybodyshield/utils/i18n.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,93 +1,94 @@
|
|
|
1
1
|
import { useMybFileUpload as e } from "../hooks/useMybFiles.js";
|
|
2
|
+
import { useTr as t } from "../hooks/useTr.js";
|
|
2
3
|
import "../hooks/index.js";
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { Paperclip as
|
|
5
|
-
import { jsx as
|
|
6
|
-
import { Button as
|
|
4
|
+
import { useRef as n } from "react";
|
|
5
|
+
import { Paperclip as r, Upload as i, X as a } from "lucide-react";
|
|
6
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
|
+
import { Button as c, Label as l, Spinner as u } from "@burdenoff/fe-libs/ui";
|
|
7
8
|
//#region src/mybodyshield/components/EvidenceUpload.tsx
|
|
8
|
-
function
|
|
9
|
-
let
|
|
10
|
-
return /* @__PURE__ */
|
|
9
|
+
function d({ id: d, label: f, value: p, onChange: m, accept: h = "image/*,application/pdf,audio/*", disabled: g = !1, hint: _ }) {
|
|
10
|
+
let v = t(), y = n(null), { upload: b, isUploading: x, progress: S, error: C, reset: w } = e();
|
|
11
|
+
return /* @__PURE__ */ s("div", {
|
|
11
12
|
className: "grid gap-1.5",
|
|
12
13
|
children: [
|
|
13
|
-
/* @__PURE__ */
|
|
14
|
-
htmlFor:
|
|
15
|
-
children:
|
|
14
|
+
/* @__PURE__ */ o(l, {
|
|
15
|
+
htmlFor: d,
|
|
16
|
+
children: f
|
|
16
17
|
}),
|
|
17
|
-
/* @__PURE__ */
|
|
18
|
-
ref:
|
|
19
|
-
id:
|
|
18
|
+
/* @__PURE__ */ o("input", {
|
|
19
|
+
ref: y,
|
|
20
|
+
id: d,
|
|
20
21
|
type: "file",
|
|
21
|
-
accept:
|
|
22
|
+
accept: h,
|
|
22
23
|
className: "hidden",
|
|
23
|
-
disabled:
|
|
24
|
+
disabled: g || x,
|
|
24
25
|
onChange: async (e) => {
|
|
25
26
|
let t = e.target.files?.[0];
|
|
26
27
|
if (e.target.value = "", t) try {
|
|
27
|
-
|
|
28
|
+
m(await b(t));
|
|
28
29
|
} catch {}
|
|
29
30
|
}
|
|
30
31
|
}),
|
|
31
|
-
|
|
32
|
+
p ? /* @__PURE__ */ s("div", {
|
|
32
33
|
className: "flex items-center gap-2 rounded-lg border border-border-seam bg-bg-sunken/60 px-3 py-2",
|
|
33
34
|
children: [
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
/* @__PURE__ */
|
|
35
|
+
/* @__PURE__ */ o(r, { className: "h-4 w-4 shrink-0 text-text-tertiary" }),
|
|
36
|
+
/* @__PURE__ */ o("span", {
|
|
36
37
|
className: "min-w-0 flex-1 truncate text-sm text-text-primary",
|
|
37
|
-
title:
|
|
38
|
-
children:
|
|
38
|
+
title: p.fileName,
|
|
39
|
+
children: p.fileName
|
|
39
40
|
}),
|
|
40
|
-
/* @__PURE__ */
|
|
41
|
+
/* @__PURE__ */ o("button", {
|
|
41
42
|
type: "button",
|
|
42
43
|
onClick: () => {
|
|
43
|
-
|
|
44
|
+
w(), m(null);
|
|
44
45
|
},
|
|
45
|
-
disabled:
|
|
46
|
-
"aria-label": "Remove attachment",
|
|
46
|
+
disabled: g,
|
|
47
|
+
"aria-label": v("mybodyshield.components.evidenceUpload.removeAttachment", "Remove attachment"),
|
|
47
48
|
className: "rounded-md p-1 text-text-tertiary hover:bg-bg-sunken hover:text-text-primary",
|
|
48
|
-
children: /* @__PURE__ */ a
|
|
49
|
+
children: /* @__PURE__ */ o(a, { className: "h-4 w-4" })
|
|
49
50
|
})
|
|
50
51
|
]
|
|
51
|
-
}) :
|
|
52
|
+
}) : x ? /* @__PURE__ */ s("div", {
|
|
52
53
|
className: "flex items-center gap-3 rounded-lg border border-border-seam bg-bg-sunken/60 px-3 py-2",
|
|
53
54
|
children: [
|
|
54
|
-
/* @__PURE__ */
|
|
55
|
+
/* @__PURE__ */ o(u, { size: "sm" }),
|
|
55
56
|
/* @__PURE__ */ o("span", {
|
|
56
57
|
className: "text-sm text-text-secondary",
|
|
57
|
-
children:
|
|
58
|
-
"Uploading… ",
|
|
59
|
-
b,
|
|
60
|
-
"%"
|
|
61
|
-
]
|
|
58
|
+
children: v("mybodyshield.components.evidenceUpload.uploading", "Uploading… {{progress}}%", { progress: S })
|
|
62
59
|
}),
|
|
63
|
-
/* @__PURE__ */
|
|
60
|
+
/* @__PURE__ */ o("div", {
|
|
64
61
|
className: "ml-auto h-1.5 w-24 overflow-hidden rounded-full bg-bg-sunken",
|
|
65
|
-
children: /* @__PURE__ */
|
|
62
|
+
children: /* @__PURE__ */ o("div", {
|
|
66
63
|
className: "h-full rounded-full bg-action-primary-bg transition-[width] duration-150",
|
|
67
|
-
style: { width: `${
|
|
64
|
+
style: { width: `${S}%` }
|
|
68
65
|
})
|
|
69
66
|
})
|
|
70
67
|
]
|
|
71
|
-
}) : /* @__PURE__ */
|
|
68
|
+
}) : /* @__PURE__ */ s(c, {
|
|
72
69
|
type: "button",
|
|
73
70
|
variant: "outline",
|
|
74
|
-
disabled:
|
|
75
|
-
onClick: () =>
|
|
71
|
+
disabled: g,
|
|
72
|
+
onClick: () => y.current?.click(),
|
|
76
73
|
className: "justify-start",
|
|
77
|
-
children: [
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ o(i, { className: "mr-1.5 h-4 w-4" }),
|
|
76
|
+
" ",
|
|
77
|
+
v("mybodyshield.components.evidenceUpload.chooseFile", "Choose file")
|
|
78
|
+
]
|
|
78
79
|
}),
|
|
79
|
-
|
|
80
|
+
_ && !C && /* @__PURE__ */ o("p", {
|
|
80
81
|
className: "text-xs text-text-tertiary",
|
|
81
|
-
children:
|
|
82
|
+
children: _
|
|
82
83
|
}),
|
|
83
|
-
|
|
84
|
+
C && /* @__PURE__ */ o("p", {
|
|
84
85
|
className: "text-xs text-status-error-text",
|
|
85
|
-
children:
|
|
86
|
+
children: C
|
|
86
87
|
})
|
|
87
88
|
]
|
|
88
89
|
});
|
|
89
90
|
}
|
|
90
91
|
//#endregion
|
|
91
|
-
export {
|
|
92
|
+
export { d as EvidenceUpload };
|
|
92
93
|
|
|
93
94
|
//# sourceMappingURL=EvidenceUpload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EvidenceUpload.js","names":[],"sources":["../../../src/mybodyshield/components/EvidenceUpload.tsx"],"sourcesContent":["/**\n * EvidenceUpload — a controlled file-attach control (Integration A).\n * @module mybodyshield/components/EvidenceUpload\n *\n * Wraps `useMybFileUpload` (the wspace-files 3-step flow). On file select it\n * uploads, shows byte-progress + the filename, and emits `{ fileId, fileName }`\n * via `onChange`. The parent stores `fileId` and passes it to the eco mutation\n * (`MybRecordMetricInput.photoFileId`, `MybCreateExerciseInput.demoFileId`).\n */\n\nimport { useRef, type ChangeEvent } from 'react';\nimport { Paperclip, Upload, X } from 'lucide-react';\nimport { Button, Label, Spinner } from '@burdenoff/fe-libs/ui';\nimport { useMybFileUpload, type UploadedMybFile } from '../hooks';\n\ninterface EvidenceUploadProps {\n id: string;\n label: string;\n value: UploadedMybFile | null;\n onChange: (value: UploadedMybFile | null) => void;\n accept?: string;\n disabled?: boolean;\n hint?: string;\n}\n\nexport function EvidenceUpload({\n id,\n label,\n value,\n onChange,\n accept = 'image/*,application/pdf,audio/*',\n disabled = false,\n hint,\n}: EvidenceUploadProps) {\n const inputRef = useRef<HTMLInputElement>(null);\n const { upload, isUploading, progress, error, reset } = useMybFileUpload();\n\n const handleSelect = async (event: ChangeEvent<HTMLInputElement>) => {\n const file = event.target.files?.[0];\n // Clear the native input so the same file can be re-selected after a remove.\n event.target.value = '';\n if (!file) return;\n try {\n const uploaded = await upload(file);\n onChange(uploaded);\n } catch {\n // Error surfaced inline via `error`; keep the form usable.\n }\n };\n\n const handleRemove = () => {\n reset();\n onChange(null);\n };\n\n return (\n <div className=\"grid gap-1.5\">\n <Label htmlFor={id}>{label}</Label>\n\n <input\n ref={inputRef}\n id={id}\n type=\"file\"\n accept={accept}\n className=\"hidden\"\n disabled={disabled || isUploading}\n onChange={handleSelect}\n />\n\n {value ? (\n <div className=\"flex items-center gap-2 rounded-lg border border-border-seam bg-bg-sunken/60 px-3 py-2\">\n <Paperclip className=\"h-4 w-4 shrink-0 text-text-tertiary\" />\n <span\n className=\"min-w-0 flex-1 truncate text-sm text-text-primary\"\n title={value.fileName}\n >\n {value.fileName}\n </span>\n <button\n type=\"button\"\n onClick={handleRemove}\n disabled={disabled}\n aria-label
|
|
1
|
+
{"version":3,"file":"EvidenceUpload.js","names":[],"sources":["../../../src/mybodyshield/components/EvidenceUpload.tsx"],"sourcesContent":["/**\n * EvidenceUpload — a controlled file-attach control (Integration A).\n * @module mybodyshield/components/EvidenceUpload\n *\n * Wraps `useMybFileUpload` (the wspace-files 3-step flow). On file select it\n * uploads, shows byte-progress + the filename, and emits `{ fileId, fileName }`\n * via `onChange`. The parent stores `fileId` and passes it to the eco mutation\n * (`MybRecordMetricInput.photoFileId`, `MybCreateExerciseInput.demoFileId`).\n */\n\nimport { useRef, type ChangeEvent } from 'react';\nimport { Paperclip, Upload, X } from 'lucide-react';\nimport { Button, Label, Spinner } from '@burdenoff/fe-libs/ui';\nimport { useMybFileUpload, useTr, type UploadedMybFile } from '../hooks';\n\ninterface EvidenceUploadProps {\n id: string;\n label: string;\n value: UploadedMybFile | null;\n onChange: (value: UploadedMybFile | null) => void;\n accept?: string;\n disabled?: boolean;\n hint?: string;\n}\n\nexport function EvidenceUpload({\n id,\n label,\n value,\n onChange,\n accept = 'image/*,application/pdf,audio/*',\n disabled = false,\n hint,\n}: EvidenceUploadProps) {\n const t = useTr();\n const inputRef = useRef<HTMLInputElement>(null);\n const { upload, isUploading, progress, error, reset } = useMybFileUpload();\n\n const handleSelect = async (event: ChangeEvent<HTMLInputElement>) => {\n const file = event.target.files?.[0];\n // Clear the native input so the same file can be re-selected after a remove.\n event.target.value = '';\n if (!file) return;\n try {\n const uploaded = await upload(file);\n onChange(uploaded);\n } catch {\n // Error surfaced inline via `error`; keep the form usable.\n }\n };\n\n const handleRemove = () => {\n reset();\n onChange(null);\n };\n\n return (\n <div className=\"grid gap-1.5\">\n <Label htmlFor={id}>{label}</Label>\n\n <input\n ref={inputRef}\n id={id}\n type=\"file\"\n accept={accept}\n className=\"hidden\"\n disabled={disabled || isUploading}\n onChange={handleSelect}\n />\n\n {value ? (\n <div className=\"flex items-center gap-2 rounded-lg border border-border-seam bg-bg-sunken/60 px-3 py-2\">\n <Paperclip className=\"h-4 w-4 shrink-0 text-text-tertiary\" />\n <span\n className=\"min-w-0 flex-1 truncate text-sm text-text-primary\"\n title={value.fileName}\n >\n {value.fileName}\n </span>\n <button\n type=\"button\"\n onClick={handleRemove}\n disabled={disabled}\n aria-label={t(\n 'mybodyshield.components.evidenceUpload.removeAttachment',\n 'Remove attachment'\n )}\n className=\"rounded-md p-1 text-text-tertiary hover:bg-bg-sunken hover:text-text-primary\"\n >\n <X className=\"h-4 w-4\" />\n </button>\n </div>\n ) : isUploading ? (\n <div className=\"flex items-center gap-3 rounded-lg border border-border-seam bg-bg-sunken/60 px-3 py-2\">\n <Spinner size=\"sm\" />\n <span className=\"text-sm text-text-secondary\">\n {t('mybodyshield.components.evidenceUpload.uploading', 'Uploading… {{progress}}%', {\n progress,\n })}\n </span>\n <div className=\"ml-auto h-1.5 w-24 overflow-hidden rounded-full bg-bg-sunken\">\n <div\n className=\"h-full rounded-full bg-action-primary-bg transition-[width] duration-150\"\n style={{ width: `${progress}%` }}\n />\n </div>\n </div>\n ) : (\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled={disabled}\n onClick={() => inputRef.current?.click()}\n className=\"justify-start\"\n >\n <Upload className=\"mr-1.5 h-4 w-4\" />{' '}\n {t('mybodyshield.components.evidenceUpload.chooseFile', 'Choose file')}\n </Button>\n )}\n\n {hint && !error && <p className=\"text-xs text-text-tertiary\">{hint}</p>}\n {error && <p className=\"text-xs text-status-error-text\">{error}</p>}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAyBA,SAAgB,EAAe,EAC7B,OACA,UACA,UACA,aACA,YAAS,mCACT,cAAW,IACX,WACsB;CACtB,IAAM,IAAI,GAAO,EACX,IAAW,EAAyB,KAAK,EACzC,EAAE,WAAQ,gBAAa,aAAU,UAAO,aAAU,GAAkB;AAoB1E,QACE,kBAAC,OAAD;EAAK,WAAU;YAAf;GACE,kBAAC,GAAD;IAAO,SAAS;cAAK;IAAc,CAAA;GAEnC,kBAAC,SAAD;IACE,KAAK;IACD;IACJ,MAAK;IACG;IACR,WAAU;IACV,UAAU,KAAY;IACtB,UA7Be,OAAO,MAAyC;KACnE,IAAM,IAAO,EAAM,OAAO,QAAQ;AAElC,WAAM,OAAO,QAAQ,IAChB,EACL,KAAI;AAEF,QADiB,MAAM,EAAO,EAAK,CACjB;aACZ;;IAsBJ,CAAA;GAED,IACC,kBAAC,OAAD;IAAK,WAAU;cAAf;KACE,kBAAC,GAAD,EAAW,WAAU,uCAAwC,CAAA;KAC7D,kBAAC,QAAD;MACE,WAAU;MACV,OAAO,EAAM;gBAEZ,EAAM;MACF,CAAA;KACP,kBAAC,UAAD;MACE,MAAK;MACL,eA9BiB;AAEzB,OADA,GAAO,EACP,EAAS,KAAK;;MA6BI;MACV,cAAY,EACV,2DACA,oBACD;MACD,WAAU;gBAEV,kBAAC,GAAD,EAAG,WAAU,WAAY,CAAA;MAClB,CAAA;KACL;QACJ,IACF,kBAAC,OAAD;IAAK,WAAU;cAAf;KACE,kBAAC,GAAD,EAAS,MAAK,MAAO,CAAA;KACrB,kBAAC,QAAD;MAAM,WAAU;gBACb,EAAE,oDAAoD,4BAA4B,EACjF,aACD,CAAC;MACG,CAAA;KACP,kBAAC,OAAD;MAAK,WAAU;gBACb,kBAAC,OAAD;OACE,WAAU;OACV,OAAO,EAAE,OAAO,GAAG,EAAS,IAAI;OAChC,CAAA;MACE,CAAA;KACF;QAEN,kBAAC,GAAD;IACE,MAAK;IACL,SAAQ;IACE;IACV,eAAe,EAAS,SAAS,OAAO;IACxC,WAAU;cALZ;KAOE,kBAAC,GAAD,EAAQ,WAAU,kBAAmB,CAAA;KAAC;KACrC,EAAE,qDAAqD,cAAc;KAC/D;;GAGV,KAAQ,CAAC,KAAS,kBAAC,KAAD;IAAG,WAAU;cAA8B;IAAS,CAAA;GACtE,KAAS,kBAAC,KAAD;IAAG,WAAU;cAAkC;IAAU,CAAA;GAC/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileLink.d.ts","sourceRoot":"","sources":["../../../src/mybodyshield/components/FileLink.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,UAAU,aAAa;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"FileLink.d.ts","sourceRoot":"","sources":["../../../src/mybodyshield/components/FileLink.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,UAAU,aAAa;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,aAAa,sCA6C5D"}
|
|
@@ -1,36 +1,45 @@
|
|
|
1
1
|
import { useMybFile as e } from "../hooks/useMybFiles.js";
|
|
2
|
+
import { useTr as t } from "../hooks/useTr.js";
|
|
2
3
|
import "../hooks/index.js";
|
|
3
|
-
import { FileText as
|
|
4
|
-
import { jsx as
|
|
4
|
+
import { FileText as n, Loader2 as r } from "lucide-react";
|
|
5
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
5
6
|
//#region src/mybodyshield/components/FileLink.tsx
|
|
6
|
-
function
|
|
7
|
-
let { data:
|
|
8
|
-
return
|
|
7
|
+
function o({ fileId: o, className: s }) {
|
|
8
|
+
let c = t(), { data: l, isLoading: u, isError: d } = e(o);
|
|
9
|
+
return o ? u ? /* @__PURE__ */ a("span", {
|
|
9
10
|
className: "inline-flex items-center gap-1.5 text-sm text-text-tertiary",
|
|
10
|
-
children: [
|
|
11
|
-
|
|
11
|
+
children: [
|
|
12
|
+
/* @__PURE__ */ i(r, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
13
|
+
" ",
|
|
14
|
+
c("mybodyshield.components.fileLink.loading", "Loading attachment…")
|
|
15
|
+
]
|
|
16
|
+
}) : d || !l ? /* @__PURE__ */ a("span", {
|
|
12
17
|
className: "inline-flex items-center gap-1.5 text-sm text-text-tertiary",
|
|
13
|
-
children: [
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
children: [
|
|
19
|
+
/* @__PURE__ */ i(n, { className: "h-3.5 w-3.5" }),
|
|
20
|
+
" ",
|
|
21
|
+
c("mybodyshield.components.fileLink.unavailable", "Attachment unavailable")
|
|
22
|
+
]
|
|
23
|
+
}) : l.downloadUrl ? /* @__PURE__ */ a("a", {
|
|
24
|
+
href: l.downloadUrl,
|
|
16
25
|
target: "_blank",
|
|
17
26
|
rel: "noopener noreferrer",
|
|
18
|
-
className:
|
|
27
|
+
className: s ?? "inline-flex items-center gap-1.5 text-sm font-medium text-action-primary-bg hover:underline",
|
|
19
28
|
children: [
|
|
20
|
-
/* @__PURE__ */
|
|
29
|
+
/* @__PURE__ */ i(n, { className: "h-3.5 w-3.5" }),
|
|
21
30
|
" ",
|
|
22
|
-
|
|
31
|
+
l.name
|
|
23
32
|
]
|
|
24
|
-
}) : /* @__PURE__ */
|
|
25
|
-
className:
|
|
33
|
+
}) : /* @__PURE__ */ a("span", {
|
|
34
|
+
className: s ?? "inline-flex items-center gap-1.5 text-sm text-text-secondary",
|
|
26
35
|
children: [
|
|
27
|
-
/* @__PURE__ */
|
|
36
|
+
/* @__PURE__ */ i(n, { className: "h-3.5 w-3.5" }),
|
|
28
37
|
" ",
|
|
29
|
-
|
|
38
|
+
l.name
|
|
30
39
|
]
|
|
31
40
|
}) : null;
|
|
32
41
|
}
|
|
33
42
|
//#endregion
|
|
34
|
-
export {
|
|
43
|
+
export { o as FileLink };
|
|
35
44
|
|
|
36
45
|
//# sourceMappingURL=FileLink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileLink.js","names":[],"sources":["../../../src/mybodyshield/components/FileLink.tsx"],"sourcesContent":["/**\n * FileLink — resolves a federated File id to a download link (Integration A).\n * @module mybodyshield/components/FileLink\n *\n * The eco queries select `evidence { id }` / `file { id }` (just the id). This\n * resolves the platform File via `getFile(id)` for its name + signed\n * `downloadUrl` so evidence/report artifacts render as a real link.\n */\n\nimport { FileText, Loader2 } from 'lucide-react';\nimport { useMybFile } from '../hooks';\n\ninterface FileLinkProps {\n fileId: string | null | undefined;\n className?: string;\n}\n\nexport function FileLink({ fileId, className }: FileLinkProps) {\n const { data, isLoading, isError } = useMybFile(fileId);\n\n if (!fileId) return null;\n\n if (isLoading) {\n return (\n <span className=\"inline-flex items-center gap-1.5 text-sm text-text-tertiary\">\n <Loader2 className=\"h-3.5 w-3.5 animate-spin\" /> Loading attachment
|
|
1
|
+
{"version":3,"file":"FileLink.js","names":[],"sources":["../../../src/mybodyshield/components/FileLink.tsx"],"sourcesContent":["/**\n * FileLink — resolves a federated File id to a download link (Integration A).\n * @module mybodyshield/components/FileLink\n *\n * The eco queries select `evidence { id }` / `file { id }` (just the id). This\n * resolves the platform File via `getFile(id)` for its name + signed\n * `downloadUrl` so evidence/report artifacts render as a real link.\n */\n\nimport { FileText, Loader2 } from 'lucide-react';\nimport { useMybFile, useTr } from '../hooks';\n\ninterface FileLinkProps {\n fileId: string | null | undefined;\n className?: string;\n}\n\nexport function FileLink({ fileId, className }: FileLinkProps) {\n const t = useTr();\n const { data, isLoading, isError } = useMybFile(fileId);\n\n if (!fileId) return null;\n\n if (isLoading) {\n return (\n <span className=\"inline-flex items-center gap-1.5 text-sm text-text-tertiary\">\n <Loader2 className=\"h-3.5 w-3.5 animate-spin\" />{' '}\n {t('mybodyshield.components.fileLink.loading', 'Loading attachment…')}\n </span>\n );\n }\n\n if (isError || !data) {\n return (\n <span className=\"inline-flex items-center gap-1.5 text-sm text-text-tertiary\">\n <FileText className=\"h-3.5 w-3.5\" />{' '}\n {t('mybodyshield.components.fileLink.unavailable', 'Attachment unavailable')}\n </span>\n );\n }\n\n const base =\n 'inline-flex items-center gap-1.5 text-sm font-medium text-action-primary-bg hover:underline';\n\n if (!data.downloadUrl) {\n return (\n <span className={className ?? 'inline-flex items-center gap-1.5 text-sm text-text-secondary'}>\n <FileText className=\"h-3.5 w-3.5\" /> {data.name}\n </span>\n );\n }\n\n return (\n <a\n href={data.downloadUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={className ?? base}\n >\n <FileText className=\"h-3.5 w-3.5\" /> {data.name}\n </a>\n );\n}\n"],"mappings":";;;;;;AAiBA,SAAgB,EAAS,EAAE,WAAQ,gBAA4B;CAC7D,IAAM,IAAI,GAAO,EACX,EAAE,SAAM,cAAW,eAAY,EAAW,EAAO;AAiCvD,QA/BK,IAED,IAEA,kBAAC,QAAD;EAAM,WAAU;YAAhB;GACE,kBAAC,GAAD,EAAS,WAAU,4BAA6B,CAAA;GAAC;GAChD,EAAE,4CAA4C,sBAAsB;GAChE;MAIP,KAAW,CAAC,IAEZ,kBAAC,QAAD;EAAM,WAAU;YAAhB;GACE,kBAAC,GAAD,EAAU,WAAU,eAAgB,CAAA;GAAC;GACpC,EAAE,gDAAgD,yBAAyB;GACvE;MAON,EAAK,cASR,kBAAC,KAAD;EACE,MAAM,EAAK;EACX,QAAO;EACP,KAAI;EACJ,WAAW,KAAa;YAJ1B;GAME,kBAAC,GAAD,EAAU,WAAU,eAAgB,CAAA;;GAAE,EAAK;GACzC;MAdF,kBAAC,QAAD;EAAM,WAAW,KAAa;YAA9B;GACE,kBAAC,GAAD,EAAU,WAAU,eAAgB,CAAA;;GAAE,EAAK;GACtC;MA3BS"}
|
|
@@ -13,6 +13,6 @@ interface MybDiscussionProps {
|
|
|
13
13
|
title?: string;
|
|
14
14
|
description?: string;
|
|
15
15
|
}
|
|
16
|
-
export declare function MybDiscussion({ entityType, entityId, title, description, }: MybDiscussionProps): import("react").JSX.Element;
|
|
16
|
+
export declare function MybDiscussion({ entityType, entityId, title: titleProp, description: descriptionProp, }: MybDiscussionProps): import("react").JSX.Element;
|
|
17
17
|
export {};
|
|
18
18
|
//# sourceMappingURL=MybDiscussion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MybDiscussion.d.ts","sourceRoot":"","sources":["../../../src/mybodyshield/components/MybDiscussion.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAWH,UAAU,kBAAkB;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;
|
|
1
|
+
{"version":3,"file":"MybDiscussion.d.ts","sourceRoot":"","sources":["../../../src/mybodyshield/components/MybDiscussion.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAWH,UAAU,kBAAkB;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAsBD,wBAAgB,aAAa,CAAC,EAC5B,UAAU,EACV,QAAQ,EACR,KAAK,EAAE,SAAS,EAChB,WAAW,EAAE,eAAe,GAC7B,EAAE,kBAAkB,+BAoIpB"}
|
|
@@ -1,97 +1,98 @@
|
|
|
1
1
|
import { useMyBodyShield as e } from "../context/MyBodyShieldContext.js";
|
|
2
2
|
import { formatDateTime as t } from "../utils/formatters.js";
|
|
3
3
|
import { EmptyState as n } from "./EmptyState.js";
|
|
4
|
-
import { ErrorView as r, LoadingView as i, Section as a } from "./StateViews.js";
|
|
5
4
|
import "../context/index.js";
|
|
6
|
-
import { useMybComments as
|
|
5
|
+
import { useMybComments as r, useMybCreateComment as i } from "../hooks/useMybComments.js";
|
|
6
|
+
import { useTr as a } from "../hooks/useTr.js";
|
|
7
7
|
import "../hooks/index.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { ErrorView as o, LoadingView as s, Section as c } from "./StateViews.js";
|
|
9
|
+
import { useState as l } from "react";
|
|
10
|
+
import { MessageSquare as u, Send as d } from "lucide-react";
|
|
11
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
12
|
+
import { Button as m, Textarea as h } from "@burdenoff/fe-libs/ui";
|
|
12
13
|
//#region src/mybodyshield/components/MybDiscussion.tsx
|
|
13
|
-
function
|
|
14
|
-
if (!e) return "You";
|
|
15
|
-
let
|
|
16
|
-
return e.name ||
|
|
14
|
+
function g(e, t) {
|
|
15
|
+
if (!e) return t("mybodyshield.components.discussion.you", "You");
|
|
16
|
+
let n = [e.firstName, e.lastName].filter(Boolean).join(" ").trim();
|
|
17
|
+
return e.name || n || e.username || e.email || t("mybodyshield.components.discussion.you", "You");
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
+
function _(e) {
|
|
19
20
|
let t = e.trim();
|
|
20
21
|
return t ? t[0].toUpperCase() : "?";
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
let { currentUser:
|
|
24
|
-
let e =
|
|
23
|
+
function v({ entityType: v, entityId: y, title: b, description: x }) {
|
|
24
|
+
let S = a(), C = b ?? S("mybodyshield.components.discussion.title", "Discussion"), w = x ?? S("mybodyshield.components.discussion.description", "Coordinate review and verification with your team."), { currentUser: T } = e(), { data: E, isLoading: D, isError: O, refetch: k } = r(v, y), A = i(v, y), [j, M] = l(""), [N, P] = l(null), F = g(T, S), I = (e) => T?.id && e.authorId === T.id ? F : S("mybodyshield.components.discussion.workspaceMember", "Workspace member"), L = async () => {
|
|
25
|
+
let e = j.trim();
|
|
25
26
|
if (e) {
|
|
26
|
-
|
|
27
|
+
P(null);
|
|
27
28
|
try {
|
|
28
|
-
await
|
|
29
|
+
await A.mutateAsync(e), M("");
|
|
29
30
|
} catch (e) {
|
|
30
|
-
|
|
31
|
+
P(e instanceof Error ? e.message : S("mybodyshield.components.discussion.postFailed", "Failed to post comment."));
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
},
|
|
34
|
-
return /* @__PURE__ */
|
|
35
|
-
title:
|
|
36
|
-
description:
|
|
37
|
-
children: /* @__PURE__ */
|
|
34
|
+
}, R = E?.items ?? [];
|
|
35
|
+
return /* @__PURE__ */ f(c, {
|
|
36
|
+
title: C,
|
|
37
|
+
description: w,
|
|
38
|
+
children: /* @__PURE__ */ p("div", {
|
|
38
39
|
className: "rounded-xl border border-border-seam bg-bg-surface/40 p-4",
|
|
39
|
-
children: [/* @__PURE__ */
|
|
40
|
+
children: [/* @__PURE__ */ p("div", {
|
|
40
41
|
className: "flex gap-3",
|
|
41
|
-
children: [/* @__PURE__ */
|
|
42
|
+
children: [/* @__PURE__ */ f("div", {
|
|
42
43
|
className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-action-primary-bg/15 text-sm font-semibold text-action-primary-bg",
|
|
43
|
-
children:
|
|
44
|
-
}), /* @__PURE__ */
|
|
44
|
+
children: _(F)
|
|
45
|
+
}), /* @__PURE__ */ p("div", {
|
|
45
46
|
className: "flex-1",
|
|
46
|
-
children: [/* @__PURE__ */
|
|
47
|
-
value:
|
|
48
|
-
onChange: (e) =>
|
|
49
|
-
placeholder: "Add a comment for your team…",
|
|
47
|
+
children: [/* @__PURE__ */ f(h, {
|
|
48
|
+
value: j,
|
|
49
|
+
onChange: (e) => M(e.target.value),
|
|
50
|
+
placeholder: S("mybodyshield.components.discussion.placeholder", "Add a comment for your team…"),
|
|
50
51
|
rows: 2
|
|
51
|
-
}), /* @__PURE__ */
|
|
52
|
+
}), /* @__PURE__ */ p("div", {
|
|
52
53
|
className: "mt-2 flex items-center justify-end gap-2",
|
|
53
|
-
children: [
|
|
54
|
+
children: [N && /* @__PURE__ */ f("span", {
|
|
54
55
|
className: "mr-auto text-xs text-status-error-text",
|
|
55
|
-
children:
|
|
56
|
-
}), /* @__PURE__ */
|
|
56
|
+
children: N
|
|
57
|
+
}), /* @__PURE__ */ p(m, {
|
|
57
58
|
size: "sm",
|
|
58
|
-
onClick:
|
|
59
|
-
disabled: !
|
|
60
|
-
children: [/* @__PURE__ */ d
|
|
59
|
+
onClick: L,
|
|
60
|
+
disabled: !j.trim() || A.isPending,
|
|
61
|
+
children: [/* @__PURE__ */ f(d, { className: "mr-1.5 h-4 w-4" }), A.isPending ? S("mybodyshield.components.discussion.posting", "Posting…") : S("mybodyshield.components.discussion.comment", "Comment")]
|
|
61
62
|
})]
|
|
62
63
|
})]
|
|
63
64
|
})]
|
|
64
|
-
}), /* @__PURE__ */
|
|
65
|
+
}), /* @__PURE__ */ f("div", {
|
|
65
66
|
className: "mt-4 border-t border-border-seam pt-4",
|
|
66
|
-
children:
|
|
67
|
-
message: "Couldn't load the discussion.",
|
|
68
|
-
onRetry: () =>
|
|
69
|
-
}) :
|
|
67
|
+
children: D ? /* @__PURE__ */ f(s, { label: S("mybodyshield.components.discussion.loading", "Loading discussion…") }) : O ? /* @__PURE__ */ f(o, {
|
|
68
|
+
message: S("mybodyshield.components.discussion.loadFailed", "Couldn't load the discussion."),
|
|
69
|
+
onRetry: () => k()
|
|
70
|
+
}) : R.length === 0 ? /* @__PURE__ */ f(n, {
|
|
70
71
|
illustration: "empty-data",
|
|
71
|
-
icon: /* @__PURE__ */
|
|
72
|
-
title: "No comments yet",
|
|
73
|
-
description: "Start the discussion by adding the first comment."
|
|
74
|
-
}) : /* @__PURE__ */
|
|
72
|
+
icon: /* @__PURE__ */ f(u, { className: "h-9 w-9" }),
|
|
73
|
+
title: S("mybodyshield.components.discussion.emptyTitle", "No comments yet"),
|
|
74
|
+
description: S("mybodyshield.components.discussion.emptyDescription", "Start the discussion by adding the first comment.")
|
|
75
|
+
}) : /* @__PURE__ */ f("ul", {
|
|
75
76
|
className: "flex flex-col gap-4",
|
|
76
|
-
children:
|
|
77
|
-
let n =
|
|
78
|
-
return /* @__PURE__ */
|
|
77
|
+
children: R.map((e) => {
|
|
78
|
+
let n = I(e), r = e.content.text ?? e.content.markdown ?? "";
|
|
79
|
+
return /* @__PURE__ */ p("li", {
|
|
79
80
|
className: "flex gap-3",
|
|
80
|
-
children: [/* @__PURE__ */
|
|
81
|
+
children: [/* @__PURE__ */ f("div", {
|
|
81
82
|
className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-bg-sunken text-sm font-semibold text-text-secondary",
|
|
82
|
-
children:
|
|
83
|
-
}), /* @__PURE__ */
|
|
83
|
+
children: _(n)
|
|
84
|
+
}), /* @__PURE__ */ p("div", {
|
|
84
85
|
className: "min-w-0 flex-1",
|
|
85
|
-
children: [/* @__PURE__ */
|
|
86
|
+
children: [/* @__PURE__ */ p("div", {
|
|
86
87
|
className: "flex flex-wrap items-baseline gap-x-2",
|
|
87
|
-
children: [/* @__PURE__ */
|
|
88
|
+
children: [/* @__PURE__ */ f("span", {
|
|
88
89
|
className: "text-sm font-semibold text-text-primary",
|
|
89
90
|
children: n
|
|
90
|
-
}), /* @__PURE__ */
|
|
91
|
+
}), /* @__PURE__ */ p("span", {
|
|
91
92
|
className: "text-xs text-text-tertiary",
|
|
92
|
-
children: [t(e.createdAt), e.edited ?
|
|
93
|
+
children: [t(e.createdAt), e.edited ? ` · ${S("mybodyshield.components.discussion.edited", "edited")}` : ""]
|
|
93
94
|
})]
|
|
94
|
-
}), /* @__PURE__ */
|
|
95
|
+
}), /* @__PURE__ */ f("p", {
|
|
95
96
|
className: "mt-0.5 whitespace-pre-wrap break-words text-sm text-text-secondary",
|
|
96
97
|
children: r
|
|
97
98
|
})]
|
|
@@ -104,6 +105,6 @@ function _({ entityType: _, entityId: v, title: y = "Discussion", description: b
|
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
107
|
//#endregion
|
|
107
|
-
export {
|
|
108
|
+
export { v as MybDiscussion };
|
|
108
109
|
|
|
109
110
|
//# sourceMappingURL=MybDiscussion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MybDiscussion.js","names":[],"sources":["../../../src/mybodyshield/components/MybDiscussion.tsx"],"sourcesContent":["/**\n * MybDiscussion — a comment thread on any mybodyshield entity (Integration B).\n * @module mybodyshield/components/MybDiscussion\n *\n * Reuses the platform EntityComment API (`getEntityComments` /\n * `createEntityComment`) keyed by `(entityType, entityId)` — no mybodyshield-svc change.\n * Renders root comments (author, body, time) + a composer. Robust to empty\n * state and errors.\n */\n\nimport { useState } from 'react';\nimport { MessageSquare, Send } from 'lucide-react';\nimport { Button, Textarea } from '@burdenoff/fe-libs/ui';\nimport { Section, LoadingView, ErrorView } from './StateViews';\nimport { EmptyState } from './EmptyState';\nimport { useMyBodyShield } from '../context';\nimport { useMybComments, useMybCreateComment, type MybComment } from '../hooks';\nimport { formatDateTime } from '../utils/formatters';\n\ninterface MybDiscussionProps {\n entityType: string;\n entityId: string;\n title?: string;\n description?: string;\n}\n\nfunction displayName(user: ReturnType<typeof useMyBodyShield>['currentUser']): string {\n if (!user) return 'You';\n const full = [user.firstName, user.lastName].filter(Boolean).join(' ').trim();\n return user.name
|
|
1
|
+
{"version":3,"file":"MybDiscussion.js","names":[],"sources":["../../../src/mybodyshield/components/MybDiscussion.tsx"],"sourcesContent":["/**\n * MybDiscussion — a comment thread on any mybodyshield entity (Integration B).\n * @module mybodyshield/components/MybDiscussion\n *\n * Reuses the platform EntityComment API (`getEntityComments` /\n * `createEntityComment`) keyed by `(entityType, entityId)` — no mybodyshield-svc change.\n * Renders root comments (author, body, time) + a composer. Robust to empty\n * state and errors.\n */\n\nimport { useState } from 'react';\nimport { MessageSquare, Send } from 'lucide-react';\nimport { Button, Textarea } from '@burdenoff/fe-libs/ui';\nimport { Section, LoadingView, ErrorView } from './StateViews';\nimport { EmptyState } from './EmptyState';\nimport { useMyBodyShield } from '../context';\nimport { useMybComments, useMybCreateComment, useTr, type MybComment } from '../hooks';\nimport { formatDateTime } from '../utils/formatters';\n\ninterface MybDiscussionProps {\n entityType: string;\n entityId: string;\n title?: string;\n description?: string;\n}\n\nfunction displayName(\n user: ReturnType<typeof useMyBodyShield>['currentUser'],\n t: ReturnType<typeof useTr>\n): string {\n if (!user) return t('mybodyshield.components.discussion.you', 'You');\n const full = [user.firstName, user.lastName].filter(Boolean).join(' ').trim();\n return (\n user.name ||\n full ||\n user.username ||\n user.email ||\n t('mybodyshield.components.discussion.you', 'You')\n );\n}\n\nfunction initialFor(label: string): string {\n const trimmed = label.trim();\n return trimmed ? trimmed[0]!.toUpperCase() : '?';\n}\n\nexport function MybDiscussion({\n entityType,\n entityId,\n title: titleProp,\n description: descriptionProp,\n}: MybDiscussionProps) {\n const t = useTr();\n const title = titleProp ?? t('mybodyshield.components.discussion.title', 'Discussion');\n const description =\n descriptionProp ??\n t(\n 'mybodyshield.components.discussion.description',\n 'Coordinate review and verification with your team.'\n );\n const { currentUser } = useMyBodyShield();\n const { data, isLoading, isError, refetch } = useMybComments(entityType, entityId);\n const createComment = useMybCreateComment(entityType, entityId);\n\n const [draft, setDraft] = useState('');\n const [error, setError] = useState<string | null>(null);\n\n const selfName = displayName(currentUser, t);\n\n const authorLabel = (comment: MybComment): string =>\n currentUser?.id && comment.authorId === currentUser.id\n ? selfName\n : t('mybodyshield.components.discussion.workspaceMember', 'Workspace member');\n\n const handleSubmit = async () => {\n const text = draft.trim();\n if (!text) return;\n setError(null);\n try {\n await createComment.mutateAsync(text);\n setDraft('');\n } catch (err) {\n setError(\n err instanceof Error\n ? err.message\n : t('mybodyshield.components.discussion.postFailed', 'Failed to post comment.')\n );\n }\n };\n\n const comments = data?.items ?? [];\n\n return (\n <Section title={title} description={description}>\n <div className=\"rounded-xl border border-border-seam bg-bg-surface/40 p-4\">\n {/* Composer */}\n <div className=\"flex gap-3\">\n <div className=\"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-action-primary-bg/15 text-sm font-semibold text-action-primary-bg\">\n {initialFor(selfName)}\n </div>\n <div className=\"flex-1\">\n <Textarea\n value={draft}\n onChange={(e) => setDraft(e.target.value)}\n placeholder={t(\n 'mybodyshield.components.discussion.placeholder',\n 'Add a comment for your team…'\n )}\n rows={2}\n />\n <div className=\"mt-2 flex items-center justify-end gap-2\">\n {error && <span className=\"mr-auto text-xs text-status-error-text\">{error}</span>}\n <Button\n size=\"sm\"\n onClick={handleSubmit}\n disabled={!draft.trim() || createComment.isPending}\n >\n <Send className=\"mr-1.5 h-4 w-4\" />\n {createComment.isPending\n ? t('mybodyshield.components.discussion.posting', 'Posting…')\n : t('mybodyshield.components.discussion.comment', 'Comment')}\n </Button>\n </div>\n </div>\n </div>\n\n {/* Thread */}\n <div className=\"mt-4 border-t border-border-seam pt-4\">\n {isLoading ? (\n <LoadingView\n label={t('mybodyshield.components.discussion.loading', 'Loading discussion…')}\n />\n ) : isError ? (\n <ErrorView\n message={t(\n 'mybodyshield.components.discussion.loadFailed',\n \"Couldn't load the discussion.\"\n )}\n onRetry={() => refetch()}\n />\n ) : comments.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n icon={<MessageSquare className=\"h-9 w-9\" />}\n title={t('mybodyshield.components.discussion.emptyTitle', 'No comments yet')}\n description={t(\n 'mybodyshield.components.discussion.emptyDescription',\n 'Start the discussion by adding the first comment.'\n )}\n />\n ) : (\n <ul className=\"flex flex-col gap-4\">\n {comments.map((comment) => {\n const label = authorLabel(comment);\n const body = comment.content.text ?? comment.content.markdown ?? '';\n return (\n <li key={comment.id} className=\"flex gap-3\">\n <div className=\"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-bg-sunken text-sm font-semibold text-text-secondary\">\n {initialFor(label)}\n </div>\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex flex-wrap items-baseline gap-x-2\">\n <span className=\"text-sm font-semibold text-text-primary\">{label}</span>\n <span className=\"text-xs text-text-tertiary\">\n {formatDateTime(comment.createdAt)}\n {comment.edited\n ? ` · ${t('mybodyshield.components.discussion.edited', 'edited')}`\n : ''}\n </span>\n </div>\n <p className=\"mt-0.5 whitespace-pre-wrap break-words text-sm text-text-secondary\">\n {body}\n </p>\n </div>\n </li>\n );\n })}\n </ul>\n )}\n </div>\n </div>\n </Section>\n );\n}\n"],"mappings":"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"}
|
|
@@ -12,6 +12,6 @@ interface MybTagsProps {
|
|
|
12
12
|
entityId: string;
|
|
13
13
|
label?: string;
|
|
14
14
|
}
|
|
15
|
-
export declare function MybTags({ entityType, entityId, label }: MybTagsProps): import("react").JSX.Element;
|
|
15
|
+
export declare function MybTags({ entityType, entityId, label: labelProp }: MybTagsProps): import("react").JSX.Element;
|
|
16
16
|
export {};
|
|
17
17
|
//# sourceMappingURL=MybTags.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MybTags.d.ts","sourceRoot":"","sources":["../../../src/mybodyshield/components/MybTags.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"MybTags.d.ts","sourceRoot":"","sources":["../../../src/mybodyshield/components/MybTags.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAqBH,UAAU,YAAY;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,OAAO,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,YAAY,+BAkN/E"}
|