-
Notifications
You must be signed in to change notification settings - Fork 4
Add ChatButton component with chat options #34
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,79 @@ | ||||||||||||||||||||||
| import { | ||||||||||||||||||||||
| Box, | ||||||||||||||||||||||
| IconButton, | ||||||||||||||||||||||
| Image, | ||||||||||||||||||||||
| Menu, | ||||||||||||||||||||||
| MenuButton, | ||||||||||||||||||||||
| MenuItem, | ||||||||||||||||||||||
| MenuList, | ||||||||||||||||||||||
| Tooltip, | ||||||||||||||||||||||
| } from '@chakra-ui/react'; | ||||||||||||||||||||||
| import { useState } from 'react'; | ||||||||||||||||||||||
| import { | ||||||||||||||||||||||
| AiOutlineMail, | ||||||||||||||||||||||
| AiOutlineMessage, | ||||||||||||||||||||||
| AiOutlinePhone, | ||||||||||||||||||||||
| } from 'react-icons/ai'; | ||||||||||||||||||||||
| import ChatWithUsIcon from '../shared/assets/img/chat-with-us-icon.svg'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| interface ChatButtonProps { | ||||||||||||||||||||||
| salesButtonAction: () => void; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export const ChatButton = ({ salesButtonAction }: ChatButtonProps) => { | ||||||||||||||||||||||
| const [showOptions, setShowOptions] = useState(false); | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused State VariableState variable 'showOptions' is declared and updated but never actually used in component logic. The Menu component manages its own internal state, making this redundant state management that could cause confusion and unnecessary re-renders. Standards
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Remove unused state. The Apply this diff to remove the unused state: - const [showOptions, setShowOptions] = useState(false);
🤖 Prompt for AI Agents |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const openChat = () => { | ||||||||||||||||||||||
| if (window?.Intercom) { | ||||||||||||||||||||||
| window?.Intercom('show'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+27
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accessing declare global {
interface Window {
Intercom?: (command: 'show' | 'hide' | 'shutdown', ...args: any[]) => void;
}
}
// This is needed to make the file a module.
export {};This will make TypeScript aware of the
Comment on lines
+27
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DOM-based XSS RiskDirect access to global window object and execution of Intercom method without validation creates DOM-based XSS vulnerability. Malicious scripts could override window.Intercom to execute arbitrary code when openChat is triggered. Commitable Suggestion
Suggested change
Standards
|
||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const openEmail = () => { | ||||||||||||||||||||||
| window.open('mailto:support@devdynamics.ai'); | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unsafe Window OperationDirect window.open call without null safety check creates runtime failure risk. Server-side rendering or restricted browser environments cause TypeError exceptions that crash component functionality. Standards
|
||||||||||||||||||||||
| }; | ||||||||||||||||||||||
| return ( | ||||||||||||||||||||||
| <Box | ||||||||||||||||||||||
| alignSelf={'center'} | ||||||||||||||||||||||
| borderRadius={'4px'} | ||||||||||||||||||||||
| border={'1px solid #4d4dff'} | ||||||||||||||||||||||
| _hover={{ backgroundColor: 'transparent' }} | ||||||||||||||||||||||
| height={'95%'} | ||||||||||||||||||||||
|
Comment on lines
+39
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These style properties use hardcoded values ( |
||||||||||||||||||||||
| > | ||||||||||||||||||||||
| <Menu> | ||||||||||||||||||||||
| <Tooltip | ||||||||||||||||||||||
| aria-label="Talk to us" | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||
| label="Talk to us" | ||||||||||||||||||||||
| hasArrow | ||||||||||||||||||||||
| placement="bottom" | ||||||||||||||||||||||
| > | ||||||||||||||||||||||
| <MenuButton> | ||||||||||||||||||||||
| <IconButton | ||||||||||||||||||||||
| aria-label="Talk to us" | ||||||||||||||||||||||
| variant="ghost" | ||||||||||||||||||||||
| bg="transparent" | ||||||||||||||||||||||
| color="text.primary" | ||||||||||||||||||||||
| _hover={{ bg: 'transparent' }} | ||||||||||||||||||||||
| onClick={() => setShowOptions(!showOptions)} | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||
| icon={<Image src={ChatWithUsIcon} />} | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Add an Severity Level: Minor
Suggested change
Why it matters? ⭐Adding an Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** index.tsx
**Line:** 58:58
**Comment:**
*Best Practice: Add an `alt` attribute to the `Image` used in the IconButton's `icon` prop for accessibility.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. |
||||||||||||||||||||||
| /> | ||||||||||||||||||||||
| </MenuButton> | ||||||||||||||||||||||
| </Tooltip> | ||||||||||||||||||||||
| <MenuList mr={'20px'}> | ||||||||||||||||||||||
| <MenuItem onClick={openChat} icon={<AiOutlineMessage size={20} />}> | ||||||||||||||||||||||
| Chat with us | ||||||||||||||||||||||
| </MenuItem> | ||||||||||||||||||||||
| <MenuItem | ||||||||||||||||||||||
| onClick={salesButtonAction} | ||||||||||||||||||||||
| icon={<AiOutlinePhone size={20} />} | ||||||||||||||||||||||
| > | ||||||||||||||||||||||
| Talk to us | ||||||||||||||||||||||
| </MenuItem> | ||||||||||||||||||||||
| <MenuItem onClick={openEmail} icon={<AiOutlineMail size={20} />}> | ||||||||||||||||||||||
| Email us | ||||||||||||||||||||||
| </MenuItem> | ||||||||||||||||||||||
| </MenuList> | ||||||||||||||||||||||
| </Menu> | ||||||||||||||||||||||
| </Box> | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Verify the asset path exists.
Ensure the SVG asset path
../shared/assets/img/chat-with-us-icon.svgis correct and the file exists.🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 152
🏁 Script executed:
Length of output: 984
🏁 Script executed:
Length of output: 502
Asset import path is invalid and will cause a module resolution error.
The import path
../shared/assets/img/chat-with-us-icon.svgis broken:shared/directory exists in the repository../prefix from the repository root exits the repository entirelyVerify the correct path to the asset file and update the import, or add the missing asset to the repository.
🤖 Prompt for AI Agents