Merge pull request #304 from Worklenz/fix/reporting-sidebar-style-fix
feat(survey-localization): add survey localization files for multiple…
This commit is contained in:
14
worklenz-frontend/public/locales/alb/survey.json
Normal file
14
worklenz-frontend/public/locales/alb/survey.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"modalTitle": "Ndihmoni të përmirësojmë përvojën tuaj",
|
||||
"skip": "Kalo për tani",
|
||||
"previous": "Prapa",
|
||||
"next": "Tjetra",
|
||||
"completeSurvey": "Përfundo Anketën",
|
||||
"submitting": "Duke dërguar përgjigjet tuaja...",
|
||||
"submitSuccessTitle": "Faleminderit!",
|
||||
"submitSuccessSubtitle": "Feedback-u juaj na ndihmon të përmirësojmë Worklenz për të gjithë.",
|
||||
"submitSuccessMessage": "Faleminderit që plotësuat anketën!",
|
||||
"submitErrorMessage": "Dështoi dërgimi i anketës. Ju lutemi provoni përsëri.",
|
||||
"submitErrorLog": "Dështoi dërgimi i anketës",
|
||||
"fetchErrorLog": "Dështoi marrja e anketës"
|
||||
}
|
||||
14
worklenz-frontend/public/locales/de/survey.json
Normal file
14
worklenz-frontend/public/locales/de/survey.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"modalTitle": "Helfen Sie uns, Ihre Erfahrung zu verbessern",
|
||||
"skip": "Für jetzt überspringen",
|
||||
"previous": "Zurück",
|
||||
"next": "Weiter",
|
||||
"completeSurvey": "Umfrage abschließen",
|
||||
"submitting": "Ihre Antworten werden übermittelt...",
|
||||
"submitSuccessTitle": "Danke!",
|
||||
"submitSuccessSubtitle": "Ihr Feedback hilft uns, Worklenz für alle zu verbessern.",
|
||||
"submitSuccessMessage": "Danke, dass Sie die Umfrage abgeschlossen haben!",
|
||||
"submitErrorMessage": "Umfrage konnte nicht übermittelt werden. Bitte versuchen Sie es erneut.",
|
||||
"submitErrorLog": "Umfrageübermittlung fehlgeschlagen",
|
||||
"fetchErrorLog": "Umfrageabruf fehlgeschlagen"
|
||||
}
|
||||
14
worklenz-frontend/public/locales/en/survey.json
Normal file
14
worklenz-frontend/public/locales/en/survey.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"modalTitle": "Help Us Improve Your Experience",
|
||||
"skip": "Skip for now",
|
||||
"previous": "Previous",
|
||||
"next": "Next",
|
||||
"completeSurvey": "Complete Survey",
|
||||
"submitting": "Submitting your responses...",
|
||||
"submitSuccessTitle": "Thank you!",
|
||||
"submitSuccessSubtitle": "Your feedback helps us improve Worklenz for everyone.",
|
||||
"submitSuccessMessage": "Thank you for completing the survey!",
|
||||
"submitErrorMessage": "Failed to submit survey. Please try again.",
|
||||
"submitErrorLog": "Failed to submit survey",
|
||||
"fetchErrorLog": "Failed to fetch survey"
|
||||
}
|
||||
14
worklenz-frontend/public/locales/es/survey.json
Normal file
14
worklenz-frontend/public/locales/es/survey.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"modalTitle": "Ayúdanos a mejorar tu experiencia",
|
||||
"skip": "Omitir por ahora",
|
||||
"previous": "Anterior",
|
||||
"next": "Siguiente",
|
||||
"completeSurvey": "Completar encuesta",
|
||||
"submitting": "Enviando tus respuestas...",
|
||||
"submitSuccessTitle": "¡Gracias!",
|
||||
"submitSuccessSubtitle": "Tus comentarios nos ayudan a mejorar Worklenz para todos.",
|
||||
"submitSuccessMessage": "¡Gracias por completar la encuesta!",
|
||||
"submitErrorMessage": "No se pudo enviar la encuesta. Por favor, inténtalo de nuevo.",
|
||||
"submitErrorLog": "Error al enviar la encuesta",
|
||||
"fetchErrorLog": "Error al obtener la encuesta"
|
||||
}
|
||||
14
worklenz-frontend/public/locales/pt/survey.json
Normal file
14
worklenz-frontend/public/locales/pt/survey.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"modalTitle": "Ajude-nos a melhorar sua experiência",
|
||||
"skip": "Pular por enquanto",
|
||||
"previous": "Anterior",
|
||||
"next": "Próximo",
|
||||
"completeSurvey": "Concluir Pesquisa",
|
||||
"submitting": "Enviando suas respostas...",
|
||||
"submitSuccessTitle": "Obrigado!",
|
||||
"submitSuccessSubtitle": "Seu feedback nos ajuda a melhorar o Worklenz para todos.",
|
||||
"submitSuccessMessage": "Obrigado por completar a pesquisa!",
|
||||
"submitErrorMessage": "Falha ao enviar a pesquisa. Por favor, tente novamente.",
|
||||
"submitErrorLog": "Falha ao enviar a pesquisa",
|
||||
"fetchErrorLog": "Falha ao buscar a pesquisa"
|
||||
}
|
||||
14
worklenz-frontend/public/locales/zh/survey.json
Normal file
14
worklenz-frontend/public/locales/zh/survey.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"modalTitle": "帮助我们提升您的体验",
|
||||
"skip": "暂时跳过",
|
||||
"previous": "上一步",
|
||||
"next": "下一步",
|
||||
"completeSurvey": "完成调查",
|
||||
"submitting": "正在提交您的回答...",
|
||||
"submitSuccessTitle": "谢谢!",
|
||||
"submitSuccessSubtitle": "您的反馈帮助我们改进 Worklenz。",
|
||||
"submitSuccessMessage": "感谢您完成调查!",
|
||||
"submitErrorMessage": "提交调查失败。请重试。",
|
||||
"submitErrorLog": "提交调查失败",
|
||||
"fetchErrorLog": "获取调查失败"
|
||||
}
|
||||
@@ -30,11 +30,21 @@ export const SurveyPromptModal: React.FC<SurveyPromptModalProps> = ({ forceShow
|
||||
const isDarkMode = themeMode === 'dark';
|
||||
|
||||
useEffect(() => {
|
||||
// Check if survey was skipped recently (within 7 days)
|
||||
const skippedAt = localStorage.getItem('survey_skipped_at');
|
||||
if (!forceShow && skippedAt) {
|
||||
const skippedDate = new Date(skippedAt);
|
||||
const now = new Date();
|
||||
const diffDays = (now.getTime() - skippedDate.getTime()) / (1000 * 60 * 60 * 24);
|
||||
if (diffDays < 3) {
|
||||
return; // Don't show modal if skipped within 7 days
|
||||
}
|
||||
}
|
||||
|
||||
if (forceShow) {
|
||||
setVisible(true);
|
||||
dispatch(resetSurveyData());
|
||||
dispatch(setSurveySubStep(0));
|
||||
|
||||
// Fetch survey info
|
||||
const fetchSurvey = async () => {
|
||||
try {
|
||||
@@ -46,16 +56,13 @@ export const SurveyPromptModal: React.FC<SurveyPromptModalProps> = ({ forceShow
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error('Failed to fetch survey', error);
|
||||
logger.error(t('survey:fetchErrorLog'), error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchSurvey();
|
||||
} else if (!loading && hasCompletedSurvey === false) {
|
||||
// Reset survey data when modal will be shown
|
||||
dispatch(resetSurveyData());
|
||||
dispatch(setSurveySubStep(0));
|
||||
|
||||
// Fetch survey info
|
||||
const fetchSurvey = async () => {
|
||||
try {
|
||||
@@ -67,20 +74,17 @@ export const SurveyPromptModal: React.FC<SurveyPromptModalProps> = ({ forceShow
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error('Failed to fetch survey', error);
|
||||
logger.error(t('survey:fetchErrorLog'), error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchSurvey();
|
||||
|
||||
// Show modal after a 5 second delay to not interrupt user immediately
|
||||
const timer = setTimeout(() => {
|
||||
setVisible(true);
|
||||
}, 5000);
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
}, [loading, hasCompletedSurvey, dispatch, forceShow]);
|
||||
}, [loading, hasCompletedSurvey, dispatch, forceShow, t]);
|
||||
|
||||
const handleComplete = async () => {
|
||||
try {
|
||||
@@ -143,7 +147,7 @@ export const SurveyPromptModal: React.FC<SurveyPromptModalProps> = ({ forceShow
|
||||
|
||||
if (response.done) {
|
||||
setSurveyCompleted(true);
|
||||
appMessage.success('Thank you for completing the survey!');
|
||||
appMessage.success(t('survey:submitSuccessMessage'));
|
||||
|
||||
// Wait a moment before closing
|
||||
setTimeout(() => {
|
||||
@@ -151,11 +155,11 @@ export const SurveyPromptModal: React.FC<SurveyPromptModalProps> = ({ forceShow
|
||||
refetch(); // Update the survey status
|
||||
}, 2000);
|
||||
} else {
|
||||
throw new Error(response.message || 'Failed to submit survey');
|
||||
throw new Error(response.message || t('survey:submitErrorMessage'));
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error('Failed to submit survey', error);
|
||||
appMessage.error('Failed to submit survey. Please try again.');
|
||||
logger.error(t('survey:submitErrorLog'), error);
|
||||
appMessage.error(t('survey:submitErrorMessage'));
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
}
|
||||
@@ -202,20 +206,20 @@ export const SurveyPromptModal: React.FC<SurveyPromptModalProps> = ({ forceShow
|
||||
return (
|
||||
<Modal
|
||||
open={visible}
|
||||
title={surveyCompleted ? null : "Help Us Improve Your Experience"}
|
||||
title={surveyCompleted ? null : t('survey:modalTitle')}
|
||||
onCancel={handleSkip}
|
||||
footer={
|
||||
surveyCompleted ? null : (
|
||||
<Flex justify="space-between" align="center">
|
||||
<div>
|
||||
<Button onClick={handleSkip}>
|
||||
Skip for now
|
||||
{t('survey:skip')}
|
||||
</Button>
|
||||
</div>
|
||||
<Flex gap={8}>
|
||||
{surveySubStep > 0 && (
|
||||
<Button onClick={handlePrevious}>
|
||||
Previous
|
||||
{t('survey:previous')}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
@@ -224,7 +228,7 @@ export const SurveyPromptModal: React.FC<SurveyPromptModalProps> = ({ forceShow
|
||||
disabled={!isCurrentStepValid()}
|
||||
loading={submitting && surveySubStep === 2}
|
||||
>
|
||||
{surveySubStep === 2 ? 'Complete Survey' : 'Next'}
|
||||
{surveySubStep === 2 ? t('survey:completeSurvey') : t('survey:next')}
|
||||
</Button>
|
||||
</Flex>
|
||||
</Flex>
|
||||
@@ -237,13 +241,13 @@ export const SurveyPromptModal: React.FC<SurveyPromptModalProps> = ({ forceShow
|
||||
{submitting ? (
|
||||
<div style={{ textAlign: 'center', padding: '40px' }}>
|
||||
<Spin size="large" />
|
||||
<p style={{ marginTop: 16 }}>Submitting your responses...</p>
|
||||
<p style={{ marginTop: 16 }}>{t('survey:submitting')}</p>
|
||||
</div>
|
||||
) : surveyCompleted ? (
|
||||
<Result
|
||||
status="success"
|
||||
title="Thank you!"
|
||||
subTitle="Your feedback helps us improve Worklenz for everyone."
|
||||
title={t('survey:submitSuccessTitle')}
|
||||
subTitle={t('survey:submitSuccessSubtitle')}
|
||||
/>
|
||||
) : (
|
||||
<div style={{ maxHeight: '70vh', overflowY: 'auto' }}>
|
||||
|
||||
Reference in New Issue
Block a user