Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ondřej Bazala
PV247
Commits
d2df3ef1
Commit
d2df3ef1
authored
Nov 28, 2021
by
Benjamín Balun
Browse files
basic modal functionality added
parent
81c29d30
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/pages/Store.tsx
View file @
d2df3ef1
...
...
@@ -12,6 +12,12 @@ const Store = () => {
usePageTitle
(
'
Store
'
);
const
{
userData
}
=
useLoggedInUser
();
const
[
selectedItem
,
setSelectedItem
]
=
useState
<
Food
|
Pokeball
>
();
const
isModalVisible
=
useMemo
(
()
=>
selectedItem
!==
undefined
,
[
selectedItem
]
);
if
(
!
userData
)
{
return
<
Loading
/>;
}
...
...
@@ -41,11 +47,21 @@ const Store = () => {
<
p
>
Price:
{
item
.
price
}
<
DollarOutlined
/>
</
p
>
<
Button
type
=
"primary"
>
Buy
</
Button
>
<
Button
type
=
"primary"
onClick
=
{
()
=>
setSelectedItem
(
item
)
}
>
Buy
</
Button
>
</
Card
>
</
Col
>
))
}
</
Row
>
<
Modal
title
=
"Confirm purchase"
visible
=
{
isModalVisible
}
onOk
=
{
()
=>
setSelectedItem
(
undefined
)
}
onCancel
=
{
()
=>
setSelectedItem
(
undefined
)
}
>
Are you sure that you want to buy
{
selectedItem
?.
name
}
?
</
Modal
>
</>
);
};
...
...
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