From a83ebcbe837a9b079089011d3b4850a8b84a816a Mon Sep 17 00:00:00 2001 From: Joshua Sigona Date: Wed, 25 Aug 2021 00:15:02 +0900 Subject: [PATCH] Saving implemented (no loading yet) --- src/App.js | 5 +++++ src/TestPanel.js | 30 +++++++++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/App.js b/src/App.js index 146c22c..af55dfa 100644 --- a/src/App.js +++ b/src/App.js @@ -809,6 +809,7 @@ function App() { const [LOGGEDINUSER,setLOGGEDINUSER] = useState("") const [LOGGEDINHASH,setLOGGEDINHASH] = useState("") + const [BUILDID,setBUILDID] = useState(undefined) function GetData(table,row,col,id){ if (row===undefined) {row=''} @@ -885,6 +886,10 @@ function App() { poisonResist={poisonResist} statDisplayAtk={statDisplayAtk} GetData={GetData} + LOGGEDINUSER={LOGGEDINUSER} + BUILDID={BUILDID} + setBUILDID={setBUILDID} + BACKENDURL={GetBackendURL(BACKENDURL)} /> diff --git a/src/TestPanel.js b/src/TestPanel.js index 6a17d5b..08f697e 100644 --- a/src/TestPanel.js +++ b/src/TestPanel.js @@ -3,6 +3,7 @@ import Modal from 'react-modal' import { DisplayIcon } from './DEFAULTS'; import { ExpandTooltip } from './components/ExpandTooltip'; 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] 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) { -const { GetData } = p +const { GetData,LOGGEDINUSER,BUILDID,BACKENDURL,setBUILDID } = p const [bpGraphMax,setbpGraphMax] = useState(1000) const [hpGraphMax,sethpGraphMax] = useState(1000) @@ -325,20 +326,27 @@ const [skillPointData,setSkillPointData] = useState([]) function SaveData() { var saveObj = { - author:author, - buildName:buildName, - className:className, - subclassName:subclassName, level:level, secondaryLevel:secondaryLevel, - weaponId:selectedWeapon[WEAPON_WEAPON].id, - armor1Id:selectedArmor1.id, - armor2Id:selectedArmor2.id, - armor3Id:selectedArmor3.id, + weaponBaseName:selectedWeapon[WEAPON_WEAPON]?.name, + weaponType:selectedWeapon[WEAPON_WEAPONTYPE]?.name, + armor1Name:selectedArmor1?.name, + armor2Name:selectedArmor2?.name, + armor3Name:selectedArmor3?.name, 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) {