-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ca997f
commit cddf923
Showing
14 changed files
with
208 additions
and
102 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { P } from '@/components/lib/typography' | ||
import SearchInput from '@/components/search/search-input' | ||
import { HTMLAttributes } from 'react' | ||
import { twMerge } from 'tailwind-merge' | ||
|
||
type NewSearchProps = HTMLAttributes<HTMLDivElement> & { | ||
handleSearch: () => void | ||
} | ||
|
||
export default function NewSearch(props: NewSearchProps) { | ||
return ( | ||
<div className={twMerge('w-full h-[90vh] flex justify-center items-center', props.className)}> | ||
<div className="w-full max-w-[720px] flex flex-col items-center px-4"> | ||
<P className="mb-10 text-2xl xl:text-3xl transition-all duration-300">How can I help you today?</P> | ||
<SearchInput handleSearch={props.handleSearch} /> | ||
</div> | ||
</div> | ||
) | ||
} |
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,56 @@ | ||
import { SearchByIdResponse } from '@/types/search' | ||
import { HTMLAttributes, useEffect, useRef, useState } from 'react' | ||
import SearchActions from './search-actions' | ||
import SearchResponse from './search-response' | ||
import SearchTitle from './search-title' | ||
import SourcesMenu from './sources-menu' | ||
import { Span } from '../lib/typography' | ||
|
||
type OldSearchResponseProps = HTMLAttributes<HTMLDivElement> & { | ||
search: SearchByIdResponse | ||
} | ||
|
||
export default function OldSearchResponse(props: OldSearchResponseProps) { | ||
const { search: searchResult, sources } = props.search | ||
const answerContainerRef = useRef<HTMLDivElement>(null) | ||
// const sourcesConatinerRef = useRef<HTMLDivElement>(null) | ||
const [answerContainerHeight, setanswerContainerHeight] = useState<number>(0) | ||
|
||
useEffect(() => { | ||
const updateHeight = () => { | ||
if (answerContainerRef.current) { | ||
setanswerContainerHeight(Math.min(answerContainerRef.current.offsetHeight, 200)) | ||
} | ||
} | ||
|
||
updateHeight() | ||
|
||
window.addEventListener('resize', updateHeight) | ||
return () => window.removeEventListener('resize', updateHeight) | ||
}, []) | ||
|
||
return ( | ||
<div className="w-full flex max-h-80"> | ||
<div className="w-full flex flex-col justify-between" ref={answerContainerRef}> | ||
<div className="w-full px-10 transition-all duration-300"> | ||
<SearchTitle className="mb-6" title={searchResult.query} /> | ||
<div className="flex items-center gap-x-3 mb-6"> | ||
<img src="images/answer-logo.svg" className="w-10 h-10" alt="answer-logo" /> | ||
<Span className="font-light text-white/80 text-xl">Answer</Span> | ||
</div> | ||
<SearchResponse className="mb-6" response={searchResult.result} /> | ||
<SearchActions | ||
searchHistoryId={searchResult.search_id} | ||
reaction={searchResult.reaction} | ||
response={searchResult.result} | ||
/> | ||
</div> | ||
</div> | ||
<SourcesMenu | ||
className="w-60 xl:w-96 p-3 transition-all duration-300 bg-white/2 rounded-l-2xl" | ||
sources={sources} | ||
style={{ maxHeight: `calc(100vh - ${answerContainerHeight}px)` }} | ||
/> | ||
</div> | ||
) | ||
} |
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
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 |
---|---|---|
@@ -1,5 +1,44 @@ | ||
import React from 'react' | ||
import { useFetchThreadByIdQuery } from '@/queries/search/fetch-thread-by-id-query' | ||
import { Fragment, HTMLAttributes, useEffect } from 'react' | ||
import { twMerge } from 'tailwind-merge' | ||
import { H1 } from '../lib/typography' | ||
import OldSearchResponse from './old-search-response' | ||
import SearchInput from './search-input' | ||
import { useSearchQuery } from '@/queries/search/search-query' | ||
|
||
export default function Thread() { | ||
return <div>Thread</div> | ||
type ThreadProps = HTMLAttributes<HTMLDivElement> & { | ||
threadId: string | ||
} | ||
|
||
export default function Thread(props: ThreadProps) { | ||
const { data } = useFetchThreadByIdQuery({ threadId: props.threadId }) | ||
const { data: newSearchResult, isLoading, isSuccess, isError, refetch: fetchSearchResult } = useSearchQuery() | ||
const handleSearch = () => { | ||
fetchSearchResult().then(r => r) | ||
} | ||
|
||
useEffect(() => { | ||
console.log(data) | ||
}, [data]) | ||
|
||
if (!data) { | ||
return null | ||
} | ||
|
||
return ( | ||
<div className={twMerge('w-full', props.className)}> | ||
<H1 className="px-10 py-4 text-2xl xl:text-3xl font-semibold">{data?.thread.title}</H1> | ||
<div className="pt-4 flex flex-col gap-y-4"> | ||
{data?.searches.map((search, index) => ( | ||
<Fragment key={`search-response-${data.thread.thread_id}-${index}`}> | ||
<OldSearchResponse search={search} /> | ||
<div className="h-0.5 bg-white/20 ml-10 mr-6"></div> | ||
</Fragment> | ||
))} | ||
</div> | ||
<div className="sticky bottom-0 pb-4 px-8 -mb-4 flex justify-start backdrop-blur-sm"> | ||
<SearchInput handleSearch={handleSearch} /> | ||
</div> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.