Update Delta column to show daily price change
Display today vs yesterday price difference with colored arrows: - Red up arrow for price increases - Green down arrow for price decreases - Gray for no change or missing data Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
22
src/App.jsx
22
src/App.jsx
@ -430,7 +430,7 @@ const ApartmentDashboard = () => {
|
|||||||
case 'daysAvailable': return dir * ((a.daysAvailable || 0) - (b.daysAvailable || 0));
|
case 'daysAvailable': return dir * ((a.daysAvailable || 0) - (b.daysAvailable || 0));
|
||||||
case 'maxPrice': return dir * ((a.maxPrice || 0) - (b.maxPrice || 0));
|
case 'maxPrice': return dir * ((a.maxPrice || 0) - (b.maxPrice || 0));
|
||||||
case 'minPrice': return dir * ((a.minPrice || 0) - (b.minPrice || 0));
|
case 'minPrice': return dir * ((a.minPrice || 0) - (b.minPrice || 0));
|
||||||
case 'delta': return dir * (((a.maxPrice || 0) - (a.minPrice || 0)) - ((b.maxPrice || 0) - (b.minPrice || 0)));
|
case 'delta': return dir * ((a.priceChangeToday || 0) - (b.priceChangeToday || 0));
|
||||||
case 'soonest': return dir * (a.soonest || '').localeCompare(b.soonest || '');
|
case 'soonest': return dir * (a.soonest || '').localeCompare(b.soonest || '');
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
@ -1084,7 +1084,25 @@ const ApartmentDashboard = () => {
|
|||||||
{visibleColumns.days && <td className="py-3 px-4 text-center">{unit.daysAvailable || 0}</td>}
|
{visibleColumns.days && <td className="py-3 px-4 text-center">{unit.daysAvailable || 0}</td>}
|
||||||
{visibleColumns.high && <td className="py-3 px-4 text-right text-gray-600">{formatPrice(unit.maxPrice)}</td>}
|
{visibleColumns.high && <td className="py-3 px-4 text-right text-gray-600">{formatPrice(unit.maxPrice)}</td>}
|
||||||
{visibleColumns.low && <td className="py-3 px-4 text-right text-gray-600">{formatPrice(unit.minPrice)}</td>}
|
{visibleColumns.low && <td className="py-3 px-4 text-right text-gray-600">{formatPrice(unit.minPrice)}</td>}
|
||||||
{visibleColumns.delta && <td className="py-3 px-4 text-right text-gray-600">{formatPrice((unit.maxPrice || 0) - (unit.minPrice || 0))}</td>}
|
{visibleColumns.delta && (
|
||||||
|
<td className={`py-3 px-4 text-right ${
|
||||||
|
unit.priceChangeToday > 0 ? 'text-red-600' :
|
||||||
|
unit.priceChangeToday < 0 ? 'text-green-600' :
|
||||||
|
'text-gray-500'
|
||||||
|
}`}>
|
||||||
|
<span className="flex items-center justify-end">
|
||||||
|
{unit.priceChangeToday !== null && unit.priceChangeToday !== 0 && (
|
||||||
|
unit.priceChangeToday > 0
|
||||||
|
? <ArrowUp className="w-4 h-4 mr-1" />
|
||||||
|
: <ArrowDown className="w-4 h-4 mr-1" />
|
||||||
|
)}
|
||||||
|
{unit.priceChangeToday !== null
|
||||||
|
? `${unit.priceChangeToday > 0 ? '+' : ''}${formatPrice(unit.priceChangeToday)}`
|
||||||
|
: '--'
|
||||||
|
}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
)}
|
||||||
{visibleColumns.soonest && <td className="py-3 px-4 text-center">{unit.soonest ? (new Date(unit.soonest) <= new Date() ? 'Now' : formatDate(unit.soonest)) : '-'}</td>}
|
{visibleColumns.soonest && <td className="py-3 px-4 text-center">{unit.soonest ? (new Date(unit.soonest) <= new Date() ? 'Now' : formatDate(unit.soonest)) : '-'}</td>}
|
||||||
{visibleColumns.actions && (
|
{visibleColumns.actions && (
|
||||||
<td className="py-3 px-4 text-center">
|
<td className="py-3 px-4 text-center">
|
||||||
|
|||||||
Reference in New Issue
Block a user