@homefile/components-v2 2.39.8 → 2.39.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/components/appBar/PeopleConnected.js +2 -2
- package/dist/components/sharedHomePanel/SharedHomeHeader.js +2 -2
- package/dist/hooks/propertyTiles/useRecordsInputs.js +14 -3
- package/dist/interfaces/propertyTiles/RecordsInputs.interface.d.ts +3 -0
- package/dist/proxies/propertyTiles/recordsInputs.proxy.js +3 -0
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { t } from 'i18next';
|
|
3
3
|
import { Flex, Img, Tooltip } from '@chakra-ui/react';
|
|
4
|
-
import {
|
|
4
|
+
import { ShareHome } from '../../assets/images';
|
|
5
5
|
import { NumberBadge } from '../../components';
|
|
6
6
|
import { useWindowDimensions } from '../../hooks';
|
|
7
7
|
import { MOBILE_WIDTH } from '../../utils';
|
|
8
8
|
export const PeopleConnected = ({ onClick, total }) => {
|
|
9
9
|
const { windowDimensions: { width }, } = useWindowDimensions();
|
|
10
10
|
const isMobile = width < MOBILE_WIDTH;
|
|
11
|
-
return (_jsx(Tooltip, { label: t('tooltips.shareHome'), children: _jsxs(Flex, { gap: "1", as: "button", onClick: onClick, id: "shareWithOthers", "data-testid": "people-connected", children: [_jsx(Img, { src:
|
|
11
|
+
return (_jsx(Tooltip, { label: t('tooltips.shareHome'), children: _jsxs(Flex, { gap: "1", as: "button", onClick: onClick, id: "shareWithOthers", "data-testid": "people-connected", children: [_jsx(Img, { src: ShareHome, "aria-label": t('tooltips.shareHome'), h: "26px", w: "auto" }), !isMobile && _jsx(NumberBadge, { total: total })] }) }));
|
|
12
12
|
};
|
|
@@ -3,9 +3,9 @@ import { useState } from 'react';
|
|
|
3
3
|
import { t } from 'i18next';
|
|
4
4
|
import { Box, DrawerHeader } from '@chakra-ui/react';
|
|
5
5
|
import { HelpButton, PanelHeader, RolesHelpModal } from '../../components';
|
|
6
|
-
import {
|
|
6
|
+
import { ShareHome } from '../../assets/images';
|
|
7
7
|
export const SharedHomeHeader = ({ children, onClose }) => {
|
|
8
8
|
const [showChildren, setShowChildren] = useState(false);
|
|
9
9
|
const handleHelpClick = () => setShowChildren(!showChildren);
|
|
10
|
-
return (_jsxs(DrawerHeader, { p: "0", children: [_jsx(PanelHeader, { handleCloseButton: onClose, icon:
|
|
10
|
+
return (_jsxs(DrawerHeader, { p: "0", children: [_jsx(PanelHeader, { handleCloseButton: onClose, icon: ShareHome, title: t('shareHome.title'), children: _jsx(Box, { mr: "base", position: "relative", children: _jsx(HelpButton, { onClick: handleHelpClick, children: showChildren && (_jsx(RolesHelpModal, { top: "40px", right: "0", onClose: handleHelpClick })) }) }) }), children] }));
|
|
11
11
|
};
|
|
@@ -5,12 +5,19 @@ export const useRecordsInputs = ({ data = {}, session = '' }) => {
|
|
|
5
5
|
const proxy = recordsInputsProxy;
|
|
6
6
|
const proxyToDB = recordsInputsToDBProxy;
|
|
7
7
|
const handleChange = (e) => {
|
|
8
|
-
var _a;
|
|
8
|
+
var _a, _b, _c;
|
|
9
9
|
const { name, value } = e.target;
|
|
10
10
|
proxy.data[name] = value;
|
|
11
|
+
// dirty tracking
|
|
12
|
+
const initial = (_b = (_a = proxy.initialData) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : '';
|
|
13
|
+
const next = value !== null && value !== void 0 ? value : '';
|
|
14
|
+
const isFieldDirty = next !== (initial !== null && initial !== void 0 ? initial : '');
|
|
15
|
+
proxy.dirtyFields[name] = isFieldDirty;
|
|
16
|
+
// recompute global dirty (cheap)
|
|
17
|
+
proxy.isDirty = Object.values(proxy.dirtyFields).some(Boolean);
|
|
11
18
|
const dbProp = propertyRecordsToDB[session][name];
|
|
12
19
|
if (session === 'community') {
|
|
13
|
-
proxyToDB.data = Object.assign(Object.assign({}, proxyToDB.data), { neighborhood: Object.assign(Object.assign({}, ((
|
|
20
|
+
proxyToDB.data = Object.assign(Object.assign({}, proxyToDB.data), { neighborhood: Object.assign(Object.assign({}, ((_c = proxyToDB.data.neighborhood) !== null && _c !== void 0 ? _c : {})), { [dbProp]: value }) });
|
|
14
21
|
return;
|
|
15
22
|
}
|
|
16
23
|
proxyToDB.data[dbProp] = dbDataParser(dbProp, value);
|
|
@@ -18,7 +25,11 @@ export const useRecordsInputs = ({ data = {}, session = '' }) => {
|
|
|
18
25
|
useEffect(() => {
|
|
19
26
|
proxy.session = session;
|
|
20
27
|
proxy.data = data;
|
|
21
|
-
|
|
28
|
+
// new for dirty fields
|
|
29
|
+
proxy.initialData = data;
|
|
30
|
+
proxy.dirtyFields = {};
|
|
31
|
+
proxy.isDirty = false;
|
|
32
|
+
}, [session, data]);
|
|
22
33
|
return {
|
|
23
34
|
handleChange,
|
|
24
35
|
};
|
|
@@ -5,6 +5,9 @@ export interface RecordsInputsI extends EditCallbackI {
|
|
|
5
5
|
export interface RecordsInputsProxyI {
|
|
6
6
|
data: EditCallbackI['data'];
|
|
7
7
|
session: EditCallbackI['session'];
|
|
8
|
+
initialData: EditCallbackI['data'];
|
|
9
|
+
dirtyFields: Record<string, boolean>;
|
|
10
|
+
isDirty: boolean;
|
|
8
11
|
}
|
|
9
12
|
type DBData = string | number | boolean | Record<string, string>;
|
|
10
13
|
export interface recordsInputsToDBProxyI {
|