mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
- Remove nested git repository from bugulma/frontend/.git - Add all frontend files to main repository tracking - Convert from separate frontend/backend repos to unified monorepo - Preserve all frontend code and development history as tracked files - Eliminate nested repository complexity for simpler development workflow This creates a proper monorepo structure with frontend and backend coexisting in the same repository for easier development and deployment.
67 lines
1.8 KiB
TypeScript
67 lines
1.8 KiB
TypeScript
import React, { useCallback } from 'react';
|
|
import { useNavigate } from 'react-router-dom';
|
|
import { useTranslation } from '@/hooks/useI18n';
|
|
import SearchInput from '@/components/ui/SearchInput';
|
|
|
|
interface SearchBarProps {
|
|
value: string;
|
|
onChange: (value: string) => void;
|
|
onSubmit?: (value: string) => void;
|
|
placeholder?: string;
|
|
showClearButton?: boolean;
|
|
onClear?: () => void;
|
|
containerClassName?: string;
|
|
navigateOnEnter?: boolean;
|
|
navigatePath?: string;
|
|
}
|
|
|
|
export const SearchBar: React.FC<SearchBarProps> = ({
|
|
value,
|
|
onChange,
|
|
onSubmit,
|
|
placeholder,
|
|
showClearButton = true,
|
|
onClear,
|
|
containerClassName,
|
|
navigateOnEnter = false,
|
|
navigatePath = '/map'
|
|
}) => {
|
|
const { t } = useTranslation();
|
|
const navigate = useNavigate();
|
|
|
|
const handleKeyDown = useCallback((e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
if (e.key === 'Enter' && value.trim()) {
|
|
e.preventDefault();
|
|
const searchValue = value.trim();
|
|
|
|
if (onSubmit) {
|
|
onSubmit(searchValue);
|
|
} else if (navigateOnEnter) {
|
|
navigate(`${navigatePath}?search=${encodeURIComponent(searchValue)}`);
|
|
}
|
|
}
|
|
}, [value, onSubmit, navigateOnEnter, navigatePath, navigate]);
|
|
|
|
const handleClear = useCallback(() => {
|
|
onChange('');
|
|
onClear?.();
|
|
}, [onChange, onClear]);
|
|
|
|
return (
|
|
<div className={`w-full md:w-auto md:flex-1 max-w-md relative ${containerClassName}`}>
|
|
<SearchInput
|
|
placeholder={placeholder || t('mapHeader.searchPlaceholder')}
|
|
value={value}
|
|
onChange={(e) => onChange(e.target.value)}
|
|
onKeyDown={handleKeyDown}
|
|
showClearButton={showClearButton}
|
|
onClear={handleClear}
|
|
autoComplete="off"
|
|
spellCheck="false"
|
|
/>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default SearchBar;
|