Merge branch 'develop' of https://gitlab.com/empatnusabangsa/ppob/ppob-frontend into develop
This commit is contained in:
commit
6f743301e4
|
@ -40,6 +40,21 @@ export const PartnerComponent = observer((props) => {
|
||||||
init();
|
init();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const changeStatus = async (id, isActive) => {
|
||||||
|
const status = isActive ? "inactive" : "active";
|
||||||
|
const status2 = isActive ? "Inactivating" : "Activating";
|
||||||
|
try {
|
||||||
|
const response = await store.partner.changeStatus(id, status);
|
||||||
|
|
||||||
|
response?.body?.statusCode === 201
|
||||||
|
? message.success(`Success ${status2} Partner`)
|
||||||
|
: message.error(`Failed ${status2} Partner`);
|
||||||
|
} catch (err) {
|
||||||
|
console.log("error", err);
|
||||||
|
message.error(`Failed ${status2} Partner`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleEditButton = (data) => {
|
const handleEditButton = (data) => {
|
||||||
console.log(data, "isi data");
|
console.log(data, "isi data");
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
|
@ -72,9 +87,13 @@ export const PartnerComponent = observer((props) => {
|
||||||
dataIndex: "status",
|
dataIndex: "status",
|
||||||
key: "status",
|
key: "status",
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<Button size="small" type={record?.status === true ? "primary" : "danger"}>
|
<Tag
|
||||||
|
color={record?.status === true ? "processing" : "#E3E8EE"}
|
||||||
|
style={{ color: "#4F566B", cursor: 'pointer' }}
|
||||||
|
onClick={() => changeStatus(record?.id, record?.status)}
|
||||||
|
>
|
||||||
{record?.status === true ? " ACTIVE" : "INACTIVE"}
|
{record?.status === true ? " ACTIVE" : "INACTIVE"}
|
||||||
</Button>
|
</Tag>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,9 +52,19 @@ export const SupplierComponent = observer((props) => {
|
||||||
setIdData(data.id);
|
setIdData(data.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeStatus = (id, isActive) => {
|
const changeStatus = async (id, isActive) => {
|
||||||
const status = isActive ? "inactive" : "active";
|
const status = isActive ? "inactive" : "active";
|
||||||
store.supplier.changeStatus(id, status);
|
const status2 = isActive ? "Inactivating" : "Activating";
|
||||||
|
try {
|
||||||
|
const response = await store.supplier.changeStatus(id, status);
|
||||||
|
|
||||||
|
response?.body?.statusCode === 201
|
||||||
|
? message.success(`Success ${status2} Supplier`)
|
||||||
|
: message.error(`Failed ${status2} Supplier`);
|
||||||
|
} catch (err) {
|
||||||
|
console.log("error", err);
|
||||||
|
message.error(`Failed ${status2} Supplier`);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
|
|
|
@ -1,13 +1,30 @@
|
||||||
import React, {useEffect, useState} from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import {Button, Card, Col, Divider, Input, List, message, Modal, Row, Space, Table, Tag,} from "antd";
|
import {
|
||||||
import {useStore} from "../../utils/useStore";
|
Button,
|
||||||
import {observer} from "mobx-react-lite";
|
Card,
|
||||||
import {ExclamationCircleOutlined, FilterOutlined, PlusSquareOutlined,} from "@ant-design/icons";
|
Col,
|
||||||
import {MembershipModal} from "./MembershipModal";
|
Divider,
|
||||||
import {BreadcumbComponent} from "../../component/BreadcumbComponent";
|
Input,
|
||||||
import {LINKS} from "../../routes/app";
|
List,
|
||||||
|
message,
|
||||||
|
Modal,
|
||||||
|
Row,
|
||||||
|
Space,
|
||||||
|
Table,
|
||||||
|
Tag,
|
||||||
|
} from "antd";
|
||||||
|
import { useStore } from "../../utils/useStore";
|
||||||
|
import { observer } from "mobx-react-lite";
|
||||||
|
import {
|
||||||
|
ExclamationCircleOutlined,
|
||||||
|
FilterOutlined,
|
||||||
|
PlusSquareOutlined,
|
||||||
|
} from "@ant-design/icons";
|
||||||
|
import { MembershipModal } from "./MembershipModal";
|
||||||
|
import { BreadcumbComponent } from "../../component/BreadcumbComponent";
|
||||||
|
import { LINKS } from "../../routes/app";
|
||||||
|
|
||||||
const {Search} = Input;
|
const { Search } = Input;
|
||||||
|
|
||||||
export const Membership = observer(() => {
|
export const Membership = observer(() => {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
@ -31,6 +48,21 @@ export const Membership = observer(() => {
|
||||||
init();
|
init();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const changeStatus = async (id, isActive) => {
|
||||||
|
const status = isActive ? "inactive" : "active";
|
||||||
|
const status2 = isActive ? "Inactivating" : "Activating";
|
||||||
|
try {
|
||||||
|
const response = await store.membership.changeStatus(id, status);
|
||||||
|
|
||||||
|
response?.body?.statusCode === 201
|
||||||
|
? message.success(`Success ${status2} Membership`)
|
||||||
|
: message.error(`Failed ${status2} Membership`);
|
||||||
|
} catch (err) {
|
||||||
|
console.log("error", err);
|
||||||
|
message.error(`Failed ${status2} Membership`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title: "Name",
|
title: "Name",
|
||||||
|
@ -48,10 +80,11 @@ export const Membership = observer(() => {
|
||||||
key: "status",
|
key: "status",
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<Tag
|
<Tag
|
||||||
color={record?.isActive === true ? "blue" : "#E3E8EE"}
|
color={record?.status === true ? "processing" : "#E3E8EE"}
|
||||||
style={{ color: "#4F566B" }}
|
style={{ color: "#4F566B", cursor: "pointer" }}
|
||||||
|
onClick={() => changeStatus(record?.id, record?.status)}
|
||||||
>
|
>
|
||||||
{record?.isActive === true ? " ACTIVE" : "INACTIVE"}
|
{record?.status === true ? " ACTIVE" : "INACTIVE"}
|
||||||
</Tag>
|
</Tag>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -198,7 +231,7 @@ export const Membership = observer(() => {
|
||||||
total: store.membership.total_data,
|
total: store.membership.total_data,
|
||||||
current: store.membership.page + 1,
|
current: store.membership.page + 1,
|
||||||
showSizeChanger: true,
|
showSizeChanger: true,
|
||||||
simple: false
|
simple: false,
|
||||||
}}
|
}}
|
||||||
onChange={async (page) => {
|
onChange={async (page) => {
|
||||||
let pageNumber = page.current;
|
let pageNumber = page.current;
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
import React from 'react';
|
import React from "react";
|
||||||
import {Form, Input, Modal, Select,} from 'antd';
|
import { Form, Input, Modal, Select } from "antd";
|
||||||
import {capitalize} from "lodash";
|
import { capitalize } from "lodash";
|
||||||
import {useStore} from "../../utils/useStore";
|
import { useStore } from "../../utils/useStore";
|
||||||
|
|
||||||
export const MembershipModal = ({
|
export const MembershipModal = ({
|
||||||
visible,
|
visible,
|
||||||
onCreate,
|
onCreate,
|
||||||
onCancel,
|
onCancel,
|
||||||
initialData,
|
initialData,
|
||||||
}) => {
|
}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const {Option} = Select;
|
const { Option } = Select;
|
||||||
const dataStatus = ["true", "false"]
|
const dataStatus = ["true", "false"];
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible={visible}
|
visible={visible}
|
||||||
|
@ -22,18 +21,18 @@ export const MembershipModal = ({
|
||||||
okText={initialData.id ? "Edit" : "Create"}
|
okText={initialData.id ? "Edit" : "Create"}
|
||||||
cancelText="Cancel"
|
cancelText="Cancel"
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
form.resetFields()
|
form.resetFields();
|
||||||
onCancel()
|
onCancel();
|
||||||
}}
|
}}
|
||||||
onOk={() => {
|
onOk={() => {
|
||||||
form
|
form
|
||||||
.validateFields()
|
.validateFields()
|
||||||
.then(values => {
|
.then((values) => {
|
||||||
onCreate(values);
|
onCreate(values);
|
||||||
form.resetFields()
|
form.resetFields();
|
||||||
})
|
})
|
||||||
.catch(info => {
|
.catch((info) => {
|
||||||
console.log('Validate Failed:', info);
|
console.log("Validate Failed:", info);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -43,36 +42,39 @@ export const MembershipModal = ({
|
||||||
name="form_in_modal"
|
name="form_in_modal"
|
||||||
initialValues={initialData}
|
initialValues={initialData}
|
||||||
>
|
>
|
||||||
|
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="username"
|
name="username"
|
||||||
label="Username"
|
label="Username"
|
||||||
rules={[{required: true, message: 'Please input Username!'}]}
|
rules={[{ required: true, message: "Please input Username!" }]}
|
||||||
>
|
>
|
||||||
<Input/>
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="password"
|
name="password"
|
||||||
label="Password"
|
label="Password"
|
||||||
rules={[{required: false, message: 'Please input password!'}]}
|
rules={[{ required: false, message: "Please input password!" }]}
|
||||||
>
|
>
|
||||||
<Input/>
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="roleId"
|
name="roleId"
|
||||||
label="Role"
|
label="Role"
|
||||||
rules={[{required: true, message: 'Please input role id!'}]}
|
rules={[{ required: true, message: "Please input role id!" }]}
|
||||||
>
|
>
|
||||||
<Select>
|
<Select>
|
||||||
{store.role.data.map(item => (
|
{store.role.data.map((item) => (
|
||||||
<Option key={item.id} value={item.id}>{item.name}</Option>
|
<Option key={item.id} value={item.id}>
|
||||||
|
{item.name}
|
||||||
|
</Option>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="superior"
|
name="superior"
|
||||||
label="Superior"
|
label="Superior"
|
||||||
rules={[{required: true, message: 'Please select superior status!'}]}
|
rules={[
|
||||||
|
{ required: true, message: "Please select superior status!" },
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<Select
|
<Select
|
||||||
showSearch
|
showSearch
|
||||||
|
@ -82,11 +84,13 @@ export const MembershipModal = ({
|
||||||
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
||||||
}
|
}
|
||||||
filterSort={(optionA, optionB) =>
|
filterSort={(optionA, optionB) =>
|
||||||
optionA.children.toLowerCase().localeCompare(optionB.children.toLowerCase())
|
optionA.children
|
||||||
|
.toLowerCase()
|
||||||
|
.localeCompare(optionB.children.toLowerCase())
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{dataStatus.map(it => {
|
{dataStatus.map((it, idx) => {
|
||||||
return <Option value={it}>{capitalize(it)}</Option>
|
return <Option value={it} key={idx}>{capitalize(it)}</Option>;
|
||||||
})}
|
})}
|
||||||
</Select>
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
|
@ -12,11 +12,14 @@ export class Membership {
|
||||||
makeAutoObservable(this);
|
makeAutoObservable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
|
||||||
async getData() {
|
async getData() {
|
||||||
const response = await http.get(`/users?page=${this.page}&pageSize=${this.pageSize}`);
|
const response = await http.get(`/users?page=${this.page}&pageSize=${this.pageSize}`);
|
||||||
console.log(response)
|
|
||||||
this.data = response.body.data ?? []
|
this.data = response.body.data.map((item, idx) => {
|
||||||
|
item.key = idx;
|
||||||
|
return item
|
||||||
|
}) ?? []
|
||||||
|
|
||||||
this.total_data = response.body.total_data ?? 0
|
this.total_data = response.body.total_data ?? 0
|
||||||
}
|
}
|
||||||
// async getData() {
|
// async getData() {
|
||||||
|
@ -25,12 +28,10 @@ export class Membership {
|
||||||
// this.total_data = response.body.total_data ?? 0
|
// this.total_data = response.body.total_data ?? 0
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@action
|
|
||||||
async create(data) {
|
async create(data) {
|
||||||
return await http.post('/users').send(data)
|
return await http.post('/users').send(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
|
||||||
async update(id, data) {
|
async update(id, data) {
|
||||||
// console.log(data)
|
// console.log(data)
|
||||||
// console.log(id)
|
// console.log(id)
|
||||||
|
@ -44,6 +45,12 @@ export class Membership {
|
||||||
return await http.del('/users/' + id);
|
return await http.del('/users/' + id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async changeStatus(id, status) {
|
||||||
|
const response = await http.get(`/users/${id}/${status}`);
|
||||||
|
await this.getData();
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,12 @@ export class Partner {
|
||||||
|
|
||||||
async getData() {
|
async getData() {
|
||||||
const response = await http.get(`/users/partner?page=${this.page}&pageSize=${this.pageSize}`);
|
const response = await http.get(`/users/partner?page=${this.page}&pageSize=${this.pageSize}`);
|
||||||
this.data = response.body.data ?? []
|
|
||||||
//console.log(response.body,"ini dari store")
|
this.data = response.body.data.map((item, idx) => {
|
||||||
|
item.key = idx;
|
||||||
|
return item
|
||||||
|
}) ?? []
|
||||||
|
|
||||||
this.total_data = response.body.count ?? 0
|
this.total_data = response.body.count ?? 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +59,11 @@ export class Partner {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async changeStatus(id, status) {
|
||||||
|
const response = await http.get(`/users/partner/${id}/${status}`);
|
||||||
|
await this.getData();
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,10 @@ export class Product {
|
||||||
|
|
||||||
async getDataSubCategories() {
|
async getDataSubCategories() {
|
||||||
const response = await http.get(`/product/sub-categories?page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`);
|
const response = await http.get(`/product/sub-categories?page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`);
|
||||||
this.dataSubCategories = response.body.data ?? []
|
this.dataSubCategories = response.body.data.map((item, idx) => {
|
||||||
|
item.key = idx;
|
||||||
|
return item
|
||||||
|
}) ?? []
|
||||||
this.total_dataSubCategories = response.body.count ?? 0
|
this.total_dataSubCategories = response.body.count ?? 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,9 +49,15 @@ export class Product {
|
||||||
|
|
||||||
this.dataCategories = response.body.data ?? []
|
this.dataCategories = response.body.data ?? []
|
||||||
this.total_dataCategories = response.body.total_data ?? 0
|
this.total_dataCategories = response.body.total_data ?? 0
|
||||||
|
|
||||||
if (this.dataCategories.length > 0) {
|
if (this.dataCategories.length > 0) {
|
||||||
this.filterCategory = this.dataCategories[0].id
|
this.filterCategory = this.dataCategories[0].id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.dataCategories = this.dataCategories.map((item, idx) => {
|
||||||
|
item.key = idx;
|
||||||
|
return item
|
||||||
|
}) ?? []
|
||||||
}
|
}
|
||||||
|
|
||||||
async create(data) {
|
async create(data) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user