switched to using api tokens instead of login credentials
This commit is contained in:
parent
86f273d12d
commit
226caf4c1e
13 changed files with 215 additions and 85 deletions
|
|
@ -9,12 +9,12 @@ const ServerList = () => {
|
|||
getServerList().then(serverList => {
|
||||
setServers(serverList);
|
||||
})
|
||||
})
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div style={{ display: "flex", flexDirection: "row", flexWrap: "wrap" }}>
|
||||
{servers.map(server => {
|
||||
return (<ServerCard name={server.owner} online={false} linkTo={server.url} key={server.name} />)
|
||||
return (<ServerCard name={server.owner} online={true} linkTo={server.url} key={server.name} />)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ const ServerSearch = ({ searchTerm, server }: ServerSearchProps) => {
|
|||
search(searchTerm, server.id).then(results => {
|
||||
setSearchResults(results);
|
||||
}).catch(err => {
|
||||
setSearchResults([]);
|
||||
alert(err);
|
||||
})
|
||||
}, [searchTerm]);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ const ServerSearchResult = ({ searchResult, server }: ServerSearchResultProps) =
|
|||
|
||||
return (
|
||||
<Link to={resultUrl} target="_blank" rel="noopener noreferrer">
|
||||
<h3>{searchResult.name} - {searchResult.productionYear}</h3>
|
||||
<h3>{searchResult.type} - {searchResult.name} - {searchResult.productionYear}</h3>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,10 @@ export interface SearchResult {
|
|||
name: string;
|
||||
id: string;
|
||||
serverId: string;
|
||||
type: SearchResultType;
|
||||
type: string;
|
||||
productionYear: string;
|
||||
}
|
||||
|
||||
export type SearchResultType = "movie" | "tv show" | "music";
|
||||
|
||||
export const search = async (searchTerm: string, serverId: string): Promise<Array<SearchResult>> => {
|
||||
const response = await axios.get<Array<SearchResult>>(`${apiUrl}/search?searchTerm=${searchTerm}&serverId=${serverId}`);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ const Search = () => {
|
|||
navigate("/");
|
||||
}
|
||||
|
||||
if (servers.length > 0) {
|
||||
// eslint-disable-next-line react-hooks/set-state-in-effect
|
||||
setServers([]);
|
||||
}
|
||||
|
||||
getServerList().then(servers => {
|
||||
if (servers.length === 0) {
|
||||
alert("No servers found");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue