Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WA Polls: Create and manage polls #3185

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
6 changes: 6 additions & 0 deletions src/assets/images/Polls.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/images/icons/SideDrawer/WaPolls.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const SvgComponent = ({ color }: { color: string }) => (
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">

Check warning on line 2 in src/assets/images/icons/SideDrawer/WaPolls.tsx

Codecov / codecov/patch

src/assets/images/icons/SideDrawer/WaPolls.tsx#L2

Added line #L2 was not covered by tests
<path
d="M13 7C13.2833 7 13.5208 6.90417 13.7125 6.7125C13.9042 6.52083 14 6.28333 14 6C14 5.71667 13.9042 5.47917 13.7125 5.2875C13.5208 5.09583 13.2833 5 13 5H10C9.71667 5 9.47917 5.09583 9.2875 5.2875C9.09583 5.47917 9 5.71667 9 6C9 6.28333 9.09583 6.52083 9.2875 6.7125C9.47917 6.90417 9.71667 7 10 7H13ZM13 13C13.2833 13 13.5208 12.9042 13.7125 12.7125C13.9042 12.5208 14 12.2833 14 12C14 11.7167 13.9042 11.4792 13.7125 11.2875C13.5208 11.0958 13.2833 11 13 11H10C9.71667 11 9.47917 11.0958 9.2875 11.2875C9.09583 11.4792 9 11.7167 9 12C9 12.2833 9.09583 12.5208 9.2875 12.7125C9.47917 12.9042 9.71667 13 10 13H13ZM6 8C6.55 8 7.02083 7.80417 7.4125 7.4125C7.80417 7.02083 8 6.55 8 6C8 5.45 7.80417 4.97917 7.4125 4.5875C7.02083 4.19583 6.55 4 6 4C5.45 4 4.97917 4.19583 4.5875 4.5875C4.19583 4.97917 4 5.45 4 6C4 6.55 4.19583 7.02083 4.5875 7.4125C4.97917 7.80417 5.45 8 6 8ZM6 14C6.55 14 7.02083 13.8042 7.4125 13.4125C7.80417 13.0208 8 12.55 8 12C8 11.45 7.80417 10.9792 7.4125 10.5875C7.02083 10.1958 6.55 10 6 10C5.45 10 4.97917 10.1958 4.5875 10.5875C4.19583 10.9792 4 11.45 4 12C4 12.55 4.19583 13.0208 4.5875 13.4125C4.97917 13.8042 5.45 14 6 14ZM2 18C1.45 18 0.979167 17.8042 0.5875 17.4125C0.195833 17.0208 0 16.55 0 16V2C0 1.45 0.195833 0.979167 0.5875 0.5875C0.979167 0.195833 1.45 0 2 0H16C16.55 0 17.0208 0.195833 17.4125 0.5875C17.8042 0.979167 18 1.45 18 2V16C18 16.55 17.8042 17.0208 17.4125 17.4125C17.0208 17.8042 16.55 18 16 18H2ZM2 16H16V2H2V16Z"
fill={color}
/>
</svg>
);
export default SvgComponent;
5 changes: 5 additions & 0 deletions src/common/HelpData.tsx
Original file line number Diff line number Diff line change
@@ -129,3 +129,8 @@ export const templateStatusInfo: HelpDataProps = {
),
link: 'https://docs.gupshup.io/docs/message-template-approvals-statuses',
};

export const pollsInfo: HelpDataProps = {
heading: 'An overview of all the polls created to date',
link: 'https://glific.github.io/docs/docs/category/flows',
};
6 changes: 4 additions & 2 deletions src/components/UI/ListIcon/ListIcon.tsx
Original file line number Diff line number Diff line change
@@ -29,10 +29,11 @@ import WaCollectionIcon from 'assets/images/icons/SideDrawer/WaGroupCollection';
import WaGroupIcon from 'assets/images/icons/SideDrawer/WhatsAppGroupIcon';
import KnowledgeBaseIcon from 'assets/images/icons/SideDrawer/KnowledgeBaseIcon';
import Assistant from 'assets/images/icons/SideDrawer/Assistant';
import WaPolls from 'assets/images/icons/SideDrawer/WaPolls';
import styles from './ListIcon.module.css';
import FiberNewIcon from '@mui/icons-material/FiberNew';
import { Badge } from '@mui/material';
import DiscordIcon from 'assets/images/icons/Discord/DiscordIcon'
import DiscordIcon from 'assets/images/icons/Discord/DiscordIcon';
export interface ListIconProps {
icon: string | undefined;
count?: number;
@@ -75,7 +76,8 @@ export const ListIcon = ({ icon = '', selected = false, count }: ListIconProps)
waGroup: WaGroupIcon,
knowledgeBase: KnowledgeBaseIcon,
assistant: Assistant,
discord:DiscordIcon
discord: DiscordIcon,
waPolls: WaPolls,
};

