Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
Signed-off-by: SarahBellaha <[email protected]>
  • Loading branch information
SarahBellaha committed Oct 30, 2024
1 parent 892e2fd commit b48a9cf
Show file tree
Hide file tree
Showing 13 changed files with 211 additions and 187 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,46 @@ type StdcmLinkedPathResultsProps = {
linkedPathResults: StdcmLinkedPathResult[];
onLinkedPathSelection: (
pathStepToUpdate: ExtremityPathStepType,
trainID: string,
trainName: string,
linkedPathStep: StdcmLinkedPathStep
) => void;
linkedOp: ExtremityPathStepType;
extremityType: ExtremityPathStepType;
};

const StdcmLinkedPathResults = ({
linkedPathResults,
onLinkedPathSelection,
linkedOp,
extremityType,
}: StdcmLinkedPathResultsProps) => (
<div className="stdcm-linked-path-results">
{linkedPathResults.map(({ trainID, origin, destination }, index) => (
{linkedPathResults.map(({ trainName, origin, destination }, index) => (
<button
key={`linked-path-${index}`}
tabIndex={0}
type="button"
className="linked-path-result-infos"
onClick={() => {
if (linkedPathResults.length === 1)
onLinkedPathSelection(linkedOp, trainID, linkedPathResults[0][linkedOp]);
onLinkedPathSelection(extremityType, trainName, linkedPathResults[0][extremityType]);
}}
>
{linkedPathResults.length > 1 ? (
<RadioButton
label={trainID}
id={`${linkedOp}-${index}`}
label={trainName}
id={`${extremityType}-${index}`}
value={`${index}`}
name={`linked-path-radio-buttons-${linkedOp}`}
name={`linked-path-radio-buttons-${extremityType}`}
onClick={({ target }) => {
const resultIndex = Number((target as HTMLInputElement).value);
onLinkedPathSelection(linkedOp, trainID, linkedPathResults[resultIndex][linkedOp]);
onLinkedPathSelection(
extremityType,
trainName,
linkedPathResults[resultIndex][extremityType]
);
}}
/>
) : (
<p className="train-id grey80">{trainID}</p>
<p className="train-name grey80">{trainName}</p>
)}
{[origin, destination].map((opPoint) => (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ const StdcmLinkedPathSearch = ({
hasSearchBeenLaunched,
launchTrainScheduleSearch,
linkedPathDate,
linkedPathID,
linkedPathResults,
selectableSlot,
setDisplaySearchButton,
setLinkedPathDate,
setLinkedPathID,
setTrainNameInput,
trainNameInput,
updateLinkedPathStep,
} = useLinkedPathSearch();

return (
<div className={`stdcm-linked-path-search-container ${className}`}>
{!displayLinkedPathSearch ? (
<button type="button" onClick={() => setShowLinkedPathSearch(true)}>
<div tabIndex={0} role="button" onClick={() => setShowLinkedPathSearch(true)}>
<StdcmDefaultCard text={defaultCardText} Icon={cardIcon} className="add-linked-path" />
</button>
</div>
) : (
<StdcmCard
name={cardName}
Expand All @@ -60,58 +60,55 @@ const StdcmLinkedPathSearch = ({
}
className="linked-path"
>
<div className="d-flex flex-column">
<div className="d-flex pr-1 pl-3">
<Input
id="linked-path-ID"
type="text"
value={linkedPathID || ''}
onChange={(e) => {
setDisplaySearchButton(true);
setLinkedPathID(e.target.value);
}}
label="N°"
/>
<DatePicker
inputProps={{
id: `linked-path-date`,
label: 'Date',
name: 'op-date',
onChange: () => {},
}}
selectableSlot={selectableSlot}
value={linkedPathDate}
onDateChange={(e) => {
setLinkedPathDate(e);
}}
/>
</div>
{displaySearchButton && (
<button
className="stdcm-linked-path-button"
type="button"
onClick={launchTrainScheduleSearch}
>
{t('find')}
</button>
)}
{!displaySearchButton && !linkedPathResults.length && (
<div className="stdcm-linked-path-button white">
<Gear size="lg" className="stdcm-linked-path-loading" />
</div>
)}
{linkedPathResults.length > 0 ? (
<StdcmLinkedPathResults
linkedPathResults={linkedPathResults}
onLinkedPathSelection={updateLinkedPathStep}
linkedOp={linkedOp}
/>
) : (
hasSearchBeenLaunched && (
<p className="text-center mb-0">{t('noCorrespondingResults')}</p>
)
)}
<div className="d-flex pr-1 pl-3">
<Input
id="linked-path-id"
type="text"
value={trainNameInput}
onChange={(e) => {
setDisplaySearchButton(true);
setTrainNameInput(e.target.value);
}}
label="N°"
/>
<DatePicker
inputProps={{
id: 'linked-path-date',
label: 'Date',
name: 'op-date',
}}
selectableSlot={selectableSlot}
value={linkedPathDate}
onDateChange={(date) => {
setLinkedPathDate(date);
}}
/>
</div>
{displaySearchButton && (
<button
className="stdcm-linked-path-button"
type="button"
onClick={launchTrainScheduleSearch}
>
{t('find')}
</button>
)}
{!displaySearchButton && !linkedPathResults.length && (
<div className="stdcm-linked-path-button white">
<Gear size="lg" className="stdcm-linked-path-loading" />
</div>
)}
{linkedPathResults.length > 0 ? (
<StdcmLinkedPathResults
linkedPathResults={linkedPathResults}
onLinkedPathSelection={updateLinkedPathStep}
extremityType={linkedOp}
/>
) : (
hasSearchBeenLaunched && (
<p className="text-center mb-0">{t('noCorrespondingResults')}</p>
)
)}
</StdcmCard>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,12 @@ const StdcmOpSchedule = ({
</div>
{opScheduleTimeType === 'preciseTime' && (
<div className="schedule">
{/* TODO: Remove empty onChange events once we fix the warning on ui-core side */}
<DatePicker
inputProps={{
id: `date-${opId}`,
label: t('trainPath.date'),
name: 'op-date',
disabled,
onChange: () => {},
}}
selectableSlot={selectableSlot}
value={arrivalDate}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const SimulationReportSheet = ({
<Text style={styles.convoyAndRoute.from}>{t('from')}</Text>
</View>
<Text style={styles.convoyAndRoute.fromNumber}>
{anteriorPath?.trainID || fakeInformation.path_number1}
{anteriorPath?.trainName || fakeInformation.path_number1}
</Text>
<Text style={styles.convoyAndRoute.fromScheduled}>
{anteriorPath &&
Expand Down Expand Up @@ -234,7 +234,7 @@ const SimulationReportSheet = ({
t('scheduledDeparture', { date: posteriorPath.date, time: posteriorPath.time })}
</Text>
<Text style={styles.convoyAndRoute.forNumber}>
{posteriorPath?.trainID || fakeInformation.path_number2}
{posteriorPath?.trainName || fakeInformation.path_number2}
</Text>
<View style={styles.convoyAndRoute.forBox}>
<Text style={styles.convoyAndRoute.for}>{t('for')}</Text>
Expand Down
Loading

0 comments on commit b48a9cf

Please sign in to comment.