Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
akanshaaa19 committed Jan 20, 2025
1 parent 5393f24 commit 825338c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 17 deletions.
36 changes: 21 additions & 15 deletions src/containers/WaGroups/WaPolls/WaPollOptions/WaPollOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const emojiStyles = {

export const WaPollOptions = ({ form: { values, setFieldValue, errors, touched }, isEditing }: WaPollOptionsProps) => {
const handleAddOption = () => {
setFieldValue('options', [...values.options, { name: '', id: Math.random() }]);
const lastId = values?.options[values?.options.length - 1]?.id;
setFieldValue('options', [...values.options, { name: '', id: lastId + 1 }]);
};

const handleInput = (value: any, id: any) => {
Expand Down Expand Up @@ -66,7 +67,7 @@ export const WaPollOptions = ({ form: { values, setFieldValue, errors, touched }
{errors['options'] && typeof errors['options'] === 'string' && errors['options']}
</FormHelperText>

{values.options.length < 10 && !isEditing && (
{values.options.length < 12 && !isEditing && (
<Button variant="outlined" onClick={handleAddOption}>
Add Option
</Button>
Expand Down Expand Up @@ -116,16 +117,24 @@ const PollOption = ({
input: {
endAdornment: !isEditing && (
<ClickAwayListener onClickAway={() => setShowEmojiPicker(false)}>
<IconButton
data-testid="emoji-picker"
color="primary"
aria-label="pick emoji"
component="span"
className={styles.EmojiButton}
onClick={() => setShowEmojiPicker(!showEmojiPicker)}
>
<EmojiEmotionsOutlinedIcon className={styles.EmojiIcon} role="img" aria-label="pick emoji" />
</IconButton>
<div>
<IconButton
data-testid="emoji-picker"
color="primary"
aria-label="pick emoji"
component="span"
className={styles.EmojiButton}
onClick={() => setShowEmojiPicker(!showEmojiPicker)}
>
<EmojiEmotionsOutlinedIcon className={styles.EmojiIcon} role="img" aria-label="pick emoji" />
</IconButton>
{showEmojiPicker && (
<EmojiPicker
onEmojiSelect={(emoji: any) => handleEmojiAdd(emoji, option.id)}
displayStyle={emojiStyles}
/>
)}
</div>
</ClickAwayListener>
),
},
Expand All @@ -140,9 +149,6 @@ const PollOption = ({
onClick={() => handleRemoveClick(option.id)}
/>
)}
{showEmojiPicker && (
<EmojiPicker onEmojiSelect={(emoji: any) => handleEmojiAdd(emoji, option.id)} displayStyle={emojiStyles} />
)}
</div>
{hasError ? <FormHelperText>{errors[ind]?.name || ''}</FormHelperText> : null}
</FormControl>
Expand Down
18 changes: 17 additions & 1 deletion src/containers/WaGroups/WaPolls/WaPollsList/WaPollsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router';

import CollectionIcon from 'assets/images/icons/Collection/Dark.svg?react';
import CopyAllOutlined from 'assets/images/icons/Flow/Copy.svg?react';
import DeleteIcon from 'assets/images/icons/Delete/Red.svg?react';
import DuplicateIcon from 'assets/images/icons/Duplicate.svg?react';
import { copyToClipboardMethod } from 'common/utils';
import { pollsInfo } from 'common/HelpData';
import { setErrorMessage, setNotification } from 'common/notification';
import { DialogBox } from 'components/UI/DialogBox/DialogBox';
Expand Down Expand Up @@ -74,14 +76,28 @@ export const WaPollsList = () => {
});
};

const copyUuid = (_id: string, item: any) => {
if (item.uuid) {
copyToClipboardMethod(item.uuid);
} else {
setNotification('Sorry! UUID not found', 'warning');
}
};

const getRestrictedAction = () => {
const action: any = { edit: false, delete: false };
return action;
};

const additionalAction = () => [
{
label: t('Copy'),
label: t('Copy UUID'),
icon: <CopyAllOutlined data-testid="copy-button" />,
parameter: 'id',
dialog: copyUuid,
},
{
label: t('Copy Poll'),
icon: <DuplicateIcon />,
parameter: 'id',
insideMore: false,
Expand Down
1 change: 1 addition & 0 deletions src/graphql/queries/WaPolls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const GET_POLLS = gql`
id
label
pollContent
uuid
}
}
`;
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/en/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -533,5 +533,6 @@
"Last name is required.": "Last name is required.",
"Failed": "Failed",
"Members": "Members",
"Group polls": "Group polls"
"Group polls": "Group polls",
"Copy Poll": "Copy Poll"
}

0 comments on commit 825338c

Please sign in to comment.