const iconImage = stringsToIcons[icon] && (
39 changes: 23 additions & 16 deletions src/config/menu.ts
Original file line number Diff line number Diff line change
@@ -51,6 +51,13 @@ const menus = (): Menu[] => [
type: 'sideDrawer',
roles: allRoles,
},
{
title: 'WhatsApp Polls',
path: '/group/polls',
icon: 'waPolls',
type: 'sideDrawer',
roles: allRoles,
},
],
},
{
@@ -279,22 +286,22 @@ const menus = (): Menu[] => [
roles: staffLevel,
},

// {
// title: "What's new",
// path: '/changelog',
// url: NEW_UI_BLOG,
// icon: 'new',
// type: 'sideDrawer',
// roles: staffLevel,
// },
{
title: "Discord",
path: '/discord',
url: DISCORD_URL,
icon: 'discord',
type: 'sideDrawer',
roles: staffLevel,
},
// {
// title: "What's new",
// path: '/changelog',
// url: NEW_UI_BLOG,
// icon: 'new',
// type: 'sideDrawer',
// roles: staffLevel,
// },
{
title: 'Discord',
path: '/discord',
url: DISCORD_URL,
icon: 'discord',
type: 'sideDrawer',
roles: staffLevel,
},
];

export const getMenus = (menuType = 'sideDrawer', role = 'Staff') =>
Original file line number Diff line number Diff line change
@@ -298,3 +298,8 @@
padding-bottom: 8px;
font-weight: bold;
}

.NoIcon {
margin: 0 1rem;
/* background-color: red !important; */
}
86 changes: 45 additions & 41 deletions src/containers/Chat/ChatMessages/ChatMessage/ChatMessage.tsx
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@ export interface ChatMessageProps {
groups?: boolean;
status?: string;
contact?: any;
showIcon?: boolean;
}

export const ChatMessage = ({
@@ -81,6 +82,7 @@ export const ChatMessage = ({
groups,
status,
contact,
showIcon = true,
}: ChatMessageProps) => {
const [showSaveMessageDialog, setShowSaveMessageDialog] = useState(false);
const Ref = useRef(null);
@@ -335,8 +337,8 @@ export const ChatMessage = ({
</Tooltip>
) : null}

<div className={styles.Inline}>
{iconLeft && icon}
<div className={`${styles.Inline} ${!showIcon && styles.NoIcon}`}>
{showIcon && iconLeft && icon}
{ErrorIcon}
<div className={chatMessageClasses.join(' ')}>
<Tooltip title={tooltipTitle} placement={isSender ? 'right' : 'left'}>
@@ -361,47 +363,49 @@ export const ChatMessage = ({
</div>
</Tooltip>

<Popper
id={popperId}
open={open}
modifiers={[
{
name: 'preventOverflow',
options: {
altBoundary: true,
{showIcon && (
<Popper
id={popperId}
open={open}
modifiers={[
{
name: 'preventOverflow',
options: {
altBoundary: true,
},
},
},
]}
anchorEl={anchorEl}
placement={placement}
transition
data-testid="popup"
>
{({ TransitionProps }) => (
<Fade {...TransitionProps} timeout={350}>
<Paper elevation={3}>
<Button className={styles.Popper} color="primary" onClick={() => setShowSaveMessageDialog(true)}>
{t('Add to speed sends')}
</Button>
{type !== 'TEXT' && (
<span>
<br />
<Button
className={styles.Popper}
color="primary"
onClick={() => downloadMedia()}
data-testid="downloadMedia"
>
{t('Download media')}
</Button>
</span>
)}
</Paper>
</Fade>
)}
</Popper>
]}
anchorEl={anchorEl}
placement={placement}
transition
data-testid="popup"
>
{({ TransitionProps }) => (
<Fade {...TransitionProps} timeout={350}>
<Paper elevation={3}>
<Button className={styles.Popper} color="primary" onClick={() => setShowSaveMessageDialog(true)}>
{t('Add to speed sends')}
</Button>
{type !== 'TEXT' && (
<span>
<br />
<Button
className={styles.Popper}
color="primary"
onClick={() => downloadMedia()}
data-testid="downloadMedia"
>
{t('Download media')}
</Button>
</span>
)}
</Paper>
</Fade>
)}
</Popper>
)}
</div>
{iconLeft ? null : icon}
{iconLeft ? null : showIcon && icon}
</div>
<div className={styles.SendBy}>{sendBy}</div>

1 change: 1 addition & 0 deletions src/containers/Chat/ChatMessages/ChatMessages.tsx
Original file line number Diff line number Diff line change
@@ -549,6 +549,7 @@ export const ChatMessages = ({ entityId, collectionId, phoneId }: ChatMessagesPr
onClick={() => showEditDialog(message.id)}
focus={index === 0}
jumpToMessage={jumpToMessage}
showIcon={!groups}
daySeparator={showDaySeparator(
reverseConversation[index].insertedAt,
reverseConversation[index + 1] ? reverseConversation[index + 1].insertedAt : null
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.Container {
background-color: #f8faf5;
border: 1px solid #cccccc;
border-radius: 4px;
margin: 1rem 0;
padding: 1rem;
}

.Title {
color: #555555;
font-weight: 500;
line-height: 18px;
font-size: 16px;
margin-bottom: 1rem;
}

.OptionField {
display: flex;
gap: 1rem;
align-items: center;
}

.TextField {
width: 100%;
background-color: #ffffff;
border-radius: 12px;
}

.Options {
display: flex;
flex-direction: column;
gap: 1rem;
}

.Options button {
width: 40%;
align-self: flex-end;
}

.RemoveIcon {
cursor: pointer;
}

.EmojiButton {
margin-right: -1rem;
}
Loading
Loading