Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
{
"title": "Tell your opinion about our websites",
"input-placeholder": "Please write here",
"success-title": "Thank you for your feedback!",
"input-placeholder": "(Optional)",
"input-placeholder-1": "What bothered you the most?",
"input-placeholder-2": "What fell short of your expectations?",
"input-placeholder-3": "What could be improved?",
"input-placeholder-4": "Any suggestions for improvement?",
"input-placeholder-5": "Wonderful! What did you like the most?",
"send": "Send",
"loading": "Sending...",
"href-to-fullform": "Go to the full form ->",
"error": "Select emote and then write feedback",
"error-submit-failed": "Submission failed. Please try again.",
"feedback-text": "Give specific feedback",
"success": "Thank you very much! We appreciate your feedback.",
"href-to-webform": "Website form",
"href-to-gameform": "Game form"
"href-to-webform": "Web form",
"href-to-gameform": "Game form",
"rating-label-1": "Bad",
"rating-label-2": "Meh..",
"rating-label-3": "OK",
"rating-label-4": "Good",
"rating-label-5": "Great"
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
{
"title": "Kerro mielipiteesi verkkosivuistamme",
"input-placeholder": "Kirjoita tΓ€hΓ€n",
"success-title": "Kiitos palautteestasi!",
"input-placeholder": "(Valinnainen)",
"input-placeholder-1": "Harmi! MikΓ€ mΓ€tti eniten?",
"input-placeholder-2": "Voi ei - mikΓ€ jΓ€i vajaaksi?",
"input-placeholder-3": "MikÀ oli hyvÀÀ ja mitÀ parantaisit?",
"input-placeholder-4": "Kiva kuulla! Parannus ehdotuksia?",
"input-placeholder-5": "Ihanaa! MikΓ€ oli parasta?",
"send": "LΓ€hetΓ€",
"loading": "LÀhetetÀÀn...",
"href-to-fullform": "Siirry koko lomakkeeseen ->",
"error": "Valitse mieliala ja sitten kirjoita palaute.",
"error-submit-failed": "LΓ€hetys epΓ€onnistui. YritΓ€ uudelleen.",
"feedback-text": "Anna tarkempi palaute",
"success": "Kiitos paljon! Arvostamme palautettasi.",
"href-to-webform": "Verkkosivulomake",
"href-to-gameform": "Pelilomake"
"href-to-webform": "Web lomake",
"href-to-gameform": "Peli lomake",
"rating-label-1": "Huono",
"rating-label-2": "Meh..",
"rating-label-3": "Ihan ok",
"rating-label-4": "HyvΓ€",
"rating-label-5": "Loistava"
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
{
"title": "ΠŸΠΎΠ΄Π΅Π»ΠΈΡ‚Π΅ΡΡŒ своим ΠΌΠ½Π΅Π½ΠΈΠ΅ΠΌ ΠΎ нашСм сайтС",
"success-title": "Бпасибо Π·Π° ваш ΠΎΡ‚Π·Ρ‹Π²!",
"input-placeholder": "ΠΠ°ΠΏΠΈΡˆΠΈΡ‚Π΅ сюда",
"input-placeholder-1": "Π§Ρ‚ΠΎ Π²Π°ΠΌ Π½Π΅ ΠΏΠΎΠ½Ρ€Π°Π²ΠΈΠ»ΠΎΡΡŒ большС всСго?",
"input-placeholder-2": "Π§Ρ‚ΠΎ Π½Π΅ ΠΎΠΏΡ€Π°Π²Π΄Π°Π»ΠΎ Π²Π°ΡˆΠΈΡ… ΠΎΠΆΠΈΠ΄Π°Π½ΠΈΠΉ?",
"input-placeholder-3": "Π§Ρ‚ΠΎ Π±Ρ‹Π»ΠΎ Ρ…ΠΎΡ€ΠΎΡˆΠΎ ΠΈ Ρ‡Ρ‚ΠΎ ΠΌΠΎΠΆΠ½ΠΎ ΡƒΠ»ΡƒΡ‡ΡˆΠΈΡ‚ΡŒ?",
"input-placeholder-4": "ΠŸΡ€ΠΈΡΡ‚Π½ΠΎ ΡΠ»Ρ‹ΡˆΠ°Ρ‚ΡŒ! Π•ΡΡ‚ΡŒ прСдлоТСния ΠΏΠΎ ΡƒΠ»ΡƒΡ‡ΡˆΠ΅Π½ΠΈΡŽ?",
"input-placeholder-5": "Π—Π°ΠΌΠ΅Ρ‡Π°Ρ‚Π΅Π»ΡŒΠ½ΠΎ! Π§Ρ‚ΠΎ ΠΏΠΎΠ½Ρ€Π°Π²ΠΈΠ»ΠΎΡΡŒ большС всСго?",
"send": "ΠžΡ‚ΠΏΡ€Π°Π²ΠΈΡ‚ΡŒ",
"loading": "ΠžΡ‚ΠΏΡ€Π°Π²ΠΊΠ°...",
"href-to-fullform": "ΠŸΠ΅Ρ€Π΅ΠΉΡ‚ΠΈ ΠΊ ΠΏΠΎΠ»Π½ΠΎΠΉ Ρ„ΠΎΡ€ΠΌΠ΅ ->",
"error": "Π’Ρ‹Π±Π΅Ρ€ΠΈΡ‚Π΅ настроСниС ΠΈ Π·Π°Ρ‚Π΅ΠΌ Π½Π°ΠΏΠΈΡˆΠΈΡ‚Π΅ ΠΎΡ‚Π·Ρ‹Π².",
"error-submit-failed": "ΠžΡ‚ΠΏΡ€Π°Π²ΠΊΠ° Π½Π΅ ΡƒΠ΄Π°Π»Π°ΡΡŒ. ΠŸΠΎΠΏΡ€ΠΎΠ±ΡƒΠΉΡ‚Π΅ снова.",
"feedback-text": "ΠžΡΡ‚Π°Π²ΡŒΡ‚Π΅ ΠΏΠΎΠ΄Ρ€ΠΎΠ±Π½Ρ‹ΠΉ ΠΎΡ‚Π·Ρ‹Π²",
"success": "Π‘ΠΎΠ»ΡŒΡˆΠΎΠ΅ спасибо! ΠœΡ‹ Ρ†Π΅Π½ΠΈΠΌ ваш ΠΎΡ‚Π·Ρ‹Π².",
"href-to-webform": "ΠžΡ‚Π·Ρ‹Π² ΠΎ сайтС",
"href-to-gameform": "ΠžΡ‚Π·Ρ‹Π² ΠΎ ΠΈΠ³Ρ€Π΅"
"href-to-webform": "Π€ΠΎΡ€ΠΌΠ° сайта",
"href-to-gameform": "Π€ΠΎΡ€ΠΌΠ° ΠΈΠ³Ρ€Ρ‹"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import React, {
memo,
DetailedHTMLProps,
InputHTMLAttributes,
TextareaHTMLAttributes,
useState,
useEffect,
useId,
Expand Down Expand Up @@ -318,12 +319,52 @@ function MultiSelectionDropdown<T>({
);
}

type TextareaFieldProps = {
label?: string;
error?: any;
className?: string;
textareaProps?: DetailedHTMLProps<
TextareaHTMLAttributes<HTMLTextAreaElement>,
HTMLTextAreaElement
>;
};

function TextareaField({ label, error, textareaProps, className = '' }: TextareaFieldProps) {
const reactId = useId();
const slug = slugifyLabel(label);
const normalizedReactId = reactId
.toString()
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-');
const textareaId =
textareaProps?.id || (slug ? `textarea-${slug}` : `textarea-${normalizedReactId}`);

return (
<div className={classNames(cls.field, {}, [className])}>
{label && <label htmlFor={textareaId}>{label}</label>}
<textarea
id={textareaId}
{...textareaProps}
/>
{error && (
<p
role="alert"
className={cls.error}
>
{error}
</p>
)}
</div>
);
}

interface IFormProps extends HTMLAttributes<HTMLFormElement> {}

interface MemoizedFormCompose {
Button: typeof Button;
Header: typeof Header;
InputField: typeof InputField;
TextareaField: typeof TextareaField;
Checkbox: typeof Checkbox;
MultiSelectionDropdown: typeof MultiSelectionDropdown;
}
Expand Down Expand Up @@ -359,6 +400,7 @@ const MemoizedForm = memo(BaseForm) as NamedExoticComponent<IFormProps> & Memoiz
MemoizedForm.Button = Button;
MemoizedForm.Header = Header;
MemoizedForm.InputField = InputField;
MemoizedForm.TextareaField = TextareaField;
MemoizedForm.Checkbox = Checkbox;
MemoizedForm.MultiSelectionDropdown = MultiSelectionDropdown;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as FeedbackSideButton } from './ui/FeedbackSideButton/FeedbackSideButton';
export { default as FeedbackCard } from './ui/FeedbackCard/FeedbackCard';
export { default as FeedbackEmoji } from './ui/FeedbackEmoji/FeedbackEmoji';
export { default as FeedbackCardSuccess } from './ui/FeedbackCardSuccess/FeedbackCardSuccess';
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@
background-color: var(--base-card-background);
display: flex;
flex-direction: column;
margin: 5px;
width: 330px !important;
height: fit-content;
padding-top: 0;
max-width: 300px;
height: 400px;
align-items: center;
gap: 10px;
gap: 8px;
box-shadow: 8px 8px 1px #000000;
border-width: 4px;
border-style: solid;
border-color: #000000;
}

.feedbackTitle {
line-height: 40px !important;
font:var(--font-sw-xl);
padding: 5px 1em 0 1em;
height: fit-content;
font-size: 24px;
font-family: 'Marko One';
font-weight: 400;
line-height: 100%;
color: var(--primary-color);
text-align: center;
width: 100%;
Expand All @@ -36,64 +34,66 @@
align-items: center;
padding: 9px 12px;
gap: 10px;
width: 300px;
width:250px;
height: 48px;
background: var(--primary-color) !important;
border: 2px solid var(--drop-shadows) !important;
border-radius: 25px !important;
box-shadow: 2px 4px 0 var(--black) !important;
}

.inputField {
label {
font: var(--font-dm-m);
font-size: 14px;
color: var(--white);
display: block;
}
}

.textInput {
font: var(--font-dm-m);
color: var(--black);
width: 300px !important;
height: 45px;
padding: 10px 10px;
height: 81px;
padding: 10px;
border-radius: 12px;
background: #FFFFFF;
border: 2px solid #000000;
box-shadow: 2px 4px 0 #121212;
border-radius: 25px !important;
box-sizing: border-box;
resize: none;
vertical-align: top;
outline: none;
}

.emojiList {
display: inline-flex !important;
justify-content: space-between;
align-items: center;
align-items: start;
width: 100%;
padding-bottom: 5px;
box-sizing: border-box;
}

.linkToForm {
display: flex;
flex-direction: row;
font: var(--font-dm-m);
color: var(--white);
height: 100px;
}

.linkToFormContainer {
width: 300px;
max-width:fit-content;
display: inline-flex !important;
flex-direction: row;
justify-content: space-between;
gap: unset;
gap: 10px;
}

.linkToFormContainer > * {
display: inline-block;
vertical-align: middle;
justify-items: end;
padding: 0 10px 0 10px;
.linkToFormLabel {
font: var(--font-dm-m);
color: var(--white);
padding: 0;
margin: 0;
}

.embedabbleVersion {
background-color: transparent !important;
border: none !important;
box-shadow: none !important;
outline: none !important;
.linkToForm {
display: flex;
flex-direction: row;
align-items: center;
font: var(--font-dm-m);
color: var(--white);
}

.externalLinkIcon {
display: inline;
vertical-align: middle !important;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useClientTranslation } from '@/shared/i18n';
import { AppExternalLinks } from '@/shared/appLinks/appExternalLinks';
import cls from './FeedbackCard.module.scss';
import FeedbackEmoji from '../FeedbackEmoji/FeedbackEmoji';
import FeedbackCardSuccess from '../FeedbackCardSuccess/FeedbackCardSuccess';

/**
* Props for the FeedbackCard component.
Expand All @@ -35,8 +36,21 @@ export default function FeedbackCard({ variant = 'full' }: FeedbackCardProps): J
const { t } = useClientTranslation('feedbackCard');
const [feedback, setFeedback] = useState<string>('');
const [feedbackEmoji, setFeedbackEmoji] = useState<number>();
const [isSubmitted, setIsSubmitted] = useState(false);
const [addFeedback, { isLoading }] = useAddFeedbackMutation();

const RATING_PLACEHOLDERS: Record<number, string> = {
1: t('input-placeholder-1'),
2: t('input-placeholder-2'),
3: t('input-placeholder-3'),
4: t('input-placeholder-4'),
5: t('input-placeholder-5'),
};

const currentPlaceholder = feedbackEmoji
? RATING_PLACEHOLDERS[feedbackEmoji]
: t('input-placeholder');

/**
* Display a toast message to the user.
* @function
Expand All @@ -56,7 +70,7 @@ export default function FeedbackCard({ variant = 'full' }: FeedbackCardProps): J
* It sends the feedback data to the server if valid.
*/
const submitFeedback = async () => {
if (!feedback || !feedbackEmoji) {
if (!feedbackEmoji) {
showToast(t('error'), 'error');
return;
}
Expand All @@ -69,13 +83,22 @@ export default function FeedbackCard({ variant = 'full' }: FeedbackCardProps): J
await addFeedback(feedbackData).unwrap();

showToast(t('success'), 'success');
setIsSubmitted(true);
setFeedback('');
setFeedbackEmoji(undefined);
} catch {
showToast(t('error-submit-failed'), 'error');
}
};

if (isSubmitted) {
return (
<FeedbackCardSuccess
className={variant === 'embedabble' ? cls.embedabbleVersion : ''}
rating={feedbackEmoji}
/>
);
}

return (
<CustomForm
className={`${cls.feedbackForm} ${variant === 'embedabble' ? cls.embedabbleVersion : ''}`}
Expand All @@ -90,9 +113,10 @@ export default function FeedbackCard({ variant = 'full' }: FeedbackCardProps): J
value={feedbackEmoji}
onImageClick={setFeedbackEmoji}
/>
<CustomForm.InputField
label=""
inputProps={{
<CustomForm.TextareaField
className={cls.inputField}
label={feedbackEmoji ? currentPlaceholder : '\u00A0'}
textareaProps={{
className: cls.textInput,
placeholder: t('input-placeholder'),
value: feedback,
Expand All @@ -118,6 +142,7 @@ export default function FeedbackCard({ variant = 'full' }: FeedbackCardProps): J
</>
)}
</CustomForm.Button>
<span className={cls.linkToFormLabel}>{t('feedback-text')}</span>
<div className={cls.linkToFormContainer}>
<a
className={cls.linkToForm}
Expand All @@ -132,6 +157,7 @@ export default function FeedbackCard({ variant = 'full' }: FeedbackCardProps): J
icon={faExternalLink}
/>
</a>

<a
className={cls.linkToForm}
href={AppExternalLinks.googleFeedback}
Expand Down
Loading
Loading