Skip to content

Commit 276f8eb

Browse files
author
aligneddev
committed
history edit price source
1 parent 699de91 commit 276f8eb

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/BikeTracking.Frontend/src/pages/HistoryPage.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
} from './miles/history-page.helpers'
2121
import './HistoryPage.css'
2222

23-
const EIA_GAS_PRICE_SOURCE = 'Source: U.S. Energy Information Administration (EIA)'
23+
const EIA_GAS_PRICE_SOURCE = 'Source: (EIA)'
2424

2525
function HistoryTable({
2626
rides,
@@ -108,7 +108,10 @@ function HistoryTable({
108108
<td>
109109
{editingRideId === ride.rideId ? (
110110
<div className="history-page-inline-editor">
111-
<label htmlFor={`edit-ride-gas-price-${ride.rideId}`}>Gas Price</label>
111+
<div style={{ display: 'flex', alignItems: 'center', gap: '4px' }}>
112+
<label htmlFor={`edit-ride-gas-price-${ride.rideId}`}>Gas Price</label>
113+
{editedGasPriceSource ? <span className="info-icon" style={{ cursor: 'pointer' }} title={editedGasPriceSource}>ℹ️</span> : null}
114+
</div>
112115
<input
113116
id={`edit-ride-gas-price-${ride.rideId}`}
114117
type="number"
@@ -117,7 +120,6 @@ function HistoryTable({
117120
value={editedGasPrice}
118121
onChange={(event) => onEditedGasPriceChange(event.target.value)}
119122
/>
120-
{editedGasPriceSource ? <p>{editedGasPriceSource}</p> : null}
121123
</div>
122124
) : ride.gasPricePerGallon != null ? (
123125
`$${ride.gasPricePerGallon.toFixed(4)}`
@@ -238,7 +240,12 @@ export function HistoryPage() {
238240
const lookup = await getGasPrice(dateOnly)
239241
if (lookup.isAvailable && lookup.pricePerGallon !== null) {
240242
setEditedGasPrice(lookup.pricePerGallon.toString())
241-
setEditedGasPriceSource(lookup.dataSource ?? EIA_GAS_PRICE_SOURCE)
243+
const source = lookup.dataSource ?? EIA_GAS_PRICE_SOURCE;
244+
if (source.includes('EIA')) {
245+
setEditedGasPriceSource(EIA_GAS_PRICE_SOURCE)
246+
} else {
247+
setEditedGasPriceSource(source.substring(0, 15))
248+
}
242249
} else {
243250
setEditedGasPriceSource('')
244251
}

0 commit comments

Comments
 (0)