File size: 2,342 Bytes
cd99321
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { MemoPlaceRow } from './PlacesSidebarRow'
import type { SidebarState } from './usePlacesSidebar'

export function PlacesList(S: SidebarState) {
  const {
    filtered, scrollContainerRef, onScrollTopChange, filter, t, canEditPlaces, onAddPlace,
    categories, selectedPlaceId, plannedIds, inDaySet, selectedIds, selectMode, selectedDayId,
    isMobile, onPlaceClick, openContextMenu, onAssignToDay, toggleSelected, setDayPickerPlace,
  } = S
  return (
    <div className="trek-stagger" style={{ flex: 1, overflowY: 'auto', minHeight: 0 }} ref={scrollContainerRef} onScroll={(e) => onScrollTopChange?.((e.currentTarget as HTMLElement).scrollTop)}>
      {filtered.length === 0 ? (
        <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', padding: '40px 16px', gap: 8 }}>
          <span className="text-content-faint" style={{ fontSize: 13 }}>
            {filter === 'unplanned' ? t('places.allPlanned') : t('places.noneFound')}
          </span>
          {canEditPlaces && <button onClick={onAddPlace} className="text-content" style={{ fontSize: 12, background: 'none', border: 'none', cursor: 'pointer', textDecoration: 'underline', fontFamily: 'inherit' }}>
            {t('places.addPlace')}
          </button>}
        </div>
      ) : (
        filtered.map(place => {
          const cat = categories.find(c => c.id === place.category_id)
          const isSelected = place.id === selectedPlaceId
          const isPlanned = plannedIds.has(place.id)
          const inDay = inDaySet.has(place.id)
          const isChecked = selectedIds.has(place.id)
          return (
            <MemoPlaceRow
              key={place.id}
              place={place}
              category={cat}
              isSelected={isSelected}
              isPlanned={isPlanned}
              inDay={inDay}
              isChecked={isChecked}
              selectMode={selectMode}
              selectedDayId={selectedDayId}
              canEditPlaces={canEditPlaces}
              isMobile={isMobile}
              t={t}
              onPlaceClick={onPlaceClick}
              onContextMenu={openContextMenu}
              onAssignToDay={onAssignToDay}
              toggleSelected={toggleSelected}
              setDayPickerPlace={setDayPickerPlace}
            />
          )
        })
      )}
    </div>
  )
}