feat: create component product
This commit is contained in:
parent
65252fd2a7
commit
8a73e728d8
|
@ -45,6 +45,7 @@
|
||||||
"jest-watch-typeahead": "0.6.1",
|
"jest-watch-typeahead": "0.6.1",
|
||||||
"less": "^3.11.1",
|
"less": "^3.11.1",
|
||||||
"less-loader": "6.1.0",
|
"less-loader": "6.1.0",
|
||||||
|
"lodash": "^4.17.21",
|
||||||
"mini-css-extract-plugin": "0.11.3",
|
"mini-css-extract-plugin": "0.11.3",
|
||||||
"mobx": "^6.3.2",
|
"mobx": "^6.3.2",
|
||||||
"mobx-react-lite": "^3.2.0",
|
"mobx-react-lite": "^3.2.0",
|
||||||
|
|
|
@ -1,30 +1,18 @@
|
||||||
import React, {useEffect, useState} from "react";
|
import React, {useState} from "react";
|
||||||
import {Button, message, Modal, Space, Table, Tag} from "antd";
|
import {Button, message, Modal, Space, Table, Tag} from "antd";
|
||||||
import {useStore} from "../../utils/useStore";
|
|
||||||
import {observer} from "mobx-react-lite";
|
import {observer} from "mobx-react-lite";
|
||||||
import {ExclamationCircleOutlined} from "@ant-design/icons";
|
import {ExclamationCircleOutlined} from "@ant-design/icons";
|
||||||
import {useHistory} from "react-router-dom";
|
import {useHistory} from "react-router-dom";
|
||||||
|
import {capitalize} from "lodash";
|
||||||
|
import {store} from "../utils/useStore";
|
||||||
|
import {PulsaModal} from "../pages/Product/PulsaModal";
|
||||||
|
|
||||||
export const Pulsa = observer(() => {
|
export const ProductComponent = observer((props) => {
|
||||||
const store = useStore();
|
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const [visibleModal, setVisibleModal] = useState(false);
|
|
||||||
const [initialData, setInitialData] = useState({});
|
const [initialData, setInitialData] = useState({});
|
||||||
const [confirmLoading, setConfirmLoading] = useState(false);
|
const [confirmLoading, setConfirmLoading] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
useEffect(() => {
|
|
||||||
const init = async () => {
|
|
||||||
try {
|
|
||||||
setIsLoading(true);
|
|
||||||
await store.product.getData();
|
|
||||||
setIsLoading(false);
|
|
||||||
} catch (e) {
|
|
||||||
setIsLoading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
init();
|
|
||||||
}, []);
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title: "Kode",
|
title: "Kode",
|
||||||
|
@ -44,8 +32,8 @@ export const Pulsa = observer(() => {
|
||||||
,
|
,
|
||||||
{
|
{
|
||||||
title: "Harga Jual",
|
title: "Harga Jual",
|
||||||
dataIndex: "mark_up_price",
|
dataIndex: "base_price",
|
||||||
key: "mark_up_price",
|
key: "base_price",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Gangguan",
|
title: "Gangguan",
|
||||||
|
@ -56,7 +44,7 @@ export const Pulsa = observer(() => {
|
||||||
color={record?.status === "AKTIF" ? "processing" : "#E3E8EE"}
|
color={record?.status === "AKTIF" ? "processing" : "#E3E8EE"}
|
||||||
style={{color: "#4F566B"}}
|
style={{color: "#4F566B"}}
|
||||||
>
|
>
|
||||||
{record?.status}
|
{capitalize(record?.status)}
|
||||||
</Tag>
|
</Tag>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -78,7 +66,12 @@ export const Pulsa = observer(() => {
|
||||||
key: "action",
|
key: "action",
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<Space size="middle">
|
<Space size="middle">
|
||||||
<Button>Edit</Button>
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setInitialData(record);
|
||||||
|
store.product.visibleModal = true;
|
||||||
|
}}
|
||||||
|
>Edit</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
handleDelete(record.id);
|
handleDelete(record.id);
|
||||||
|
@ -90,6 +83,7 @@ export const Pulsa = observer(() => {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const deleteData = async (id) => {
|
const deleteData = async (id) => {
|
||||||
try {
|
try {
|
||||||
console.log(id);
|
console.log(id);
|
||||||
|
@ -101,6 +95,7 @@ export const Pulsa = observer(() => {
|
||||||
message.error("Gagal menghapus");
|
message.error("Gagal menghapus");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = (id) => {
|
const handleDelete = (id) => {
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: "Are you sure delete this record?",
|
title: "Are you sure delete this record?",
|
||||||
|
@ -116,14 +111,52 @@ export const Pulsa = observer(() => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onSubmit = async (data) => {
|
||||||
|
if (initialData.id) {
|
||||||
|
setInitialData({})
|
||||||
|
setConfirmLoading(true);
|
||||||
|
try {
|
||||||
|
await store.product.update(initialData.id, data)
|
||||||
|
message.success("Success Update Data Member")
|
||||||
|
} catch (e) {
|
||||||
|
message.error("Failed Update Data Member")
|
||||||
|
}
|
||||||
|
setConfirmLoading(false);
|
||||||
|
store.product.visibleModal = false;
|
||||||
|
} else {
|
||||||
|
setInitialData({})
|
||||||
|
setConfirmLoading(true);
|
||||||
|
try {
|
||||||
|
await store.product.create(data)
|
||||||
|
message.success("Success Add New Member")
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e, "apa errornya")
|
||||||
|
message.error("Failed Add Member")
|
||||||
|
}
|
||||||
|
setConfirmLoading(false);
|
||||||
|
store.product.visibleModal = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Table
|
<Table
|
||||||
style={{textAlign: "center"}}
|
style={{textAlign: "center"}}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={store.product.data}
|
dataSource={props.data}
|
||||||
bordered
|
bordered
|
||||||
/>
|
/>
|
||||||
|
<PulsaModal visible={store.product.visibleModal}
|
||||||
|
confirmLoading={confirmLoading}
|
||||||
|
initialData={initialData}
|
||||||
|
onCreate={async (data) => {
|
||||||
|
await onSubmit(data)
|
||||||
|
}}
|
||||||
|
onCancel={() => {
|
||||||
|
setInitialData({})
|
||||||
|
store.product.visibleModal = false;
|
||||||
|
}}/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
|
@ -1,24 +1,38 @@
|
||||||
import React, {useState} from "react";
|
import React, {useEffect, useState} from "react";
|
||||||
import {Button, Card, Col, Input, message, Row, Tabs} from "antd";
|
import {Button, Card, Col, Input, Row, Tabs} from "antd";
|
||||||
import {FilterOutlined, PlusSquareOutlined,} from "@ant-design/icons";
|
import {FilterOutlined, PlusSquareOutlined,} from "@ant-design/icons";
|
||||||
import {BreadcumbComponent} from "../../component/BreadcumbComponent";
|
import {BreadcumbComponent} from "../../component/BreadcumbComponent";
|
||||||
import {Pulsa} from "./Pulsa";
|
|
||||||
import {PulsaModal} from "./PulsaModal";
|
|
||||||
import {useStore} from "../../utils/useStore";
|
import {useStore} from "../../utils/useStore";
|
||||||
import {observer} from "mobx-react-lite";
|
import {observer} from "mobx-react-lite";
|
||||||
|
import {ProductComponent} from "../../component/ProductComponent";
|
||||||
|
|
||||||
const {TabPane} = Tabs;
|
const {TabPane} = Tabs;
|
||||||
const {Search} = Input;
|
const {Search} = Input;
|
||||||
|
|
||||||
export const Product = observer(() => {
|
export const Product = observer(() => {
|
||||||
const [visibleModal, setVisibleModal] = useState(false)
|
|
||||||
const [initialData, setInitialData] = useState({})
|
|
||||||
const [confirmLoading, setConfirmLoading] = useState(false);
|
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const callback = (key) => {
|
|
||||||
|
useEffect(() => {
|
||||||
|
const init = async () => {
|
||||||
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
await store.product.getDataCategories();
|
||||||
|
await store.product.getData();
|
||||||
|
setIsLoading(false);
|
||||||
|
} catch (e) {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
init();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleChangeTabPane = async (key) => {
|
||||||
|
store.product.filterCategory = key;
|
||||||
console.log(key);
|
console.log(key);
|
||||||
};
|
};
|
||||||
|
|
||||||
const routeData = [
|
const routeData = [
|
||||||
{
|
{
|
||||||
route: "/app/home",
|
route: "/app/home",
|
||||||
|
@ -29,32 +43,7 @@ export const Product = observer(() => {
|
||||||
name: <span style={{fontWeight: 'bold'}}>Product</span>,
|
name: <span style={{fontWeight: 'bold'}}>Product</span>,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const onSubmit = async (data) => {
|
|
||||||
if (initialData.id) {
|
|
||||||
setInitialData({})
|
|
||||||
setConfirmLoading(true);
|
|
||||||
try {
|
|
||||||
await store.product.update(initialData.id, data)
|
|
||||||
message.success("Success Update Data Member")
|
|
||||||
} catch (e) {
|
|
||||||
message.error("Failed Update Data Member")
|
|
||||||
}
|
|
||||||
setConfirmLoading(false);
|
|
||||||
setVisibleModal(false);
|
|
||||||
} else {
|
|
||||||
setInitialData({})
|
|
||||||
setConfirmLoading(true);
|
|
||||||
try {
|
|
||||||
await store.product.create(data)
|
|
||||||
message.success("Success Add New Member")
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e, "apa errornya")
|
|
||||||
message.error("Failed Add Member")
|
|
||||||
}
|
|
||||||
setConfirmLoading(false);
|
|
||||||
setVisibleModal(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<div className={["ppob-container"].join(" ")}>
|
<div className={["ppob-container"].join(" ")}>
|
||||||
<BreadcumbComponent data={routeData}/>
|
<BreadcumbComponent data={routeData}/>
|
||||||
|
@ -71,44 +60,28 @@ export const Product = observer(() => {
|
||||||
placeholder="input search text"
|
placeholder="input search text"
|
||||||
style={{width: 200, marginRight: 10}}
|
style={{width: 200, marginRight: 10}}
|
||||||
/>
|
/>
|
||||||
<Button onClick={() => setVisibleModal(true)}>
|
<Button onClick={() => store.product.visibleModal = true}>
|
||||||
<PlusSquareOutlined/> New
|
<PlusSquareOutlined/> New
|
||||||
</Button>
|
</Button>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<Tabs
|
<Tabs
|
||||||
defaultActiveKey="1"
|
onChange={handleChangeTabPane}
|
||||||
onChange={callback}
|
|
||||||
size="default"
|
size="default"
|
||||||
tabBarGutter="50"
|
tabBarGutter="50"
|
||||||
>
|
>
|
||||||
<TabPane tab="Pulsa" key="1">
|
{store.product.dataCategories.map((item) => (
|
||||||
<Pulsa/>
|
<TabPane
|
||||||
</TabPane>
|
tab={item.name}
|
||||||
<TabPane tab="Game Voucher" key="2">
|
key={item.id}
|
||||||
Game Voucher
|
>
|
||||||
</TabPane>
|
<ProductComponent
|
||||||
<TabPane tab="Product" key="3">
|
data={store.product.data}
|
||||||
Product
|
/>
|
||||||
</TabPane>
|
</TabPane>
|
||||||
<TabPane tab="Prduct" key="4">
|
))}
|
||||||
Prduct
|
|
||||||
</TabPane>
|
|
||||||
<TabPane tab="Prdct" key="5">
|
|
||||||
Prdct
|
|
||||||
</TabPane>
|
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</Card>
|
</Card>
|
||||||
<PulsaModal visible={visibleModal}
|
|
||||||
confirmLoading={confirmLoading}
|
|
||||||
initialData={initialData}
|
|
||||||
onCreate={async (data) => {
|
|
||||||
onSubmit(data)
|
|
||||||
}}
|
|
||||||
onCancel={() => {
|
|
||||||
setInitialData({})
|
|
||||||
setVisibleModal(false);
|
|
||||||
}}/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,30 +1,50 @@
|
||||||
import React, {useEffect, useState} from "react";
|
import React, {useEffect, useState} from "react";
|
||||||
import {Form, Input, Modal, Select} from "antd";
|
import {Form, Input, Modal, Select} from "antd";
|
||||||
import {useStore} from "../../utils/useStore";
|
import {useStore} from "../../utils/useStore";
|
||||||
|
import {observer} from "mobx-react-lite";
|
||||||
|
|
||||||
export const PulsaModal = ({visible, onCreate, onCancel}) => {
|
export const PulsaModal = observer(({visible, onCreate, onCancel, initialData}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const {Option} = Select;
|
const {Option} = Select;
|
||||||
const dataStatus = ["Active", "Inactive"];
|
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const [visibleModal, setVisibleModal] = useState(false);
|
const [visibleModal, setVisibleModal] = useState(false);
|
||||||
const [initialData, setInitialData] = useState({});
|
|
||||||
const [confirmLoading, setConfirmLoading] = useState(false);
|
const [confirmLoading, setConfirmLoading] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const init = async () => {
|
|
||||||
try {
|
|
||||||
setIsLoading(true);
|
|
||||||
await store.categories.getData();
|
|
||||||
setIsLoading(false);
|
|
||||||
} catch (e) {
|
|
||||||
setIsLoading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
const init = async () => {
|
||||||
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
await store.product.getDataSubCategories();
|
||||||
|
setIsLoading(false);
|
||||||
|
} catch (e) {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
|
const subCategoriesOption = [
|
||||||
|
<Option key={123} value={123}>
|
||||||
|
{123}
|
||||||
|
</Option>,
|
||||||
|
<Option key={431} value={123}>
|
||||||
|
{123}
|
||||||
|
</Option>
|
||||||
|
];
|
||||||
|
|
||||||
|
const subCategoriesOption2 = store.product.dataSubCategories.slice().map(subCategory => {
|
||||||
|
return (
|
||||||
|
<Option key={subCategory.id} value={subCategory.id}>
|
||||||
|
{subCategory.name}
|
||||||
|
</Option>
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(store.product.dataSubCategories, 'subCategoriesOption2');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible={visible}
|
visible={visible}
|
||||||
|
@ -68,7 +88,7 @@ export const PulsaModal = ({visible, onCreate, onCancel}) => {
|
||||||
<Input/>
|
<Input/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="markUpPrice"
|
name="base_price"
|
||||||
label="Mark Up Price"
|
label="Mark Up Price"
|
||||||
rules={[{required: true, message: "Please input mark up price!"}]}
|
rules={[{required: true, message: "Please input mark up price!"}]}
|
||||||
>
|
>
|
||||||
|
@ -92,17 +112,24 @@ export const PulsaModal = ({visible, onCreate, onCancel}) => {
|
||||||
</Select>
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="subCategoriesId"
|
name="sub_category"
|
||||||
label="Sub Categories"
|
label="Sub categories"
|
||||||
rules={[{required: true, message: "Please select Sub Category!"}]}
|
rules={[{required: true, message: "Please select sub categories!"}]}
|
||||||
>
|
>
|
||||||
<Select placeholder="Select Sub Category" allowClear>
|
<Select placeholder="Select Sub Category" allowClear>
|
||||||
{store.categories.data.map((it) => {
|
{subCategoriesOption2}
|
||||||
return <Option value={it.id}>{it.name}</Option>;
|
|
||||||
})}
|
|
||||||
</Select>
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
{/*<Form.Item*/}
|
||||||
|
{/* name="subCategories"*/}
|
||||||
|
{/* label="Sub Categories"*/}
|
||||||
|
{/* rules={[{required: true, message: "Please select Sub Category!"}]}*/}
|
||||||
|
{/*>*/}
|
||||||
|
{/* <Select placeholder="Select Sub Category" allowClear>*/}
|
||||||
|
{/* {subCategoriesOption2}*/}
|
||||||
|
{/* </Select>*/}
|
||||||
|
{/*</Form.Item>*/}
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
import {action, makeAutoObservable} from "mobx";
|
|
||||||
import {http} from "../utils/http";
|
|
||||||
|
|
||||||
export class Categories {
|
|
||||||
page = 0;
|
|
||||||
pageSize = 10
|
|
||||||
data = [];
|
|
||||||
total_data = 0
|
|
||||||
|
|
||||||
constructor(ctx) {
|
|
||||||
this.ctx = ctx;
|
|
||||||
makeAutoObservable(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@action
|
|
||||||
async getData() {
|
|
||||||
const response = await http.get(`/product/sub-categories?page=${this.page}&pageSize=${this.pageSize}`);
|
|
||||||
console.log(response, 'Data cate')
|
|
||||||
console.log(JSON.stringify(response.body.data), 'Data')
|
|
||||||
|
|
||||||
this.data = response.body.data ?? []
|
|
||||||
this.total_data = response.body.total_data ?? 0
|
|
||||||
}
|
|
||||||
|
|
||||||
@action
|
|
||||||
async create(data) {
|
|
||||||
return await http.post('/user').send(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
@action
|
|
||||||
async update(id, data) {
|
|
||||||
return await http.put('/user/' + id).send(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
async delete(id) {
|
|
||||||
return await http.del('/product/' + id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ import {Authentication} from "./authentication";
|
||||||
import {User} from "./user";
|
import {User} from "./user";
|
||||||
import {Membership} from "./membership";
|
import {Membership} from "./membership";
|
||||||
import {Product} from "./product";
|
import {Product} from "./product";
|
||||||
import {Categories} from "./categories";
|
|
||||||
import {TokenUtil} from "../utils/token";
|
import {TokenUtil} from "../utils/token";
|
||||||
|
|
||||||
export class Store {
|
export class Store {
|
||||||
|
@ -12,7 +11,6 @@ export class Store {
|
||||||
user = new User(this);
|
user = new User(this);
|
||||||
membership = new Membership(this);
|
membership = new Membership(this);
|
||||||
product = new Product(this);
|
product = new Product(this);
|
||||||
categories = new Categories(this);
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
TokenUtil.loadToken();
|
TokenUtil.loadToken();
|
||||||
|
|
|
@ -5,33 +5,66 @@ export class Product {
|
||||||
page = 0;
|
page = 0;
|
||||||
pageSize = 10
|
pageSize = 10
|
||||||
data = [];
|
data = [];
|
||||||
total_data = 0
|
total_data = 0;
|
||||||
|
filterCategory = null;
|
||||||
|
|
||||||
|
pageCategories = 0;
|
||||||
|
pageSizeCategories = 10
|
||||||
|
dataCategories = [];
|
||||||
|
total_dataCategories = 0;
|
||||||
|
|
||||||
|
pageSubCategories = 0;
|
||||||
|
pageSizeSubCategories = 10
|
||||||
|
dataSubCategories = [];
|
||||||
|
total_dataSubCategories = 0;
|
||||||
|
|
||||||
|
visibleModal = false;
|
||||||
|
|
||||||
constructor(ctx) {
|
constructor(ctx) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
makeAutoObservable(this);
|
makeAutoObservable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
|
||||||
async getData() {
|
async getData() {
|
||||||
const response = await http.get(`/product?page=${this.page}&pageSize=${this.pageSize}`);
|
const response = await http.get(`/product/by-categories?categories=${this.filterCategory}&page=${this.page}&pageSize=${this.pageSize}`);
|
||||||
|
|
||||||
this.data = response.body.data ?? []
|
this.data = response.body.data ?? []
|
||||||
this.total_data = response.body.total_data ?? 0
|
this.total_data = response.body.total_data ?? 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
async getDataSubCategories() {
|
||||||
async create(data) {
|
const response = await http.get(`/product/sub-categories?pageSize=${this.pageSizeSubCategories}`);
|
||||||
return await http.post('/product').send(data)
|
this.dataSubCategories = response.body.data ?? []
|
||||||
|
this.total_dataSubCategories = response.body.count ?? 0
|
||||||
|
}
|
||||||
|
|
||||||
|
async getDataCategories() {
|
||||||
|
const response = await http.get(`/product/categories?page=${this.pageCategories}&pageSize=${this.pageSizeCategories}`);
|
||||||
|
|
||||||
|
this.dataCategories = response.body.data ?? []
|
||||||
|
this.total_dataCategories = response.body.total_data ?? 0
|
||||||
|
if (this.dataCategories.length > 0) {
|
||||||
|
this.filterCategory = this.dataCategories[0].id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
async create(data) {
|
||||||
|
const response = await http.post('/product', data);
|
||||||
|
await this.getData();
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
async update(id, data) {
|
async update(id, data) {
|
||||||
return await http.put('/user/' + id).send(data);
|
const response = await http.put(`/product/${id}`, data);
|
||||||
|
await this.getData();
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(id) {
|
async delete(id) {
|
||||||
return await http.del('/product/' + id);
|
const response = await http.del(`/product/${id}`);
|
||||||
|
await this.getData();
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7784,7 +7784,7 @@ lodash.uniq@^4.5.0:
|
||||||
|
|
||||||
lodash@^4.17.21:
|
lodash@^4.17.21:
|
||||||
version "4.17.21"
|
version "4.17.21"
|
||||||
resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz"
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
|
||||||
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
||||||
|
|
||||||
loglevel@^1.6.8:
|
loglevel@^1.6.8:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user