|
|
@ -18,10 +18,13 @@ import { FaCheckCircle } from 'react-icons/fa'; |
|
|
|
const parse = require('csv-parse/lib/sync') |
|
|
|
const parse = require('csv-parse/lib/sync') |
|
|
|
const axios = require('axios'); |
|
|
|
const axios = require('axios'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const dataSplitters = [0,135,250,388] |
|
|
|
|
|
|
|
|
|
|
|
const BACKEND_URL = "https://projectdivar.com:4505" |
|
|
|
const BACKEND_URL = "https://projectdivar.com:4505" |
|
|
|
|
|
|
|
|
|
|
|
function ItemGroup(p) { |
|
|
|
function ItemGroup(p) { |
|
|
|
const { data } = p |
|
|
|
const { data } = p |
|
|
|
|
|
|
|
const { setData1,setData2,setData3,setData4,setLastModified,lastModified } = p |
|
|
|
const [displayData,setDisplayData] = useState([]) |
|
|
|
const [displayData,setDisplayData] = useState([]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(()=>{ |
|
|
|
useEffect(()=>{ |
|
|
@ -49,11 +52,36 @@ function ItemGroup(p) { |
|
|
|
<img src={"https://xivapi.com"+item.icon}/> {item.name} |
|
|
|
<img src={"https://xivapi.com"+item.icon}/> {item.name} |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
|
<Col> |
|
|
|
<Col> |
|
|
|
<input style={{width:"5em"}} value={item.obtained} className="mt-1 bg-secondary" onChange={(f)=>{var correctedVal=Math.min(item.required,f.currentTarget.value); if (f.currentTarget.value>=item.required) {f.currentTarget.blur()} axios.post(BACKEND_URL+"/updateItem",{obtained:correctedVal,id:item.id,last_modified:new Date()}); var newData=[...displayData];newData[i].obtained=correctedVal;p.setLastModified(new Date());setDisplayData(newData.sort((a,b)=>{ |
|
|
|
<input style={{width:"5em"}} value={item.obtained} className="mt-1 bg-secondary" onChange={(f)=>{var correctedVal=Math.min(item.required,f.currentTarget.value); if (f.currentTarget.value>=item.required) {f.currentTarget.blur()}
|
|
|
|
if (b.required===b.obtained&&a.required!==a.obtained) {return -1} |
|
|
|
axios.get(BACKEND_URL+"/lastUpdate") |
|
|
|
if (b.required===b.obtained&&a.required===a.obtained) {return a.id-b.id} |
|
|
|
.then(async(data)=>{ |
|
|
|
if (b.required!==b.obtained&&a.required!==a.obtained) {return a.id-b.id} |
|
|
|
if (new Date(data.data[0].last_modified)>lastModified) { |
|
|
|
}));}} type="number" min="0" max={item.required}/> / {item.required} {item.required!==item.obtained&&<FaCheckCircle style={{color:"green"}} onClick={(f)=>{ |
|
|
|
console.log("Updating entries... "+[lastModified,data.data[0].last_modified]) |
|
|
|
|
|
|
|
setLastModified(new Date()) |
|
|
|
|
|
|
|
return await axios.get("https://projectdivar.com:4505/getData") |
|
|
|
|
|
|
|
.then((data)=>{ |
|
|
|
|
|
|
|
//setData(data.data)
|
|
|
|
|
|
|
|
setData1(data.data.slice(dataSplitters[0],dataSplitters[1])) |
|
|
|
|
|
|
|
setData2(data.data.slice(dataSplitters[1],dataSplitters[2])) |
|
|
|
|
|
|
|
setData3(data.data.slice(dataSplitters[2],dataSplitters[3])) |
|
|
|
|
|
|
|
setData4(data.data.slice(dataSplitters[3],data.data.length)) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.then((data)=>{ |
|
|
|
|
|
|
|
axios.post(BACKEND_URL+"/updateItem",{obtained:correctedVal,id:item.id,last_modified:new Date()}); |
|
|
|
|
|
|
|
var newData=[...displayData];newData[i].obtained=correctedVal; |
|
|
|
|
|
|
|
setLastModified(new Date()); |
|
|
|
|
|
|
|
setDisplayData(newData.sort((a,b)=>{ |
|
|
|
|
|
|
|
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} |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.catch((err)=>{ |
|
|
|
|
|
|
|
console.log(err.message) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}} type="number" min="0" max={item.required}/> / {item.required} {item.required!==item.obtained&&<FaCheckCircle style={{color:"green"}} onClick={(f)=>{ |
|
|
|
var correctedVal=item.required; if (f.currentTarget.value>=item.required) {f.currentTarget.blur()} axios.post(BACKEND_URL+"/updateItem",{obtained:correctedVal,id:item.id,last_modified:new Date()}); var newData=[...displayData];newData[i].obtained=correctedVal;p.setLastModified(new Date());setDisplayData(newData.sort((a,b)=>{ |
|
|
|
var correctedVal=item.required; if (f.currentTarget.value>=item.required) {f.currentTarget.blur()} axios.post(BACKEND_URL+"/updateItem",{obtained:correctedVal,id:item.id,last_modified:new Date()}); var newData=[...displayData];newData[i].obtained=correctedVal;p.setLastModified(new Date());setDisplayData(newData.sort((a,b)=>{ |
|
|
|
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} |
|
|
@ -92,10 +120,10 @@ function App() { |
|
|
|
return axios.get("https://projectdivar.com:4505/getData") |
|
|
|
return axios.get("https://projectdivar.com:4505/getData") |
|
|
|
.then((data)=>{ |
|
|
|
.then((data)=>{ |
|
|
|
//setData(data.data)
|
|
|
|
//setData(data.data)
|
|
|
|
setData(data.data.slice(0,135)) |
|
|
|
setData(data.data.slice(dataSplitters[0],dataSplitters[1])) |
|
|
|
setData2(data.data.slice(135,250)) |
|
|
|
setData2(data.data.slice(dataSplitters[1],dataSplitters[2])) |
|
|
|
setData3(data.data.slice(250,388)) |
|
|
|
setData3(data.data.slice(dataSplitters[2],dataSplitters[3])) |
|
|
|
setData4(data.data.slice(388,data.data.length)) |
|
|
|
setData4(data.data.slice(dataSplitters[3],data.data.length)) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
@ -194,10 +222,10 @@ function App() { |
|
|
|
{data.length>0? |
|
|
|
{data.length>0? |
|
|
|
<> |
|
|
|
<> |
|
|
|
<Accordion className="bg-dark" defaultActiveKey="0"> |
|
|
|
<Accordion className="bg-dark" defaultActiveKey="0"> |
|
|
|
<ItemGroup name="Gathering Items" akey="0" data={data} setData={setData} setLastModified={setLastModified}/> |
|
|
|
<ItemGroup name="Gathering Items" akey="0" data={data} lastModified={lastModified} setLastModified={setLastModified} setData={setData} setData1={setData} setData2={setData2} setData3={setData3} setData4={setData4}/> |
|
|
|
<ItemGroup name="Other Items" akey="1" data={data2} setData={setData2} setLastModified={setLastModified}/> |
|
|
|
<ItemGroup name="Other Items" akey="1" data={data2} lastModified={lastModified} setLastModified={setLastModified} setData={setData2} setData1={setData} setData2={setData2} setData3={setData3} setData4={setData4}/> |
|
|
|
<ItemGroup name="Pre-crafting" akey="2" data={data3} setData={setData3} setLastModified={setLastModified}/> |
|
|
|
<ItemGroup name="Pre-crafting" akey="2" data={data3} lastModified={lastModified} setLastModified={setLastModified} setData={setData3} setData1={setData} setData2={setData2} setData3={setData3} setData4={setData4}/> |
|
|
|
<ItemGroup name="Crafting Items" akey="3" data={data4} setData={setData4} setLastModified={setLastModified}/> |
|
|
|
<ItemGroup name="Crafting Items" akey="3" data={data4} lastModified={lastModified} setLastModified={setLastModified} setData={setData4} setData1={setData} setData2={setData2} setData3={setData3} setData4={setData4}/> |
|
|
|
</Accordion> |
|
|
|
</Accordion> |
|
|
|
</>: |
|
|
|
</>: |
|
|
|
!disabled&& |
|
|
|
!disabled&& |
|
|
|