Commit f7f8b780 authored by Benjamín Balun's avatar Benjamín Balun
Browse files

removed unused code

parent 55654d01
import { Button, Card, Col, Modal, Row, Typography } from 'antd';
import { DollarOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import { useMemo, useState } from 'react';
import usePageTitle from '../hooks/usePageTitle';
import { Food, food } from '../data/food';
......@@ -13,12 +12,6 @@ const Store = () => {
usePageTitle('Store');
const { userData } = useLoggedInUser();
const [selectedItem, setSelectedItem] = useState<Food | Pokeball>();
const isModalVisible = useMemo(
() => selectedItem !== undefined,
[selectedItem]
);
const buyItem = async (item: Food | Pokeball) => {
const modal = Modal.confirm({
title: 'Confirm purchase',
......@@ -54,13 +47,13 @@ const Store = () => {
.then(() =>
Modal.success({
title: 'Success',
content: `You are now a proud owner of the ${item.name}`
content: `Congratulation! You are now a proud owner of the ${item.name}.`
})
)
.catch(() =>
Modal.error({
title: 'Oops ... an error occured',
content: 'An error occured during a purchase. Try again later'
content: 'An error occured during a purchase. Try again later...'
})
);
}
......@@ -73,7 +66,7 @@ const Store = () => {
return (
<>
<div style={{ textAlign: 'right' }}>
<div style={{ textAlign: 'right', margin: '1rem' }}>
<Typography>
Current funds: {userData?.actualScore} <DollarOutlined />
</Typography>
......@@ -96,7 +89,6 @@ const Store = () => {
<p>
Price: {item.price} <DollarOutlined />
</p>
{/* <Button type="primary" onClick={() => setSelectedItem(item)}> */}
<Button type="primary" onClick={() => buyItem(item)}>
Buy
</Button>
......@@ -104,15 +96,6 @@ const Store = () => {
</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>
</>
);
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment