Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
rpg-workshop
Commits
7ee10b5e
Commit
7ee10b5e
authored
Oct 02, 2021
by
Joe Ziemba
Browse files
delete characters, async methods
parent
56d77919
Changes
19
Hide whitespace changes
Inline
Side-by-side
src/PF2CharacterBuilder/_components/FeatEntry.js
View file @
7ee10b5e
...
...
@@ -18,8 +18,8 @@ const FeatEntry = (props) => {
<
/button
>
)
:
(
<
div
className
=
"
grid grid-cols-8 gap 2
"
>
<
span
className
=
"
text-lg col-span-1 text-gray-400 pl-2
"
>
s
{
props
.
label
}
<
span
className
=
"
text-lg col-span-1 text-gray-400 pl-2
"
>
s
{
props
.
label
}
<
/span
>
<
span
className
=
"
col-span-6
"
>
<
p
className
=
"
text-lg mb-1
"
>
{
props
.
feat
.
name
}
<
/p
>
...
...
src/PF2CharacterBuilder/_components/SubNav.js
View file @
7ee10b5e
import
React
from
"
react
"
import
{
Link
}
from
"
react-
router-dom
"
import
{
toast
}
from
"
react-
toastify
"
import
{
UserContext
}
from
"
context
"
import
{
firebase
}
from
"
services/Firebase
"
import
{
toast
}
from
"
react-toastify
"
import
NavButton
from
"
_globalComponents/NavButton
"
import
{
Modal
}
from
"
_globalComponents
"
import
{
Modal
,
NavButton
,
OpenOrDeleteItem
}
from
"
_globalComponents
"
class
SubNav
extends
React
.
Component
{
constructor
(
props
)
{
...
...
@@ -17,18 +15,43 @@ class SubNav extends React.Component {
this
.
getCharacters
=
this
.
getCharacters
.
bind
(
this
)
this
.
closeModal
=
this
.
closeModal
.
bind
(
this
)
this
.
deleteCharacter
=
this
.
deleteCharacter
.
bind
(
this
)
this
.
saveCharacter
=
this
.
saveCharacter
.
bind
(
this
)
}
async
getCharacters
()
{
const
snapshot
=
await
firebase
.
getPF2CharactersForUser
(
this
.
context
.
currentUser
.
uid
)
let
characters
=
[]
snapshot
.
forEach
((
doc
)
=>
{
characters
.
push
({
...
doc
.
data
(),
uid
:
doc
.
id
,
id
:
doc
.
id
})
})
if
(
characters
.
length
===
0
)
toast
(
"
You have no saved characters
"
)
this
.
setState
({
characters
,
showOpenModal
:
characters
.
length
>
0
})
}
async
saveCharacter
()
{
if
(
this
.
props
.
character
.
name
)
{
let
character
=
await
firebase
.
savePF2Character
(
this
.
props
.
character
)
if
(
character
)
this
.
props
.
history
.
push
(
`/pf2/character-builder/
${
character
.
id
}
`
)
}
else
{
toast
.
error
(
"
Cannot Save a character without a name
"
)
}
}
async
deleteCharacter
(
character
)
{
await
firebase
.
deletePF2Character
(
character
.
id
)
await
this
.
getCharacters
()
toast
(
"
Deleted
"
+
character
.
name
)
}
getCharacters
()
{
firebase
.
getPF2CharactersForUser
(
this
.
context
.
currentUser
.
uid
)
.
then
((
snapshot
)
=>
{
let
characters
=
[]
snapshot
.
forEach
((
doc
)
=>
{
characters
.
push
({
...
doc
.
data
(),
uid
:
doc
.
id
})
})
this
.
setState
({
characters
,
showOpenModal
:
true
})
})
async
selectCharacter
(
id
)
{
const
character
=
await
this
.
props
.
getCharacter
(
id
)
this
.
closeModal
()
toast
(
"
Opened
"
+
character
.
name
)
}
closeModal
()
{
...
...
@@ -49,16 +72,7 @@ class SubNav extends React.Component {
{
this
.
context
.
currentUser
&&
(
<
React
.
Fragment
>
<
NavButton
color
=
"
navy
"
onClick
=
{()
=>
{
if
(
this
.
props
.
character
.
name
)
{
firebase
.
savePF2Character
(
this
.
props
.
character
)
}
else
{
toast
.
error
(
"
Cannot Save a character without a name
"
)
}
}}
>
<
NavButton
color
=
"
navy
"
onClick
=
{
this
.
saveCharacter
}
>
Save
<
/NavButton
>
...
...
@@ -74,18 +88,24 @@ class SubNav extends React.Component {
show
=
{
this
.
state
.
showOpenModal
}
closeFunction
=
{
this
.
closeModal
}
>
{
this
.
state
.
characters
.
map
((
character
)
=>
{
return
(
<
Link
key
=
{
character
.
uid
}
className
=
"
block text-black w-full px-8 py-2 hover:bg-gray-200 transition-colors
"
to
=
{
"
/pf2/character-builder/
"
+
character
.
uid
}
onClick
=
{
this
.
closeModal
}
>
{
character
.
name
}
<
/Link
>
)
})}
<
ul
className
=
"
text-black
"
>
{
this
.
state
.
characters
.
map
((
character
)
=>
{
return
(
<
OpenOrDeleteItem
key
=
{
character
.
uid
}
id
=
{
character
.
uid
}
selectFunc
=
{
async
()
=>
await
this
.
selectCharacter
(
character
.
uid
)
}
deleteFunc
=
{
async
()
=>
await
this
.
deleteCharacter
(
character
)
}
>
{
character
.
name
}
<
/OpenOrDeleteItem
>
)
})}
<
/ul
>
<
/Modal
>
)}
<
/div
>
...
...
src/PF2CharacterBuilder/_modals/RedesignAnnounceModal.js
View file @
7ee10b5e
...
...
@@ -25,12 +25,7 @@ export const RedesignAnnounceModal = () => {
const
headingClasses
=
cn
(
"
text-2xl md:text-3xl mb-4
"
)
return
(
<
Modal
large
show
=
{
show
}
title
=
""
closeFunction
=
{
onClose
}
>
<
Modal
large
show
=
{
show
}
title
=
""
closeFunction
=
{
onClose
}
>
<
div
className
=
"
text-base md:text-lg leading-normal px-8 py-6 md:px-16 md:py-8
"
>
<
h3
className
=
{
headingClasses
}
>
RPGWorkshop
has
a
new
look
!<
/h3
>
<
p
className
=
"
mb-5
"
>
...
...
src/StatblockGenerator/FormSections/AbilityScoresForm.js
View file @
7ee10b5e
...
...
@@ -4,7 +4,7 @@ import { StatblockContext } from "context"
export
const
AbilityScoresForm
=
()
=>
{
const
abilities
=
[
"
str
"
,
"
dex
"
,
"
con
"
,
"
int
"
,
"
wis
"
,
"
cha
"
]
const
{
stats
}
=
useContext
(
StatblockContext
)
const
{
stats
,
updateAbility
}
=
useContext
(
StatblockContext
)
return
(
<
div
className
=
"
grid grid-rows-1 grid-cols-6 gap-4
"
>
{
abilities
.
map
((
ability
)
=>
{
...
...
@@ -15,9 +15,7 @@ export const AbilityScoresForm = () => {
options
=
{
global
.
abilityScores
}
value
=
{
stats
.
abilities
[
ability
]}
fieldName
=
{
ability
}
onChange
=
{(
e
)
=>
this
.
props
.
updateAbility
(
ability
,
e
.
target
.
value
)
}
onChange
=
{(
e
)
=>
updateAbility
(
ability
,
e
.
target
.
value
)}
center
/>
<
/div
>
...
...
src/StatblockGenerator/FormSections/LegendaryActionsForm.js
View file @
7ee10b5e
import
React
,
{
useContext
}
from
"
react
"
import
NavButton
from
"
_globalComponents/NavButton
"
import
{
Input
}
from
"
_globalComponents
"
import
{
Input
,
NavButton
}
from
"
_globalComponents
"
import
{
StatblockContext
}
from
"
context
"
import
{
FeatureBlock
}
from
"
StatblockGenerator/_components/FeatureBlock
"
...
...
src/StatblockGenerator/_components/GeneratorNav.js
View file @
7ee10b5e
import
React
from
"
react
"
import
{
Modal
}
from
"
_globalComponents
"
import
NavButton
from
"
_globalComponents
/NavButton
"
import
{
toast
}
from
"
react-toastify
"
import
{
Modal
,
NavButton
,
OpenOrDeleteItem
}
from
"
_globalComponents
"
import
{
UserContext
}
from
"
context
"
import
{
firebase
}
from
"
services/Firebase
"
...
...
@@ -38,10 +38,19 @@ export class GeneratorNav extends React.Component {
this
.
closeModal
()
this
.
props
.
setStatblock
(
statblock
)
this
.
props
.
history
.
push
(
"
/dnd5e/statblock-generator/
"
+
statblock
.
uid
)
toast
(
"
Opened
"
+
statblock
.
name
)
}
saveStatblock
(
statblock
)
{
firebase
.
saveStatblock
(
statblock
)
async
saveStatblock
(
statblock
)
{
const
newId
=
await
firebase
.
saveStatblock
(
statblock
)
this
.
props
.
history
.
push
(
"
/dnd5e/statblock-generator/
"
+
newId
)
}
async
deleteStatblock
(
statblock
)
{
await
firebase
.
deleteStatblock
(
statblock
.
uid
)
toast
(
"
Deleted
"
+
statblock
.
name
)
this
.
closeModal
()
this
.
getCharacters
()
}
render
()
{
...
...
@@ -60,8 +69,8 @@ export class GeneratorNav extends React.Component {
<
React
.
Fragment
>
<
NavButton
color
=
"
red
"
onClick
=
{()
=>
{
this
.
saveStatblock
(
this
.
props
.
statblock
)
onClick
=
{
async
()
=>
{
await
this
.
saveStatblock
(
this
.
props
.
statblock
)
}}
>
Save
...
...
@@ -82,17 +91,23 @@ export class GeneratorNav extends React.Component {
color
=
"
bg-red-900
"
closeFunction
=
{
this
.
closeModal
}
>
{
this
.
state
.
statblocks
.
map
((
statblock
,
i
)
=>
{
return
(
<
button
key
=
{
i
}
className
=
"
text-left block text-black w-full px-8 py-2 hover:bg-gray-200 transition-colors
"
onClick
=
{()
=>
this
.
selectStatblock
(
statblock
)}
>
{
statblock
.
name
}
<
/button
>
)
})}
<
ul
>
{
this
.
state
.
statblocks
.
map
((
statblock
,
i
)
=>
{
return
(
<
OpenOrDeleteItem
key
=
{
i
}
id
=
{
statblock
.
id
}
className
=
"
text-left block text-black w-full px-8 py-2 hover:bg-gray-200 transition-colors
"
selectFunc
=
{()
=>
this
.
selectStatblock
(
statblock
)}
deleteFunc
=
{
async
()
=>
await
this
.
deleteStatblock
(
statblock
)
}
>
{
statblock
.
name
}
<
/OpenOrDeleteItem
>
)
})}
<
/ul
>
<
/Modal
>
<
/div
>
<
/nav
>
...
...
src/_assets/css/main.css
View file @
7ee10b5e
.c-toast
{
min-height
:
44px
;
padding-left
:
1rem
;
box-shadow
:
1px
1px
8px
2px
rgba
(
0
,
0
,
0
,
0.35
);
}
.c-toast
:first-child
{
margin-top
:
5.5rem
;
}
.c-toast
{
min-height
:
44px
;
padding-left
:
1rem
;
color
:
black
;
box-shadow
:
1px
1px
8px
2px
rgba
(
0
,
0
,
0
,
0.35
)}
.c-toast
:first-child
{
margin-top
:
1rem
}
.Toastify__toast--success
{
background-color
:
#048535
!important
;
color
:
white
!important
}
.Toastify__toast--default
{
color
:
black
!important
}
.Toastify__toast--error
{
color
:
white
!important
}
.c-statbox
{
position
:
relative
;
text-align
:
center
}
.c-statbox__stat
{
display
:
block
;
font-size
:
1.3333rem
;
margin
:
0
;
padding-top
:
0.25rem
;
line-height
:
1
;
font-family
:
"Vollkorn"
,
Times
,
serif
}
.c-statbox__title
{
max-width
:
60px
;
margin
:
0
auto
;
display
:
block
;
font-size
:
0.6rem
;
text-transform
:
uppercase
;
border-top
:
1px
solid
#a2a2a2
}
.c-statbox__select
{
border
:
none
}
.c-statbox--large
{
font-weight
:
bolder
}
.c-statbox--large
.c-statbox__title
{
font-size
:
0.75rem
;
max-width
:
80px
;
line-height
:
2
}
.c-statbox--large
.c-statbox__stat
{
font-size
:
1.75rem
}
.c-statbox--secondary
{
max-width
:
20px
;
border
:
none
}
.c-statbox--secondary
.c-statbox__title
{
border
:
none
;
font-style
:
italic
}
.Toastify__toast--success
{
background
:
#04a542
;
}
.c-statbox
{
position
:
relative
;
text-align
:
center
;
}
.c-statbox__stat
{
display
:
block
;
font-size
:
1.3333rem
;
margin
:
0
;
padding-top
:
0.25rem
;
line-height
:
1
;
font-family
:
"Vollkorn"
,
Times
,
serif
;
}
.c-statbox__title
{
max-width
:
60px
;
margin
:
0
auto
;
display
:
block
;
font-size
:
0.6rem
;
text-transform
:
uppercase
;
border-top
:
1px
solid
#a2a2a2
;
}
.c-statbox__select
{
border
:
none
;
}
.c-statbox--large
{
font-weight
:
bolder
;
}
.c-statbox--large
.c-statbox__title
{
font-size
:
0.75rem
;
max-width
:
80px
;
line-height
:
2
;
}
.c-statbox--large
.c-statbox__stat
{
font-size
:
1.75rem
;
}
.c-statbox--secondary
{
max-width
:
20px
;
border
:
none
;
}
.c-statbox--secondary
.c-statbox__title
{
border
:
none
;
font-style
:
italic
;
}
/*# sourceMappingURL=main.css.map */
\ No newline at end of file
src/_assets/css/main.css.map
View file @
7ee10b5e
...
...
@@ -8,5 +8,5 @@
"../scss/pf/statbox.scss"
],
"names": [],
"mappings": "AEAA,AAAA,QAAQ,AAAC,CAIP,UAAU,CAAE,IAAI,CAChB,YAAY,CAAE,IAAI,CA
E
lB,UAAU,CAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,gBAAmB,CAChD,AARD,AACE,QADM,AACL,YAAY,AAAC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
src/_assets/css/toast.css
View file @
7ee10b5e
.c-toast
{
min-height
:
44px
;
padding-left
:
1rem
;
box-shadow
:
1px
1px
8px
2px
rgba
(
0
,
0
,
0
,
0.35
)}
.c-toast
:first-child
{
margin-top
:
5.5
rem
}
.Toastify__toast--success
{
background
:
#04a542
}
.c-toast
{
min-height
:
44px
;
padding-left
:
1rem
;
color
:
black
;
box-shadow
:
1px
1px
8px
2px
rgba
(
0
,
0
,
0
,
0.35
)}
.c-toast
:first-child
{
margin-top
:
1
rem
}
.Toastify__toast--success
{
background
-color
:
#048535
!important
;
color
:
white
!important
}
.Toastify__toast--default
{
color
:
black
!important
}
.Toastify__toast--error
{
color
:
white
!important
}
/*# sourceMappingURL=toast.css.map */
\ No newline at end of file
src/_assets/css/toast.css.map
View file @
7ee10b5e
...
...
@@ -5,5 +5,5 @@
"../scss/toast.scss"
],
"names": [],
"mappings": "AAAA,AAAA,QAAQ,AAAC,CAIP,UAAU,CAAE,IAAI,CAChB,YAAY,CAAE,IAAI,CA
E
lB,UAAU,CAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,gBAA
e
,CAC
5C
,AARD,AACE,QADM,AACL,YAAY,AAAC,CACZ,UAAU,CAAE,
M
AA
M
,CAC
n
B,AAOH,AAAA,yBAAyB,AAAC,CACxB,
UAAU,CAAE,OAAO,CACp
B"
"mappings": "AAAA,AAAA,QAAQ,AAAC,CAIP,UAAU,CAAE,IAAI,CAChB,YAAY,CAAE,IAAI,CA
C
lB,
KAAK,CAAE,KAAK,CACZ,
UAAU,CAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,gBAA
mB
,CAC
hD
,AARD,AACE,QADM,AACL,YAAY,AAAC,CACZ,UAAU,CAAE,
I
AA
I
,CAC
j
B,AAOH,AAAA,yBAAyB,AAAC,CACxB,
gBAAgB,CAAE,kBAAkB,CACpC,KAAK,CAAE,gBAAgB,CACxB,AAED,AAAA,yBAAyB,AAAC,CACxB,KAAK,CAAE,gBAAgB,CACxB,AAED,AAAA,uBAAuB,AAAC,CACtB,KAAK,CAAE,gBAAgB,CACx
B"
}
\ No newline at end of file
src/_assets/scss/toast.scss
View file @
7ee10b5e
.c-toast
{
&
:first-child
{
margin-top
:
5
.5
rem
;
margin-top
:
1
rem
;
}
min-height
:
44px
;
padding-left
:
1rem
;
color
:
black
;
box-shadow
:
1px
1px
8px
2px
rgba
(
0
,
0
,
0
,
0
.35
);
}
.Toastify__toast--success
{
background
:
#04a542
;
background-color
:
#048535
!
important
;
color
:
white
!
important
;
}
.Toastify__toast--default
{
color
:
black
!
important
;
}
.Toastify__toast--error
{
color
:
white
!
important
;
}
src/_globalComponents/NavButton.js
View file @
7ee10b5e
import
React
from
"
react
"
const
NavButton
=
({
className
,
children
,
onClick
,
color
=
""
,
})
=>
{
const
NavButton
=
({
className
,
children
,
onClick
,
color
=
""
})
=>
{
let
bg
,
bgHover
if
(
color
===
"
red
"
)
{
bg
=
"
bg-red-900
"
...
...
src/_globalComponents/OpenAndDeleteItem.js
0 → 100644
View file @
7ee10b5e
import
React
from
"
react
"
export
const
OpenOrDeleteItem
=
({
id
,
children
,
selectFunc
,
deleteFunc
,
})
=>
{
return
(
<
li
className
=
"
block w-full group transition-colors flex hover:bg-gray-200
"
key
=
{
id
}
>
<
button
className
=
"
text-black text-left flex-1 px-8 py-4 transition-colors
"
onClick
=
{
selectFunc
}
>
{
children
}
<
/button
>
<
button
onClick
=
{
deleteFunc
}
className
=
"
text-gray-400 flex-initial px-8 hover:bg-red-900 hover:text-white transition-colors
"
title
=
"
Delete Character
"
>
<
i
className
=
"
fas fa-minus-square
"
/>
<
span
style
=
{{
display
:
"
block
"
,
visibility
:
"
hidden
"
,
maxWidth
:
"
0px
"
,
maxHeight
:
"
0px
"
,
overflow
:
"
hidden
"
,
}}
>
Delete
<
/span
>
<
/button
>
<
/li
>
)
}
src/_globalComponents/SelectField.js
View file @
7ee10b5e
...
...
@@ -7,7 +7,9 @@ const SelectField = (props) => {
return
(
<
div
className
=
{
`form-group
${
props
.
center
?
"
text-center
"
:
""
}
`
}
>
<
label
className
=
""
htmlFor
=
{
props
.
fieldName
}
>
{
props
.
label
}
<
/label
>
<
label
className
=
""
htmlFor
=
{
props
.
fieldName
}
>
{
props
.
label
}
<
/label
>
<
select
className
=
{
`py-1 px-2 border rounded-md text-sm block w-full border-gray-300
${
props
.
center
?
"
text-center
"
:
""
...
...
src/_globalComponents/index.js
View file @
7ee10b5e
export
{
default
as
NavButton
}
from
"
./NavButton
"
export
{
OpenOrDeleteItem
}
from
"
./OpenAndDeleteItem
"
export
{
default
as
Accordion
}
from
"
./Accordion/Accordion
"
export
{
default
as
Column
}
from
"
./Column
"
export
{
default
as
Input
}
from
"
./Input
"
...
...
src/services/Firebase.js
View file @
7ee10b5e
...
...
@@ -24,6 +24,7 @@ class Firebase {
this
.
signInWithGoogle
=
this
.
signInWithGoogle
.
bind
(
this
)
this
.
getCurrentUser
=
this
.
getCurrentUser
.
bind
(
this
)
this
.
signOut
=
this
.
signOut
.
bind
(
this
)
this
.
deletePF2Character
=
this
.
deletePF2Character
.
bind
(
this
)
}
getRedirect
()
{
...
...
@@ -35,14 +36,6 @@ class Firebase {
return
user
})
.
catch
(
function
()
{
// // Handle Errors here.
// var errorCode = error.code;
// var errorMessage = error.message;
// // The email of the user's account used.
// var email = error.email;
// // The firebase.auth.AuthCredential type that was used.
// var credential = error.credential;
// // ...
return
"
fail
"
})
}
...
...
@@ -88,34 +81,30 @@ class Firebase {
this
.
auth
.
signOut
()
}
saveStatblock
(
statblock
)
{
async
saveStatblock
(
statblock
)
{
console
.
log
(
"
save
"
)
if
(
statblock
.
uid
)
{
this
.
db
await
this
.
db
.
collection
(
"
5e-statblocks
"
)
.
doc
(
statblock
.
uid
)
.
update
(
statblock
)
.
then
(()
=>
{
toast
.
success
(
"
Updated
"
+
statblock
.
name
,
{
autoClose
:
1000
,
})
})
}
else
{
this
.
load5eStatblocksForUser
().
then
((
response
)
=>
{
if
(
response
.
docs
.
length
>=
5
)
{
toast
.
error
(
"
You can only save up to 5 statblocks.
"
)
}
else
{
statblock
.
userId
=
this
.
auth
.
currentUser
.
uid
this
.
db
.
collection
(
"
5e-statblocks
"
)
.
add
(
statblock
)
.
then
(()
=>
{
toast
.
success
(
"
Saved
"
+
statblock
.
name
,
{
autoClose
:
1000
,
})
})
}
toast
.
success
(
"
Updated
"
+
statblock
.
name
,
{
autoClose
:
1000
,
})
}
else
{
let
response
=
await
this
.
load5eStatblocksForUser
()
if
(
response
.
docs
.
length
>=
5
)
{
toast
.
error
(
"
You can only save up to 5 statblocks.
"
)
}
else
{
statblock
.
userId
=
this
.
auth
.
currentUser
.
uid
response
=
await
this
.
db
.
collection
(
"
5e-statblocks
"
).
add
(
statblock
)
toast
.
success
(
"
Saved
"
+
statblock
.
name
,
{
autoClose
:
1000
,
})
return
response
.
id
}
}
}
...
...
@@ -129,35 +118,33 @@ class Firebase {
getStatblock
(
statblockID
)
{
return
this
.
db
.
collection
(
"
5e-statblocks
"
).
doc
(
statblockID
).
get
()
}
async
deleteStatblock
(
statblockID
)
{
await
this
.
db
.
collection
(
"
5e-statblocks
"
).
doc
(
statblockID
).
delete
()
}
// Pathfinder Methods
savePF2Character
(
character
,
showToast
=
true
)
{
async
savePF2Character
(
character
,
showToast
=
true
)
{
if
(
character
.
uid
)
{
this
.
db
await
this
.
db
.
collection
(
"
pf2-characters
"
)
.
doc
(
character
.
uid
)
.
update
(
character
)
.
then
(()
=>
{
if
(
showToast
)
toast
.
success
(
"
Saved
"
+
character
.
name
,
{
autoClose
:
1000
})
})
if
(
showToast
)
toast
.
success
(
"
Updated
"
+
character
.
name
,
{
autoClose
:
1000
})
}
else
{
this
.
getPF2CharactersForUser
(
character
.
uid
).
then
((
response
)
=>
{
if
(
response
.
docs
.
length
>=
5
)
{
toast
.
error
(
"
You can only save up to 5 characters.
"
)
}
else
{
character
.
userId
=
this
.
auth
.
currentUser
.
uid
this
.
db
.
collection
(
"
pf2-characters
"
)
.
add
(
character
)
.
then
(()
=>
{
if
(
showToast
)
toast
.
success
(
"
Saved
"
+
character
.
name
,
{
autoClose
:
1000
,
})
})
}
})
let
response
=
await
this
.
getPF2CharactersForUser
(
character
.
uid
)
if
(
response
.
docs
.
length
>=
5
)
{
toast
.
error
(
"
You can only save up to 5 characters.
"
)
}
else
{
character
.
userId
=
this
.
auth
.
currentUser
.
uid
response
=
await
this
.
db
.
collection
(
"
pf2-characters
"
)
.
add
(
character
)
if
(
showToast
)
toast
.
success
(
"
Saved
"
+
character
.
name
,
{
autoClose
:
1000
,
})
return
response
}
}
}
...
...
@@ -165,8 +152,12 @@ class Firebase {
return
this
.
db
.
collection
(
"
pf2-characters
"
).
doc
(
characterID
).
get
()
}
getPF2CharactersForUser
()
{
return
this
.
db
async
deletePF2Character
(
characterID
)
{
await
this
.
db
.
collection
(
"
pf2-characters
"
).
doc
(
characterID
).
delete
()
}
async
getPF2CharactersForUser
()
{
return
await
this
.
db
.
collection
(
"
pf2-characters
"
)
.
where
(
"
userId
"
,
"
==
"
,
this
.
auth
.
currentUser
.
uid
)
.
get
()
...
...
src/views/CharacterBuilder.js
View file @
7ee10b5e
...
...
@@ -59,25 +59,17 @@ export class CharacterBuilder extends React.Component {
}
}
componentDidUpdate
(
prevProps
)
{
if
(
prevProps
.
match
.
params
.
characterId
!==
this
.
props
.
match
.
params
.
characterId
)
this
.
getCharacter
(
this
.
props
.
match
.
params
.
characterId
)
}
async
getCharacter
(
characterId
)
{
const
response
=
await
firebase
.
getPF2Character
(
characterId
)
let
character
=
response
.
data
()
character
.
uid
=
characterId
getCharacter
(
characterId
)
{
firebase
.
getPF2Character
(
characterId
).
then
((
response
)
=>
{
let
character
=
response
.
data
()
character
.
uid
=
characterId
migrateToLatest
(
character
)
migrateToLatest
(
character
)
this
.
updateStats
(
character
,
()
=>
{
this
.
props
.
history
.
push
(
`/pf2/character-builder/
${
characterId
}
`
)
})
this
.
updateStats
(
character
,
()
=>
{
this
.
props
.
history
.
push
(
`/pf2/character-builder/
${
characterId
}
`
)
})
return
character
}
updateName
(
e
)
{
...
...
@@ -90,6 +82,7 @@ export class CharacterBuilder extends React.Component {
let
blankCharacter
=
getBlankCharacter
()
this
.
setState
({
character
:
blankCharacter
},
()
=>
{
this
.
props
.
history
.
push
(
"
/pf2/character-builder
"
)
toast
(
"
Cleared Sheet
"
)
})
}
...
...
@@ -385,6 +378,7 @@ export class CharacterBuilder extends React.Component {
selectSkill
:
this
.
selectSkill
,
selectFeat
:
this
.
selectFeat
,
deleteFeat
:
this
.
deleteFeat
,
getCharacter
:
this
.
getCharacter
,
Classes
,
Ancestries
,
Backgrounds
,
...
...
@@ -395,9 +389,11 @@ export class CharacterBuilder extends React.Component {
<
main
className
=
""
>
<
PF2CharacterContext
.
Provider
value
=
{
context
}
>
<
SubNav
history
=
{
this
.
props
.
history
}
reset
=
{
this
.
reset
}
character
=
{
character
}
setCharacter
=
{
this
.
setCharacter
}
getCharacter
=
{
this
.
getCharacter
}
/
>
<
div
className
=
"
pt-20 px-2 max-w-5xl mx-auto
"
>
<
CharacterBasics
...
...
src/views/StatblockGenerator.css
View file @
7ee10b5e
...
...
@@ -254,6 +254,6 @@ h4.form-header {
}
.rbt-token
{
background-color
:
#
FEE2E
2
!important
;
background-color
:
#
fee2e
2
!important
;
color
:
#7f1d1d
!important
;
}
src/views/StatblockGenerator.js
View file @
7ee10b5e
...
...
@@ -10,6 +10,7 @@ import {
import
{
StatblockContext
,
UserContext
}
from
"
context
"
import
{
firebase
}
from
"
services/Firebase
"
import
"
./StatblockGenerator.css
"
import
{
toast
}
from
"
react-toastify
"
const
initialState
=
{
exportView
:
false
,
...
...
@@ -152,6 +153,7 @@ class StatblockGenerator extends Component {
...
state
,
})
this
.
props
.
history
.
push
(
"
/dnd5e/statblock-generator
"
)
toast
(
"
Sheet Cleared
"
)
}
updateState
(
e
)
{
...
...
@@ -417,10 +419,7 @@ class StatblockGenerator extends Component {
)}
{
!
this
.
state
.
exportView
&&
(
<
div
className
=
"
flex flex-wrap mt-12
"
>
<
div
className
=
"
flex-1 mt-8
"
style
=
{{
minWidth
:
"
410px
"
}}
>
<
div
className
=
"
flex-1 mt-8
"
style
=
{{
minWidth
:
"
410px
"
}}
>
<
StatBlockForm
stats
=
{
this
.
state
}
updateState
=
{
this
.
updateState
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment