From 825338c113321b9f2c55a02df53ac96a88cb9fab Mon Sep 17 00:00:00 2001 From: Akansha Sakhre Date: Mon, 20 Jan 2025 16:01:11 +0530 Subject: [PATCH] minor fixes --- .../WaPolls/WaPollOptions/WaPollOptions.tsx | 36 +++++++++++-------- .../WaPolls/WaPollsList/WaPollsList.tsx | 18 +++++++++- src/graphql/queries/WaPolls.ts | 1 + src/i18n/en/en.json | 3 +- 4 files changed, 41 insertions(+), 17 deletions(-) diff --git a/src/containers/WaGroups/WaPolls/WaPollOptions/WaPollOptions.tsx b/src/containers/WaGroups/WaPolls/WaPollOptions/WaPollOptions.tsx index 6ed1965e1..8c2195988 100644 --- a/src/containers/WaGroups/WaPolls/WaPollOptions/WaPollOptions.tsx +++ b/src/containers/WaGroups/WaPolls/WaPollOptions/WaPollOptions.tsx @@ -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) => { @@ -66,7 +67,7 @@ export const WaPollOptions = ({ form: { values, setFieldValue, errors, touched } {errors['options'] && typeof errors['options'] === 'string' && errors['options']} - {values.options.length < 10 && !isEditing && ( + {values.options.length < 12 && !isEditing && ( @@ -116,16 +117,24 @@ const PollOption = ({ input: { endAdornment: !isEditing && ( setShowEmojiPicker(false)}> - setShowEmojiPicker(!showEmojiPicker)} - > - - +
+ setShowEmojiPicker(!showEmojiPicker)} + > + + + {showEmojiPicker && ( + handleEmojiAdd(emoji, option.id)} + displayStyle={emojiStyles} + /> + )} +
), }, @@ -140,9 +149,6 @@ const PollOption = ({ onClick={() => handleRemoveClick(option.id)} /> )} - {showEmojiPicker && ( - handleEmojiAdd(emoji, option.id)} displayStyle={emojiStyles} /> - )} {hasError ? {errors[ind]?.name || ''} : null} diff --git a/src/containers/WaGroups/WaPolls/WaPollsList/WaPollsList.tsx b/src/containers/WaGroups/WaPolls/WaPollsList/WaPollsList.tsx index 913cdc9e9..f2a30d1f7 100644 --- a/src/containers/WaGroups/WaPolls/WaPollsList/WaPollsList.tsx +++ b/src/containers/WaGroups/WaPolls/WaPollsList/WaPollsList.tsx @@ -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'; @@ -74,6 +76,14 @@ 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; @@ -81,7 +91,13 @@ export const WaPollsList = () => { const additionalAction = () => [ { - label: t('Copy'), + label: t('Copy UUID'), + icon: , + parameter: 'id', + dialog: copyUuid, + }, + { + label: t('Copy Poll'), icon: , parameter: 'id', insideMore: false, diff --git a/src/graphql/queries/WaPolls.ts b/src/graphql/queries/WaPolls.ts index 115698edf..fd7856701 100644 --- a/src/graphql/queries/WaPolls.ts +++ b/src/graphql/queries/WaPolls.ts @@ -7,6 +7,7 @@ export const GET_POLLS = gql` id label pollContent + uuid } } `; diff --git a/src/i18n/en/en.json b/src/i18n/en/en.json index e2fb3db4f..245289e58 100644 --- a/src/i18n/en/en.json +++ b/src/i18n/en/en.json @@ -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" }