stitching pulsa component
This commit is contained in:
@@ -1,25 +1,65 @@
|
||||
import React from "react";
|
||||
import {Button, Card, Col, Dropdown, Menu, message, Modal, Row, Space,} from "antd";
|
||||
import {DownOutlined, TabletOutlined, UserOutlined} from "@ant-design/icons";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useStore } from "../../utils/useStore";
|
||||
import { Button, Card, Col, Dropdown, Menu, message, Modal, Row, Space, } from "antd";
|
||||
import { DownOutlined, TabletOutlined, UserOutlined } from "@ant-design/icons";
|
||||
|
||||
export const Pulsa = () => {
|
||||
|
||||
function handleMenuClick(e) {
|
||||
message.info("Click on menu item.");
|
||||
console.log("click", e);
|
||||
const store = useStore();
|
||||
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const [productData, setProductData] = useState([])
|
||||
const [productFilter, setProductFilter] = useState("")
|
||||
// useEffect(()=>{
|
||||
// if(!productFilter){
|
||||
// setProductData(store.transaction.data)
|
||||
// }
|
||||
// },[productFilter])
|
||||
|
||||
useEffect(() => {
|
||||
const init = async () => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
await store.transaction.getDataSubCategories();
|
||||
await store.transaction.getData();
|
||||
setIsLoading(false);
|
||||
} catch (e) {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
init();
|
||||
}, []);
|
||||
|
||||
// data
|
||||
useEffect(() => {
|
||||
console.log('⚡ transaction data store', store.transaction.data)
|
||||
setProductData(store.transaction.data)
|
||||
}, [store.transaction.data])
|
||||
|
||||
// Subcategory
|
||||
useEffect(() => {
|
||||
console.log('⚡ transaction subcategory store', store.transaction.dataSubCategories)
|
||||
}, [store.transaction.dataSubCategories])
|
||||
|
||||
|
||||
function handleMenuClick(item) {
|
||||
message.info("⚡ Click on menu item.");
|
||||
console.log("⚡ click", item);
|
||||
setProductFilter(item.name)
|
||||
}
|
||||
|
||||
const menu = (
|
||||
<Menu onClick={handleMenuClick}>
|
||||
<Menu.Item key="1" icon={<UserOutlined/>}>
|
||||
1st menu item
|
||||
</Menu.Item>
|
||||
<Menu.Item key="2" icon={<UserOutlined/>}>
|
||||
2nd menu item
|
||||
</Menu.Item>
|
||||
<Menu.Item key="3" icon={<UserOutlined/>}>
|
||||
3rd menu item
|
||||
</Menu.Item>
|
||||
<Menu style={{
|
||||
backgroundColor: 'white'
|
||||
}}>
|
||||
{store.transaction.dataSubCategories.map((item, index) => (
|
||||
<Menu.Item key="1" icon={<UserOutlined />} onClick={() => handleMenuClick(item)} >
|
||||
{item.name}
|
||||
</Menu.Item>
|
||||
))}
|
||||
|
||||
</Menu>
|
||||
);
|
||||
|
||||
@@ -29,55 +69,12 @@ export const Pulsa = () => {
|
||||
});
|
||||
}
|
||||
|
||||
const dataCard = [
|
||||
{
|
||||
title: "DATA AXIS BRONET 2GB-60HR",
|
||||
price: "Harga : Rp.6.000",
|
||||
},
|
||||
{
|
||||
title: "DATA AXIS BRONET 2GB-60HR",
|
||||
price: "Harga : Rp.6.000",
|
||||
},
|
||||
{
|
||||
title: "DATA AXIS BRONET 2GB-60HR",
|
||||
price: "Harga : Rp.6.000",
|
||||
},
|
||||
{
|
||||
title: "DATA AXIS BRONET 2GB-60HR",
|
||||
price: "Harga : Rp.6.000",
|
||||
},
|
||||
{
|
||||
title: "DATA AXIS BRONET 2GB-60HR",
|
||||
price: "Harga : Rp.6.000",
|
||||
},
|
||||
{
|
||||
title: "DATA AXIS BRONET 2GB-60HR",
|
||||
price: "Harga : Rp.6.000",
|
||||
},
|
||||
{
|
||||
title: "DATA AXIS BRONET 2GB-60HR",
|
||||
price: "Harga : Rp.6.000",
|
||||
},
|
||||
{
|
||||
title: "DATA AXIS BRONET 2GB-60HR",
|
||||
price: "Harga : Rp.6.000",
|
||||
},
|
||||
{
|
||||
title: "DATA AXIS BRONET 2GB-60HR",
|
||||
price: "Harga : Rp.6.000",
|
||||
},
|
||||
{
|
||||
title: "DATA AXIS BRONET 2GB-60HR",
|
||||
price: "Harga : Rp.6.000",
|
||||
},
|
||||
]
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Row>
|
||||
<span style={{fontWeight: "bold", marginBottom: "10px"}}>
|
||||
Sub-Category
|
||||
</span>
|
||||
<span style={{ fontWeight: "bold", marginBottom: "10px" }}>
|
||||
Sub-Category
|
||||
</span>
|
||||
</Row>
|
||||
<Row>
|
||||
<Space wrap>
|
||||
@@ -88,34 +85,34 @@ export const Pulsa = () => {
|
||||
color: "grey",
|
||||
}}
|
||||
>
|
||||
<TabletOutlined/>
|
||||
<TabletOutlined />
|
||||
Select sub-Category
|
||||
<DownOutlined/>
|
||||
<DownOutlined />
|
||||
</Button>
|
||||
</Dropdown>
|
||||
</Space>
|
||||
</Row>
|
||||
<Row>
|
||||
<span style={{fontWeight: "bold", marginBottom: "10px"}}>
|
||||
Produk & Nominal
|
||||
</span>
|
||||
<span style={{ fontWeight: "bold", marginBottom: "10px" }}>
|
||||
Produk & Nominal
|
||||
</span>
|
||||
</Row>
|
||||
<Row>
|
||||
{dataCard.map((item, index) => (
|
||||
{productData.map((item, index) => (
|
||||
<Col key={index} xs={24} md={16} lg={8}>
|
||||
<Card onClick={success}>
|
||||
<span style={{color: "black"}}>{item.title}</span>
|
||||
<br/>
|
||||
<span style={{color: "grey", fontSize: 10}}>{item.price}</span>
|
||||
<span style={{ color: "black" }}>{item.name}</span>
|
||||
<br />
|
||||
<span style={{ color: "grey", fontSize: 10 }}>{item.price}</span>
|
||||
</Card>
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
<Col style={{textAlign: "right"}}>
|
||||
<Button style={{backgroundColor: "#2D9CDB", color: "white"}}>
|
||||
<Col style={{ textAlign: "right" }}>
|
||||
<Button style={{ backgroundColor: "#2D9CDB", color: "white" }}>
|
||||
Beli Sekarang
|
||||
</Button>
|
||||
</Col>
|
||||
</div>
|
||||
);
|
||||
);
|
||||
};
|
||||
|
Reference in New Issue
Block a user