Skip to content

Commit 0b2512b

Browse files
committed
fix feedback button
1 parent e227b4c commit 0b2512b

3 files changed

Lines changed: 18 additions & 15 deletions

File tree

src/ui/language/translations.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ const translations = {
6464
placeholder: "Enter your text",
6565
submitting: "Submitting...",
6666
submitBtn: "Submit",
67-
messagePrompt: "Or send us an email. We will get back to you as quickly as we can!"
67+
messagePrompt: "Or send us an email. We will get back to you as quickly as we can!",
68+
successMessage: "Thank you for your feedback!",
6869
},
6970
principles: {
7071
header: "And this is how it works",
@@ -349,7 +350,8 @@ const translations = {
349350
placeholder: "Gib deinen Text ein",
350351
submitting: "Wird gesendet...",
351352
submitBtn: "Absenden",
352-
messagePrompt: "Oder schick uns eine Nachricht. Wir melden uns so schnell wie möglich zurück!"
353+
messagePrompt: "Oder schick uns eine Nachricht. Wir melden uns so schnell wie möglich zurück!",
354+
successMessage: "Vielen Dank für dein Feedback!",
353355
},
354356
principles: {
355357
header: "Und so funktioniert's",

src/ui/screens/landing-page/sections/feedback/components/FeedbackBox.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ const FeedbackBox = ({ isDesktop }) => {
1313
const {
1414
feedbackText,
1515
setFeedbackText,
16+
success,
1617
error,
1718
submitFeedback,
1819
} = useFeedbackHandler();
1920

2021
return (
2122
<VBox
2223
sx={{
23-
gap: theme.spacing(8),
24+
gap: 4,
2425
width: '100%',
2526
border: isDesktop ? `1px solid ${theme.palette.black.light}` : null,
2627
borderRadius: theme.shape.borderRadius,
@@ -29,7 +30,7 @@ const FeedbackBox = ({ isDesktop }) => {
2930
}}>
3031
<VBox sx={{
3132
alignItems: isDesktop ? 'flex-start' : 'flex-end',
32-
gap: theme.spacing(4),
33+
gap: 4,
3334
}}>
3435
<Typography variant="h4" sx={{ fontWeight: 400 }}>
3536
{t('home.feedback.writePrompt')}
@@ -56,9 +57,14 @@ const FeedbackBox = ({ isDesktop }) => {
5657
onClick={submitFeedback}
5758
/>
5859
</VBox>
60+
{(success) && (
61+
<Typography color="success.main">
62+
{t('home.feedback.successMessage')}
63+
</Typography>
64+
)}
5965
{error && (
6066
<Typography color="error">
61-
{error} {/* Error message displayed here */}
67+
{error}
6268
</Typography>
6369
)}
6470
<HBox sx={{
@@ -75,7 +81,7 @@ const FeedbackBox = ({ isDesktop }) => {
7581
<HBox sx={{ flex: 2, alignItems: "center", justifyContent: "flex-end" }}>
7682
<EmailIcon />
7783
<Link href={`mailto:info@foerderfunke.org`}
78-
sx={{ textDecoration: 'underline', color: theme.palette.black.main }}>
84+
sx={{ textDecoration: 'underline', color: 'black.main' }}>
7985
info@foerderfunke.org
8086
</Link>
8187
</HBox>

src/ui/screens/landing-page/sections/feedback/hooks/useFeedbackHandler.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@ import { useState } from "react";
22

33
const useFeedbackHandler = () => {
44
const [feedbackText, setFeedbackText] = useState("");
5-
const [feedbackValue, setFeedbackValue] = useState(null);
65
const [isSubmitting, setIsSubmitting] = useState(false);
6+
const [success, setSuccess] = useState(false);
77
const [error, setError] = useState(null);
88

99
const submitFeedback = async () => {
10-
const body = {
11-
feedback_value: feedbackValue,
12-
feedback_text: feedbackText,
13-
};
10+
const body = { feedback_text: feedbackText };
1411

1512
try {
1613
setIsSubmitting(true);
@@ -25,13 +22,11 @@ const useFeedbackHandler = () => {
2522
body: JSON.stringify(body),
2623
});
2724

28-
// Check if response status is not 200
2925
if (response.status !== 200) {
3026
throw new Error(`Request failed with status ${response.status}`);
3127
}
3228

33-
const result = await response.json();
34-
console.log("Response:", result);
29+
setSuccess(true);
3530
} catch (err) {
3631
console.error("Error sending feedback:", err);
3732
setError("Failed to submit feedback: " + err.message);
@@ -43,8 +38,8 @@ const useFeedbackHandler = () => {
4338
return {
4439
feedbackText,
4540
setFeedbackText,
46-
setFeedbackValue,
4741
isSubmitting,
42+
success,
4843
error,
4944
submitFeedback,
5045
};

0 commit comments

Comments
 (0)