Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pages/launches/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ export default function LaunchesPage() {

{!isLoadingAllLaunches && launches.length > 0 && (
<Box sx={launchesGridSx}>
{launches.map((launch) => (
{launches.map((launch, index) => (
<LaunchSummaryCard
key={`${launch.name}-${launch.launch_datetime}`}
launch={launch}
index={index}
onDetailsClick={handleLaunchDetails}
/>
))}
Expand Down
15 changes: 11 additions & 4 deletions src/components/LaunchCard/LaunchSummaryCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@ import { LaunchSummaryCardProps } from '@/src/shared/props/components/launch-sum
import MapIcon from '@mui/icons-material/Map';
import { colors } from '@/src/shared/styles/colors';

export default function LaunchSummaryCard({ launch, onDetailsClick }: LaunchSummaryCardProps) {
export default function LaunchSummaryCard({ launch, index, onDetailsClick }: LaunchSummaryCardProps) {
return (
<Card key={`${launch.name}-${launch.launch_datetime}`} elevation={1} sx={cardSx}>
<CardHeader
sx={cardHeaderSx}
title={
<Box sx={titleBoxSx}>
<Typography variant="h6" component="h2" sx={titleTypographySx}>
{formatLaunchName(launch.name)}
</Typography>
<Box sx={titleTextBoxSx}>
<Typography variant="body2" color="text.secondary" sx={indexTypographySx}>
{`#${index + 1}`}
</Typography>
<Typography variant="h6" component="h2" sx={titleTypographySx}>
{formatLaunchName(launch.name)}
</Typography>
</Box>
<Chip
icon={<HeightIcon />}
label={formatAltitudeInKm(launch.max_altitude)}
Expand Down Expand Up @@ -54,7 +59,9 @@ const cardSx = { height: '100%', borderRadius: 3 };
const chipSx = { backgroundColor: colors.primary[600] };
const cardHeaderSx = { pb: 0 };
const titleBoxSx = { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 2 };
const titleTextBoxSx = { display: 'flex', alignItems: 'center', gap: 1 };
const titleTypographySx = { fontWeight: 700 };
const indexTypographySx = { fontWeight: 500, color: colors.primary[600] };
const cardContentSx = { py: 0, mb: 0 };
const citiesBoxSx = { display: 'flex', alignItems: 'flex-start' };
const cardActionsSx = { justifyContent: 'flex-end', pt: 0 };
Expand Down
1 change: 1 addition & 0 deletions src/shared/props/components/launch-summary-card.props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import { LaunchSummary } from '../../types/api/launches-api.types';

export type LaunchSummaryCardProps = {
launch: LaunchSummary;
index: number;
onDetailsClick: (launch: LaunchSummary) => void;
};
Loading