|
|
@ -44,8 +44,15 @@ function ItemGroup(p) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function submit(f,item,i){ |
|
|
|
return <Accordion.Item className="bg-dark" eventKey={p.akey}> |
|
|
|
var correctedVal=Math.min(item.required,f.currentTarget.value); if (f.currentTarget.value>=item.required) {f.currentTarget.blur()}
|
|
|
|
<Accordion.Header className="panel-body bg-dark">{p.name}</Accordion.Header> |
|
|
|
|
|
|
|
<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")}> |
|
|
|
|
|
|
|
<Col> |
|
|
|
|
|
|
|
<img src={"https://xivapi.com"+item.icon}/> {item.name} |
|
|
|
|
|
|
|
</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.get(BACKEND_URL+"/lastUpdate") |
|
|
|
axios.get(BACKEND_URL+"/lastUpdate") |
|
|
|
.then(async(data)=>{ |
|
|
|
.then(async(data)=>{ |
|
|
|
if (new Date(data.data[0].last_modified)>lastModified) { |
|
|
|
if (new Date(data.data[0].last_modified)>lastModified) { |
|
|
@ -74,17 +81,7 @@ function ItemGroup(p) { |
|
|
|
.catch((err)=>{ |
|
|
|
.catch((err)=>{ |
|
|
|
console.log(err.message) |
|
|
|
console.log(err.message) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
}} type="number" min="0" max={item.required}/> / {item.required} {item.required!==item.obtained&&<FaCheckCircle style={{color:"green"}} onClick={(f)=>{ |
|
|
|
|
|
|
|
|
|
|
|
return <Accordion.Item className="bg-dark" eventKey={p.akey}> |
|
|
|
|
|
|
|
<Accordion.Header className="panel-body bg-dark">{p.name}</Accordion.Header> |
|
|
|
|
|
|
|
<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")}> |
|
|
|
|
|
|
|
<Col> |
|
|
|
|
|
|
|
<img src={"https://xivapi.com"+item.icon}/> {item.name} |
|
|
|
|
|
|
|
</Col> |
|
|
|
|
|
|
|
<Col> |
|
|
|
|
|
|
|
<input id={"input_"+item.id} style={{width:"5em"}} defaultValue={item.obtained} className="mt-1 bg-secondary" onKeyDown={(k)=>{if (k.key==='Enter') {submit({currentTarget:document.getElementById("input_"+item.id)},item,i)}}} onBlur={(f)=>{submit(f,item,i)}} 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} |
|
|
|