openreplay/frontend/app/components/Spots/SpotsList/SpotsListHeader.tsx
Delirium 2cd96b0df0
Highlight UI (#2951)
* ui: start highlight ui

* ui: tag items

* ui: connecting highlights to notes api...

* Highlight feature refinements (#2948)

* ui: move clips player to foss, connect notes api to hl

* ui: tune note/hl editing, prevent zoom slider body from jumping around

* ui: safe check for tag

* ui: fix thumbnail gen

* ui: fix thumbnail gen

* ui: make player modal wider, add shadow

* ui: custom warn barge for clips

* ui: swap icon for note event wrapper

* ui: rm other, fix cancel

* ui: moving around creation modal

* ui: bg tint

* ui: rm disabled for text btn

* ui: fix ownership sorting

* ui: close player on bg click

* ui: fix query, fix min distance for default range

* ui: move hl list header out of list comp

* ui: spot list header segmented size

* Various improvements in highlights (#2955)

* ui: update hl in hlPanel comp

* ui: rm debug

* ui: fix icons file

---------

Co-authored-by: Sudheer Salavadi <connect.uxmaster@gmail.com>
2025-01-24 09:59:54 +01:00

102 lines
2.8 KiB
TypeScript

import { Button, Input, Segmented } from 'antd';
import { observer } from 'mobx-react-lite';
import React from 'react';
import { useStore } from 'App/mstore';
import { debounce } from 'App/utils';
import ReloadButton from 'Shared/ReloadButton';
const SpotsListHeader = observer(
({
onDelete,
selectedCount,
onClearSelection,
tenantHasSpots,
onRefresh,
}: {
onDelete: () => void;
selectedCount: number;
onClearSelection: () => void;
onRefresh: () => void;
isEmpty?: boolean;
tenantHasSpots: boolean;
}) => {
const { spotStore } = useStore();
const debouncedFetch = React.useMemo(
() => debounce(spotStore.fetchSpots, 250),
[]
);
const onSearch = (value: string) => {
spotStore.setQuery(value);
void spotStore.fetchSpots();
};
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
spotStore.setQuery(e.target.value);
debouncedFetch();
};
const onFilterChange = (key: 'all' | 'own') => {
spotStore.setFilter(key);
void spotStore.fetchSpots();
};
const handleSegmentChange = (value: string) => {
const key = value === 'All Spots' ? 'all' : 'own';
onFilterChange(key);
};
return (
<div className={'flex items-center justify-between w-full'}>
<div className="flex gap-1 items-center">
<h1 className={'text-2xl capitalize mr-2'}>Spot List</h1>
<ReloadButton buttonSize={'small'} onClick={onRefresh} iconSize={14} />
</div>
{tenantHasSpots ? (
<div className="flex gap-2 items-center">
<div className={'ml-auto'}>
{selectedCount > 0 && (
<>
<Button
type="text"
onClick={onClearSelection}
className="mr-2 px-3"
>
Clear
</Button>
<Button onClick={onDelete} type="primary" ghost>
Delete ({selectedCount})
</Button>
</>
)}
</div>
<Segmented
options={['All Spots', 'My Spots']}
value={spotStore.filter === 'all' ? 'All Spots' : 'My Spots'}
onChange={handleSegmentChange}
className="mr-4 lg:hidden xl:flex"
size={'small'}
/>
<div className="w-56">
<Input.Search
value={spotStore.query}
allowClear
name="spot-search"
placeholder="Filter by title"
onChange={handleInputChange}
onSearch={onSearch}
className="rounded-lg"
size="small"
/>
</div>
</div>
) : null}
</div>
);
}
);
export default SpotsListHeader;