From ed9ea8a976b27bfeea4de4ed8a282304c08023ae Mon Sep 17 00:00:00 2001 From: Francesco Meli Date: Thu, 15 Aug 2024 13:44:09 +0200 Subject: [PATCH] fix: reset url session storage when searching new cities --- src/components/Request/Request.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/Request/Request.tsx b/src/components/Request/Request.tsx index 6761e81..7b3c130 100644 --- a/src/components/Request/Request.tsx +++ b/src/components/Request/Request.tsx @@ -1,7 +1,7 @@ import axios from 'axios' import classnames from 'classnames' import { useEffect, useState } from 'react' -import { useLocalStorage } from 'usehooks-ts' +import { useLocalStorage, useSessionStorage } from 'usehooks-ts' import { TreeSelect, Button } from 'antd' import { Navigate } from 'react-router-dom' import { Location, RequestResponse } from '../../types' @@ -24,6 +24,7 @@ const Request = ({ const [request, setRequest] = useLocalStorage('requestUUID', null) const [error, setError] = useState(null) const [codes, setCodes] = useState(null) + const [_, setUrl] = useSessionStorage('url', null) const handleRequest = () => { axios.post('/v1/request', { codes }).then((response) => { @@ -55,6 +56,10 @@ const Request = ({ }) }, [setCitiesTree]) + useEffect(() => { + setUrl(null) + }, [setUrl]) + if (request) { return }