Skip to content

Commit

Permalink
prepopulate suggest wiki input field from search field
Browse files Browse the repository at this point in the history
  • Loading branch information
Damola18 committed Jul 11, 2024
1 parent 05f0b44 commit fcc7ded
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/components/Layout/Navbar/NavSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ const NavSearch = (props: NavSearchProps) => {
<SuggestWikiModal
isOpen={isSuggestWikiOpen}
onClose={onSuggestWikiClose}
prePopulatedSearch={query}
/>
</>
)
Expand Down
21 changes: 16 additions & 5 deletions src/components/Layout/Navbar/SuggestWiki.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Modal } from '@/components/Elements'
import { useState, useEffect } from 'react'
import {
Box,
Button,
Expand Down Expand Up @@ -30,16 +31,26 @@ const sumbitButton = (
)
}

interface SuggestWikiModalProps extends Partial<ModalProps> {
prePopulatedSearch?: string
}

const SuggestWikiModal = ({
onClose = () => {},
isOpen = true,
}: Partial<ModalProps>) => {
prePopulatedSearch = '',
}: SuggestWikiModalProps) => {
const { t } = useTranslation('common')
const [input, setInput] = React.useState('')
const [email, setEmail] = React.useState('')
const [isSubmitted, setIsSubmitted] = React.useState(false)
const [loading, setLoading] = React.useState(false)
const [input, setInput] = useState(prePopulatedSearch)
const [email, setEmail] = useState('')
const [isSubmitted, setIsSubmitted] = useState(false)
const [loading, setLoading] = useState(false)
const [error, setError] = React.useState('')

useEffect(() => {
setInput(prePopulatedSearch)
}, [prePopulatedSearch])

const handleInputChange: ChangeEventHandler<HTMLTextAreaElement> = (e) => {
const inputValue = e.target.value
setInput(inputValue)
Expand Down

0 comments on commit fcc7ded

Please sign in to comment.