Skip to content

Commit

Permalink
fix comments 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Akctarus committed May 15, 2024
1 parent e54cc9a commit 300c917
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 34 deletions.
2 changes: 1 addition & 1 deletion front/public/locales/fr/stdcm.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"stdcmErrorNoPaths": "Incompatibilité avec d'autres sillons.",
"stdcmNoResults": "Aucun sillon trouvé",
"stdcmResults": "Résultats",
"stdcmSimulationReport": "Fiche de simulation"
"stdcmSimulationReport": "Fiche simulation"
}
40 changes: 20 additions & 20 deletions front/src/applications/stdcm/components/SimulationReportSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Table, TR, TH, TD } from '@ag-media/react-pdf-table';
import { Page, Text, Image, Document, View } from '@react-pdf/renderer';
import { useTranslation } from 'react-i18next';

import iconAlert from 'assets/simulationSheet/icon_alert_fill.png';
import logoSNCF from 'assets/simulationSheet/logo_sncf_reseau.png';
import iconAlert from 'assets/simulationReportSheet/icon_alert_fill.png';
import logoSNCF from 'assets/simulationReportSheet/logo_sncf_reseau.png';
import type { PostStdcmApiResponse, RollingStockWithLiveries } from 'common/api/osrdEditoastApi';
import { formatDay } from 'utils/date';
import { getStopDurationTime, getStopTime } from 'utils/timeManipulation';
Expand All @@ -26,7 +26,7 @@ const SimulationReportSheet = ({
number,
mapCanvas,
}: SimulationReportSheetProps) => {
const { t } = useTranslation('stdcm-simulation-sheet');
const { t } = useTranslation('stdcm-simulation-report-sheet');
const creationDate = t('formattedDate', formatCreationDate(stdcmData.path.created));

let renderedIndex = 0;
Expand All @@ -53,26 +53,26 @@ const SimulationReportSheet = ({
return (
<Document>
<Page wrap={false} style={styles.main.page} size={[1344]}>
<View style={styles.banner.alertBanner}>
<Image src={iconAlert} style={styles.banner.alertIcon} />
<Text style={styles.banner.simulationTitle}>{t('simulation')}</Text>
<Text style={styles.banner.message}>{t('warningMessage')}</Text>
<View style={styles.header.alertBanner}>
<Image src={iconAlert} style={styles.header.alertIcon} />
<Text style={styles.header.simulationTitle}>{t('simulation')}</Text>
<Text style={styles.header.message}>{t('warningMessage')}</Text>
</View>
<View style={styles.banner.numberDateBanner}>
<View style={styles.banner.stdcmTitleBox}>
<View style={styles.banner.stdcm}>
<Text style={styles.banner.title}>{t('stdcm')}</Text>
<Text style={styles.banner.creation}>{t('stdcmCreation')}</Text>
<View style={styles.header.numberDateBanner}>
<View style={styles.header.stdcmTitleBox}>
<View style={styles.header.stdcm}>
<Text style={styles.header.title}>{t('stdcm')}</Text>
<Text style={styles.header.creation}>{t('stdcmCreation')}</Text>
</View>
</View>
<View style={styles.banner.numericInfo}>
<Text style={styles.banner.number}>
<View style={styles.header.numericInfo}>
<Text style={styles.header.number}>
{number}
</Text>
<Text style={styles.banner.creationDate}>{creationDate}</Text>
<Text style={styles.header.creationDate}>{creationDate}</Text>
</View>
<Image src={logoSNCF} style={styles.banner.sncfLogo} />
<Image src={logoSNCF} style={styles.header.sncfLogo} />
</View>

<View style={styles.rcInfo.rcInfo}>
Expand Down Expand Up @@ -133,7 +133,7 @@ const SimulationReportSheet = ({
</View>
<Text style={styles.convoyAndRoute.fromNumber}>{fakeInformation.path_number1}</Text>
<Text style={styles.convoyAndRoute.fromScheduled}>
{t('scheduledArrival')} {arrivalTime}
{`${t('scheduledArrival')} ${arrivalTime}`}
</Text>
</View>
<View style={styles.convoyAndRoute.stopTableContainer}>
Expand Down Expand Up @@ -203,7 +203,7 @@ const SimulationReportSheet = ({
</View>
<View style={styles.convoyAndRoute.forBanner}>
<Text style={styles.convoyAndRoute.forScheduled}>
{t('scheduledDeparture')} {departureTime}
{`${t('scheduledDeparture')} ${departureTime}`}
</Text>
<Text style={styles.convoyAndRoute.forNumber}>{fakeInformation.path_number2}</Text>
<View style={styles.convoyAndRoute.forBox}>
Expand Down Expand Up @@ -348,8 +348,8 @@ const SimulationReportSheet = ({
<View style={styles.map.map}>
<Image src={mapCanvas} />
</View>
<View style={styles.warranty.warrantyBox}>
<Text style={styles.warranty.warrantyMessage}>{t('withoutWarranty')}</Text>
<View style={styles.footer.warrantyBox}>
<Text style={styles.footer.warrantyMessage}>{t('withoutWarranty')}</Text>
</View>
</Page>
</Document>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { StyleSheet, Font } from '@react-pdf/renderer';

import IBMPlexMonoBold from 'assets/simulationSheet/fonts/IBM-Plex-Mono/IBMPlexMono-Bold.ttf';
import IBMPlexMonoMedium from 'assets/simulationSheet/fonts/IBM-Plex-Mono/IBMPlexMono-Medium.ttf';
import IBMPlexMonoRegular from 'assets/simulationSheet/fonts/IBM-Plex-Mono/IBMPlexMono-Regular.ttf';
import IBMPlexMonoSemiBold from 'assets/simulationSheet/fonts/IBM-Plex-Mono/IBMPlexMono-SemiBold.ttf';
import IBMPlexSansBold from 'assets/simulationSheet/fonts/IBM-Plex-Sans/IBMPlexSans-Bold.ttf';
import IBMPlexSansItalic from 'assets/simulationSheet/fonts/IBM-Plex-Sans/IBMPlexSans-Italic.ttf';
import IBMPlexSansMedium from 'assets/simulationSheet/fonts/IBM-Plex-Sans/IBMPlexSans-Medium.ttf';
import IBMPlexSansRegular from 'assets/simulationSheet/fonts/IBM-Plex-Sans/IBMPlexSans-Regular.ttf';
import IBMPlexSansSemiBold from 'assets/simulationSheet/fonts/IBM-Plex-Sans/IBMPlexSans-SemiBold.ttf';
import IBMPlexMonoBold from 'assets/simulationReportSheet/fonts/IBM-Plex-Mono/IBMPlexMono-Bold.ttf';
import IBMPlexMonoMedium from 'assets/simulationReportSheet/fonts/IBM-Plex-Mono/IBMPlexMono-Medium.ttf';
import IBMPlexMonoRegular from 'assets/simulationReportSheet/fonts/IBM-Plex-Mono/IBMPlexMono-Regular.ttf';
import IBMPlexMonoSemiBold from 'assets/simulationReportSheet/fonts/IBM-Plex-Mono/IBMPlexMono-SemiBold.ttf';
import IBMPlexSansBold from 'assets/simulationReportSheet/fonts/IBM-Plex-Sans/IBMPlexSans-Bold.ttf';
import IBMPlexSansItalic from 'assets/simulationReportSheet/fonts/IBM-Plex-Sans/IBMPlexSans-Italic.ttf';
import IBMPlexSansMedium from 'assets/simulationReportSheet/fonts/IBM-Plex-Sans/IBMPlexSans-Medium.ttf';
import IBMPlexSansRegular from 'assets/simulationReportSheet/fonts/IBM-Plex-Sans/IBMPlexSans-Regular.ttf';
import IBMPlexSansSemiBold from 'assets/simulationReportSheet/fonts/IBM-Plex-Sans/IBMPlexSans-SemiBold.ttf';

Font.register({
family: 'IBM Plex Sans',
Expand Down Expand Up @@ -39,7 +39,7 @@ const styles = {
fontFamily: 'IBM Plex Sans',
},
}),
banner: StyleSheet.create({
header: StyleSheet.create({
alertBanner: {
height: '64',
backgroundColor: '#000000',
Expand Down Expand Up @@ -548,7 +548,7 @@ const styles = {
backgroundColor: '#EBEBEA',
},
}),
warranty: StyleSheet.create({
footer: StyleSheet.create({
warrantyBox: {
height: '64',
marginTop: '16',
Expand Down
3 changes: 1 addition & 2 deletions front/src/applications/stdcm/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function generateRandomString(length: number): string {
return [...Array(length)].map(() => Math.floor(Math.random() * 10)).join('');
return Array.from({ length }, () => Math.floor(Math.random() * 10)).join('');
}

// TODO: The number must be calculated from a hash of stdcm inputs (to have a stable number). It is currently generated randomly, so there could be duplicates.
Expand All @@ -12,7 +12,6 @@ export function generateCodeNumber(): string {
return `${month}${year}-${randomPart1}-${randomPart2}`;
}

// This function displays the date as : "DD/MM/YY à HH:MM" in french, and "YY/MM/DD at HH:MM" in english
export function formatCreationDate(date: string) {
const creationDate = new Date(date);
const day = creationDate.getDate();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed front/src/assets/simulationSheet/icon_alert_fill.png
Binary file not shown.
Binary file not shown.

0 comments on commit 300c917

Please sign in to comment.