@homefile/components-v2 2.49.3 → 2.49.5
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/assets/locales/en/index.json +2 -1
- package/dist/components/buttons/LeftButton.js +1 -1
- package/dist/components/icons/Plus.d.ts +2 -2
- package/dist/components/inboxTile/panel/MessageCard.js +4 -5
- package/dist/components/inboxTile/panel/MessageChatPanel.js +18 -5
- package/dist/components/inboxTile/panel/MessagePanel.d.ts +1 -1
- package/dist/components/inboxTile/panel/MessagePanel.js +17 -3
- package/dist/components/inboxTile/panel/MessageSenderCard.d.ts +2 -0
- package/dist/components/inboxTile/panel/MessageSenderCard.js +28 -0
- package/dist/components/inboxTile/panel/MessageSenderCardAddress.d.ts +2 -0
- package/dist/components/inboxTile/panel/MessageSenderCardAddress.js +8 -0
- package/dist/components/inboxTile/panel/MessageSenderCardHeader.d.ts +1 -0
- package/dist/components/inboxTile/panel/MessageSenderCardHeader.js +7 -0
- package/dist/components/inboxTile/panel/MessageSenderCardInfo.d.ts +2 -0
- package/dist/components/inboxTile/panel/MessageSenderCardInfo.js +14 -0
- package/dist/components/inboxTile/panel/index.d.ts +4 -0
- package/dist/components/inboxTile/panel/index.js +4 -0
- package/dist/interfaces/inboxTile/MessageChatPanel.interface.d.ts +1 -1
- package/dist/interfaces/inboxTile/MessagePanel.interface.d.ts +4 -2
- package/dist/interfaces/inboxTile/MessageSenderCard.interface.d.ts +18 -0
- package/dist/interfaces/inboxTile/MessageSenderCard.interface.js +1 -0
- package/dist/interfaces/inboxTile/index.d.ts +1 -0
- package/dist/interfaces/inboxTile/index.js +1 -0
- package/dist/stories/inboxTile/MessagePanel.stories.js +26 -1
- package/dist/utils/Formaters.utils.d.ts +1 -0
- package/dist/utils/Formaters.utils.js +14 -8
- package/package.json +1 -1
|
@@ -524,7 +524,8 @@
|
|
|
524
524
|
"forwardTo": "Simply forward images & paperwork to ",
|
|
525
525
|
"forwardTo2": " or add a receipt image below.",
|
|
526
526
|
"from": "From: ",
|
|
527
|
-
"message": "Message"
|
|
527
|
+
"message": "Message",
|
|
528
|
+
"senderDetails": "Customer Details"
|
|
528
529
|
},
|
|
529
530
|
"launchpad": {
|
|
530
531
|
"menu": {
|
|
@@ -14,5 +14,5 @@ import { Button } from '@chakra-ui/react';
|
|
|
14
14
|
import { Plus } from '../../components';
|
|
15
15
|
export const LeftButton = (_a) => {
|
|
16
16
|
var { bgColor = 'green.1', onClick, height = '1.75rem', label } = _a, props = __rest(_a, ["bgColor", "onClick", "height", "label"]);
|
|
17
|
-
return (_jsxs(Button, Object.assign({}, props, { h: height, variant: "leftRounded", bg: bgColor, onClick: onClick, px: "1rem", children: [_jsx(Plus, {}), label] })));
|
|
17
|
+
return (_jsxs(Button, Object.assign({}, props, { h: height, variant: "leftRounded", bg: bgColor, onClick: onClick, px: "1rem", children: [_jsx(Plus, { size: "1em" }), label] })));
|
|
18
18
|
};
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { Avatar, Box, Center, chakra, Container, Divider, Flex, Stack, Text, } from '@chakra-ui/react';
|
|
2
|
+
import { Avatar, Box, Center, Container, Divider, Flex, Stack, Text, } from '@chakra-ui/react';
|
|
4
3
|
import { ChatBubble } from '../../../assets/images';
|
|
5
4
|
import { TextBadge } from '../../../components';
|
|
6
|
-
import {
|
|
5
|
+
import { formatLongDateWithAt } from '../../../utils';
|
|
7
6
|
export const MessageCard = ({ message, onClick, variant = 'inbox', }) => {
|
|
8
7
|
const { currentUser, from, subject, date, isNew, chatReplies, description = '', } = message;
|
|
9
|
-
const formattedDate =
|
|
8
|
+
const formattedDate = formatLongDateWithAt({ date });
|
|
10
9
|
const showChatBubble = Number(chatReplies === null || chatReplies === void 0 ? void 0 : chatReplies.length) > 0;
|
|
11
10
|
const isInbox = variant === 'inbox';
|
|
12
11
|
const isCurrentUser = (currentUser === null || currentUser === void 0 ? void 0 : currentUser.userName) === from;
|
|
13
|
-
return (_jsxs(Flex, { gap: "base", children: [!isCurrentUser && !isInbox && (_jsx(Avatar, { size: "sm", name: from, bg: "blue.4", fontWeight: "bold", color: "neutral.white" })), _jsx(Container, { as: isInbox ? 'button' : 'div', bg: isCurrentUser ? 'yellow.6' : 'neutral.white', transition: "background-color 0.3s", textAlign: "left", _hover: isInbox ? { bg: 'lightGreen.1' } : {}, onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(message), children: _jsxs(Box, { children: [!isCurrentUser && (
|
|
12
|
+
return (_jsxs(Flex, { gap: "base", children: [!isCurrentUser && !isInbox && (_jsx(Avatar, { size: "sm", name: from, bg: "blue.4", fontWeight: "bold", color: "neutral.white" })), _jsx(Container, { as: isInbox ? 'button' : 'div', bg: isCurrentUser ? 'yellow.6' : 'neutral.white', transition: "background-color 0.3s", textAlign: "left", _hover: isInbox ? { bg: 'lightGreen.1' } : {}, onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(message), children: _jsxs(Box, { children: [!isCurrentUser && (_jsx(Flex, { justify: "space-between", align: "center", py: "1", pr: "base", pl: isNew ? '' : 'base', children: _jsxs(Flex, { gap: "base", align: "center", position: "relative", left: isNew ? '-13px' : '', children: [isNew && isInbox && (_jsx(TextBadge, { text: "New", showAnimation: false, bgColor: "violet.1" })), _jsx(Text, { variant: "home", fontSize: "xs", children: formattedDate })] }) })), isInbox && _jsx(Divider, {}), _jsxs(Stack, { spacing: "base", p: "base", children: [_jsxs(Flex, { align: "center", justify: "space-between", children: [_jsx(Text, { variant: "home", fontWeight: "bold", children: subject }), showChatBubble && isInbox && (_jsx(Center, { backgroundImage: `url(${ChatBubble})`, backgroundRepeat: "no-repeat", backgroundSize: "contain", backgroundPosition: "bottom", w: "20px", h: "24px", children: _jsx(Text, { fontSize: "10px", color: "blue.2", fontWeight: "bold", children: chatReplies === null || chatReplies === void 0 ? void 0 : chatReplies.length }) }))] }), isInbox && (_jsx(Text, { variant: "home", noOfLines: 3, textOverflow: "ellipsis", dangerouslySetInnerHTML: {
|
|
14
13
|
__html: description,
|
|
15
14
|
} })), !isInbox && (_jsx(Text, { variant: "home", dangerouslySetInnerHTML: {
|
|
16
15
|
__html: description,
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
11
|
import { useState } from 'react';
|
|
3
12
|
import { t } from 'i18next';
|
|
@@ -13,16 +22,20 @@ export const MessageChatPanel = ({ message, onBack, onClose, onReply, }) => {
|
|
|
13
22
|
const onChange = (content) => {
|
|
14
23
|
setValue(content);
|
|
15
24
|
};
|
|
25
|
+
const handleReply = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
var _a;
|
|
27
|
+
yield onReply({
|
|
28
|
+
id: (_a = message === null || message === void 0 ? void 0 : message._id) !== null && _a !== void 0 ? _a : '',
|
|
29
|
+
message: value,
|
|
30
|
+
});
|
|
31
|
+
setValue('');
|
|
32
|
+
});
|
|
16
33
|
return (_jsxs(DrawerContent, { bg: "lightBlue.1", children: [_jsx(DrawerHeader, { p: "0", children: _jsx(PanelHeader, { handleCloseButton: onClose, title: (_a = message === null || message === void 0 ? void 0 : message.from) !== null && _a !== void 0 ? _a : '', icon: Document2 }) }), _jsxs(DrawerBody, { p: "0", children: [onBack && (_jsx(Box, { bg: "lightBlue.2", py: "2", px: "base", children: _jsx(BackCircleButton, { onClick: onBack }) })), _jsx(Stack, { spacing: "base", p: "base", pb: "4", children: (_b = message === null || message === void 0 ? void 0 : message.chatReplies) === null || _b === void 0 ? void 0 : _b.map((reply) => (_jsx(MessageCard, { message: Object.assign(Object.assign({}, reply), { currentUser: message.currentUser }), variant: "chat" }, reply._id))) })] }), _jsx(DrawerFooter, { p: "0", maxH: "400px", children: _jsx(WrapperWithShadow, { animation: up, fadeDelay: 0.2, children: _jsxs(Stack, { spacing: "base", children: [_jsx(Text, { children: t('inbox.createReply') }), _jsx(QuillEditor, { theme: "snow", value: value, modules: { toolbar }, onChange: onChange, placeholder: t('inbox.enterContent') }), _jsx(FooterButtons, { px: "0", button1: {
|
|
17
34
|
buttonStyle: 'secondaryFooter',
|
|
18
35
|
label: t('buttons.send'),
|
|
19
36
|
isDisabled: Number(value.length) === 0,
|
|
20
37
|
onClick: () => {
|
|
21
|
-
|
|
22
|
-
return onReply({
|
|
23
|
-
id: (_a = message === null || message === void 0 ? void 0 : message._id) !== null && _a !== void 0 ? _a : '',
|
|
24
|
-
message: value,
|
|
25
|
-
});
|
|
38
|
+
void handleReply();
|
|
26
39
|
},
|
|
27
40
|
} })] }) }) })] }));
|
|
28
41
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { MessagePanelI } from '../../../interfaces';
|
|
2
|
-
export declare const MessagePanel: ({ messages, onClick, onClose }: MessagePanelI) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const MessagePanel: ({ icon, messages, onClick, onClose, title, email, firstName, lastName, phone, address, city, state, zip, showAvatar, showHeader, onAction, actionLabel, }: MessagePanelI) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,11 +2,25 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { t } from 'i18next';
|
|
3
3
|
import { Box, DrawerBody, DrawerContent, DrawerHeader, Stack, } from '@chakra-ui/react';
|
|
4
4
|
import { Inbox } from '../../../assets/images';
|
|
5
|
-
import { BaseCounter, MessageCard, PanelHeader, SelectInput, } from '../../../components';
|
|
5
|
+
import { BaseCounter, MessageCard, MessageSenderCard, PanelHeader, SelectInput, } from '../../../components';
|
|
6
6
|
import { useMessagePanel } from '../../../hooks';
|
|
7
7
|
import { pluralize } from '../../../utils';
|
|
8
|
-
export const MessagePanel = ({ messages, onClick, onClose }) => {
|
|
8
|
+
export const MessagePanel = ({ icon = Inbox, messages, onClick, onClose, title = t('inbox.message'), email, firstName, lastName, phone, address, city, state, zip, showAvatar, showHeader, onAction, actionLabel, }) => {
|
|
9
9
|
const { currentSort, sortedMessages, handleSelectItem, items } = useMessagePanel(messages);
|
|
10
10
|
const baseCounterText = `${t('counter.showing')} ${sortedMessages.length} ${t('counter.of')} ${messages.length} ${pluralize(sortedMessages.length, t('inbox.message').toLowerCase())} `;
|
|
11
|
-
|
|
11
|
+
const senderCardData = {
|
|
12
|
+
email,
|
|
13
|
+
firstName,
|
|
14
|
+
lastName,
|
|
15
|
+
phone,
|
|
16
|
+
address,
|
|
17
|
+
city,
|
|
18
|
+
state,
|
|
19
|
+
zip,
|
|
20
|
+
showAvatar,
|
|
21
|
+
showHeader,
|
|
22
|
+
onAction,
|
|
23
|
+
actionLabel,
|
|
24
|
+
};
|
|
25
|
+
return (_jsxs(DrawerContent, { bg: "lightBlue.1", children: [_jsx(DrawerHeader, { p: "0", children: _jsx(PanelHeader, { handleCloseButton: onClose, title: title, icon: icon }) }), _jsx(DrawerBody, { p: "0", children: _jsxs(Stack, { spacing: "base", children: [_jsxs(Box, { children: [_jsx(MessageSenderCard, Object.assign({}, senderCardData)), _jsx(Box, { p: "base", bg: "lightBlue.2", children: _jsx(SelectInput, { handleClick: handleSelectItem, initialValue: currentSort, items: items }) })] }), _jsx(Box, { px: "base", children: _jsx(BaseCounter, { text: baseCounterText }) }), _jsx(Stack, { spacing: "1", pl: "26px", pr: "base", children: sortedMessages.map((message) => (_jsx(MessageCard, { message: message, onClick: onClick }, message._id))) })] }) })] }));
|
|
12
26
|
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { MessageSenderCardI } from '../../../interfaces';
|
|
2
|
+
export declare const MessageSenderCard: ({ address, city, email, firstName, lastName, phone, showAvatar, showHeader, state, zip, onAction, actionLabel, }: MessageSenderCardI) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Flex, Stack, Text } from '@chakra-ui/react';
|
|
3
|
+
import { MessageSenderCardHeader, MessageSenderCardInfo, LeftButton, } from '../../../components';
|
|
4
|
+
export const MessageSenderCard = ({ address, city, email, firstName, lastName, phone, showAvatar = true, showHeader = true, state, zip, onAction, actionLabel = '', }) => {
|
|
5
|
+
const hasData = firstName || lastName || email || phone || address || city || state || zip;
|
|
6
|
+
if (!hasData) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return (_jsxs(Box, { position: "relative", w: "100%", children: [_jsx(Box, { bg: "lightGreen.1", p: "base", children: _jsxs(Stack, { spacing: "2", children: [showHeader && _jsx(MessageSenderCardHeader, {}), _jsx(CardBody, { address,
|
|
10
|
+
city,
|
|
11
|
+
email,
|
|
12
|
+
firstName,
|
|
13
|
+
lastName,
|
|
14
|
+
phone,
|
|
15
|
+
showAvatar,
|
|
16
|
+
state,
|
|
17
|
+
zip })] }) }), onAction && (_jsx(Box, { position: "absolute", right: "0", top: "2", children: _jsx(LeftButton, { bgColor: "blue.2", onClick: onAction, label: actionLabel, fontSize: "sm", fontWeight: "medium", gap: "1" }) }))] }));
|
|
18
|
+
};
|
|
19
|
+
const CardBody = ({ address, city, email, firstName, lastName, phone, showAvatar, state, zip, }) => {
|
|
20
|
+
const hasContact = Boolean(phone || email);
|
|
21
|
+
return (_jsxs(Flex, { align: "stretch", gap: "8", children: [_jsx(MessageSenderCardInfo, { address,
|
|
22
|
+
city,
|
|
23
|
+
firstName,
|
|
24
|
+
lastName,
|
|
25
|
+
state,
|
|
26
|
+
showAvatar,
|
|
27
|
+
zip }), hasContact && (_jsxs(_Fragment, { children: [_jsx(Box, { bg: "lightBlue.2", w: "1px" }), _jsxs(Stack, { spacing: "0", justify: "end", children: [phone && (_jsx(Text, { fontSize: "12px", fontFamily: "secondary", lineHeight: "15px", children: phone })), email && (_jsx(Text, { variant: "email", fontSize: "12px", fontFamily: "secondary", lineHeight: "15px", children: email }))] })] }))] }));
|
|
28
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Stack, Text } from '@chakra-ui/react';
|
|
3
|
+
export const MessageSenderCardAddress = ({ address, city, state, zip, }) => {
|
|
4
|
+
if (!address && !city && !state && !zip) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return (_jsxs(Stack, { spacing: "0", minH: "full", children: [address && (_jsx(Text, { variant: "address", lineHeight: "13px", children: address })), (city || state || zip) && (_jsxs(Text, { variant: "address", lineHeight: "13px", children: [city, city && state ? ', ' : '', state, " ", zip] }))] }));
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MessageSenderCardHeader: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { t } from 'i18next';
|
|
3
|
+
import { Flex, Image, Text } from '@chakra-ui/react';
|
|
4
|
+
import { BillingAddress } from '../../../assets/images';
|
|
5
|
+
export const MessageSenderCardHeader = () => {
|
|
6
|
+
return (_jsxs(Flex, { align: "center", gap: "2", children: [_jsx(Image, { src: BillingAddress, alt: "Sender Details", h: "18px", w: "auto" }), _jsx(Text, { fontSize: "10px", textTransform: "uppercase", lineHeight: "1", children: t('inbox.senderDetails') })] }));
|
|
7
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar, Flex, Box, Text } from '@chakra-ui/react';
|
|
3
|
+
import { MessageSenderCardAddress } from '../../../components';
|
|
4
|
+
export const MessageSenderCardInfo = ({ address, city, firstName, lastName, state, showAvatar = true, zip, }) => {
|
|
5
|
+
const name = `${firstName} ${lastName}`.trim();
|
|
6
|
+
const hasAddress = Boolean(address || city || state || zip);
|
|
7
|
+
if (!name && !hasAddress) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return (_jsxs(Flex, { gap: "base", align: "center", children: [showAvatar && name && (_jsx(Avatar, { boxSize: "50px", borderRadius: "none", bg: "blue.4", fontWeight: "bold", color: "neutral.white", name: name })), _jsxs(Box, { children: [name && (_jsx(Text, { fontWeight: "medium", fontSize: "lg", lineHeight: "1.2", children: name })), _jsx(MessageSenderCardAddress, { address,
|
|
11
|
+
city,
|
|
12
|
+
state,
|
|
13
|
+
zip })] })] }));
|
|
14
|
+
};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export * from './MessageCard';
|
|
2
2
|
export * from './MessageChatPanel';
|
|
3
3
|
export * from './MessagePanel';
|
|
4
|
+
export * from './MessageSenderCard';
|
|
5
|
+
export * from './MessageSenderCardHeader';
|
|
6
|
+
export * from './MessageSenderCardInfo';
|
|
7
|
+
export * from './MessageSenderCardAddress';
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export * from './MessageCard';
|
|
2
2
|
export * from './MessageChatPanel';
|
|
3
3
|
export * from './MessagePanel';
|
|
4
|
+
export * from './MessageSenderCard';
|
|
5
|
+
export * from './MessageSenderCardHeader';
|
|
6
|
+
export * from './MessageSenderCardInfo';
|
|
7
|
+
export * from './MessageSenderCardAddress';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { InboxMessageI } from '../../interfaces';
|
|
2
|
-
export interface MessagePanelI {
|
|
1
|
+
import { InboxMessageI, MessageSenderCardI } from '../../interfaces';
|
|
2
|
+
export interface MessagePanelI extends Partial<MessageSenderCardI> {
|
|
3
|
+
icon?: string;
|
|
3
4
|
messages: InboxMessageI[];
|
|
5
|
+
title?: string;
|
|
4
6
|
onClick: (message: InboxMessageI) => void;
|
|
5
7
|
onClose: () => void;
|
|
6
8
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface SenderDetailsInfoI {
|
|
2
|
+
email?: string;
|
|
3
|
+
firstName?: string;
|
|
4
|
+
lastName?: string;
|
|
5
|
+
phone?: string;
|
|
6
|
+
showAvatar?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface SenderDetailsAddressI {
|
|
9
|
+
address?: string;
|
|
10
|
+
city?: string;
|
|
11
|
+
state?: string;
|
|
12
|
+
zip?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface MessageSenderCardI extends SenderDetailsInfoI, SenderDetailsAddressI {
|
|
15
|
+
onAction?: () => void;
|
|
16
|
+
actionLabel?: string;
|
|
17
|
+
showHeader?: boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,13 +1,35 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
11
|
import { MessageChatPanel, MessagePanel, RightPanel } from '../../components';
|
|
3
12
|
import { action } from '@storybook/addon-actions';
|
|
4
13
|
import { messagesMock } from '../../mocks';
|
|
5
14
|
import { Fragment, useState } from 'react';
|
|
15
|
+
import { Manager } from '../../assets/images';
|
|
6
16
|
export default {
|
|
7
17
|
title: 'Components/Inbox',
|
|
8
18
|
component: MessagePanel,
|
|
9
19
|
args: {
|
|
10
20
|
messages: messagesMock,
|
|
21
|
+
title: 'Service Ticket : 422325623',
|
|
22
|
+
icon: Manager,
|
|
23
|
+
firstName: 'Michael',
|
|
24
|
+
lastName: 'Smith',
|
|
25
|
+
email: 'email.address@gmail.com',
|
|
26
|
+
phone: '555-555-1212',
|
|
27
|
+
address: '1134 South First Avenue',
|
|
28
|
+
city: 'Austin',
|
|
29
|
+
state: 'TX',
|
|
30
|
+
zip: '78732',
|
|
31
|
+
showAvatar: true,
|
|
32
|
+
showHeader: true,
|
|
11
33
|
},
|
|
12
34
|
decorators: [
|
|
13
35
|
(Story) => (_jsx(RightPanel, { isOpen: true, onClose: action('onClose'), children: _jsx(Story, {}) })),
|
|
@@ -16,9 +38,12 @@ export default {
|
|
|
16
38
|
export const MessagePanelComponent = (args) => {
|
|
17
39
|
const [showMessageChat, setShowMessageChat] = useState(false);
|
|
18
40
|
const [selectedMessage, setSelectedMessage] = useState(undefined);
|
|
41
|
+
const onReply = action('onReply');
|
|
19
42
|
const handleMessageChatToggle = () => setShowMessageChat(!showMessageChat);
|
|
20
43
|
return (_jsxs(Fragment, { children: [_jsx(MessagePanel, Object.assign({}, args, { onClick: (message) => {
|
|
21
44
|
setSelectedMessage(message);
|
|
22
45
|
handleMessageChatToggle();
|
|
23
|
-
} })), _jsx(RightPanel, { isOpen: showMessageChat, onClose: handleMessageChatToggle, children: _jsx(MessageChatPanel, { message: selectedMessage, onReply:
|
|
46
|
+
}, onAction: action('onAction'), actionLabel: "NOTE" })), _jsx(RightPanel, { isOpen: showMessageChat, onClose: handleMessageChatToggle, children: _jsx(MessageChatPanel, { message: selectedMessage, onReply: (reply) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
onReply(reply);
|
|
48
|
+
}), onClose: action('onCloseChatPanel'), onBack: handleMessageChatToggle }) })] }));
|
|
24
49
|
};
|
|
@@ -5,6 +5,7 @@ interface FormatDateI {
|
|
|
5
5
|
}
|
|
6
6
|
export declare const formatDate: ({ date, locale }: FormatDateI) => string;
|
|
7
7
|
export declare const formatDateWithAt: ({ date, locale, }: FormatDateI) => string;
|
|
8
|
+
export declare const formatLongDateWithAt: ({ date }: FormatDateI) => string;
|
|
8
9
|
export declare const shortFormatDate: ({ date, locale, }: FormatDateI) => string;
|
|
9
10
|
export declare const monthAndYearFormatDate: ({ date, locale, }: FormatDateI) => string;
|
|
10
11
|
export declare const dayAndMonthFormatDate: ({ date, locale, }: FormatDateI) => string;
|
|
@@ -35,6 +35,14 @@ export const formatDateWithAt = ({ date, locale = 'en-US', }) => {
|
|
|
35
35
|
.replaceAll('/', '.');
|
|
36
36
|
return dateFormat + ' @ ' + timeFormat;
|
|
37
37
|
};
|
|
38
|
+
export const formatLongDateWithAt = ({ date }) => {
|
|
39
|
+
if (!date)
|
|
40
|
+
return '';
|
|
41
|
+
const parsedDate = new Date(date);
|
|
42
|
+
const dateFormat = format(parsedDate, 'EEEE MMM d, yyyy');
|
|
43
|
+
const timeFormat = format(parsedDate, 'h:mm a');
|
|
44
|
+
return `${dateFormat} @${timeFormat}`;
|
|
45
|
+
};
|
|
38
46
|
export const shortFormatDate = ({ date, locale = 'en-US', }) => {
|
|
39
47
|
if (!date)
|
|
40
48
|
return '';
|
|
@@ -104,21 +112,19 @@ export const joinDayMonthYear = (value) => {
|
|
|
104
112
|
});
|
|
105
113
|
};
|
|
106
114
|
export const formatISODate = (value) => {
|
|
107
|
-
const displayValue =
|
|
115
|
+
const displayValue = isValid(parseISO(value)) || isValid(new Date(value))
|
|
108
116
|
? format(value, 'MM/dd/yyyy')
|
|
109
117
|
: '';
|
|
110
118
|
return displayValue;
|
|
111
119
|
};
|
|
112
120
|
export const toQuantity = (q) => {
|
|
113
|
-
if (typeof q ===
|
|
114
|
-
return Number.isFinite(q) ? q :
|
|
115
|
-
const cleaned = (q !== null && q !== void 0 ? q :
|
|
116
|
-
.toString()
|
|
117
|
-
.replace(/\D/g, ""); // remove all non-digits
|
|
121
|
+
if (typeof q === 'number')
|
|
122
|
+
return Number.isFinite(q) ? q : '';
|
|
123
|
+
const cleaned = (q !== null && q !== void 0 ? q : '').toString().replace(/\D/g, ''); // remove all non-digits
|
|
118
124
|
if (!cleaned)
|
|
119
|
-
return
|
|
125
|
+
return ''; // no digits found
|
|
120
126
|
const n = Number(cleaned);
|
|
121
|
-
return Number.isInteger(n) && n > 0 ? n :
|
|
127
|
+
return Number.isInteger(n) && n > 0 ? n : '';
|
|
122
128
|
};
|
|
123
129
|
export const formatCurrency = ({ country = 'en-US', currrency = 'USD', value, }) => {
|
|
124
130
|
if (!value) {
|