@serhii.olishevskyi/docs 1.0.7 → 1.0.9
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/{UserPopoverComponent-ZPPVLFBL.mjs → UserPopoverComponent-VE2Q77FP.mjs} +1 -1
- package/dist/{chunk-VCRXKPJ4.mjs → chunk-I4NSFSES.mjs} +263 -81
- package/dist/index.d.mts +37 -2
- package/dist/index.d.ts +37 -2
- package/dist/index.js +353 -161
- package/dist/index.mjs +8 -4
- package/package.json +1 -1
|
@@ -1672,14 +1672,206 @@ var useAppSettings = () => {
|
|
|
1672
1672
|
return context;
|
|
1673
1673
|
};
|
|
1674
1674
|
|
|
1675
|
+
// src/context/UserSettingsProvider.tsx
|
|
1676
|
+
import { createContext as createContext12, useContext as useContext12, useEffect as useEffect8, useState as useState11, useCallback as useCallback6 } from "react";
|
|
1677
|
+
|
|
1678
|
+
// src/types/user.types.ts
|
|
1679
|
+
var defaultUserSettings = {
|
|
1680
|
+
sidebar_open: true,
|
|
1681
|
+
chat_open: false,
|
|
1682
|
+
language: "ua",
|
|
1683
|
+
theme_mode: "light"
|
|
1684
|
+
};
|
|
1685
|
+
|
|
1686
|
+
// src/context/UserSettingsProvider.tsx
|
|
1687
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1688
|
+
var UserSettingsContext = createContext12(void 0);
|
|
1689
|
+
var UserSettingsProvider = ({ children }) => {
|
|
1690
|
+
const supabase = useSupabase();
|
|
1691
|
+
const { user, isAuthenticated, loading: isAuthLoading } = useAuth();
|
|
1692
|
+
const userId = user?.id;
|
|
1693
|
+
const [settings, setSettings] = useState11({
|
|
1694
|
+
id: "",
|
|
1695
|
+
...defaultUserSettings
|
|
1696
|
+
});
|
|
1697
|
+
const [loading, setLoading] = useState11(true);
|
|
1698
|
+
const [error, setError] = useState11(null);
|
|
1699
|
+
const [activeChatUserId, setActiveChatUserId] = useState11(null);
|
|
1700
|
+
const fetchSettings = useCallback6(async () => {
|
|
1701
|
+
if (isAuthLoading) return;
|
|
1702
|
+
if (!isAuthenticated || !userId) {
|
|
1703
|
+
setSettings({ id: "", ...defaultUserSettings });
|
|
1704
|
+
setLoading(false);
|
|
1705
|
+
return;
|
|
1706
|
+
}
|
|
1707
|
+
try {
|
|
1708
|
+
setSettings((prev) => {
|
|
1709
|
+
if (prev.id !== userId) {
|
|
1710
|
+
setLoading(true);
|
|
1711
|
+
}
|
|
1712
|
+
return prev;
|
|
1713
|
+
});
|
|
1714
|
+
setError(null);
|
|
1715
|
+
let { data, error: fetchError } = await supabase.from("user_settings").select("*").eq("id", userId).maybeSingle();
|
|
1716
|
+
if (fetchError) throw fetchError;
|
|
1717
|
+
if (!data) {
|
|
1718
|
+
const newSettings = {
|
|
1719
|
+
id: userId,
|
|
1720
|
+
sidebar_open: defaultUserSettings.sidebar_open ?? true,
|
|
1721
|
+
chat_open: defaultUserSettings.chat_open ?? false,
|
|
1722
|
+
language: defaultUserSettings.language ?? "ua",
|
|
1723
|
+
theme_mode: defaultUserSettings.theme_mode ?? "light"
|
|
1724
|
+
};
|
|
1725
|
+
const { data: insertedData, error: insertError } = await supabase.from("user_settings").insert(newSettings).select().single();
|
|
1726
|
+
if (insertError) {
|
|
1727
|
+
if (insertError.code === "23505") {
|
|
1728
|
+
const { data: retryData } = await supabase.from("user_settings").select("*").eq("id", userId).single();
|
|
1729
|
+
data = retryData;
|
|
1730
|
+
} else {
|
|
1731
|
+
throw insertError;
|
|
1732
|
+
}
|
|
1733
|
+
} else {
|
|
1734
|
+
data = insertedData;
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
if (data) {
|
|
1738
|
+
setSettings({
|
|
1739
|
+
...defaultUserSettings,
|
|
1740
|
+
...data
|
|
1741
|
+
});
|
|
1742
|
+
if (data.theme_mode) {
|
|
1743
|
+
localStorage.setItem(THEME_MODE_STORAGE_KEY, data.theme_mode);
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
} catch (err) {
|
|
1747
|
+
console.error("Failed to load user settings from Supabase:", err);
|
|
1748
|
+
setError(err.message || "Failed to load user settings");
|
|
1749
|
+
} finally {
|
|
1750
|
+
setLoading(false);
|
|
1751
|
+
}
|
|
1752
|
+
}, [isAuthenticated, isAuthLoading, userId]);
|
|
1753
|
+
useEffect8(() => {
|
|
1754
|
+
fetchSettings();
|
|
1755
|
+
}, [fetchSettings]);
|
|
1756
|
+
const toggleSidebar = useCallback6(
|
|
1757
|
+
async (open) => {
|
|
1758
|
+
const isExplicitBoolean = typeof open === "boolean";
|
|
1759
|
+
const nextState = isExplicitBoolean ? open : !settings.sidebar_open;
|
|
1760
|
+
setSettings((prev) => ({ ...prev, sidebar_open: nextState }));
|
|
1761
|
+
if (!userId) return;
|
|
1762
|
+
try {
|
|
1763
|
+
const { error: error2 } = await supabase.from("user_settings").update({ sidebar_open: nextState, updated_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", userId);
|
|
1764
|
+
if (error2) throw error2;
|
|
1765
|
+
} catch (err) {
|
|
1766
|
+
console.error("Failed to update sidebar state:", err);
|
|
1767
|
+
setSettings((prev) => ({ ...prev, sidebar_open: !nextState }));
|
|
1768
|
+
}
|
|
1769
|
+
},
|
|
1770
|
+
[settings.sidebar_open, userId]
|
|
1771
|
+
);
|
|
1772
|
+
const toggleChat = useCallback6(
|
|
1773
|
+
async (open) => {
|
|
1774
|
+
const isExplicitBoolean = typeof open === "boolean";
|
|
1775
|
+
const nextState = isExplicitBoolean ? open : !settings.chat_open;
|
|
1776
|
+
setSettings((prev) => ({ ...prev, chat_open: nextState }));
|
|
1777
|
+
if (!userId) return;
|
|
1778
|
+
try {
|
|
1779
|
+
const { error: error2 } = await supabase.from("user_settings").update({ chat_open: nextState, updated_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", userId);
|
|
1780
|
+
if (error2) throw error2;
|
|
1781
|
+
} catch (err) {
|
|
1782
|
+
console.error("Failed to update chat state:", err);
|
|
1783
|
+
setSettings((prev) => ({ ...prev, chat_open: !nextState }));
|
|
1784
|
+
}
|
|
1785
|
+
},
|
|
1786
|
+
[settings.chat_open, userId]
|
|
1787
|
+
);
|
|
1788
|
+
const openChatWithUser = useCallback6(
|
|
1789
|
+
async (targetUserId) => {
|
|
1790
|
+
setActiveChatUserId(targetUserId);
|
|
1791
|
+
if (!settings.chat_open) {
|
|
1792
|
+
await toggleChat(true);
|
|
1793
|
+
}
|
|
1794
|
+
},
|
|
1795
|
+
[settings.chat_open, toggleChat]
|
|
1796
|
+
);
|
|
1797
|
+
const setLanguage = useCallback6(
|
|
1798
|
+
async (newLanguage) => {
|
|
1799
|
+
const previousLanguage = settings.language;
|
|
1800
|
+
setSettings((prev) => ({ ...prev, language: newLanguage }));
|
|
1801
|
+
if (!userId) return;
|
|
1802
|
+
try {
|
|
1803
|
+
const { error: error2 } = await supabase.from("user_settings").update({ language: newLanguage, updated_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", userId);
|
|
1804
|
+
if (error2) throw error2;
|
|
1805
|
+
} catch (err) {
|
|
1806
|
+
console.error("Failed to update language on server:", err);
|
|
1807
|
+
setSettings((prev) => ({ ...prev, language: previousLanguage }));
|
|
1808
|
+
}
|
|
1809
|
+
},
|
|
1810
|
+
[settings.language, userId]
|
|
1811
|
+
);
|
|
1812
|
+
const setThemeMode = useCallback6(
|
|
1813
|
+
async (newMode) => {
|
|
1814
|
+
const previousMode = settings.theme_mode;
|
|
1815
|
+
setSettings((prev) => ({ ...prev, theme_mode: newMode }));
|
|
1816
|
+
localStorage.setItem(THEME_MODE_STORAGE_KEY, newMode);
|
|
1817
|
+
if (!userId) return;
|
|
1818
|
+
try {
|
|
1819
|
+
const { error: error2 } = await supabase.from("user_settings").update({ theme_mode: newMode, updated_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", userId);
|
|
1820
|
+
if (error2) throw error2;
|
|
1821
|
+
} catch (err) {
|
|
1822
|
+
console.error("Failed to update theme mode on server:", err);
|
|
1823
|
+
setSettings((prev) => ({ ...prev, theme_mode: previousMode }));
|
|
1824
|
+
}
|
|
1825
|
+
},
|
|
1826
|
+
[settings.theme_mode, userId]
|
|
1827
|
+
);
|
|
1828
|
+
return /* @__PURE__ */ jsx14(
|
|
1829
|
+
UserSettingsContext.Provider,
|
|
1830
|
+
{
|
|
1831
|
+
value: {
|
|
1832
|
+
settings,
|
|
1833
|
+
loading,
|
|
1834
|
+
error,
|
|
1835
|
+
activeChatUserId,
|
|
1836
|
+
toggleSidebar,
|
|
1837
|
+
toggleChat,
|
|
1838
|
+
openChatWithUser,
|
|
1839
|
+
setLanguage,
|
|
1840
|
+
setThemeMode,
|
|
1841
|
+
refreshSettings: fetchSettings
|
|
1842
|
+
},
|
|
1843
|
+
children
|
|
1844
|
+
}
|
|
1845
|
+
);
|
|
1846
|
+
};
|
|
1847
|
+
var useUserSettings = () => {
|
|
1848
|
+
const context = useContext12(UserSettingsContext);
|
|
1849
|
+
if (!context) {
|
|
1850
|
+
throw new Error("useUserSettings should be used within the UserSettingsProvider");
|
|
1851
|
+
}
|
|
1852
|
+
return context;
|
|
1853
|
+
};
|
|
1854
|
+
|
|
1855
|
+
// src/context/PublicThemeProvider.tsx
|
|
1856
|
+
import { useMemo as useMemo6 } from "react";
|
|
1857
|
+
import { ThemeProvider as MuiThemeProvider2 } from "@mui/material";
|
|
1858
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
1859
|
+
var PublicThemeProvider = ({ children }) => {
|
|
1860
|
+
const publicTheme = useMemo6(() => buildMuiTheme(INITIAL_THEME_CONFIG), []);
|
|
1861
|
+
return /* @__PURE__ */ jsx15(MuiThemeProvider2, { theme: publicTheme, children });
|
|
1862
|
+
};
|
|
1863
|
+
|
|
1675
1864
|
// src/context/index.ts
|
|
1676
1865
|
var Providers = {
|
|
1677
1866
|
Supabase: SupabaseProvider,
|
|
1678
1867
|
AppSettings: AppSettingsProvider,
|
|
1868
|
+
Auth: AuthProvider,
|
|
1869
|
+
UserSettings: UserSettingsProvider,
|
|
1679
1870
|
Translate: TranslateProvider,
|
|
1680
1871
|
TranslationEdit: TranslationEditProvider,
|
|
1681
1872
|
Localization: LocalizationProvider,
|
|
1682
|
-
|
|
1873
|
+
PublicTheme: PublicThemeProvider,
|
|
1874
|
+
ProtectedTheme: ThemeProvider,
|
|
1683
1875
|
Breadcrumb: BreadcrumbProvider,
|
|
1684
1876
|
Toast: ToastProvider,
|
|
1685
1877
|
Confirmation: ConfirmationProvider,
|
|
@@ -1687,26 +1879,26 @@ var Providers = {
|
|
|
1687
1879
|
};
|
|
1688
1880
|
|
|
1689
1881
|
// src/UI/components/data.display/UserStatusChipComponent.tsx
|
|
1690
|
-
import { jsx as
|
|
1882
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1691
1883
|
var UserStatusChipComponent = ({ overrideNamespace, state }) => {
|
|
1692
1884
|
const confirm = useConfirmation();
|
|
1693
1885
|
const handleShowReason = async (e) => {
|
|
1694
1886
|
e.stopPropagation();
|
|
1695
1887
|
if (!state.locked_reason) return;
|
|
1696
1888
|
await confirm({
|
|
1697
|
-
title: /* @__PURE__ */
|
|
1889
|
+
title: /* @__PURE__ */ jsx16(TranslateText, { overrideNamespace: overrideNamespace || "system_widgets", children: "Lock Reason" }),
|
|
1698
1890
|
message: state.locked_reason,
|
|
1699
1891
|
type: "info",
|
|
1700
|
-
confirmText: /* @__PURE__ */
|
|
1892
|
+
confirmText: /* @__PURE__ */ jsx16(TranslateText, { overrideNamespace: overrideNamespace || "system_widgets", children: "OK" }),
|
|
1701
1893
|
showNoButton: false,
|
|
1702
1894
|
showCancelButton: false
|
|
1703
1895
|
});
|
|
1704
1896
|
};
|
|
1705
1897
|
if (state.profile_archived) {
|
|
1706
|
-
return /* @__PURE__ */
|
|
1898
|
+
return /* @__PURE__ */ jsx16(
|
|
1707
1899
|
Chip,
|
|
1708
1900
|
{
|
|
1709
|
-
label: /* @__PURE__ */
|
|
1901
|
+
label: /* @__PURE__ */ jsx16(TranslateText, { overrideNamespace: overrideNamespace || "system_widgets", children: "Archived" }),
|
|
1710
1902
|
color: "default",
|
|
1711
1903
|
size: "small",
|
|
1712
1904
|
variant: "filled"
|
|
@@ -1714,10 +1906,10 @@ var UserStatusChipComponent = ({ overrideNamespace, state }) => {
|
|
|
1714
1906
|
);
|
|
1715
1907
|
}
|
|
1716
1908
|
if (state.profile_locked) {
|
|
1717
|
-
return /* @__PURE__ */
|
|
1909
|
+
return /* @__PURE__ */ jsx16(
|
|
1718
1910
|
Chip,
|
|
1719
1911
|
{
|
|
1720
|
-
label: /* @__PURE__ */
|
|
1912
|
+
label: /* @__PURE__ */ jsx16(TranslateText, { overrideNamespace: overrideNamespace || "system_widgets", children: "System Locked" }),
|
|
1721
1913
|
color: "error",
|
|
1722
1914
|
size: "small",
|
|
1723
1915
|
variant: "filled"
|
|
@@ -1725,30 +1917,30 @@ var UserStatusChipComponent = ({ overrideNamespace, state }) => {
|
|
|
1725
1917
|
);
|
|
1726
1918
|
}
|
|
1727
1919
|
if (state.excluded) {
|
|
1728
|
-
return /* @__PURE__ */
|
|
1920
|
+
return /* @__PURE__ */ jsx16(
|
|
1729
1921
|
Chip,
|
|
1730
1922
|
{
|
|
1731
|
-
label: /* @__PURE__ */
|
|
1923
|
+
label: /* @__PURE__ */ jsx16(TranslateText, { overrideNamespace: overrideNamespace || "system_widgets", children: "Excluded" }),
|
|
1732
1924
|
size: "small"
|
|
1733
1925
|
}
|
|
1734
1926
|
);
|
|
1735
1927
|
}
|
|
1736
1928
|
if (state.locked) {
|
|
1737
|
-
return /* @__PURE__ */
|
|
1929
|
+
return /* @__PURE__ */ jsx16(
|
|
1738
1930
|
Chip,
|
|
1739
1931
|
{
|
|
1740
|
-
label: /* @__PURE__ */
|
|
1932
|
+
label: /* @__PURE__ */ jsx16(TranslateText, { overrideNamespace: overrideNamespace || "system_widgets", children: "Locked" }),
|
|
1741
1933
|
color: "error",
|
|
1742
1934
|
size: "small",
|
|
1743
1935
|
onDelete: state.locked_reason ? handleShowReason : void 0,
|
|
1744
|
-
deleteIcon: state.locked_reason ? /* @__PURE__ */
|
|
1936
|
+
deleteIcon: state.locked_reason ? /* @__PURE__ */ jsx16(IconButton2, { size: "small", component: "span", sx: { p: 0.2 }, children: /* @__PURE__ */ jsx16(InfoOutlinedIcon, { fontSize: "small" }) }) : void 0
|
|
1745
1937
|
}
|
|
1746
1938
|
);
|
|
1747
1939
|
}
|
|
1748
|
-
return /* @__PURE__ */
|
|
1940
|
+
return /* @__PURE__ */ jsx16(
|
|
1749
1941
|
Chip,
|
|
1750
1942
|
{
|
|
1751
|
-
label: /* @__PURE__ */
|
|
1943
|
+
label: /* @__PURE__ */ jsx16(TranslateText, { overrideNamespace: overrideNamespace || "system_widgets", children: "Active" }),
|
|
1752
1944
|
color: "success",
|
|
1753
1945
|
size: "small",
|
|
1754
1946
|
variant: "outlined"
|
|
@@ -1758,32 +1950,32 @@ var UserStatusChipComponent = ({ overrideNamespace, state }) => {
|
|
|
1758
1950
|
|
|
1759
1951
|
// src/UI/components/data.display/UserRoleChipComponent.tsx
|
|
1760
1952
|
import { Chip as Chip2 } from "@mui/material";
|
|
1761
|
-
import { jsx as
|
|
1953
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1762
1954
|
var UserRoleChipComponent = ({ overrideNamespace, role }) => {
|
|
1763
1955
|
switch (role) {
|
|
1764
1956
|
case "superadmin":
|
|
1765
|
-
return /* @__PURE__ */
|
|
1957
|
+
return /* @__PURE__ */ jsx17(
|
|
1766
1958
|
Chip2,
|
|
1767
1959
|
{
|
|
1768
|
-
label: /* @__PURE__ */
|
|
1960
|
+
label: /* @__PURE__ */ jsx17(TranslateText, { overrideNamespace: overrideNamespace || "system_widgets", children: "Superadministrator" }),
|
|
1769
1961
|
color: "error",
|
|
1770
1962
|
size: "small"
|
|
1771
1963
|
}
|
|
1772
1964
|
);
|
|
1773
1965
|
case "admin":
|
|
1774
|
-
return /* @__PURE__ */
|
|
1966
|
+
return /* @__PURE__ */ jsx17(
|
|
1775
1967
|
Chip2,
|
|
1776
1968
|
{
|
|
1777
|
-
label: /* @__PURE__ */
|
|
1969
|
+
label: /* @__PURE__ */ jsx17(TranslateText, { overrideNamespace: overrideNamespace || "system_widgets", children: "Administrator" }),
|
|
1778
1970
|
color: "primary",
|
|
1779
1971
|
size: "small"
|
|
1780
1972
|
}
|
|
1781
1973
|
);
|
|
1782
1974
|
default:
|
|
1783
|
-
return /* @__PURE__ */
|
|
1975
|
+
return /* @__PURE__ */ jsx17(
|
|
1784
1976
|
Chip2,
|
|
1785
1977
|
{
|
|
1786
|
-
label: /* @__PURE__ */
|
|
1978
|
+
label: /* @__PURE__ */ jsx17(TranslateText, { overrideNamespace: overrideNamespace || "system_widgets", children: "User" }),
|
|
1787
1979
|
variant: "outlined",
|
|
1788
1980
|
size: "small"
|
|
1789
1981
|
}
|
|
@@ -1792,14 +1984,14 @@ var UserRoleChipComponent = ({ overrideNamespace, role }) => {
|
|
|
1792
1984
|
};
|
|
1793
1985
|
|
|
1794
1986
|
// src/UI/components/buttons/CopyClipboardButtonComponent.tsx
|
|
1795
|
-
import { useState as
|
|
1987
|
+
import { useState as useState12 } from "react";
|
|
1796
1988
|
import { IconButton as IconButton3 } from "@mui/material";
|
|
1797
1989
|
import CheckIcon from "@mui/icons-material/Check";
|
|
1798
1990
|
import CopyIcon from "@mui/icons-material/ContentCopy";
|
|
1799
1991
|
|
|
1800
1992
|
// src/UI/components/data.display/TranslatableTooltipComponent.tsx
|
|
1801
1993
|
import { Tooltip as Tooltip2 } from "@mui/material";
|
|
1802
|
-
import { jsx as
|
|
1994
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1803
1995
|
var TranslatableTooltipComponent = ({
|
|
1804
1996
|
overrideNamespace,
|
|
1805
1997
|
title,
|
|
@@ -1808,10 +2000,10 @@ var TranslatableTooltipComponent = ({
|
|
|
1808
2000
|
...props
|
|
1809
2001
|
}) => {
|
|
1810
2002
|
const { isTranslationMode } = useTranslationEdit();
|
|
1811
|
-
return /* @__PURE__ */
|
|
2003
|
+
return /* @__PURE__ */ jsx18(
|
|
1812
2004
|
Tooltip2,
|
|
1813
2005
|
{
|
|
1814
|
-
title: typeof title === "string" ? /* @__PURE__ */
|
|
2006
|
+
title: typeof title === "string" ? /* @__PURE__ */ jsx18(TranslateText, { overrideNamespace, children: title }) : title,
|
|
1815
2007
|
slotProps: {
|
|
1816
2008
|
popper: {
|
|
1817
2009
|
sx: isTranslationMode ? {
|
|
@@ -1825,13 +2017,13 @@ var TranslatableTooltipComponent = ({
|
|
|
1825
2017
|
},
|
|
1826
2018
|
leaveDelay: isTranslationMode ? 1e3 : 100,
|
|
1827
2019
|
...props,
|
|
1828
|
-
children: disableSpan ? children : /* @__PURE__ */
|
|
2020
|
+
children: disableSpan ? children : /* @__PURE__ */ jsx18("span", { children })
|
|
1829
2021
|
}
|
|
1830
2022
|
);
|
|
1831
2023
|
};
|
|
1832
2024
|
|
|
1833
2025
|
// src/UI/components/buttons/CopyClipboardButtonComponent.tsx
|
|
1834
|
-
import { jsx as
|
|
2026
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
1835
2027
|
var CopyClipboardButtonComponent = ({
|
|
1836
2028
|
overrideNamespace,
|
|
1837
2029
|
textToCopy,
|
|
@@ -1844,7 +2036,7 @@ var CopyClipboardButtonComponent = ({
|
|
|
1844
2036
|
sx,
|
|
1845
2037
|
...iconButtonProps
|
|
1846
2038
|
}) => {
|
|
1847
|
-
const [copied, setCopied] =
|
|
2039
|
+
const [copied, setCopied] = useState12(false);
|
|
1848
2040
|
const handleCopy = async (e) => {
|
|
1849
2041
|
e.stopPropagation();
|
|
1850
2042
|
if (!textToCopy) return;
|
|
@@ -1861,7 +2053,7 @@ var CopyClipboardButtonComponent = ({
|
|
|
1861
2053
|
console.error("Failed to copy text to clipboard:", error);
|
|
1862
2054
|
}
|
|
1863
2055
|
};
|
|
1864
|
-
return /* @__PURE__ */
|
|
2056
|
+
return /* @__PURE__ */ jsx19(TranslatableTooltipComponent, { title: copied ? copiedTooltipText : copyTooltipText, children: /* @__PURE__ */ jsx19("span", { children: /* @__PURE__ */ jsx19(
|
|
1865
2057
|
IconButton3,
|
|
1866
2058
|
{
|
|
1867
2059
|
size,
|
|
@@ -1869,25 +2061,13 @@ var CopyClipboardButtonComponent = ({
|
|
|
1869
2061
|
disabled: !textToCopy || iconButtonProps.disabled,
|
|
1870
2062
|
sx: { p: 0.25, ...sx },
|
|
1871
2063
|
...iconButtonProps,
|
|
1872
|
-
children: copied ? /* @__PURE__ */
|
|
2064
|
+
children: copied ? /* @__PURE__ */ jsx19(CheckIcon, { fontSize: size === "large" ? "medium" : "small", color: "success" }) : /* @__PURE__ */ jsx19(CopyIcon, { fontSize: size === "large" ? "medium" : "small" })
|
|
1873
2065
|
}
|
|
1874
2066
|
) }) });
|
|
1875
2067
|
};
|
|
1876
2068
|
|
|
1877
|
-
// src/context/UserSettingsProvider.tsx
|
|
1878
|
-
import { createContext as createContext12, useContext as useContext12, useEffect as useEffect8, useState as useState12, useCallback as useCallback6 } from "react";
|
|
1879
|
-
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1880
|
-
var UserSettingsContext = createContext12(void 0);
|
|
1881
|
-
var useUserSettings = () => {
|
|
1882
|
-
const context = useContext12(UserSettingsContext);
|
|
1883
|
-
if (!context) {
|
|
1884
|
-
throw new Error("useUserSettings should be used within the UserSettingsProvider");
|
|
1885
|
-
}
|
|
1886
|
-
return context;
|
|
1887
|
-
};
|
|
1888
|
-
|
|
1889
2069
|
// src/UI/components/data.display/UserPopoverComponent.tsx
|
|
1890
|
-
import { Fragment as Fragment2, jsx as
|
|
2070
|
+
import { Fragment as Fragment2, jsx as jsx20, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1891
2071
|
var useUserStatus = (supabase, userId, open) => {
|
|
1892
2072
|
const [lastSeenAt, setLastSeenAt] = useState13(null);
|
|
1893
2073
|
const [loading, setLoading] = useState13(true);
|
|
@@ -1992,7 +2172,7 @@ var UserPopoverComponent = ({
|
|
|
1992
2172
|
}, [open, userId, currentMembership?.id, activeCompanyId]);
|
|
1993
2173
|
const getStatusChip = () => {
|
|
1994
2174
|
if (!profileData) return null;
|
|
1995
|
-
return /* @__PURE__ */
|
|
2175
|
+
return /* @__PURE__ */ jsx20(UserStatusChipComponent, { state: { profile_archived: profileData.archived, profile_locked: profileData.locked, excluded: membershipData?.excluded || false, locked: membershipData?.locked || false, locked_reason: membershipData?.locked_reason || "" } });
|
|
1996
2176
|
};
|
|
1997
2177
|
const getStatusTypographyColor = (isOnline2, lastSeenAt2) => {
|
|
1998
2178
|
if (isOnline2) return "success";
|
|
@@ -2013,7 +2193,7 @@ var UserPopoverComponent = ({
|
|
|
2013
2193
|
return "inherit";
|
|
2014
2194
|
};
|
|
2015
2195
|
const canChat = currentMembership && membershipData && currentMembership.id !== membershipData.id;
|
|
2016
|
-
return /* @__PURE__ */
|
|
2196
|
+
return /* @__PURE__ */ jsx20(
|
|
2017
2197
|
Popover,
|
|
2018
2198
|
{
|
|
2019
2199
|
open,
|
|
@@ -2032,7 +2212,7 @@ var UserPopoverComponent = ({
|
|
|
2032
2212
|
}
|
|
2033
2213
|
}
|
|
2034
2214
|
},
|
|
2035
|
-
children: loading ? /* @__PURE__ */
|
|
2215
|
+
children: loading ? /* @__PURE__ */ jsx20(Box4, { sx: { display: "flex", justifyContent: "center", py: 4 }, children: /* @__PURE__ */ jsx20(CircularProgress2, { size: 28 }) }) : profileData ? /* @__PURE__ */ jsxs6(Box4, { sx: { display: "flex", flexDirection: "column" }, children: [
|
|
2036
2216
|
/* @__PURE__ */ jsxs6(
|
|
2037
2217
|
Box4,
|
|
2038
2218
|
{
|
|
@@ -2043,7 +2223,7 @@ var UserPopoverComponent = ({
|
|
|
2043
2223
|
bgcolor: "action.selected"
|
|
2044
2224
|
},
|
|
2045
2225
|
children: [
|
|
2046
|
-
coverUrl && /* @__PURE__ */
|
|
2226
|
+
coverUrl && /* @__PURE__ */ jsx20(
|
|
2047
2227
|
Box4,
|
|
2048
2228
|
{
|
|
2049
2229
|
component: "img",
|
|
@@ -2059,7 +2239,7 @@ var UserPopoverComponent = ({
|
|
|
2059
2239
|
}
|
|
2060
2240
|
}
|
|
2061
2241
|
),
|
|
2062
|
-
/* @__PURE__ */
|
|
2242
|
+
/* @__PURE__ */ jsx20(
|
|
2063
2243
|
IconButton4,
|
|
2064
2244
|
{
|
|
2065
2245
|
size: "small",
|
|
@@ -2077,7 +2257,7 @@ var UserPopoverComponent = ({
|
|
|
2077
2257
|
transform: "scale(1.1)"
|
|
2078
2258
|
}
|
|
2079
2259
|
},
|
|
2080
|
-
children: /* @__PURE__ */
|
|
2260
|
+
children: /* @__PURE__ */ jsx20(CloseIcon, { fontSize: "small" })
|
|
2081
2261
|
}
|
|
2082
2262
|
)
|
|
2083
2263
|
]
|
|
@@ -2085,7 +2265,7 @@ var UserPopoverComponent = ({
|
|
|
2085
2265
|
),
|
|
2086
2266
|
/* @__PURE__ */ jsxs6(Box4, { sx: { p: 2, pt: 0 }, children: [
|
|
2087
2267
|
/* @__PURE__ */ jsxs6(Stack, { direction: "row", spacing: 1.5, sx: { alignItems: "flex-end", mt: "-18px", mb: 1 }, children: [
|
|
2088
|
-
/* @__PURE__ */
|
|
2268
|
+
/* @__PURE__ */ jsx20(
|
|
2089
2269
|
Badge,
|
|
2090
2270
|
{
|
|
2091
2271
|
overlap: "circular",
|
|
@@ -2122,7 +2302,7 @@ var UserPopoverComponent = ({
|
|
|
2122
2302
|
}
|
|
2123
2303
|
}
|
|
2124
2304
|
},
|
|
2125
|
-
children: /* @__PURE__ */
|
|
2305
|
+
children: /* @__PURE__ */ jsx20(
|
|
2126
2306
|
Avatar,
|
|
2127
2307
|
{
|
|
2128
2308
|
src: avatarUrl || coverUrl || void 0,
|
|
@@ -2142,52 +2322,52 @@ var UserPopoverComponent = ({
|
|
|
2142
2322
|
}
|
|
2143
2323
|
),
|
|
2144
2324
|
/* @__PURE__ */ jsxs6(Box4, { sx: { overflow: "hidden", pb: 0.5 }, children: [
|
|
2145
|
-
/* @__PURE__ */
|
|
2146
|
-
membershipData?.employee_post && /* @__PURE__ */
|
|
2325
|
+
/* @__PURE__ */ jsx20(Typography2, { variant: "subtitle1", sx: { fontWeight: 600, lineHeight: 1.2 }, noWrap: true, children: profileData.display_name || `${profileData.first_name || ""} ${profileData.last_name || ""}` }),
|
|
2326
|
+
membershipData?.employee_post && /* @__PURE__ */ jsx20(Typography2, { variant: "body2", color: "text.secondary", noWrap: true, children: membershipData.employee_post })
|
|
2147
2327
|
] })
|
|
2148
2328
|
] }),
|
|
2149
2329
|
/* @__PURE__ */ jsxs6(Stack, { direction: "row", spacing: 1, sx: { my: 1, flexWrap: "wrap", gap: 0.5 }, children: [
|
|
2150
2330
|
getStatusChip(),
|
|
2151
|
-
/* @__PURE__ */
|
|
2331
|
+
/* @__PURE__ */ jsx20(UserRoleChipComponent, { role: membershipData?.role || "user" })
|
|
2152
2332
|
] }),
|
|
2153
|
-
/* @__PURE__ */
|
|
2333
|
+
/* @__PURE__ */ jsx20(Divider, { sx: { my: 1.5 } }),
|
|
2154
2334
|
/* @__PURE__ */ jsxs6(Stack, { spacing: 1, sx: { fontSize: "0.875rem", mb: 1.5 }, children: [
|
|
2155
2335
|
/* @__PURE__ */ jsxs6(Stack, { direction: "row", spacing: 1, sx: { alignItems: "center" }, color: "text.secondary", children: [
|
|
2156
|
-
/* @__PURE__ */
|
|
2157
|
-
/* @__PURE__ */
|
|
2158
|
-
/* @__PURE__ */
|
|
2336
|
+
/* @__PURE__ */ jsx20(AccessTimeIcon, { fontSize: "small", color: getStatusIconColor(isOnline, lastSeenAt) }),
|
|
2337
|
+
/* @__PURE__ */ jsx20(Typography2, { variant: "body2", color: getStatusTypographyColor(isOnline, lastSeenAt), children: isOnline ? /* @__PURE__ */ jsx20(TranslateText, { overrideNamespace: overrideNamespace || "form_components", children: "Online" }) : lastSeenAt ? /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
2338
|
+
/* @__PURE__ */ jsx20(TranslateText, { overrideNamespace: overrideNamespace || "form_components", children: "Last seen" }),
|
|
2159
2339
|
":",
|
|
2160
2340
|
" ",
|
|
2161
|
-
/* @__PURE__ */
|
|
2162
|
-
] }) : /* @__PURE__ */
|
|
2341
|
+
/* @__PURE__ */ jsx20("strong", { children: formatRelativeTime(lastSeenAt) })
|
|
2342
|
+
] }) : /* @__PURE__ */ jsx20(TranslateText, { overrideNamespace: overrideNamespace || "form_components", children: "Offline" }) })
|
|
2163
2343
|
] }),
|
|
2164
2344
|
profileData.email && /* @__PURE__ */ jsxs6(Stack, { direction: "row", spacing: 1, sx: { alignItems: "center" }, color: "text.secondary", children: [
|
|
2165
|
-
/* @__PURE__ */
|
|
2166
|
-
/* @__PURE__ */
|
|
2167
|
-
/* @__PURE__ */
|
|
2345
|
+
/* @__PURE__ */ jsx20(EmailIcon, { fontSize: "small" }),
|
|
2346
|
+
/* @__PURE__ */ jsx20(Typography2, { variant: "body2", color: "text.primary", noWrap: true, sx: { flexGrow: 1 }, children: profileData.email }),
|
|
2347
|
+
/* @__PURE__ */ jsx20(CopyClipboardButtonComponent, { textToCopy: profileData.email })
|
|
2168
2348
|
] }),
|
|
2169
2349
|
membershipData?.employee_post && /* @__PURE__ */ jsxs6(Stack, { direction: "row", spacing: 1, sx: { alignItems: "center" }, color: "text.secondary", children: [
|
|
2170
|
-
/* @__PURE__ */
|
|
2171
|
-
/* @__PURE__ */
|
|
2172
|
-
/* @__PURE__ */
|
|
2350
|
+
/* @__PURE__ */ jsx20(WorkIcon, { fontSize: "small" }),
|
|
2351
|
+
/* @__PURE__ */ jsx20(Typography2, { variant: "body2", color: "text.primary", noWrap: true, sx: { flexGrow: 1 }, children: membershipData.employee_post }),
|
|
2352
|
+
/* @__PURE__ */ jsx20(CopyClipboardButtonComponent, { textToCopy: membershipData.employee_post })
|
|
2173
2353
|
] }),
|
|
2174
2354
|
profileData.phone && /* @__PURE__ */ jsxs6(Stack, { direction: "row", spacing: 1, sx: { alignItems: "center" }, color: "text.secondary", children: [
|
|
2175
|
-
/* @__PURE__ */
|
|
2176
|
-
/* @__PURE__ */
|
|
2355
|
+
/* @__PURE__ */ jsx20(PhoneIcon, { fontSize: "small" }),
|
|
2356
|
+
/* @__PURE__ */ jsx20(Typography2, { variant: "body2", color: "text.primary", children: profileData.phone })
|
|
2177
2357
|
] }),
|
|
2178
2358
|
profileData.birthday && /* @__PURE__ */ jsxs6(Stack, { direction: "row", spacing: 1, sx: { alignItems: "center" }, color: "text.secondary", children: [
|
|
2179
|
-
/* @__PURE__ */
|
|
2180
|
-
/* @__PURE__ */
|
|
2359
|
+
/* @__PURE__ */ jsx20(CakeIcon, { fontSize: "small" }),
|
|
2360
|
+
/* @__PURE__ */ jsx20(Typography2, { variant: "body2", color: "text.primary", children: formatDate(profileData.birthday) })
|
|
2181
2361
|
] }),
|
|
2182
2362
|
membershipData?.created_at && /* @__PURE__ */ jsxs6(Stack, { direction: "row", spacing: 1, sx: { alignItems: "center" }, color: "text.secondary", children: [
|
|
2183
|
-
/* @__PURE__ */
|
|
2363
|
+
/* @__PURE__ */ jsx20(CalendarIcon, { fontSize: "small" }),
|
|
2184
2364
|
/* @__PURE__ */ jsxs6(Typography2, { variant: "body2", color: "text.primary", children: [
|
|
2185
|
-
/* @__PURE__ */
|
|
2365
|
+
/* @__PURE__ */ jsx20(TranslateText, { overrideNamespace: overrideNamespace || "form_components", children: "In company from" }),
|
|
2186
2366
|
": ",
|
|
2187
2367
|
formatDate(membershipData.created_at)
|
|
2188
2368
|
] })
|
|
2189
2369
|
] }),
|
|
2190
|
-
profileData.description && /* @__PURE__ */
|
|
2370
|
+
profileData.description && /* @__PURE__ */ jsx20(
|
|
2191
2371
|
Typography2,
|
|
2192
2372
|
{
|
|
2193
2373
|
variant: "caption",
|
|
@@ -2203,28 +2383,28 @@ var UserPopoverComponent = ({
|
|
|
2203
2383
|
}
|
|
2204
2384
|
)
|
|
2205
2385
|
] }),
|
|
2206
|
-
/* @__PURE__ */
|
|
2386
|
+
/* @__PURE__ */ jsx20(Divider, { sx: { my: 1 } }),
|
|
2207
2387
|
/* @__PURE__ */ jsxs6(Stack, { direction: "row", spacing: 1, sx: { justifyContent: "space-around", pt: 0.5 }, children: [
|
|
2208
|
-
/* @__PURE__ */
|
|
2209
|
-
/* @__PURE__ */
|
|
2210
|
-
/* @__PURE__ */
|
|
2388
|
+
/* @__PURE__ */ jsx20(TranslatableTooltipComponent, { title: /* @__PURE__ */ jsx20(TranslateText, { overrideNamespace: overrideNamespace || "form_components", children: "Send a notification" }), children: /* @__PURE__ */ jsx20(IconButton4, { size: "small", color: "primary", children: /* @__PURE__ */ jsx20(NotificationIcon, { fontSize: "small" }) }) }),
|
|
2389
|
+
/* @__PURE__ */ jsx20(TranslatableTooltipComponent, { title: /* @__PURE__ */ jsx20(TranslateText, { overrideNamespace: overrideNamespace || "form_components", children: "Set a task" }), children: /* @__PURE__ */ jsx20(IconButton4, { size: "small", color: "primary", children: /* @__PURE__ */ jsx20(TaskIcon, { fontSize: "small" }) }) }),
|
|
2390
|
+
/* @__PURE__ */ jsx20(TranslatableTooltipComponent, { title: /* @__PURE__ */ jsx20(TranslateText, { overrideNamespace: overrideNamespace || "form_components", children: "Start a chat" }), children: /* @__PURE__ */ jsx20(
|
|
2211
2391
|
IconButton4,
|
|
2212
2392
|
{
|
|
2213
2393
|
size: "small",
|
|
2214
2394
|
color: "primary",
|
|
2215
2395
|
disabled: !canChat,
|
|
2216
2396
|
onClick: () => membershipData && openChatWithUser(membershipData.id),
|
|
2217
|
-
children: /* @__PURE__ */
|
|
2397
|
+
children: /* @__PURE__ */ jsx20(ChatIcon, { fontSize: "small" })
|
|
2218
2398
|
}
|
|
2219
2399
|
) })
|
|
2220
2400
|
] })
|
|
2221
2401
|
] })
|
|
2222
|
-
] }) : /* @__PURE__ */
|
|
2402
|
+
] }) : /* @__PURE__ */ jsx20(Box4, { sx: { p: 2 }, children: /* @__PURE__ */ jsx20(
|
|
2223
2403
|
Typography2,
|
|
2224
2404
|
{
|
|
2225
2405
|
color: "error",
|
|
2226
2406
|
variant: "body2",
|
|
2227
|
-
children: /* @__PURE__ */
|
|
2407
|
+
children: /* @__PURE__ */ jsx20(TranslateText, { overrideNamespace: overrideNamespace || "form_components", children: "Failed to load user data" })
|
|
2228
2408
|
}
|
|
2229
2409
|
) })
|
|
2230
2410
|
}
|
|
@@ -2259,6 +2439,8 @@ export {
|
|
|
2259
2439
|
useConfirmation,
|
|
2260
2440
|
AppSettingsProvider,
|
|
2261
2441
|
useAppSettings,
|
|
2442
|
+
UserSettingsProvider,
|
|
2443
|
+
useUserSettings,
|
|
2262
2444
|
Providers,
|
|
2263
2445
|
UserStatusChipComponent,
|
|
2264
2446
|
UserRoleChipComponent,
|