Correctly reset server state when the URL is changed

This commit is contained in:
Dane Everitt 2020-04-12 16:19:43 -07:00
parent b9239594ca
commit fc31d6347e
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 81 additions and 60 deletions

View file

@ -11,6 +11,7 @@ import { Server } from '@/api/server/getServer';
import { ApplicationStore } from '@/state';
import { httpErrorToHuman } from '@/api/http';
import { Link } from 'react-router-dom';
import styled from 'styled-components';
type Props = RequiredModalProps;
@ -18,6 +19,19 @@ interface Values {
term: string;
}
const ServerResult = styled(Link)`
${tw`flex items-center bg-neutral-900 p-4 rounded border-l-4 border-neutral-900 no-underline`};
transition: all 250ms linear;
&:hover {
${tw`shadow border-cyan-500`};
}
&:not(:last-of-type) {
${tw`mb-2`};
}
`;
const SearchWatcher = () => {
const { values, submitForm } = useFormikContext<Values>();
@ -91,10 +105,9 @@ export default ({ ...props }: Props) => {
<div className={'mt-6'}>
{
servers.map(server => (
<Link
<ServerResult
key={server.uuid}
to={`/server/${server.id}`}
className={'flex items-center block bg-neutral-900 p-4 rounded border-l-4 border-neutral-900 no-underline hover:shadow hover:border-cyan-500 transition-colors duration-250'}
onClick={() => props.onDismissed()}
>
<div>
@ -112,7 +125,7 @@ export default ({ ...props }: Props) => {
{server.node}
</span>
</div>
</Link>
</ServerResult>
))
}
</div>