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 {
display: table;
margin-right: 1rem;
table-layout: fixed;
}
.cl_headers, .cl_table_row {

View File

@ -1,7 +1,6 @@
import React, {useState, useRef, useLayoutEffect, useReducer} from 'react';
import './CreateLeague.css';
import twemoji from 'twemoji';
import $, {getJSON} from 'jquery';
interface LeagueStructureState {
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}
onChange={e => {
let params = new URLSearchParams({query: e.target.value, page_len: '5', page_num: '0'});
$.getJSON("/api/teams/search?" + params.toString(), data => {
console.log(data);
setSearchResults(data);
})
fetch("/api/teams/search?" + params.toString())
.then(response => response.json())
.then(data => setSearchResults(data));
setNewName(e.target.value);
}}/>
</div>

View File

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