Saving implemented (no loading yet)

master
Joshua Sigona 3 years ago
parent 81dd37a4b3
commit a83ebcbe83
  1. 5
      src/App.js
  2. 30
      src/TestPanel.js

@ -809,6 +809,7 @@ function App() {
const [LOGGEDINUSER,setLOGGEDINUSER] = useState("") const [LOGGEDINUSER,setLOGGEDINUSER] = useState("")
const [LOGGEDINHASH,setLOGGEDINHASH] = useState("") const [LOGGEDINHASH,setLOGGEDINHASH] = useState("")
const [BUILDID,setBUILDID] = useState(undefined)
function GetData(table,row,col,id){ function GetData(table,row,col,id){
if (row===undefined) {row=''} if (row===undefined) {row=''}
@ -885,6 +886,10 @@ function App() {
poisonResist={poisonResist} poisonResist={poisonResist}
statDisplayAtk={statDisplayAtk} statDisplayAtk={statDisplayAtk}
GetData={GetData} GetData={GetData}
LOGGEDINUSER={LOGGEDINUSER}
BUILDID={BUILDID}
setBUILDID={setBUILDID}
BACKENDURL={GetBackendURL(BACKENDURL)}
/> />
</Route> </Route>
<Route path={process.env.PUBLIC_URL+"/login"}> <Route path={process.env.PUBLIC_URL+"/login"}>

@ -3,6 +3,7 @@ import Modal from 'react-modal'
import { DisplayIcon } from './DEFAULTS'; import { DisplayIcon } from './DEFAULTS';
import { ExpandTooltip } from './components/ExpandTooltip'; import { ExpandTooltip } from './components/ExpandTooltip';
import { SkillTree } from './skilltree/skillTree'; import { SkillTree } from './skilltree/skillTree';
import axios from 'axios';
//Helper variables for Weapon selector with structure: [weapon_type,weapon,potential,potential_tooltip,weapon_existence_data] //Helper variables for Weapon selector with structure: [weapon_type,weapon,potential,potential_tooltip,weapon_existence_data]
const WEAPON_WEAPONTYPE=0;const WEAPON_WEAPON=1;const WEAPON_POTENTIAL=2;const WEAPON_POTENTIAL_TOOLTIP=3;const WEAPON_EXISTENCE_DATA=4; const WEAPON_WEAPONTYPE=0;const WEAPON_WEAPON=1;const WEAPON_POTENTIAL=2;const WEAPON_POTENTIAL_TOOLTIP=3;const WEAPON_EXISTENCE_DATA=4;
@ -287,7 +288,7 @@ function SkillTreeContainer(p){
function TestPanel(p) { function TestPanel(p) {
const { GetData } = p const { GetData,LOGGEDINUSER,BUILDID,BACKENDURL,setBUILDID } = p
const [bpGraphMax,setbpGraphMax] = useState(1000) const [bpGraphMax,setbpGraphMax] = useState(1000)
const [hpGraphMax,sethpGraphMax] = useState(1000) const [hpGraphMax,sethpGraphMax] = useState(1000)
@ -325,20 +326,27 @@ const [skillPointData,setSkillPointData] = useState([])
function SaveData() { function SaveData() {
var saveObj = { var saveObj = {
author:author,
buildName:buildName,
className:className,
subclassName:subclassName,
level:level, level:level,
secondaryLevel:secondaryLevel, secondaryLevel:secondaryLevel,
weaponId:selectedWeapon[WEAPON_WEAPON].id, weaponBaseName:selectedWeapon[WEAPON_WEAPON]?.name,
armor1Id:selectedArmor1.id, weaponType:selectedWeapon[WEAPON_WEAPONTYPE]?.name,
armor2Id:selectedArmor2.id, armor1Name:selectedArmor1?.name,
armor3Id:selectedArmor3.id, armor2Name:selectedArmor2?.name,
armor3Name:selectedArmor3?.name,
points:points, points:points,
skillPointData:skillPointData skillPointData:skillPointData,
} }
console.log(saveObj) axios.post(BACKENDURL+"/submitBuild",{
id:BUILDID,
username:LOGGEDINUSER,
creator:author,
build_name:buildName,
class1:className,
class2:subclassName,
data:JSON.stringify(saveObj),})
.then((data)=>{
setBUILDID(data.data.id)
})
} }
function rarityCheck(v) { function rarityCheck(v) {

Loading…
Cancel
Save