-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1805 from stakwork/feature/follow-up
feat: add follow up question
- Loading branch information
Showing
6 changed files
with
90 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { FormProvider, useForm } from 'react-hook-form' | ||
import styled from 'styled-components' | ||
import SearchIcon from '~/components/Icons/SearchIcon' | ||
import { SearchBar } from '~/components/SearchBar' | ||
import { Flex } from '~/components/common/Flex' | ||
import { useDataStore } from '~/stores/useDataStore' | ||
import { useUserStore } from '~/stores/useUserStore' | ||
import { colors } from '~/utils' | ||
|
||
export const AiSearch = () => { | ||
const form = useForm<{ search: string }>({ mode: 'onChange' }) | ||
const { fetchData, setAbortRequests } = useDataStore((s) => s) | ||
const { setBudget } = useUserStore((s) => s) | ||
const { reset } = form | ||
|
||
const handleSubmit = form.handleSubmit(({ search }) => { | ||
fetchData(setBudget, setAbortRequests, search) | ||
reset({ search: '' }) | ||
}) | ||
|
||
return ( | ||
<AiSearchWrapper> | ||
<FormProvider {...form}> | ||
<Search> | ||
<SearchBar onSubmit={handleSubmit} placeholder="Ask follow-up" /> | ||
<InputButton | ||
data-testid="search-ai_action_icon" | ||
onClick={() => { | ||
handleSubmit() | ||
}} | ||
> | ||
<SearchIcon /> | ||
</InputButton> | ||
</Search> | ||
</FormProvider> | ||
</AiSearchWrapper> | ||
) | ||
} | ||
|
||
const AiSearchWrapper = styled(Flex)` | ||
position: sticky; | ||
bottom: 0; | ||
padding: 12px; | ||
border-top: 1px solid ${colors.black}; | ||
` | ||
|
||
const Search = styled(Flex).attrs({ | ||
direction: 'row', | ||
justify: 'center', | ||
align: 'center', | ||
})` | ||
flex-grow: 1; | ||
` | ||
|
||
const InputButton = styled(Flex).attrs({ | ||
align: 'center', | ||
justify: 'center', | ||
p: 5, | ||
})` | ||
font-size: 32px; | ||
color: ${colors.mainBottomIcons}; | ||
cursor: pointer; | ||
transition-duration: 0.2s; | ||
margin-left: -42px; | ||
z-index: 2; | ||
&:hover { | ||
/* background-color: ${colors.gray200}; */ | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters