|
@@ -6,8 +6,8 @@ import { useDispatch,useSelector } from 'react-redux';
|
|
|
|
|
|
|
|
|
import s from './DetailGood.module.css';
|
|
|
-import { makeOrderById } from '../../../api-data'
|
|
|
import { asyncGetGoodById } from '../../../redux/goods/operations';
|
|
|
+import { asyncMakeOrderById } from '../../../redux/user/operations';
|
|
|
import { getGood} from '../../../redux/goods/selector';
|
|
|
|
|
|
function DetailCategory() {
|
|
@@ -15,19 +15,20 @@ function DetailCategory() {
|
|
|
const dispatch = useDispatch();
|
|
|
const good = useSelector(getGood);
|
|
|
|
|
|
-
|
|
|
+ const randomPrice = (min, max) => Math.floor(Math.random() * (max - min + 1) + min)
|
|
|
+ const price = randomPrice(1,10)
|
|
|
+ const handlePurchase = async () => dispatch(asyncMakeOrderById(id, price))
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
dispatch(asyncGetGoodById(id))
|
|
|
}, [dispatch, id]);
|
|
|
|
|
|
- const handlePurchase = () => makeOrderById("5dc4b2553f23b553bf3540fc")
|
|
|
-console.log(good[0])
|
|
|
-
|
|
|
return (
|
|
|
good.length !== 0 &&(
|
|
|
<div className={s.detailGood_wrapper}>
|
|
|
<p>name : {good[0].name?good[0].name:'missed'}</p>
|
|
|
<p>createdAt : {good[0].createdAt ? good[0].createdAt : 'missed'}</p>
|
|
|
+ <p>fake price for redux : {price}</p>
|
|
|
<p>price : {good[0].price?good[0].price:'missed'}</p>
|
|
|
<p>description : {good[0].description?good[0].description:'missed'}</p>
|
|
|
<img src={`http://shop-roles.asmer.fs.a-level.com.ua/${good[0].images&&good[0].images[0].url}`}
|