Skip to content

Commit 11fe8c7

Browse files
authored
Merge pull request #3656 from olindost/feature/3535-add-sentiment-feedback-option
Added Sentiment Feedback Option to Feedback Modal
2 parents 6b966f1 + 87ba85a commit 11fe8c7

File tree

3 files changed

+86
-18
lines changed

3 files changed

+86
-18
lines changed

govtool/frontend/src/context/usersnapContext.tsx

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import React, {
66
useMemo,
77
} from "react";
88
import { InitOptions, WidgetApi, loadSpace } from "@usersnap/browser";
9+
import { useTranslation } from "react-i18next";
910

1011
type WidgetValues = {
1112
assignee?: string;
@@ -65,6 +66,7 @@ export const UsersnapProvider = ({
6566
children,
6667
}: UsersnapProviderProps) => {
6768
const [usersnapApi, setUsersnapApi] = useState<UsersnapAPI | null>(null);
69+
const { t } = useTranslation();
6870

6971
const openFeedbackWindow = useCallback(() => {
7072
if (usersnapApi) {
@@ -77,15 +79,47 @@ export const UsersnapProvider = ({
7779
if (API_KEY) {
7880
try {
7981
const api = await loadSpace(API_KEY);
80-
api.init(initParams);
82+
api.init({
83+
...initParams,
84+
customFields: {
85+
sentiment_score: {
86+
type: 'rating',
87+
label: t("feedback.sentimentScore"),
88+
required: true,
89+
options: [1, 2, 3, 4, 5]
90+
},
91+
additional_notes: {
92+
type: 'textarea',
93+
label: t("feedback.additionalNotes"),
94+
required: false
95+
}
96+
},
97+
feedbackTypes: [
98+
{
99+
id: 'bug',
100+
label: t("feedback.reportBug"),
101+
description: t("feedback.reportBugDescription")
102+
},
103+
{
104+
id: 'idea',
105+
label: t("feedback.suggestIdea"),
106+
description: t("feedback.suggestIdeaDescription")
107+
},
108+
{
109+
id: 'sentiment',
110+
label: t("feedback.sentimentFeedback"),
111+
description: t("feedback.sentimentFeedbackDescription")
112+
}
113+
]
114+
});
81115
setUsersnapApi(api);
82116
} catch (error) {
83117
console.error(error);
84118
}
85119
}
86120
};
87121
initUsersnapSpace();
88-
}, [initParams, API_KEY]);
122+
}, [initParams, API_KEY, t]);
89123

90124
const value = useMemo(() => ({ openFeedbackWindow }), [openFeedbackWindow]);
91125

@@ -98,4 +132,4 @@ export const UsersnapProvider = ({
98132

99133
export function useUsersnapApi() {
100134
return useContext(UsersnapContext);
101-
}
135+
}

govtool/frontend/src/i18n/locales/en.json

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@
109109
"noDelegationDescription": "Find a DRep to vote on your behalf.",
110110
"noDelegationActionButton": "View DRep Directory",
111111
"dRepDelegationTitle": "Your Voting Power of <strong>₳{{ada}}</strong>\nis Delegated to:",
112-
"noConfidenceDelegationTitle": "You have delegated your Voting Power <strong>₳{{ada}}</strong>\nto No Confidence",
113-
"abstainDelegationTitle": "You have delegated your Voting Power <strong>₳{{ada}}</strong>\nto Abstain",
112+
"noConfidenceDelegationTitle": "You have delegated your Voting Power <strong>₳{{ada}}</strong>\nto \"No Confidence\"",
113+
"abstainDelegationTitle": "You have delegated your Voting Power <strong>₳{{ada}}</strong>\nto \"Abstain\"",
114114
"abstainDescription": "You have selected to apply your Voting Power to Abstain on every vote.",
115115
"noDescription": "You have selected to apply your Voting Power to No Confidence on every vote.",
116116
"inProgress": {
@@ -283,8 +283,8 @@
283283
"abstainCardDefaultTitle": "Abstain from Every Vote",
284284
"automatedVotingOptions": "Automated Voting Options",
285285
"editBtn": "Edit DRep data",
286-
"delegatedToAbstainTitle": "You have delegated ₳{{ada}} to Abstain",
287-
"delegatedToNoConfidenceTitle": "You have delegated ₳{{ada}} to No Confidence",
286+
"delegatedToAbstainTitle": "You have delegated ₳{{ada}} to \"Abstain\"",
287+
"delegatedToNoConfidenceTitle": "You have delegated ₳{{ada}} to \"No Confidence\"",
288288
"delegatedToAbstainDescription": "You have selected to apply your Voting Power to Abstain on every vote.",
289289
"delegatedToNoConfidenceDescription": "You have selected to apply your Voting Power to No Confidence on every vote.",
290290
"delegationOptions": "Delegation Options",
@@ -429,7 +429,7 @@
429429
"chooseHowToVote": "Choose how you want to vote:",
430430
"contextAboutYourVote": "Context about your vote",
431431
"dataMissing": "Data Missing",
432-
"dataMissingTooltipExplanation": "Please click View Details for more information.",
432+
"dataMissingTooltipExplanation": "Please click \"View Details\" for more information.",
433433
"details": "Governance Details:",
434434
"expiresDateWithEpoch": "Expires: <0>{{date}}</0> <1>(Epoch {{epoch}})</1>",
435435
"expiryDate": "Expiry date:",
@@ -656,7 +656,7 @@
656656
},
657657
"pendingValidation": {
658658
"title": "GovTool Is Checking Your Data",
659-
"message": "GovTool will read the URL that you supplied and make a check to see if its identical with the information that you entered on the form."
659+
"message": "GovTool will read the URL that you supplied and make a check to see if it's identical with the information that you entered on the form."
660660
}
661661
},
662662
"dRepData": {
@@ -694,7 +694,7 @@
694694
"description": "Looks like you have already successfully completed your registration and you currently are a DRep.\n\nYou can view your details in the DRep Directory.",
695695
"viewDetails": "View your DRep details"
696696
},
697-
"becomeADRep": "Become a DRep",
697+
"becomeADrep": "Become a DRep",
698698
"descriptionStepTwo": "By clicking register you create your DRep ID within your wallet and become a DRep.\n\nOnce the registration has completed your DRep ID will be shown on your dashboard. You will be able to share your DRep ID so that other ada holders can delegate their voting power to you.",
699699
"headingStepTwo": "Confirm DRep registration",
700700
"register": "Register",
@@ -721,7 +721,7 @@
721721
}
722722
},
723723
"retirement": {
724-
"notADRep": {
724+
"notADrep": {
725725
"title": "You are not a DRep",
726726
"description": "Looks like you cannot retire, because currently you are not a DRep."
727727
},
@@ -769,7 +769,7 @@
769769
},
770770
"noConfidence": {
771771
"heading": "No confidence",
772-
"paragraphOne": "If you dont have trust in the current constitutional committee you signal No-confidence. By voting ‘No’ means you dont want governance actions to be ratified."
772+
"paragraphOne": "If you don't have trust in the current constitutional committee you signal 'No-confidence'. By voting 'No' means you don't want governance actions to be ratified."
773773
},
774774
"todRep": {
775775
"heading": "Delegation to DRep",
@@ -782,7 +782,7 @@
782782
},
783783
"expiryDate": {
784784
"heading": "Expiry Date",
785-
"paragraphOne": "The date when the governance action will expiry if it doesnt reach ratification thresholds.",
785+
"paragraphOne": "The date when the governance action will expiry if it doesn't reach ratification thresholds.",
786786
"paragraphTwo": "IMPORTANT: If the governance action is ratified before the expiry date it will be considered ratified and it will not be available to vote on afterwards."
787787
},
788788
"submissionDate": {
@@ -796,7 +796,7 @@
796796
}
797797
},
798798
"wallet": {
799-
"cantSeeWalletQuestion": "Cant see your wallet? Check what wallets are currently compatible with GovTool ",
799+
"cantSeeWalletQuestion": "Can't see your wallet? Check what wallets are currently compatible with GovTool ",
800800
"chooseWallet": "Choose the wallet you want to connect with:",
801801
"connect": "Connect",
802802
"connectWallet": "Connect Wallet",
@@ -833,7 +833,7 @@
833833
},
834834
"intersectWebsite": {
835835
"title": "Intersect website",
836-
"description": "Intersect is a member-based organization for the Cardano ecosystem — putting the community at the center of Cardanos development",
836+
"description": "Intersect is a member-based organization for the Cardano ecosystem — putting the community at the center of Cardano's development",
837837
"link": "Intersect website"
838838
}
839839
},
@@ -855,7 +855,18 @@
855855
"cip129DrepId": "(CIP-129) DRep ID",
856856
"cip105DRepId": "Legacy DRep ID (CIP-105)",
857857
"email": "Email",
858-
"feedback": "Feedback",
858+
"feedback": {
859+
"title": "Feedback",
860+
"reportBug": "Report a Bug",
861+
"suggestIdea": "Suggest a New Idea",
862+
"sentimentFeedback": "Sentiment Feedback",
863+
"sentimentScore": "How would you rate your experience?",
864+
"additionalNotes": "Additional Notes",
865+
"submit": "Submit Feedback",
866+
"reportBugDescription": "Something is not working as expected",
867+
"suggestIdeaDescription": "Share your ideas for improvement",
868+
"sentimentFeedbackDescription": "Rate your experience and provide feedback"
869+
},
859870
"filter": "Filter",
860871
"goBack": "Go back",
861872
"goToMainnet": "Go to Mainnet",
@@ -887,4 +898,4 @@
887898
"viewDetails": "View details",
888899
"votingPower": "Voting power",
889900
"yourself": "Yourself"
890-
}
901+
}

tests/govtool-frontend/playwright/tests/10-user-snap/userSnap.spec.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,27 @@ test.describe("Submit Usersnap", () => {
187187

188188
await expect(page.getByText("Thank you!")).toBeVisible();
189189
});
190-
});
190+
191+
test("10F. Should submit sentiment feedback", async ({ page }) => {
192+
// Intercept Usersnap submit API
193+
await interceptUsersnap(page);
194+
await interceptBucket(page);
195+
196+
await page
197+
.getByRole("button", { name: "Share Your Experience" })
198+
.click();
199+
200+
// Select a rating
201+
await page.getByLabel("How would you rate your experience?").click();
202+
await page.getByRole("button", { name: "4" }).click();
203+
204+
// Add additional notes
205+
await page
206+
.getByPlaceholder("Additional Notes")
207+
.fill(faker.lorem.paragraph(2));
208+
209+
await page.getByRole("button", { name: "Submit Feedback" }).click();
210+
211+
await expect(page.getByText("Thank you!")).toBeVisible();
212+
});
213+
});

0 commit comments

Comments
 (0)