diff --git a/src/App.js b/src/App.js index cd12fc2..3cf06d8 100755 --- a/src/App.js +++ b/src/App.js @@ -14,8 +14,10 @@ import Accordion from 'react-bootstrap/Accordion'; import ToastContainer from 'react-bootstrap/ToastContainer' import Toast from 'react-bootstrap/Toast' import Nav from 'react-bootstrap/Nav' +import Spinner from 'react-bootstrap/Spinner'; import { FaCheckCircle } from 'react-icons/fa'; +import { IoCheckmarkCircleOutline,IoCloseCircleSharp,IoAlertCircleOutline } from 'react-icons/io5'; const parse = require('csv-parse/lib/sync') @@ -114,20 +116,208 @@ function DarkInput(p){ } function SorterApp(){ + + function submitForm(){ + if (item1.length>0&&item2.length>0&&item3.length>0&&item4.length>0&&item5.length>0&& + item1_2.length>0&&item2_2.length>0&&item3_2.length>0&&item4_2.length>0&&item5_2.length>0){ + setChecking(true); + + for (let i of [ + {"endItem":item1,"beginItem":item1_2,"resultFunc":setResult1}, + {"endItem":item2,"beginItem":item2_2,"resultFunc":setResult2}, + {"endItem":item3,"beginItem":item3_2,"resultFunc":setResult3}, + {"endItem":item4,"beginItem":item4_2,"resultFunc":setResult4}, + {"endItem":item5,"beginItem":item5_2,"resultFunc":setResult5}, + ]) { + let itemData1={} + let itemData2={} + axios.get(encodeURI("https://xivapi.com/search?string="+i.endItem)) + .then((data)=>{ + var results = data.data.Results + for (var r of results) { + if (r.Name===i.endItem&&r.UrlType==="Item") { + return axios.get(encodeURI("https://xivapi.com"+r.Url)) + } + } + i.resultFunc(NOTFOUND) + throw new Error("Item 1 Not Found!"); + } + ) + .then((data)=>{ + var results = data.data + itemData1={...results} + return axios.get(encodeURI("https://xivapi.com/search?string="+i.beginItem)) + }) + .then((data)=>{ + var results = data.data.Results + for (var r of results) { + if (r.Name===i.beginItem&&r.UrlType==="Item") { + return axios.get(encodeURI("https://xivapi.com"+r.Url)) + } + } + i.resultFunc(NOTFOUND) + throw new Error("Item 2 Not Found!"); + } + ) + .then((data)=>{ + var results = data.data + itemData2={...results} + if (itemData1.ItemSortCategory.ID{console.log(err);}) + .finally(()=>{setChecking(false)}) + } + //axios.get(encodeURI("https://xivapi.com/search?string="+i)) + } + } + + const retainerNames = ["Ayayayayay","Howdoesanyonenameall","Kkittyy","Butwhy","Nowitsabun","Finalretainer"]; + const NONE=0; + const REJECTED=1; + const SUCCESS=2; + const NOTFOUND=3; + const [item1,setItem1] = useState("") const [item2,setItem2] = useState("") const [item3,setItem3] = useState("") const [item4,setItem4] = useState("") const [item5,setItem5] = useState("") - const [item6,setItem6] = useState("") + const [item1_2,setItem1_2] = useState("") + const [item2_2,setItem2_2] = useState("") + const [item3_2,setItem3_2] = useState("") + const [item4_2,setItem4_2] = useState("") + const [item5_2,setItem5_2] = useState("") + const [result1,setResult1] = useState(NONE) + const [result2,setResult2] = useState(NONE) + const [result3,setResult3] = useState(NONE) + const [result4,setResult4] = useState(NONE) + const [result5,setResult5] = useState(NONE) + + const [checking,setChecking] = useState(false) return <> - Item 1:{setItem1(f.currentTarget.value);}}> - - - - - + + + Ending {retainerNames[0]} Item 1: + + + {if (k.key==='Enter') {submitForm()}}} value={item1} onChange={(f)=>{setItem1(f.currentTarget.value);}}> + + + Beginning {retainerNames[1]} Item 1: + + + {if (k.key==='Enter') {submitForm()}}} value={item1_2} onChange={(f)=>{setItem1_2(f.currentTarget.value);}}> + + + {result1===NONE?<> + :result1===SUCCESS? + :result1===NOTFOUND? + :} + + + + + Ending {retainerNames[1]} Item 2: + + + {if (k.key==='Enter') {submitForm()}}} value={item2} onChange={(f)=>{setItem2(f.currentTarget.value);}}> + + + Beginning {retainerNames[2]} Item 2: + + + {if (k.key==='Enter') {submitForm()}}} value={item2_2} onChange={(f)=>{setItem2_2(f.currentTarget.value);}}> + + + {result2===NONE?<> + :result2===SUCCESS? + :result2===NOTFOUND? + :} + + + + + Ending {retainerNames[2]} Item 3: + + + {if (k.key==='Enter') {submitForm()}}} value={item3} onChange={(f)=>{setItem3(f.currentTarget.value);}}> + + + Beginning {retainerNames[3]} Item 3: + + + {if (k.key==='Enter') {submitForm()}}} value={item3_2} onChange={(f)=>{setItem3_2(f.currentTarget.value);}}> + + + {result3===NONE?<> + :result3===SUCCESS? + :result3===NOTFOUND? + :} + + + + + Ending {retainerNames[3]} Item 4: + + + {if (k.key==='Enter') {submitForm()}}} value={item4} onChange={(f)=>{setItem4(f.currentTarget.value);}}> + + + Beginning {retainerNames[4]} Item 4: + + + {if (k.key==='Enter') {submitForm()}}} value={item4_2} onChange={(f)=>{setItem4_2(f.currentTarget.value);}}> + + + {result4===NONE?<> + :result4===SUCCESS? + :result4===NOTFOUND? + :} + + + + + Ending {retainerNames[4]} Item 5: + + + {if (k.key==='Enter') {submitForm()}}} value={item5} onChange={(f)=>{setItem5(f.currentTarget.value);}}> + + + Beginning {retainerNames[5]} Item 5: + + + {if (k.key==='Enter') {submitForm()}}} value={item5_2} onChange={(f)=>{setItem5_2(f.currentTarget.value);}}> + + + {result5===NONE?<> + :result5===SUCCESS? + :result5===NOTFOUND? + :} + + + + A + + + + } @@ -311,9 +501,9 @@ function App() { BUN logo BUN Collab App {contributor.length>0&&<> - {setNav("main")}}>Main - {setNav("sort")}}>Sort Check - {setNav("list")}}>Grocery List + {setNav("main")}}>Main + {setNav("sort")}}>Sort Check + {setNav("list")}}>Grocery List Signed in as {contributor} }