Add in routes for saving/identifying builds.

master
Joshua Sigona 3 years ago
parent dd21de6a64
commit 4ddf3da42d
  1. 48
      src/App.js
  2. 29
      src/TestPanel.js

@ -12,7 +12,8 @@ import {
HashRouter, HashRouter,
Switch, Switch,
Route, Route,
useHistory useHistory,
useParams
} from "react-router-dom"; } from "react-router-dom";
import { HashLink as Link } from 'react-router-hash-link'; import { HashLink as Link } from 'react-router-hash-link';
@ -809,7 +810,9 @@ function App() {
const [LOGGEDINUSER,setLOGGEDINUSER] = useState("") const [LOGGEDINUSER,setLOGGEDINUSER] = useState("")
const [LOGGEDINHASH,setLOGGEDINHASH] = useState("") const [LOGGEDINHASH,setLOGGEDINHASH] = useState("")
const [BUILDID,setBUILDID] = useState(undefined)
const PANELPATHWBUILD = process.env.PUBLIC_URL+"/test/:BUILDID"
const PANELPATH = process.env.PUBLIC_URL+"/test"
function GetData(table,row,col,id){ function GetData(table,row,col,id){
if (row===undefined) {row=''} if (row===undefined) {row=''}
@ -857,12 +860,43 @@ function App() {
</Helmet> </Helmet>
<AdminPanel setUpdate={setUpdate} setTESTMODE={setTESTMODE} BACKENDURL={BACKENDURL} TESTMODE={TESTMODE} DATA={GetData}/> <AdminPanel setUpdate={setUpdate} setTESTMODE={setTESTMODE} BACKENDURL={BACKENDURL} TESTMODE={TESTMODE} DATA={GetData}/>
</Route> </Route>
<Route path={process.env.PUBLIC_URL+"/test"}> <Route path={PANELPATHWBUILD}>
<Helmet> <TestHeader/>
<title>{"Test - "+APP_TITLE}</title> <TestPanel
</Helmet> APP_TITLE={APP_TITLE}
path={PANELPATHWBUILD}
author={author}
buildName={buildName}
className={className}
secondaryClassName={secondaryClassName}
classLv={classLv}
secondaryClassLv={secondaryClassLv}
bp={bp}
hp={hp}
pp={pp}
def={def}
weaponUp1={weaponUp1}
weaponUp2={weaponUp2}
weaponUp3={weaponUp3}
damageResist={damageResist}
burnResist={burnResist}
shockResist={shockResist}
panicResist={panicResist}
stunResist={stunResist}
freezeResist={freezeResist}
blindResist={blindResist}
poisonResist={poisonResist}
statDisplayAtk={statDisplayAtk}
GetData={GetData}
LOGGEDINUSER={LOGGEDINUSER}
BACKENDURL={GetBackendURL(BACKENDURL)}
/>
</Route>
<Route path={PANELPATH}>
<TestHeader/> <TestHeader/>
<TestPanel <TestPanel
APP_TITLE={APP_TITLE}
path={PANELPATH}
author={author} author={author}
buildName={buildName} buildName={buildName}
className={className} className={className}
@ -887,8 +921,6 @@ function App() {
statDisplayAtk={statDisplayAtk} statDisplayAtk={statDisplayAtk}
GetData={GetData} GetData={GetData}
LOGGEDINUSER={LOGGEDINUSER} LOGGEDINUSER={LOGGEDINUSER}
BUILDID={BUILDID}
setBUILDID={setBUILDID}
BACKENDURL={GetBackendURL(BACKENDURL)} BACKENDURL={GetBackendURL(BACKENDURL)}
/> />
</Route> </Route>

@ -4,6 +4,9 @@ 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'; import axios from 'axios';
import Helmet from 'react-helmet'
import { useLocation,useHistory,useParams,matchPath } from 'react-router';
//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;
@ -288,7 +291,12 @@ function SkillTreeContainer(p){
function TestPanel(p) { function TestPanel(p) {
const { GetData,LOGGEDINUSER,BUILDID,BACKENDURL,setBUILDID } = p
let { BUILDID } = useParams()
let history = useHistory();
let location = useLocation();
const { GetData,LOGGEDINUSER,BACKENDURL,APP_TITLE } = p
const [bpGraphMax,setbpGraphMax] = useState(1000) const [bpGraphMax,setbpGraphMax] = useState(1000)
const [hpGraphMax,sethpGraphMax] = useState(1000) const [hpGraphMax,sethpGraphMax] = useState(1000)
@ -350,10 +358,19 @@ function SaveData() {
class2:subclassName, class2:subclassName,
data:JSON.stringify(saveObj),}) data:JSON.stringify(saveObj),})
.then((data)=>{ .then((data)=>{
setBUILDID(data.data.id) const match=matchPath(location.pathname,{
path:p.path,
exact:true,
strict:false
})
history.push(match.path.replace("/:BUILDID","")+"/"+data.data.id)
}) })
} }
function LoadData() {
}
function rarityCheck(v) { function rarityCheck(v) {
return v!==undefined?v.rarity!==undefined?" r"+v.rarity:"":"" return v!==undefined?v.rarity!==undefined?" r"+v.rarity:"":""
} }
@ -389,9 +406,17 @@ useEffect(()=>{
setSkillPointData(pointsDataArr) setSkillPointData(pointsDataArr)
},[className,GetData]) },[className,GetData])
useEffect(()=>{
console.log(BUILDID)
},[BUILDID])
//console.log(p.GetData("class",p.className,"icon")) //console.log(p.GetData("class",p.className,"icon"))
return (<> return (<>
<Helmet>
<title>{"Test - "+APP_TITLE+(BUILDID?" Build #"+BUILDID:"")}</title>
</Helmet>
<div className="main"> <div className="main">
<div className="containerA"> <div className="containerA">
<div className="box basicInfoBox"> <div className="box basicInfoBox">

Loading…
Cancel
Save