diff --git a/apps/react/src/app/components/search-history/index.ts b/apps/react/src/app/components/search-history/index.ts new file mode 100644 index 000000000..1b4268e7b --- /dev/null +++ b/apps/react/src/app/components/search-history/index.ts @@ -0,0 +1,2 @@ +export { SearchHistory } from './search-history' +export type { SearchHistoryProps, SearchItem } from './search-history' diff --git a/apps/react/src/app/components/search-history/search-history.scss b/apps/react/src/app/components/search-history/search-history.scss new file mode 100644 index 000000000..0473ac1d6 --- /dev/null +++ b/apps/react/src/app/components/search-history/search-history.scss @@ -0,0 +1,93 @@ +.search-history { + margin: 20px 0; + + :global { + .p-accordion { + border: 1px solid #e0e0e0; + border-radius: 4px; + } + + .p-accordion-header { + padding: 0; + + a { + padding: 12px 16px; + } + } + + .p-accordion-content { + padding: 0; + } + } +} + +.search-history__header { + display: flex; + justify-content: space-between; + align-items: center; + width: 100%; + font-weight: 500; +} + +.search-history__count { + background: #1976d2; + color: white; + border-radius: 12px; + padding: 2px 8px; + font-size: 12px; + font-weight: 600; +} + +.search-history__list { + display: flex; + flex-direction: column; +} + +.search-history__item { + display: flex; + align-items: center; + justify-content: space-between; + padding: 12px 16px; + border-top: 1px solid #f0f0f0; + + &:hover { + background: #f9f9f9; + } +} + +.search-history__button { + flex: 1; + background: none; + border: none; + padding: 0; + text-align: left; + cursor: pointer; + display: flex; + flex-direction: column; + gap: 4px; +} + +.search-history__text { + font-weight: 500; + color: #333; +} + +.search-history__type { + font-size: 12px; + color: #999; + text-transform: uppercase; +} + +.search-history__delete { + background: none; + border: none; + color: #999; + cursor: pointer; + font-size: 16px; + padding: 4px 8px; + margin-left: 8px; + + &:hover { + color: #d32f2f; + } +} diff --git a/apps/react/src/app/components/search-history/search-history.tsx b/apps/react/src/app/components/search-history/search-history.tsx new file mode 100644 index 000000000..6f6cf81d6 --- /dev/null +++ b/apps/react/src/app/components/search-history/search-history.tsx @@ -0,0 +1,76 @@ +import React from 'react' +import { Accordion, AccordionTab } from 'primereact/accordion' +import { useTranslation } from 'react-i18next' +import './search-history.scss' + +export interface SearchItem { + id: string + type: 'flight-number' | 'route' + displayText: string + query: any + timestamp: number +} + +export interface SearchHistoryProps { + searches: SearchItem[] + onSearchSelect: (search: SearchItem) => void + onSearchClear?: (searchId: string) => void + 'data-testid'?: string +} + +export const SearchHistory: React.FC = ({ + searches, + onSearchSelect, + onSearchClear, + 'data-testid': dataTestId, +}) => { + const { t } = useTranslation() + + if (!searches || searches.length === 0) { + return null + } + + const header = ( +
+ {t('SHARED.SEARCH_HISTORY')} + {searches.length} +
+ ) + + return ( +
+ + +
+ {searches.map((search) => ( +
+ + {onSearchClear && ( + + )} +
+ ))} +
+
+
+
+ ) +}