@homefile/components-v2 2.17.2 → 2.17.4
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/forms/dynamicForm/fields/uiFields/TileBody.tsx +0 -1
- package/dist/components/homeAssistant/monitorAlerts/AlertHeader.d.ts +3 -1
- package/dist/components/homeAssistant/monitorAlerts/AlertHeader.js +3 -3
- package/dist/components/homeAssistant/monitorAlerts/BackendAlert.d.ts +2 -0
- package/dist/components/homeAssistant/monitorAlerts/BackendAlert.js +9 -0
- package/dist/components/homeAssistant/monitorAlerts/BackendAlertCard.d.ts +3 -0
- package/dist/components/homeAssistant/monitorAlerts/BackendAlertCard.js +22 -0
- package/dist/components/homeAssistant/monitorAlerts/index.d.ts +2 -0
- package/dist/components/homeAssistant/monitorAlerts/index.js +2 -0
- package/dist/helpers/homeAssistant/HomeAssistant.helper.d.ts +9 -0
- package/dist/helpers/homeAssistant/HomeAssistant.helper.js +27 -1
- package/dist/interfaces/forms/dynamicForm/DynamicForm.interface.d.ts +2 -2
- package/dist/interfaces/homeAssistant/BackendAlert.interface.d.ts +7 -0
- package/dist/interfaces/homeAssistant/BackendAlert.interface.js +1 -0
- package/dist/interfaces/homeAssistant/BackendAlertCard.interface.d.ts +9 -0
- package/dist/interfaces/homeAssistant/BackendAlertCard.interface.js +1 -0
- package/dist/interfaces/homeAssistant/index.d.ts +2 -0
- package/dist/interfaces/homeAssistant/index.js +2 -0
- package/dist/mocks/forms/dynamicForm.mock.d.ts +1 -0
- package/dist/mocks/forms/dynamicForm.mock.js +11 -0
- package/dist/stories/homeAssistant/monitorAlerts/BackendAlert.stories.d.ts +5 -0
- package/dist/stories/homeAssistant/monitorAlerts/BackendAlert.stories.js +14 -0
- package/dist/stories/homeAssistant/monitorAlerts/MonitorAlerts.stories.d.ts +5 -0
- package/dist/stories/homeAssistant/monitorAlerts/MonitorAlerts.stories.js +12 -0
- package/dist/utils/Alerts.utils.d.ts +7 -0
- package/dist/utils/Alerts.utils.js +10 -0
- package/package.json +1 -1
- package/src/components/forms/dynamicForm/fields/uiFields/TileBody.tsx +0 -1
- package/src/components/homeAssistant/monitorAlerts/AlertHeader.tsx +15 -4
- package/src/components/homeAssistant/monitorAlerts/BackendAlert.tsx +22 -0
- package/src/components/homeAssistant/monitorAlerts/BackendAlertCard.tsx +51 -0
- package/src/components/homeAssistant/monitorAlerts/index.ts +2 -0
- package/src/helpers/homeAssistant/HomeAssistant.helper.tsx +36 -0
- package/src/interfaces/forms/dynamicForm/DynamicForm.interface.ts +2 -0
- package/src/interfaces/homeAssistant/BackendAlert.interface.ts +16 -0
- package/src/interfaces/homeAssistant/BackendAlertCard.interface.ts +9 -0
- package/src/interfaces/homeAssistant/index.ts +2 -0
- package/src/mocks/forms/dynamicForm.mock.ts +13 -0
- package/src/stories/homeAssistant/monitorAlerts/BackendAlert.stories.tsx +17 -0
- package/src/stories/homeAssistant/monitorAlerts/MonitorAlerts.stories.tsx +15 -0
- package/src/utils/Alerts.utils.ts +12 -0
- /package/dist/stories/homeAssistant/monitorAlerts/{HomeAssistant.stories.d.ts → BaseAlertCard.stories.d.ts} +0 -0
- /package/dist/stories/homeAssistant/monitorAlerts/{HomeAssistant.stories.js → BaseAlertCard.stories.js} +0 -0
- /package/src/stories/homeAssistant/monitorAlerts/{HomeAssistant.stories.tsx → BaseAlertCard.stories.tsx} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { t } from 'i18next';
|
|
3
|
-
import { Flex, Center, Image, Text } from '@chakra-ui/react';
|
|
3
|
+
import { Flex, Center, Image, Text, Box } from '@chakra-ui/react';
|
|
4
4
|
import { Exclamation } from '../../../assets/images';
|
|
5
|
-
export const AlertHeader = () => {
|
|
6
|
-
return (_jsx(Flex, { justifyContent: "space-between", px: "base", py: "1", bg:
|
|
5
|
+
export const AlertHeader = ({ bg = 'error.2' }) => {
|
|
6
|
+
return (_jsx(Flex, { justifyContent: "space-between", px: "base", py: "1", bg: bg, borderTopRadius: "lg", align: "center", children: _jsxs(Flex, { align: "center", gap: "2", children: [_jsxs(Center, { p: "1", position: "relative", h: "18px", w: "18px", children: [_jsx(Box, { borderRadius: "full", bg: "neutral.white", opacity: 0.3, h: "full", w: "full", position: "absolute", top: "50%", left: "50%", transform: "translate(-50%, -50%)" }), _jsx(Image, { src: Exclamation, h: "100%", w: "auto" })] }), _jsx(Text, { color: "white", fontSize: "sm", fontWeight: "medium", textTransform: "uppercase", children: t('homeAssistant.monitorAlerts.homeAction') })] }) }));
|
|
7
7
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { BackendAlertCard } from '../..';
|
|
3
|
+
import { getCategoryStyles } from '../../../utils/Alerts.utils';
|
|
4
|
+
export const BackendAlert = ({ category, form }) => {
|
|
5
|
+
var _a, _b, _c;
|
|
6
|
+
const { headerBg, alertIcon, alertIconBg, alertTitle } = getCategoryStyles(category);
|
|
7
|
+
const alertHeader = form === null || form === void 0 ? void 0 : form.find((item) => item.type === 'alertHeader');
|
|
8
|
+
return (_jsx(BackendAlertCard, { alertBg: headerBg, alertIcon: alertIcon, alertTitle: alertTitle, bg: alertIconBg, icon: (_a = alertHeader === null || alertHeader === void 0 ? void 0 : alertHeader.icon) !== null && _a !== void 0 ? _a : '', title: (_b = alertHeader === null || alertHeader === void 0 ? void 0 : alertHeader.label) !== null && _b !== void 0 ? _b : '', description: (_c = alertHeader === null || alertHeader === void 0 ? void 0 : alertHeader.description) !== null && _c !== void 0 ? _c : '', children: "content" }));
|
|
9
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { BackendAlertCardI } from '../../../interfaces';
|
|
3
|
+
export declare const BackendAlertCard: ({ alertBg, alertIcon, alertTitle, children, icon, ...props }: PropsWithChildren<BackendAlertCardI>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { t } from 'i18next';
|
|
14
|
+
import { Box, Button, Collapse, Flex, useDisclosure } from '@chakra-ui/react';
|
|
15
|
+
import { AlertHeader, AlertTemplate, AlertTitle } from '../..';
|
|
16
|
+
import { Warranty } from '../../../assets/images';
|
|
17
|
+
import { fieldIcons } from '../../../helpers';
|
|
18
|
+
export const BackendAlertCard = (_a) => {
|
|
19
|
+
var { alertBg = 'error.2', alertIcon = Warranty, alertTitle = t('homeAssistant.monitorAlerts.protection'), children, icon = 'warning' } = _a, props = __rest(_a, ["alertBg", "alertIcon", "alertTitle", "children", "icon"]);
|
|
20
|
+
const { isOpen, onToggle } = useDisclosure();
|
|
21
|
+
return (_jsxs(Box, { display: "flex", flexDir: "column", bg: "neutral.white", boxShadow: "lg", borderRadius: "lg", overflow: "hidden", maxW: "420px", children: [_jsx(AlertHeader, { bg: alertBg }), _jsx(AlertTitle, { alertIcon: alertIcon, alertTitle: alertTitle }), _jsx(AlertTemplate, Object.assign({}, props, { icon: fieldIcons[icon] })), _jsx(Collapse, { in: isOpen, animateOpacity: true, children: _jsx(Box, { p: "base", bg: "lightBlue.1", children: children }) }), _jsx(Flex, { py: "base", bg: "lightBlue.1", justify: "flex-end", children: _jsx(Button, { variant: "leftRounded", w: "fit-content", px: "8", fontSize: "sm", fontWeight: "medium", onClick: onToggle, bg: isOpen ? 'blue.8' : 'blue.2', children: t(`homeAssistant.monitorAlerts.${isOpen ? 'collapse' : 'review'}`) }) })] }));
|
|
22
|
+
};
|
|
@@ -3,6 +3,8 @@ export * from './AlertHeader';
|
|
|
3
3
|
export * from './AlertTemplate';
|
|
4
4
|
export * from './AlertTitle';
|
|
5
5
|
export * from './BaseAlertCard';
|
|
6
|
+
export * from './BackendAlert';
|
|
7
|
+
export * from './BackendAlertCard';
|
|
6
8
|
export * from './WeatherWidget';
|
|
7
9
|
export * from './HomefileMonitoring';
|
|
8
10
|
export * from './MonitorAlerts';
|
|
@@ -3,6 +3,8 @@ export * from './AlertHeader';
|
|
|
3
3
|
export * from './AlertTemplate';
|
|
4
4
|
export * from './AlertTitle';
|
|
5
5
|
export * from './BaseAlertCard';
|
|
6
|
+
export * from './BackendAlert';
|
|
7
|
+
export * from './BackendAlertCard';
|
|
6
8
|
export * from './WeatherWidget';
|
|
7
9
|
export * from './HomefileMonitoring';
|
|
8
10
|
export * from './MonitorAlerts';
|
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import { HomeAssistantStepI } from '../../interfaces';
|
|
2
|
+
import { AlertCategory } from '../../interfaces/homeAssistant/BackendAlert.interface';
|
|
2
3
|
export declare const homeAssistantSteps: Array<HomeAssistantStepI>;
|
|
4
|
+
interface CategoryConfigI {
|
|
5
|
+
label: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
color: string;
|
|
8
|
+
accent: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const CATEGORY_CONFIG: Record<AlertCategory, CategoryConfigI>;
|
|
11
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fire, House, LargeAppliances, Target, Temperature, Water, } from '../../assets/images';
|
|
1
|
+
import { Fire, GearTime, House, LargeAppliances, Target, Temperature, Water, } from '../../assets/images';
|
|
2
2
|
export const homeAssistantSteps = [
|
|
3
3
|
{
|
|
4
4
|
title: 'Goals',
|
|
@@ -25,3 +25,29 @@ export const homeAssistantSteps = [
|
|
|
25
25
|
icon: Water,
|
|
26
26
|
},
|
|
27
27
|
];
|
|
28
|
+
export const CATEGORY_CONFIG = {
|
|
29
|
+
safeguard: {
|
|
30
|
+
label: 'Protection Monitor',
|
|
31
|
+
color: '#DB1DA1',
|
|
32
|
+
accent: '#FDDDF8',
|
|
33
|
+
icon: GearTime,
|
|
34
|
+
},
|
|
35
|
+
maintain: {
|
|
36
|
+
label: 'Maintenance Monitor',
|
|
37
|
+
color: '#8CC421',
|
|
38
|
+
accent: '#B9DEF2',
|
|
39
|
+
icon: GearTime,
|
|
40
|
+
},
|
|
41
|
+
budget: {
|
|
42
|
+
label: 'Budget Monitor',
|
|
43
|
+
color: '#1D8BDB',
|
|
44
|
+
accent: '#B9DEF2',
|
|
45
|
+
icon: GearTime,
|
|
46
|
+
},
|
|
47
|
+
improve: {
|
|
48
|
+
label: 'Improvement Monitor',
|
|
49
|
+
color: '#8516A7',
|
|
50
|
+
accent: '#B9DEF2',
|
|
51
|
+
icon: GearTime,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AIGridFieldI, FolderFileI, MenuItemI, PartnerFooterI, TileCtaI } from '../..';
|
|
2
|
-
export type KindTypes = 'ai-image' | 'ai-grid' | 'checkbox' | 'checkbox-agreement' | 'checkbox-group' | 'currency' | 'date' | 'email' | 'file' | 'grid' | 'group' | 'hidden' | 'notes' | 'number' | 'radio' | 'rating' | 'select' | 'string' | 'switch' | 'telephone' | 'text' | 'textarea' | 'default' | UIKindTypes | HomeItemTypes;
|
|
1
|
+
import { AIGridFieldI, AlertFieldType, FolderFileI, MenuItemI, PartnerFooterI, TileCtaI } from '../..';
|
|
2
|
+
export type KindTypes = 'ai-image' | 'ai-grid' | 'checkbox' | 'checkbox-agreement' | 'checkbox-group' | 'currency' | 'date' | 'email' | 'file' | 'grid' | 'group' | 'hidden' | 'notes' | 'number' | 'radio' | 'rating' | 'select' | 'string' | 'switch' | 'telephone' | 'text' | 'textarea' | 'default' | UIKindTypes | HomeItemTypes | AlertFieldType;
|
|
3
3
|
export type UIKindTypes = 'tile-body' | 'tile-body-logo' | 'tile-body-header' | 'tile-body-section' | 'tile-body-section-grid' | 'tile-body-partner-image' | 'tile-body-description' | 'tile-form' | 'tile-body-action' | 'vertical-icon' | 'primary-cta' | 'secondary-cta';
|
|
4
4
|
export type HomeItemTypes = 'appliances' | 'images' | 'guidelines' | 'item-related' | 'item-icon-btn';
|
|
5
5
|
export type IconTypes = 'barcode' | 'battery' | 'billing' | 'book' | 'book-opened' | 'calc' | 'calendar' | 'check' | 'co2' | 'contact' | 'date' | 'default' | 'detector' | 'electricity' | 'goldbars' | 'heart' | 'image' | 'notes' | 'palette' | 'people' | 'price' | 'rating' | 'receipt' | 'registry' | 'sprinkler' | 'tools' | 'wind' | '68' | 'calendar2' | 'water' | 'calendar-drop' | 'umbrella' | 'heater' | 'roof' | 'foundation' | 'solar-panel' | 'pool' | 'drop' | 'mobile-drop' | 'light' | 'plate' | 'pressure-washer' | 'house' | 'target' | 'title' | 'company' | UIIconTypes;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DynamicFormI } from '..';
|
|
2
|
+
export type AlertCategory = 'safeguard' | 'maintain' | 'budget' | 'improve';
|
|
3
|
+
export type AlertTabType = 'details' | 'filter-size' | 'purchase' | 'hire-out';
|
|
4
|
+
export type AlertFieldType = 'alertHeader' | 'text' | 'iconSection' | 'tabList' | 'list';
|
|
5
|
+
export interface BackendAlertI extends DynamicFormI {
|
|
6
|
+
category: AlertCategory;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './ApplianceButton.interface';
|
|
2
2
|
export * from './ApplianceSteps.interface';
|
|
3
|
+
export * from './BackendAlert.interface';
|
|
3
4
|
export * from './BaseAlertCard.interface';
|
|
5
|
+
export * from './BackendAlertCard.interface';
|
|
4
6
|
export * from './HomeAssistantButton.interface';
|
|
5
7
|
export * from './HomeAssistantPanel.interface';
|
|
6
8
|
export * from './HomeAssistantStepper.interface';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './ApplianceButton.interface';
|
|
2
2
|
export * from './ApplianceSteps.interface';
|
|
3
|
+
export * from './BackendAlert.interface';
|
|
3
4
|
export * from './BaseAlertCard.interface';
|
|
5
|
+
export * from './BackendAlertCard.interface';
|
|
4
6
|
export * from './HomeAssistantButton.interface';
|
|
5
7
|
export * from './HomeAssistantPanel.interface';
|
|
6
8
|
export * from './HomeAssistantStepper.interface';
|
|
@@ -839,3 +839,14 @@ export const unknownFormMock = {
|
|
|
839
839
|
updatedAt: '2025-04-17T19:26:39.435Z',
|
|
840
840
|
__v: 0,
|
|
841
841
|
};
|
|
842
|
+
export const alertFieldsMock = [
|
|
843
|
+
{
|
|
844
|
+
id: faker.database.mongodbObjectId(),
|
|
845
|
+
name: 'Filter',
|
|
846
|
+
label: 'Time to change your heating & cooling air filter.',
|
|
847
|
+
description: 'Changing your air filter every 30 days ensures efficient system performance and improves indoor air quality by trapping dust and allergens.',
|
|
848
|
+
icon: 'wind',
|
|
849
|
+
value: false,
|
|
850
|
+
type: 'alertHeader',
|
|
851
|
+
},
|
|
852
|
+
];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
import { BackendAlertI } from '../../../interfaces';
|
|
3
|
+
declare const _default: Meta<BackendAlertI>;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const BackendAlertComponent: (args: BackendAlertI) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { BackendAlert } from '../../../components';
|
|
3
|
+
import { alertFieldsMock } from '../../../mocks';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Components/HomeAssistant/MonitorAlerts',
|
|
6
|
+
component: BackendAlert,
|
|
7
|
+
args: {
|
|
8
|
+
category: 'budget',
|
|
9
|
+
form: alertFieldsMock,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
export const BackendAlertComponent = (args) => {
|
|
13
|
+
return _jsx(BackendAlert, Object.assign({}, args));
|
|
14
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
import { MonitorAlertsI } from '../../../interfaces';
|
|
3
|
+
declare const _default: Meta<MonitorAlertsI>;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const MonitorAlertsComponent: (args: MonitorAlertsI) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { MonitorAlerts } from '../../../components';
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Components/HomeAssistant/MonitorAlerts',
|
|
5
|
+
component: MonitorAlerts,
|
|
6
|
+
args: {
|
|
7
|
+
alertId: 'change-air-filter',
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
export const MonitorAlertsComponent = (args) => {
|
|
11
|
+
return _jsx(MonitorAlerts, Object.assign({}, args));
|
|
12
|
+
};
|
package/package.json
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
import { t } from 'i18next'
|
|
2
|
-
import { Flex, Center, Image, Text } from '@chakra-ui/react'
|
|
2
|
+
import { Flex, Center, Image, Text, Box } from '@chakra-ui/react'
|
|
3
3
|
import { Exclamation } from '@/assets/images'
|
|
4
4
|
|
|
5
|
-
export const AlertHeader = () => {
|
|
5
|
+
export const AlertHeader = ({ bg = 'error.2' }) => {
|
|
6
6
|
return (
|
|
7
7
|
<Flex
|
|
8
8
|
justifyContent="space-between"
|
|
9
9
|
px="base"
|
|
10
10
|
py="1"
|
|
11
|
-
bg=
|
|
11
|
+
bg={bg}
|
|
12
12
|
borderTopRadius="lg"
|
|
13
13
|
align="center"
|
|
14
14
|
>
|
|
15
15
|
<Flex align="center" gap="2">
|
|
16
|
-
<Center p="1"
|
|
16
|
+
<Center p="1" position="relative" h="18px" w="18px">
|
|
17
|
+
<Box
|
|
18
|
+
borderRadius="full"
|
|
19
|
+
bg="neutral.white"
|
|
20
|
+
opacity={0.3}
|
|
21
|
+
h="full"
|
|
22
|
+
w="full"
|
|
23
|
+
position="absolute"
|
|
24
|
+
top="50%"
|
|
25
|
+
left="50%"
|
|
26
|
+
transform="translate(-50%, -50%)"
|
|
27
|
+
/>
|
|
17
28
|
<Image src={Exclamation} h="100%" w="auto" />
|
|
18
29
|
</Center>
|
|
19
30
|
<Text
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BackendAlertCard } from '@/components'
|
|
2
|
+
import { BackendAlertI } from '@/interfaces'
|
|
3
|
+
import { getCategoryStyles } from '@/utils/Alerts.utils'
|
|
4
|
+
|
|
5
|
+
export const BackendAlert = ({ category, form }: BackendAlertI) => {
|
|
6
|
+
const { headerBg, alertIcon, alertIconBg, alertTitle } =
|
|
7
|
+
getCategoryStyles(category)
|
|
8
|
+
const alertHeader = form?.find((item) => item.type === 'alertHeader')
|
|
9
|
+
return (
|
|
10
|
+
<BackendAlertCard
|
|
11
|
+
alertBg={headerBg}
|
|
12
|
+
alertIcon={alertIcon}
|
|
13
|
+
alertTitle={alertTitle}
|
|
14
|
+
bg={alertIconBg}
|
|
15
|
+
icon={alertHeader?.icon ?? ''}
|
|
16
|
+
title={alertHeader?.label ?? ''}
|
|
17
|
+
description={alertHeader?.description ?? ''}
|
|
18
|
+
>
|
|
19
|
+
content
|
|
20
|
+
</BackendAlertCard>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react'
|
|
2
|
+
import { t } from 'i18next'
|
|
3
|
+
import { Box, Button, Collapse, Flex, useDisclosure } from '@chakra-ui/react'
|
|
4
|
+
import { AlertHeader, AlertTemplate, AlertTitle } from '@/components'
|
|
5
|
+
import { BackendAlertCardI, IconTypes } from '@/interfaces'
|
|
6
|
+
import { Warranty } from '@/assets/images'
|
|
7
|
+
import { fieldIcons } from '@/helpers'
|
|
8
|
+
|
|
9
|
+
export const BackendAlertCard = ({
|
|
10
|
+
alertBg = 'error.2',
|
|
11
|
+
alertIcon = Warranty,
|
|
12
|
+
alertTitle = t('homeAssistant.monitorAlerts.protection'),
|
|
13
|
+
children,
|
|
14
|
+
icon = 'warning',
|
|
15
|
+
...props
|
|
16
|
+
}: PropsWithChildren<BackendAlertCardI>) => {
|
|
17
|
+
const { isOpen, onToggle } = useDisclosure()
|
|
18
|
+
return (
|
|
19
|
+
<Box
|
|
20
|
+
display="flex"
|
|
21
|
+
flexDir="column"
|
|
22
|
+
bg="neutral.white"
|
|
23
|
+
boxShadow="lg"
|
|
24
|
+
borderRadius="lg"
|
|
25
|
+
overflow="hidden"
|
|
26
|
+
maxW="420px"
|
|
27
|
+
>
|
|
28
|
+
<AlertHeader bg={alertBg} />
|
|
29
|
+
<AlertTitle alertIcon={alertIcon} alertTitle={alertTitle} />
|
|
30
|
+
<AlertTemplate {...props} icon={fieldIcons[icon as IconTypes]} />
|
|
31
|
+
<Collapse in={isOpen} animateOpacity>
|
|
32
|
+
<Box p="base" bg="lightBlue.1">
|
|
33
|
+
{children}
|
|
34
|
+
</Box>
|
|
35
|
+
</Collapse>
|
|
36
|
+
<Flex py="base" bg="lightBlue.1" justify="flex-end">
|
|
37
|
+
<Button
|
|
38
|
+
variant="leftRounded"
|
|
39
|
+
w="fit-content"
|
|
40
|
+
px="8"
|
|
41
|
+
fontSize="sm"
|
|
42
|
+
fontWeight="medium"
|
|
43
|
+
onClick={onToggle}
|
|
44
|
+
bg={isOpen ? 'blue.8' : 'blue.2'}
|
|
45
|
+
>
|
|
46
|
+
{t(`homeAssistant.monitorAlerts.${isOpen ? 'collapse' : 'review'}`)}
|
|
47
|
+
</Button>
|
|
48
|
+
</Flex>
|
|
49
|
+
</Box>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
@@ -3,6 +3,8 @@ export * from './AlertHeader'
|
|
|
3
3
|
export * from './AlertTemplate'
|
|
4
4
|
export * from './AlertTitle'
|
|
5
5
|
export * from './BaseAlertCard'
|
|
6
|
+
export * from './BackendAlert'
|
|
7
|
+
export * from './BackendAlertCard'
|
|
6
8
|
export * from './WeatherWidget'
|
|
7
9
|
export * from './HomefileMonitoring'
|
|
8
10
|
export * from './MonitorAlerts'
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Fire,
|
|
3
|
+
GearTime,
|
|
3
4
|
House,
|
|
4
5
|
LargeAppliances,
|
|
5
6
|
Target,
|
|
@@ -7,6 +8,7 @@ import {
|
|
|
7
8
|
Water,
|
|
8
9
|
} from '@/assets/images'
|
|
9
10
|
import { HomeAssistantStepI } from '@/interfaces'
|
|
11
|
+
import { AlertCategory } from '@/interfaces/homeAssistant/BackendAlert.interface'
|
|
10
12
|
|
|
11
13
|
export const homeAssistantSteps: Array<HomeAssistantStepI> = [
|
|
12
14
|
{
|
|
@@ -34,3 +36,37 @@ export const homeAssistantSteps: Array<HomeAssistantStepI> = [
|
|
|
34
36
|
icon: Water,
|
|
35
37
|
},
|
|
36
38
|
]
|
|
39
|
+
|
|
40
|
+
interface CategoryConfigI {
|
|
41
|
+
label: string
|
|
42
|
+
icon: string
|
|
43
|
+
color: string
|
|
44
|
+
accent: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const CATEGORY_CONFIG: Record<AlertCategory, CategoryConfigI> = {
|
|
48
|
+
safeguard: {
|
|
49
|
+
label: 'Protection Monitor',
|
|
50
|
+
color: '#DB1DA1',
|
|
51
|
+
accent: '#FDDDF8',
|
|
52
|
+
icon: GearTime,
|
|
53
|
+
},
|
|
54
|
+
maintain: {
|
|
55
|
+
label: 'Maintenance Monitor',
|
|
56
|
+
color: '#8CC421',
|
|
57
|
+
accent: '#B9DEF2',
|
|
58
|
+
icon: GearTime,
|
|
59
|
+
},
|
|
60
|
+
budget: {
|
|
61
|
+
label: 'Budget Monitor',
|
|
62
|
+
color: '#1D8BDB',
|
|
63
|
+
accent: '#B9DEF2',
|
|
64
|
+
icon: GearTime,
|
|
65
|
+
},
|
|
66
|
+
improve: {
|
|
67
|
+
label: 'Improvement Monitor',
|
|
68
|
+
color: '#8516A7',
|
|
69
|
+
accent: '#B9DEF2',
|
|
70
|
+
icon: GearTime,
|
|
71
|
+
},
|
|
72
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AIGridFieldI,
|
|
3
|
+
AlertFieldType,
|
|
3
4
|
FolderFileI,
|
|
4
5
|
MenuItemI,
|
|
5
6
|
PartnerFooterI,
|
|
@@ -32,6 +33,7 @@ export type KindTypes =
|
|
|
32
33
|
| 'default'
|
|
33
34
|
| UIKindTypes
|
|
34
35
|
| HomeItemTypes
|
|
36
|
+
| AlertFieldType
|
|
35
37
|
|
|
36
38
|
export type UIKindTypes =
|
|
37
39
|
| 'tile-body'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DynamicFormI } from '@/interfaces'
|
|
2
|
+
|
|
3
|
+
export type AlertCategory = 'safeguard' | 'maintain' | 'budget' | 'improve'
|
|
4
|
+
|
|
5
|
+
export type AlertTabType = 'details' | 'filter-size' | 'purchase' | 'hire-out'
|
|
6
|
+
|
|
7
|
+
export type AlertFieldType =
|
|
8
|
+
| 'alertHeader'
|
|
9
|
+
| 'text'
|
|
10
|
+
| 'iconSection'
|
|
11
|
+
| 'tabList'
|
|
12
|
+
| 'list'
|
|
13
|
+
|
|
14
|
+
export interface BackendAlertI extends DynamicFormI {
|
|
15
|
+
category: AlertCategory
|
|
16
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './ApplianceButton.interface'
|
|
2
2
|
export * from './ApplianceSteps.interface'
|
|
3
|
+
export * from './BackendAlert.interface'
|
|
3
4
|
export * from './BaseAlertCard.interface'
|
|
5
|
+
export * from './BackendAlertCard.interface'
|
|
4
6
|
export * from './HomeAssistantButton.interface'
|
|
5
7
|
export * from './HomeAssistantPanel.interface'
|
|
6
8
|
export * from './HomeAssistantStepper.interface'
|
|
@@ -853,3 +853,16 @@ export const unknownFormMock: Record<string, any> = {
|
|
|
853
853
|
updatedAt: '2025-04-17T19:26:39.435Z',
|
|
854
854
|
__v: 0,
|
|
855
855
|
}
|
|
856
|
+
|
|
857
|
+
export const alertFieldsMock: ReportI[] = [
|
|
858
|
+
{
|
|
859
|
+
id: faker.database.mongodbObjectId(),
|
|
860
|
+
name: 'Filter',
|
|
861
|
+
label: 'Time to change your heating & cooling air filter.',
|
|
862
|
+
description:
|
|
863
|
+
'Changing your air filter every 30 days ensures efficient system performance and improves indoor air quality by trapping dust and allergens.',
|
|
864
|
+
icon: 'wind',
|
|
865
|
+
value: false,
|
|
866
|
+
type: 'alertHeader',
|
|
867
|
+
},
|
|
868
|
+
]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react'
|
|
2
|
+
import { BackendAlert } from '@/components'
|
|
3
|
+
import { BackendAlertI } from '@/interfaces'
|
|
4
|
+
import { alertFieldsMock } from '@/mocks'
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/HomeAssistant/MonitorAlerts',
|
|
8
|
+
component: BackendAlert,
|
|
9
|
+
args: {
|
|
10
|
+
category: 'budget',
|
|
11
|
+
form: alertFieldsMock,
|
|
12
|
+
},
|
|
13
|
+
} as Meta<BackendAlertI>
|
|
14
|
+
|
|
15
|
+
export const BackendAlertComponent = (args: BackendAlertI) => {
|
|
16
|
+
return <BackendAlert {...args} />
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react'
|
|
2
|
+
import { MonitorAlerts } from '@/components'
|
|
3
|
+
import { MonitorAlertsI } from '@/interfaces'
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Components/HomeAssistant/MonitorAlerts',
|
|
7
|
+
component: MonitorAlerts,
|
|
8
|
+
args: {
|
|
9
|
+
alertId: 'change-air-filter',
|
|
10
|
+
},
|
|
11
|
+
} as Meta<MonitorAlertsI>
|
|
12
|
+
|
|
13
|
+
export const MonitorAlertsComponent = (args: MonitorAlertsI) => {
|
|
14
|
+
return <MonitorAlerts {...args} />
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CATEGORY_CONFIG } from '@/helpers'
|
|
2
|
+
import { AlertCategory } from '@/interfaces'
|
|
3
|
+
|
|
4
|
+
export function getCategoryStyles(cat: AlertCategory) {
|
|
5
|
+
const cfg = CATEGORY_CONFIG[cat]
|
|
6
|
+
return {
|
|
7
|
+
headerBg: cfg.color,
|
|
8
|
+
alertTitle: cfg.label,
|
|
9
|
+
alertIcon: cfg.icon,
|
|
10
|
+
alertIconBg: cfg.accent,
|
|
11
|
+
}
|
|
12
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|