Removed all warnings

main
sigonasr2 2 years ago
parent 53406cd6d6
commit 88ea058b7d
  1. 94
      src/App.js

@ -1,4 +1,3 @@
import logo from './logo512.png';
import './App.css'; import './App.css';
import 'bootstrap/dist/css/bootstrap.min.css'; import 'bootstrap/dist/css/bootstrap.min.css';
@ -35,7 +34,6 @@ const progress2 = new Audio(process.env.PUBLIC_URL+"/progress2.mp3")
function ItemGroup(p) { function ItemGroup(p) {
const { data } = p const { data } = p
const { contributor } = p const { contributor } = p
const { setData1,setData2,setData3,setData4,setLastModified,lastModified } = p
const [displayData,setDisplayData] = useState([]) const [displayData,setDisplayData] = useState([])
const [lockout,setLockout] = useState(false) const [lockout,setLockout] = useState(false)
@ -44,6 +42,7 @@ function ItemGroup(p) {
if (b.required===b.obtained&&a.required!==a.obtained) {return -1} if (b.required===b.obtained&&a.required!==a.obtained) {return -1}
if (b.required===b.obtained&&a.required===a.obtained) {return a.id-b.id} if (b.required===b.obtained&&a.required===a.obtained) {return a.id-b.id}
if (b.required!==b.obtained&&a.required!==a.obtained) {return a.id-b.id} if (b.required!==b.obtained&&a.required!==a.obtained) {return a.id-b.id}
return 0
})) }))
},[data]) },[data])
@ -57,9 +56,9 @@ function ItemGroup(p) {
function updateItem(item,target,contributor) { function updateItem(item,target,contributor) {
var correctedVal=Math.min(item.required,target.value); var correctedVal=Math.min(item.required,target.value);
if (correctedVal==item.obtained) {return;} if (correctedVal===Number(item.obtained)) {return;}
setLockout(true) setLockout(true)
axios.post(BACKEND_URL+"/updateItem",{obtained:correctedVal,id:item.id,last_modified:new Date(),item_name:item.name,username:contributor,required:item.required,operation:correctedVal==item.required?"FINISH":correctedVal>item.obtained?"INCREASE":"SET",previous_amt:item.obtained}) axios.post(BACKEND_URL+"/updateItem",{obtained:correctedVal,id:item.id,last_modified:new Date(),item_name:item.name,username:contributor,required:item.required,operation:correctedVal===Number(item.required)?"FINISH":correctedVal>item.obtained?"INCREASE":"SET",previous_amt:item.obtained})
.then((data)=>{ .then((data)=>{
setLockout(false) setLockout(false)
}) })
@ -73,7 +72,7 @@ function ItemGroup(p) {
<Accordion.Body className="panel-body"> <Accordion.Body className="panel-body">
{displayData.map((item,i,arr)=><Row key={item.id} className={"pb-1 pt-1 text-light"+(Number(item.obtained)===0?" notStarted":Number(item.obtained)===Number(item.required)?" completed":" inProgress")}> {displayData.map((item,i,arr)=><Row key={item.id} className={"pb-1 pt-1 text-light"+(Number(item.obtained)===0?" notStarted":Number(item.obtained)===Number(item.required)?" completed":" inProgress")}>
<Col> <Col>
<img src={"https://xivapi.com"+item.icon}/> {item.name} <img src={"https://xivapi.com"+item.icon} alt={item.name}/> {item.name}
</Col> </Col>
<Col> <Col>
<input disabled={lockout} id={"field_"+item.id} style={{width:"5em"}} defaultValue={item.obtained} className="mt-1 bg-secondary" <input disabled={lockout} id={"field_"+item.id} style={{width:"5em"}} defaultValue={item.obtained} className="mt-1 bg-secondary"
@ -111,7 +110,6 @@ function Notification(p) {
} }
function DarkInput(p){ function DarkInput(p){
const {props}=p;
return <input type="text" className="bg-dark text-white" {...p}></input> return <input type="text" className="bg-dark text-white" {...p}></input>
} }
@ -172,14 +170,14 @@ function SorterApp(){
setChecking(false) setChecking(false)
return return
} else } else
if (itemData1.ItemSortCategory.ID==itemData2.ItemSortCategory.ID&& if (itemData1.ItemSortCategory.ID===itemData2.ItemSortCategory.ID&&
itemData1.ItemUICategory.ID<itemData2.ItemUICategory.ID){ itemData1.ItemUICategory.ID<itemData2.ItemUICategory.ID){
i.resultFunc(SUCCESS) i.resultFunc(SUCCESS)
setChecking(false) setChecking(false)
return return
} else } else
if (itemData1.ItemSortCategory.ID==itemData2.ItemSortCategory.ID&& if (itemData1.ItemSortCategory.ID===itemData2.ItemSortCategory.ID&&
itemData1.ItemUICategory.ID==itemData2.ItemUICategory.ID&& itemData1.ItemUICategory.ID===itemData2.ItemUICategory.ID&&
itemData1.ID<itemData2.ID){ itemData1.ID<itemData2.ID){
i.resultFunc(SUCCESS) i.resultFunc(SUCCESS)
setChecking(false) setChecking(false)
@ -346,12 +344,10 @@ function App() {
const [succeeded,setSucceeded] = useState(0) const [succeeded,setSucceeded] = useState(0)
const [failed,setFailed] = useState(0) const [failed,setFailed] = useState(0)
const [total,setTotal] = useState(0) const [total,setTotal] = useState(0)
const [listData,setListData] = useState([])
const [lastModified,setLastModified] = useState(new Date()) const [lastModified,setLastModified] = useState(new Date())
const [contributor,setContributor] = useState("") const [contributor,setContributor] = useState("")
const [notifications,setNotifications] = useState([]) const [notifications,setNotifications] = useState([])
const [closedNotifications,setClosedNotifications] = useState([])
const [nav,setNav] = useState("main") const [nav,setNav] = useState("main")
@ -428,41 +424,6 @@ function App() {
const disabled=true const disabled=true
function downloadData(d,val,max) {
if (val<max) {
axios.get(encodeURI("https://xivapi.com/search?string="+d[val].Item))
.then((data)=>{
var results = data.data.Results
var found=false
for (var r of results) {
if (r.Name===d[val].Item&&r.UrlType==="Item") {
found=true
//console.log("Found "+r)
setSucceeded(succeeded+1)
var dataObj = {
itemid:r.ID,
name:r.Name,
obtained:0,
required:d[val].Needed,
icon:r.Icon
}
return axios.post(BACKEND_URL+"/setItem",dataObj)
}
}
if (!found) {
setFailed(failed+1)
console.log("Could not find "+d[val].Item+"....")
}
})
.then(()=>{
setTimeout(downloadData(d,val+1,max),250)
})
.catch((err)=>{
setFailed(failed+1)
})
}
}
useEffect(()=>{ useEffect(()=>{
if (update) { if (update) {
axios.get("https://projectdivar.com:4505/getData") axios.get("https://projectdivar.com:4505/getData")
@ -491,15 +452,50 @@ function App() {
if (succeeded+failed===total) { if (succeeded+failed===total) {
setUpdate(true) setUpdate(true)
} }
},[succeeded,failed]) },[succeeded,failed,total])
useEffect(()=>{ useEffect(()=>{
const downloadData=(d,val,max)=>{
if (val<max) {
axios.get(encodeURI("https://xivapi.com/search?string="+d[val].Item))
.then((data)=>{
var results = data.data.Results
var found=false
for (var r of results) {
if (r.Name===d[val].Item&&r.UrlType==="Item") {
found=true
//console.log("Found "+r)
setSucceeded(succeeded+1)
var dataObj = {
itemid:r.ID,
name:r.Name,
obtained:0,
required:d[val].Needed,
icon:r.Icon
}
return axios.post(BACKEND_URL+"/setItem",dataObj)
}
}
if (!found) {
setFailed(failed+1)
console.log("Could not find "+d[val].Item+"....")
}
})
.then(()=>{
setTimeout(downloadData(d,val+1,max),250)
})
.catch((err)=>{
setFailed(failed+1)
})
}
}
var d = parse(fileData,{columns:true,skip_empty_lines:true}) var d = parse(fileData,{columns:true,skip_empty_lines:true})
console.log(d) console.log(d)
var promises = []
downloadData(d,0,d.length) downloadData(d,0,d.length)
setTotal(d.length) setTotal(d.length)
},[fileData]) },[fileData,failed,succeeded])
return ( return (
<Container className="bg-dark" fluid> <Container className="bg-dark" fluid>

Loading…
Cancel
Save