change to using fetch over jquery

This commit is contained in:
Elijah Steres 2021-01-11 14:14:54 -05:00
parent c3a35c07a4
commit 74c9da684f
3 changed files with 16 additions and 22 deletions

View File

@ -58,7 +58,6 @@ input:focus {
.cl_league_structure_table { .cl_league_structure_table {
display: table; display: table;
margin-right: 1rem; margin-right: 1rem;
table-layout: fixed;
} }
.cl_headers, .cl_table_row { .cl_headers, .cl_table_row {

View File

@ -1,7 +1,6 @@
import React, {useState, useRef, useLayoutEffect, useReducer} from 'react'; import React, {useState, useRef, useLayoutEffect, useReducer} from 'react';
import './CreateLeague.css'; import './CreateLeague.css';
import twemoji from 'twemoji'; import twemoji from 'twemoji';
import $, {getJSON} from 'jquery';
interface LeagueStructureState { interface LeagueStructureState {
subleagues: SubleagueState[] subleagues: SubleagueState[]
@ -262,10 +261,9 @@ function Division(props: {state: DivisionState, dispatch:(action: DistributiveOm
<input type="text" className="cl_newteam_name" placeholder="Add team..." value={newName} ref={newNameInput} <input type="text" className="cl_newteam_name" placeholder="Add team..." value={newName} ref={newNameInput}
onChange={e => { onChange={e => {
let params = new URLSearchParams({query: e.target.value, page_len: '5', page_num: '0'}); let params = new URLSearchParams({query: e.target.value, page_len: '5', page_num: '0'});
$.getJSON("/api/teams/search?" + params.toString(), data => { fetch("/api/teams/search?" + params.toString())
console.log(data); .then(response => response.json())
setSearchResults(data); .then(data => setSearchResults(data));
})
setNewName(e.target.value); setNewName(e.target.value);
}}/> }}/>
</div> </div>

View File

@ -7,10 +7,8 @@ import GamePage from './GamePage';
import CreateLeague from './CreateLeague'; import CreateLeague from './CreateLeague';
import discordlogo from "./img/discord.png"; import discordlogo from "./img/discord.png";
import reportWebVitals from './reportWebVitals'; import reportWebVitals from './reportWebVitals';
import $ from 'jquery'
$(document).ready(function() { ReactDOM.render(
ReactDOM.render(
<React.StrictMode> <React.StrictMode>
<Router> <Router>
<Header /> <Header />
@ -22,8 +20,7 @@ $(document).ready(function() {
</Router> </Router>
</React.StrictMode>, </React.StrictMode>,
document.getElementById('root') document.getElementById('root')
); );
});
function Header() { function Header() {