Skip to content
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

fix: feedback #44

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/next/public/static/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@
"feedback": {
"title": "Feedback",
"placeholder": "Write your problem.",
"submit": "Submit"
"submit": "Submit",
"success": "Your feedback has been successfully sent.",
"error": "An error occurred while sending your feedback."
},
"navbar": {
"home": "Home",
Expand Down
4 changes: 3 additions & 1 deletion apps/next/public/static/locales/tr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
"feedback": {
"title": "Geri Bildirim",
"placeholder": "Lütfen geri bildiriminizi giriniz.",
"submit": "Gönder"
"submit": "Gönder",
"success": "Geri bildiriminiz başarıyla gönderildi. Teşekkür ederiz.",
"error": "Geri bildiriminiz gönderilirken bir hata oluştu. Lütfen daha sonra tekrar deneyiniz."
},
"notifications": {
"success": "Başarılı",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
TooltipContent,
TooltipProvider,
TooltipTrigger,
toast,
} from "@wordigo/ui";
import { cn } from "@wordigo/ui/lib/utils";
import { useTranslation } from "next-i18next";
Expand All @@ -23,17 +24,31 @@ const Feedback = () => {
const [active, setActive] = useState();
const feedbacks = useFeedbacksConstants();
const [inputValue, setInputValue] = useState<string>("");
const [calendarOpen, setCalendarOpen] = useState(false);
const [FeedBack, { status, isLoading, data }] = usePostFeedBackMutation();

const handleSubmitFeedback = () => {
void FeedBack({
description: inputValue,
rate: active,
});
})
.then(() => {
toast({
title: t("notifications.success"),
description: t("feedback.success"),
});
setCalendarOpen(false);
})
.catch(() => {
toast({
title: t("notifications.error"),
description: t("feedback.error"),
});
});
};

return (
<Popover>
<Popover open={calendarOpen} onOpenChange={setCalendarOpen}>
<PopoverTrigger asChild>
<Button variant="outline">{t("feedback.title")}</Button>
</PopoverTrigger>
Expand Down
5 changes: 5 additions & 0 deletions apps/next/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import ProfileSlice from "./profile/slice";
import { publicDictionariesApi } from "./publicDictionaries/api";
import publicDictionaresSlice from "./publicDictionaries/slice";
import { configureStore } from "@reduxjs/toolkit";
import { feedbackApi } from "./feedback/api";
import FeedbackSlice from "./feedback/slice";

const store = configureStore({
reducer: {
Expand All @@ -20,11 +22,13 @@ const store = configureStore({
common: CommonSlice,
profile: ProfileSlice,
publicDictionaries: publicDictionaresSlice,
feedback: FeedbackSlice,
[authApi.reducerPath]: authApi.reducer,
[publicDictionariesApi.reducerPath]: publicDictionariesApi.reducer,
[dictionaryApi.reducerPath]: dictionaryApi.reducer,
[dictionaryWordApi.reducerPath]: dictionaryWordApi.reducer,
[profileApi.reducerPath]: profileApi.reducer,
[feedbackApi.reducerPath]: feedbackApi.reducer,
},
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({ serializableCheck: false }).concat([
Expand All @@ -33,6 +37,7 @@ const store = configureStore({
dictionaryWordApi.middleware,
profileApi.middleware,
publicDictionariesApi.middleware,
feedbackApi.middleware,
]),
});

Expand Down
Loading
Loading