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

Add feedback email adress after simulation in stdcm #11031

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

Caracol3
Copy link
Contributor

@Caracol3 Caracol3 commented Mar 4, 2025

@github-actions github-actions bot added the area:front Work on Standard OSRD Interface modules label Mar 4, 2025
@Caracol3 Caracol3 force-pushed the mcy/front-stdcm-add-email-adress-after-simulation branch from 61232fc to 1f4c658 Compare March 5, 2025 09:25
@codecov-commenter
Copy link

codecov-commenter commented Mar 5, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.71%. Comparing base (0d068db) to head (d93402c).
Report is 10 commits behind head on dev.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #11031      +/-   ##
==========================================
+ Coverage   80.69%   80.71%   +0.02%     
==========================================
  Files        1098     1099       +1     
  Lines      111888   111987      +99     
  Branches      745      745              
==========================================
+ Hits        90290    90395     +105     
+ Misses      21555    21549       -6     
  Partials       43       43              
Flag Coverage Δ
editoast 72.41% <ø> (+0.03%) ⬆️
front 89.94% <100.00%> (+0.01%) ⬆️
gateway 2.18% <ø> (ø)
osrdyne 2.53% <ø> (ø)
railjson_generator 87.58% <ø> (ø)
tests 87.90% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Caracol3 Caracol3 force-pushed the mcy/front-stdcm-add-email-adress-after-simulation branch from 1f4c658 to 519cc42 Compare March 5, 2025 09:55
@Caracol3 Caracol3 force-pushed the mcy/front-stdcm-add-email-adress-after-simulation branch from 519cc42 to d93402c Compare March 5, 2025 10:11
@Caracol3 Caracol3 marked this pull request as ready for review March 5, 2025 10:12
@Caracol3 Caracol3 requested review from a team as code owners March 5, 2025 10:12
Copy link
Contributor

@kmer2016 kmer2016 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we open the mail in a new tab?

import { getSelectedSimulation } from 'reducers/osrdconf/stdcmConf/selectors';
import { dateTimeFormatting } from 'utils/date';

const FeedbackCard = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to keep the same name used for the file

Suggested change
const FeedbackCard = () => {
const StdcmFeedback = () => {

Comment on lines +28 to +50
const handleEmailClick = () => {
const subject = encodeURIComponent(t('mailFeedback.subject'));

const trainInfo = encodeURIComponent(`

********

${t('mailFeedback.simulationDetails')}:

${t('consist.tractionEngine')}: ${trainName}
${t('consist.compositionCode')}: ${consistCode}
${t('consist.tonnage')}: ${consistMass}
${t('consist.length')}: ${consistLength}
${t('consist.maxSpeed')}: ${maxSpeed}

${t('trainPath.origin')}: ${origin}
${t('trainPath.destination')}: ${destination}
${t('departureTime')}: ${departureTime}
`);
const body = `${trainInfo}${t('mailFeedback.body')}`;

window.location.href = `mailto:[email protected]?subject=${subject}&body=${body}`;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The email content formatting could be simplified:

Suggested change
const handleEmailClick = () => {
const subject = encodeURIComponent(t('mailFeedback.subject'));
const trainInfo = encodeURIComponent(`
********
${t('mailFeedback.simulationDetails')}:
${t('consist.tractionEngine')}: ${trainName}
${t('consist.compositionCode')}: ${consistCode}
${t('consist.tonnage')}: ${consistMass}
${t('consist.length')}: ${consistLength}
${t('consist.maxSpeed')}: ${maxSpeed}
${t('trainPath.origin')}: ${origin}
${t('trainPath.destination')}: ${destination}
${t('departureTime')}: ${departureTime}
`);
const body = `${trainInfo}${t('mailFeedback.body')}`;
window.location.href = `mailto:[email protected]?subject=${subject}&body=${body}`;
};
const handleEmailClick = () => {
const subject = encodeURIComponent(t('mailFeedback.subject'));
const separator = '********';
const messageContent = `
${separator}
${t('mailFeedback.simulationDetails')}:
${t('consist.tractionEngine')}: ${trainName}
${t('consist.compositionCode')}: ${consistCode}
${t('consist.tonnage')}: ${consistMass}
${t('consist.length')}: ${consistLength}
${t('consist.maxSpeed')}: ${maxSpeed}
${t('trainPath.origin')}: ${origin}
${t('trainPath.destination')}: ${destination}
${t('departureTime')}: ${departureTime}
${separator}
${t('mailFeedback.body')}
${separator}`;

This:

  • Moves formatting out of translation files
  • Layout/formatting is managed in the component

@@ -49,6 +50,14 @@
"anterior": "Indiquer le sillon antérieur",
"posterior": "Indiquer le sillon postérieur"
},
"mailFeedback": {
"body": "%0A********%0A%0ANous%20vous%20invitons%20à%20nous%20envoyer%20un%20message.%0ADès%20que%20vous%20avez%20un%20gêne%20ou%20une%20remarque,%0Amême%20si%20vous%20n’y%20mettez%20pas%20la%20forme.%0A%0AMerci%20à%20vous%20par%20avance,%0AL’équipe%20du%20projet%20LMR%0A%0A(vous%20pouvez%20effacer%20ce%20message)%0A%0A********",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The translation key contains formatting that should be handled in the component:

This way:

  • Translation file only contains content
  • Layout/formatting is managed in the component
  • Easier to maintain and update translations
Suggested change
"body": "%0A********%0A%0ANous%20vous%20invitons%20à%20nous%20envoyer%20un%20message.%0ADès%20que%20vous%20avez%20un%20gêne%20ou%20une%20remarque,%0Amême%20si%20vous%20n’y%20mettez%20pas%20la%20forme.%0A%0AMerci%20à%20vous%20par%20avance,%0AL’équipe%20du%20projet%20LMR%0A%0A(vous%20pouvez%20effacer%20ce%20message)%0A%0A********",
"body": "Nous vous invitons à nous envoyer un message.\nDès que vous avez une gêne ou une remarque,\nmême si vous n'y mettez pas la forme.\n\nMerci à vous par avance,\nL'équipe du projet LMR\n\n(vous pouvez effacer ce message)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:front Work on Standard OSRD Interface modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add feedback mail adress in stdcm
3 participants