Skip to content

Commit

Permalink
fix: feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufgns committed Oct 23, 2023
1 parent 2fa2504 commit 1f9edce
Show file tree
Hide file tree
Showing 6 changed files with 15,062 additions and 1,309 deletions.
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 @@ -21,6 +22,7 @@ import { useState } from "react";
const Feedback = () => {
const { t } = useTranslation();
const [active, setActive] = useState();
const [popup, setPopup] = useState(false);
const feedbacks = useFeedbacksConstants();
const [inputValue, setInputValue] = useState<string>("");
const [FeedBack, { status, isLoading, data }] = usePostFeedBackMutation();
Expand All @@ -29,12 +31,30 @@ const Feedback = () => {
void FeedBack({
description: inputValue,
rate: active,
});
})
.then(() => {
setPopup(false);
toast({
title: t("notifications.success"),
description: t("feedback.success"),
});
})
.catch(() => {
toast({
title: t("notifications.error"),
description: t("feedback.error"),
});
});
};

const testHandle = () => {
console.log("test");
setPopup(true);
};

return (
<Popover>
<PopoverTrigger asChild>
<PopoverTrigger>
<Button variant="outline">{t("feedback.title")}</Button>
</PopoverTrigger>
<PopoverContent className="w-80">
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

0 comments on commit 1f9edce

Please sign in to comment.