Skip to content

Commit fa2e639

Browse files
Merge pull request #190 from mercedes-benz/VULCAN-926/feedback-feature
Vulcan 926/feedback feature
2 parents 8741343 + 4a23a74 commit fa2e639

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/component/custom/Feedback.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import Snackbar from '@mui/material/Snackbar';
66
import Alert from '@mui/material/Alert';
77
import Modal from '@mui/material/Modal';
88
import Box from '@mui/material/Box';
9-
import { filesToBase64 } from '../../utils/shareUtils';
9+
import { buildURL, extractQueryParams, filesToBase64, getPath } from '../../utils/shareUtils';
10+
import { useSelector } from 'react-redux';
11+
import { getPages } from '../../dashboard/DashboardSelectors';
12+
import { getGlobalParameters, getPageNumber } from '../../settings/SettingsSelectors';
1013

1114
interface FeedbackErrors {
1215
name?: string;
@@ -47,6 +50,9 @@ const Feedback = () => {
4750
maxHeight: '90vh',
4851
overflowY: 'auto',
4952
};
53+
const pages = useSelector((state) => getPages(state));
54+
const parameters = useSelector((state) => getGlobalParameters(state));
55+
const pageNumber = useSelector((state) => getPageNumber(state));
5056

5157
useEffect(() => {
5258
const fetchUserInfo = async () => {
@@ -122,13 +128,16 @@ const Feedback = () => {
122128
name: reporterName,
123129
};
124130
const base64EncodedFiles = attachments ? await filesToBase64(attachments) : null;
131+
const url: URL = buildURL(
132+
getPath(window.location.href),
133+
extractQueryParams(pages, pageNumber, parameters, true)
134+
);
125135
const requestBody = {
126136
contact: reporterContact,
127137
description: description,
128138
attachments: base64EncodedFiles,
129-
source: window.location.href
139+
source: url.toString(),
130140
};
131-
console.log("URL is ", `${dbQueryUrl}/v1/send-feedback`);
132141
await axios
133142
.post(`${dbQueryUrl}/v1/send-feedback`, requestBody, {
134143
headers: {
@@ -225,7 +234,7 @@ const Feedback = () => {
225234
required
226235
/>
227236
{errors.email && <div style={{ color: 'red', fontStyle: 'italic' }}>{errors.email}</div>}
228-
{emailStatus && <small style={{ color: 'lightgray', fontStyle: 'italic'}}>{emailStatus}</small>}
237+
{emailStatus && <small style={{ color: 'lightgray', fontStyle: 'italic' }}>{emailStatus}</small>}
229238
</label>
230239

231240
<label style={{ marginTop: '1em' }}>
@@ -259,11 +268,10 @@ const Feedback = () => {
259268
style={{
260269
marginTop: '2em',
261270
display: 'flex',
262-
justifyContent: 'flex-end',
271+
justifyContent: 'center',
263272
gap: '1em',
264273
}}
265274
>
266-
<Button onClick={closeModal}>Cancel</Button>
267275
<Button style={{ padding: '10px 24px' }} type='submit'>
268276
Submit
269277
</Button>

0 commit comments

Comments
 (0)