mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 16:33:16 +00:00
feat(collections): "want to revisit" status for saved places (#2567)
A fourth status after visited, for a place already seen that the user wants to go back to. It joins the one-tap cycle, the filters, the pickers, the assistant cards and the MCP status tool, and counts as visited wherever visits are counted (isVisitedCollectionStatus), so "visited everywhere" keeps it. The status pickers go two by two where four would not fit.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* FE-AI-COLL-010 to FE-AI-COLL-017
|
||||
* FE-AI-COLL-010 to FE-AI-COLL-017, FE-AI-COLL-040
|
||||
*
|
||||
* The answer cards of the collections as the chat draws them: a list's head
|
||||
* with its size, people and places per status, its saved places as rows
|
||||
@@ -57,6 +57,14 @@ describe('collection answer cards', () => {
|
||||
expect(view.onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/collections/12' });
|
||||
});
|
||||
|
||||
it('FE-AI-COLL-040: the places to revisit have a pill of their own in the head, in the visited tone (#2567)', () => {
|
||||
draw([placesCard({ list: { ...placesCard().list, counts: { idea: 3, want: 5, visited: 4, revisit: 7 } } })]);
|
||||
const card = screen.getByRole('region', { name: 'Saved places in Paris food' });
|
||||
const pill = within(card).getByText('Want to revisit').parentElement as HTMLElement;
|
||||
expect(within(pill).getByText('7')).toBeInTheDocument();
|
||||
expect(within(card).getByText('Visited').parentElement?.className).toBe(pill.className);
|
||||
});
|
||||
|
||||
it('FE-AI-COLL-011: a saved place shows its status, two labels and the rest counted, its rating and the trip having it', () => {
|
||||
draw([placesCard({ places: [savedPlace({ inTripPlaceId: 6 })] })]);
|
||||
expect(screen.getByText('Septime')).toBeInTheDocument();
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import type {
|
||||
CollectionCardDelta,
|
||||
CollectionCardLabel,
|
||||
CollectionCardList,
|
||||
CollectionCardPlace,
|
||||
CollectionListsCard,
|
||||
CollectionPlacesCard,
|
||||
import {
|
||||
type CollectionCardDelta,
|
||||
type CollectionCardLabel,
|
||||
type CollectionCardList,
|
||||
type CollectionCardPlace,
|
||||
type CollectionListsCard,
|
||||
type CollectionPlacesCard,
|
||||
isVisitedCollectionStatus,
|
||||
} from '@trek/shared';
|
||||
import { Bookmark, Info, Tag } from 'lucide-react';
|
||||
import type { ReactNode } from 'react';
|
||||
@@ -110,7 +111,7 @@ function ListChip({ list }: { list: CollectionCardList }) {
|
||||
function statusChange(status: NonNullable<CollectionCardDelta['status']>, t: T): ReactNode {
|
||||
const to = STATUS_META[status.to];
|
||||
const before = status.from ? t(STATUS_META[status.from].labelKey) : null;
|
||||
const tone = status.to === 'visited' ? 'success' : 'neutral';
|
||||
const tone = isVisitedCollectionStatus(status.to) ? 'success' : 'neutral';
|
||||
return <FactChange key="status" icon={to.icon} before={before} after={t(to.labelKey)} tone={tone} />;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
import type { CollectionCardLabel, CollectionCardList, CollectionCardPlace, CollectionStatus } from '@trek/shared';
|
||||
import {
|
||||
type CollectionCardLabel,
|
||||
type CollectionCardList,
|
||||
type CollectionCardPlace,
|
||||
type CollectionStatus,
|
||||
isVisitedCollectionStatus,
|
||||
} from '@trek/shared';
|
||||
import { Star } from 'lucide-react';
|
||||
import type { CSSProperties } from 'react';
|
||||
|
||||
import { useTranslation } from '../../../../i18n';
|
||||
import { safeHexColor } from '../../../../utils/safeColor';
|
||||
import { STATUS_META } from '../../../Collections/collectionStatus';
|
||||
import { STATUS_META, STATUS_ORDER } from '../../../Collections/collectionStatus';
|
||||
import { SoftPill, tintOf, WhiteBadge } from '../../../Planner/planParts';
|
||||
import PlaceAvatar from '../../../shared/PlaceAvatar';
|
||||
import { Tooltip } from '../../../shared/Tooltip';
|
||||
@@ -93,7 +99,7 @@ export function StatusPill({ status, count }: { status: CollectionStatus; count?
|
||||
<Icon size={10} strokeWidth={2.4} aria-hidden="true" className="flex-none" style={{ color: meta.color }} />
|
||||
);
|
||||
return (
|
||||
<SoftPill tone={status === 'visited' ? 'success' : 'neutral'} icon={icon}>
|
||||
<SoftPill tone={isVisitedCollectionStatus(status) ? 'success' : 'neutral'} icon={icon}>
|
||||
{count !== undefined && <span className="tabular-nums">{count}</span>}
|
||||
<span>{t(meta.labelKey)}</span>
|
||||
</SoftPill>
|
||||
@@ -140,7 +146,7 @@ export function ListHead({ list, first = true }: { list: CollectionCardList; fir
|
||||
</div>
|
||||
{counts && (
|
||||
<CardFacts>
|
||||
{(['idea', 'want', 'visited'] as const).map((status) => (
|
||||
{STATUS_ORDER.map((status) => (
|
||||
<StatusPill key={status} status={status} count={counts[status]} />
|
||||
))}
|
||||
</CardFacts>
|
||||
|
||||
Reference in New Issue
Block a user