Spaces:
Running
Running
File size: 1,658 Bytes
6c6fa5f 3299552 c2adf08 3299552 6c6fa5f 3299552 6c6fa5f 3299552 6c6fa5f 3299552 6c6fa5f 3299552 c2adf08 3299552 6c6fa5f 3299552 6c6fa5f 3299552 6c6fa5f 3299552 6c6fa5f 3299552 |
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 55 56 57 58 59 60 61 62 63 |
import React, { useState } from 'react';
import {
Box,
TextField,
Button,
Typography,
Paper,
CircularProgress
} from '@mui/material';
import SearchIcon from '@mui/icons-material/Search';
import styled from '@emotion/styled';
const StyledPaper = styled(Paper)(({ theme }) => ({
padding: theme.spacing(3),
marginBottom: theme.spacing(3),
}));
const SearchForm = ({ onSearch, isLoading }) => {
const [query, setQuery] = useState('');
const handleSubmit = (e) => {
e.preventDefault();
if (query.trim()) {
onSearch(query, 'both'); // Always use both models
}
};
return (
<StyledPaper elevation={2}>
<Typography variant="h5" gutterBottom sx={{ fontWeight: 'bold' }}>
Explore Al-Ghazali's Wisdom
</Typography>
<Typography variant="subtitle1" gutterBottom color="textSecondary">
Search through "The Alchemy of Happiness"
</Typography>
<Box component="form" onSubmit={handleSubmit} sx={{ mt: 2 }}>
<TextField
fullWidth
variant="outlined"
label="What would you like to know?"
value={query}
onChange={(e) => setQuery(e.target.value)}
InputProps={{
endAdornment: (
<Button
type="submit"
color="primary"
variant="contained"
disabled={isLoading}
sx={{ ml: 1 }}
>
{isLoading ? <CircularProgress size={24} /> : <SearchIcon />}
</Button>
),
}}
/>
</Box>
</StyledPaper>
);
};
export default SearchForm; |