Skip to content

Commit

Permalink
tt: fix cards
Browse files Browse the repository at this point in the history
  • Loading branch information
a-type committed Apr 1, 2024
1 parent d2a4398 commit 3e3d231
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
7 changes: 0 additions & 7 deletions apps/trip-tick/web/src/components/trips/TripView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,6 @@ function TripViewChecklistItem({
onCompletionChanged(0);
}
};
const subOnChecked = (checked: boolean) => {
if (checked) {
onCompletionChanged(completedQuantity + 1);
} else {
onCompletionChanged(completedQuantity - 1);
}
};

const {
ref,
Expand Down
20 changes: 16 additions & 4 deletions apps/trip-tick/web/src/components/trips/TripsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { TripMenu } from './TripMenu.jsx';
import { H2 } from '@a-type/ui/components/typography';
import { AddTripButton } from './AddTripButton.jsx';
import { Divider } from '@a-type/ui/components/divider';
import { Chip } from '@a-type/ui/components/chip';

export interface TripsListProps {}

Expand Down Expand Up @@ -76,7 +77,9 @@ export function TripsList({}: TripsListProps) {
}

function TripsListItem({ trip }: { trip: Trip }) {
const { name, startsAt } = hooks.useWatch(trip);
const { name, startsAt, location } = hooks.useWatch(trip);
hooks.useWatch(location);
const locationName = location?.get('name');

const isPast = startsAt && startsAt < Date.now();

Expand All @@ -91,9 +94,18 @@ function TripsListItem({ trip }: { trip: Trip }) {
<CardMain compact={!!isPast} asChild>
<Link to={`/trips/${trip.get('id')}`} className="relative bg-white">
<CardTitle className="relative z-1">{name}</CardTitle>
<CardContent className="text-xs relative z-1">
{startsAt ? new Date(startsAt).toLocaleDateString() : 'Unscheduled'}
{isPast ? '' : ` | {completedItems} / {totalItems} items`}
<CardContent className="text-xs relative z-1 flex flex-row gap-1 flex-wrap">
{locationName && <Chip className="bg-white">{locationName}</Chip>}
<Chip className="bg-white">
{startsAt
? new Date(startsAt).toLocaleDateString()
: 'Unscheduled'}
</Chip>
{!isPast && (
<Chip className="bg-white">
{completedItems} / {totalItems} items
</Chip>
)}
</CardContent>
{!isPast && (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function LocationSelect({
className={classNames('font-normal', className)}
onClick={() => setShowEdit(true)}
>
<Icon name="placeholder" />
<Icon name="location" />
{value.get('name')}
</Button>
);
Expand Down

0 comments on commit 3e3d231

Please sign in to comment.