Skip to content

Commit

Permalink
fix: the link on the search page corresponds to the domain searched for
Browse files Browse the repository at this point in the history
  • Loading branch information
maelgangloff committed Dec 27, 2024
1 parent d3adc4b commit 0e0a8be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions assets/pages/search/DomainSearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,30 @@ import {t} from 'ttag'
import {DomainSearchBar, FieldType} from "../../components/search/DomainSearchBar";
import {DomainResult} from "../../components/search/DomainResult";
import {showErrorAPI} from "../../utils/functions/showErrorAPI";
import {useParams} from "react-router-dom";
import {useNavigate, useParams} from "react-router-dom";

export default function DomainSearchPage() {
const [domain, setDomain] = useState<Domain | null>()
const [messageApi, contextHolder] = message.useMessage()
const navigate = useNavigate()

const {query} = useParams()

const onFinish: FormProps<FieldType>['onFinish'] = (values) => {
navigate('/search/domain/' + values.ldhName)
}

useEffect(() => {
if (query === undefined) return

setDomain(null)
getDomain(values.ldhName).then(d => {
getDomain(query).then(d => {
setDomain(d)
messageApi.success(t`Found !`)
}).catch((e: AxiosError) => {
setDomain(undefined)
showErrorAPI(e, messageApi)
})
}

useEffect(() => {
if (query) onFinish({ldhName: query})
}, [query])

return <Flex gap="middle" align="center" justify="center" vertical>
Expand Down
4 changes: 2 additions & 2 deletions translations/translations.pot
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,11 @@ msgstr ""
msgid "Sorry, the page you visited does not exist."
msgstr ""

#: assets/pages/search/DomainSearchPage.tsx:21
#: assets/pages/search/DomainSearchPage.tsx:28
msgid "Found !"
msgstr ""

#: assets/pages/search/DomainSearchPage.tsx:41
#: assets/pages/search/DomainSearchPage.tsx:44
msgid ""
"Although the domain exists in my database, it has been deleted from the "
"WHOIS by its registrar."
Expand Down

0 comments on commit 0e0a8be

Please sign in to comment.