From afc0559456e4b32f53a59ef97adbcc6fb0f92ec9 Mon Sep 17 00:00:00 2001 From: pal-sig <88981777+pal-sig@users.noreply.github.com> Date: Thu, 2 Dec 2021 20:12:38 +0530 Subject: [PATCH] feat(UI): sendfeedback is updated (#416) * feat(UI): sendfeedback is updated * chore(UI): config slack hook url is updated * fix(chore): button size is updated * fix(bug): user feedback is updated * chore(bug): z-index is fixed * fix(bug): applayout is updated * fix(bug): applayout is updated --- frontend/src/api/userFeedback/sendFeedback.ts | 21 +++ .../container/AppLayout/FeedBack/index.tsx | 127 ++++++++++++++++++ .../container/AppLayout/FeedBack/styles.ts | 61 +++++++++ frontend/src/container/AppLayout/index.tsx | 16 +-- frontend/src/container/AppLayout/styles.ts | 7 +- .../types/api/userFeedback/sendResponse.ts | 4 + 6 files changed, 223 insertions(+), 13 deletions(-) create mode 100644 frontend/src/api/userFeedback/sendFeedback.ts create mode 100644 frontend/src/container/AppLayout/FeedBack/index.tsx create mode 100644 frontend/src/container/AppLayout/FeedBack/styles.ts create mode 100644 frontend/src/types/api/userFeedback/sendResponse.ts diff --git a/frontend/src/api/userFeedback/sendFeedback.ts b/frontend/src/api/userFeedback/sendFeedback.ts new file mode 100644 index 000000000000..abf811378c2e --- /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 000000000000..13e027980653 --- /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? + + + + + + + +