moved search related types to types/search

This commit is contained in:
Abhinav 2022-01-04 15:48:33 +05:30
parent b5b31a8350
commit 79f6ebc454
5 changed files with 38 additions and 29 deletions

View file

@ -5,7 +5,6 @@ import AsyncSelect from 'react-select/async';
import { components } from 'react-select';
import debounce from 'debounce-promise';
import {
Bbox,
getHolidaySuggestion,
getYearSuggestion,
parseHumanDate,
@ -26,6 +25,7 @@ import ImageIcon from './icons/ImageIcon';
import VideoIcon from './icons/VideoIcon';
import { IconButton } from './Container';
import { EnteFile, FILE_TYPE } from 'types/file';
import { Suggestion, SuggestionType, DateValue, Bbox } from 'types/search';
const Wrapper = styled.div<{ isDisabled: boolean; isOpen: boolean }>`
position: fixed;
@ -76,23 +76,6 @@ const SearchInput = styled.div`
margin: auto;
`;
export enum SuggestionType {
DATE,
LOCATION,
COLLECTION,
IMAGE,
VIDEO,
}
export interface DateValue {
date?: number;
month?: number;
year?: number;
}
export interface Suggestion {
type: SuggestionType;
label: string;
value: Bbox | DateValue | number;
}
interface Props {
isOpen: boolean;
isFirstFetch: boolean;

View file

@ -52,8 +52,8 @@ import {
sortFiles,
sortFilesIntoCollections,
} from 'utils/file';
import SearchBar, { DateValue } from 'components/SearchBar';
import { Bbox } from 'services/searchService';
import { DateValue, Bbox } from 'types/search';
import SearchBar from 'components/SearchBar';
import SelectedFileOptions from 'components/pages/gallery/SelectedFileOptions';
import CollectionSelector, {
CollectionSelectorAttributes,

View file

@ -1,21 +1,21 @@
import * as chrono from 'chrono-node';
import { getEndpoint } from 'utils/common/apiUtil';
import { getToken } from 'utils/common/key';
import { DateValue, Suggestion, SuggestionType } from 'components/SearchBar';
import HTTPService from './HTTPService';
import { Collection } from 'types/collection';
import { EnteFile } from 'types/file';
import { logError } from 'utils/sentry';
import {
DateValue,
LocationSearchResponse,
Suggestion,
SuggestionType,
} from 'types/search';
const ENDPOINT = getEndpoint();
const DIGITS = new Set(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']);
export type Bbox = [number, number, number, number];
export interface LocationSearchResponse {
place: string;
bbox: Bbox;
}
export const getMapboxToken = () => process.env.NEXT_PUBLIC_MAPBOX_TOKEN;
export function parseHumanDate(humanDate: string): DateValue[] {
const date = chrono.parseDate(humanDate);

27
src/types/search/index.ts Normal file
View file

@ -0,0 +1,27 @@
export type Bbox = [number, number, number, number];
export interface LocationSearchResponse {
place: string;
bbox: Bbox;
}
export const getMapboxToken = () => process.env.NEXT_PUBLIC_MAPBOX_TOKEN;
export enum SuggestionType {
DATE,
LOCATION,
COLLECTION,
IMAGE,
VIDEO,
}
export interface DateValue {
date?: number;
month?: number;
year?: number;
}
export interface Suggestion {
type: SuggestionType;
label: string;
value: Bbox | DateValue | number;
}

View file

@ -1,6 +1,5 @@
import { DateValue } from 'components/SearchBar';
import { EnteFile } from 'types/file';
import { Bbox } from 'services/searchService';
import { Bbox, DateValue } from 'types/search';
export function isInsideBox(
file: { longitude: number; latitude: number },