diff --git a/frontend/src/api/userFeedback/sendFeedback.ts b/frontend/src/api/userFeedback/sendFeedback.ts new file mode 100644 index 0000000000..abf811378c --- /dev/null +++ b/frontend/src/api/userFeedback/sendFeedback.ts @@ -0,0 +1,21 @@ +import axios from 'api'; +import { Props } from 'types/api/userFeedback/sendResponse'; + +const sendFeedback = async (props: Props): Promise => { + const response = await axios.post( + '/feedback', + { + email: props.email, + message: props.message, + }, + { + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + }, + ); + + return response.status; +}; + +export default sendFeedback; diff --git a/frontend/src/container/AppLayout/FeedBack/index.tsx b/frontend/src/container/AppLayout/FeedBack/index.tsx new file mode 100644 index 0000000000..13e0279806 --- /dev/null +++ b/frontend/src/container/AppLayout/FeedBack/index.tsx @@ -0,0 +1,127 @@ +import { CloseCircleOutlined, CommentOutlined } from '@ant-design/icons'; +import { Button, Divider, Form, Input, notification, Typography } from 'antd'; +import { Callbacks } from 'rc-field-form/lib/interface'; +import React, { useCallback, useState } from 'react'; + +import { + Button as IconButton, + ButtonContainer, + Card, + CenterText, + Container, + TitleContainer, + FormItem, +} from './styles'; +const { Title } = Typography; +const { TextArea } = Input; +import sendFeedbackApi from 'api/userFeedback/sendFeedback'; + +const Feedback = (): JSX.Element => { + const [isOpen, setisOpen] = useState(false); + const [form] = Form.useForm(); + const [isLoading, setIsLoading] = useState(false); + + const [notifications, Element] = notification.useNotification(); + + const isToggleHandler = useCallback(() => { + setisOpen((state) => !state); + }, []); + + const onFinishHandler: Callbacks['onFinish'] = async ( + value: Feedback, + ): Promise => { + try { + setIsLoading(true); + const { feedback, email = '' } = value; + + const response = await sendFeedbackApi({ + email, + message: feedback, + }); + + if (response === 200) { + notifications.success({ + message: 'Thanks for your feedback!', + description: + 'We have noted down your feedback and will work on improving SIgNoz based on that!', + }); + + isToggleHandler(); + } else { + notifications.error({ + message: 'Error!', + description: 'Something went wrong', + }); + } + setIsLoading(false); + } catch (error) { + notifications.error({ + message: 'Something went wrong', + }); + setIsLoading(false); + } + }; + + return ( + + {!isOpen && ( + + + + )} + + {Element} + + {isOpen && ( +
+ + + + How can we improve SigNoz? + + + + + + + +