Merge branch 'develop' into 'devops-staging'
Develop See merge request empatnusabangsa/ppob/ppob-frontend!4
This commit is contained in:
commit
bbc9c31ccd
|
@ -1,11 +1,23 @@
|
||||||
import React, {useContext, useEffect, useState} from "react";
|
import React, { useContext, useEffect, useState } from "react";
|
||||||
import {Button, Form, Input, message, Modal, Select, Space, Table, Tag,} from "antd";
|
import {
|
||||||
import {observer} from "mobx-react-lite";
|
Button,
|
||||||
import {ExclamationCircleOutlined} from "@ant-design/icons";
|
Form,
|
||||||
import {useHistory} from "react-router-dom";
|
Input,
|
||||||
import {useStore} from "../utils/useStore";
|
message,
|
||||||
import {LINKS} from "../routes/app";
|
Modal,
|
||||||
import {ModalLoaderContext} from "../utils/modal";
|
Select,
|
||||||
|
Space,
|
||||||
|
Table,
|
||||||
|
Tag,
|
||||||
|
List,
|
||||||
|
Divider,
|
||||||
|
} from "antd";
|
||||||
|
import { observer } from "mobx-react-lite";
|
||||||
|
import { ExclamationCircleOutlined } from "@ant-design/icons";
|
||||||
|
import { useHistory } from "react-router-dom";
|
||||||
|
import { useStore } from "../utils/useStore";
|
||||||
|
import { LINKS } from "../routes/app";
|
||||||
|
import { ModalLoaderContext } from "../utils/modal";
|
||||||
|
|
||||||
export const PartnerComponent = observer((props) => {
|
export const PartnerComponent = observer((props) => {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
@ -78,7 +90,7 @@ export const PartnerComponent = observer((props) => {
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<Tag
|
<Tag
|
||||||
color={record?.status === true ? "processing" : "#E3E8EE"}
|
color={record?.status === true ? "processing" : "#E3E8EE"}
|
||||||
style={{color: "#4F566B", cursor: "pointer"}}
|
style={{ color: "#4F566B", cursor: "pointer" }}
|
||||||
>
|
>
|
||||||
{record?.status === true ? " ACTIVE" : "INACTIVE"}
|
{record?.status === true ? " ACTIVE" : "INACTIVE"}
|
||||||
</Tag>
|
</Tag>
|
||||||
|
@ -121,7 +133,7 @@ export const PartnerComponent = observer((props) => {
|
||||||
const handleDelete = (id) => {
|
const handleDelete = (id) => {
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: "Are you sure delete this record?",
|
title: "Are you sure delete this record?",
|
||||||
icon: <ExclamationCircleOutlined/>,
|
icon: <ExclamationCircleOutlined />,
|
||||||
okText: "Yes",
|
okText: "Yes",
|
||||||
okType: "primary",
|
okType: "primary",
|
||||||
cancelText: "Cancel",
|
cancelText: "Cancel",
|
||||||
|
@ -181,36 +193,126 @@ export const PartnerComponent = observer((props) => {
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Table
|
{store.ui.mediaQuery.isDesktop && (
|
||||||
style={{textAlign: "center"}}
|
<Table
|
||||||
columns={columns}
|
style={{ textAlign: "center" }}
|
||||||
dataSource={store.partner.data}
|
columns={columns}
|
||||||
bordered
|
dataSource={store.partner.data}
|
||||||
pagination={{
|
bordered
|
||||||
pageSize: store.partner.pageSize,
|
pagination={{
|
||||||
total: store.partner.total_data,
|
pageSize: store.partner.pageSize,
|
||||||
current: store.partner.page + 1,
|
total: store.partner.total_data,
|
||||||
showSizeChanger: true,
|
current: store.partner.page + 1,
|
||||||
simple: false,
|
showSizeChanger: true,
|
||||||
}}
|
simple: false,
|
||||||
onChange={async (page) => {
|
}}
|
||||||
let pageNumber = page.current;
|
onChange={async (page) => {
|
||||||
store.partner.pageSize = page.pageSize;
|
let pageNumber = page.current;
|
||||||
store.partner.page = pageNumber - 1;
|
store.partner.pageSize = page.pageSize;
|
||||||
modalLoader.setLoading(true);
|
store.partner.page = pageNumber - 1;
|
||||||
await store.partner.getData();
|
modalLoader.setLoading(true);
|
||||||
modalLoader.setLoading(false);
|
await store.partner.getData();
|
||||||
}}
|
modalLoader.setLoading(false);
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{store.ui.mediaQuery.isMobile && (
|
||||||
|
<List
|
||||||
|
itemLayout="horizontal"
|
||||||
|
position={"top"}
|
||||||
|
pagination={{
|
||||||
|
onChange: async (page) => {
|
||||||
|
store.partner.pageSize = page.pageSize;
|
||||||
|
store.partner.page = page.current;
|
||||||
|
modalLoader.setLoading(true);
|
||||||
|
await store.partner.getData();
|
||||||
|
modalLoader.setLoading(false);
|
||||||
|
},
|
||||||
|
pageSize: store.partner.pageSize,
|
||||||
|
total: store.partner.total_data,
|
||||||
|
current: store.partner.page,
|
||||||
|
style: { marginBottom: "1rem", marginRight: "1rem" },
|
||||||
|
}}
|
||||||
|
dataSource={store.partner.data}
|
||||||
|
style={{ padding: 0 }}
|
||||||
|
renderItem={(item) => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<List.Item
|
||||||
|
key={item.id}
|
||||||
|
style={{
|
||||||
|
backgroundColor: "#ffffff",
|
||||||
|
paddingTop: 0,
|
||||||
|
paddingBottom: 0,
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<List.Item.Meta
|
||||||
|
className={["cariparkir-container"].join(" ")}
|
||||||
|
title={item.code}
|
||||||
|
description={
|
||||||
|
<div style={{}}>
|
||||||
|
<p>
|
||||||
|
<small>Nama : {item.name}</small> <br />
|
||||||
|
<small>Npwp : {item.npwp}</small> <br />
|
||||||
|
<small>Address : {item.address}</small>
|
||||||
|
<Space size="middle">
|
||||||
|
<Button
|
||||||
|
type={
|
||||||
|
item?.status === true ? "danger" : "primary"
|
||||||
|
}
|
||||||
|
onClick={() =>
|
||||||
|
changeStatus(item?.id, item?.status)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{item?.status === true ? "Inactive" : "Active"}
|
||||||
|
</Button>
|
||||||
|
<Button onClick={() => handleEditButton(item)}>
|
||||||
|
Edit
|
||||||
|
</Button>
|
||||||
|
{/* <Button onClick={() => handleDelete(record.id)}>Delete</Button> */}
|
||||||
|
<Button onClick={() => changePassword(item)}>
|
||||||
|
Change Password
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
</p>
|
||||||
|
<p></p>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<div style={{ marginRight: 16 }}>
|
||||||
|
<p
|
||||||
|
style={{
|
||||||
|
fontSize: 9,
|
||||||
|
marginBottom: 40,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Tag
|
||||||
|
color={item?.status === true ? "processing" : "#E3E8EE"}
|
||||||
|
style={{ color: "#4F566B", cursor: "pointer" }}
|
||||||
|
>
|
||||||
|
{item?.status === true ? " ACTIVE" : "INACTIVE"}
|
||||||
|
</Tag>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</List.Item>
|
||||||
|
<Divider plain style={{ margin: 0 }} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Modal
|
<Modal
|
||||||
visible={store.partner.visibleModalPartner}
|
visible={store.partner.visibleModalPartner}
|
||||||
title={
|
title={
|
||||||
isChangePassword
|
isChangePassword
|
||||||
? "Change Member Password"
|
? "Change Member Password"
|
||||||
: idData
|
: idData
|
||||||
? "Edit Partner"
|
? "Edit Partner"
|
||||||
: "Create a new partner"
|
: "Create a new partner"
|
||||||
}
|
}
|
||||||
okText={idData ? "Edit" : "Create"}
|
okText={idData ? "Edit" : "Create"}
|
||||||
cancelText="Cancel"
|
cancelText="Cancel"
|
||||||
|
@ -238,11 +340,11 @@ export const PartnerComponent = observer((props) => {
|
||||||
label="Name"
|
label="Name"
|
||||||
rules={[
|
rules={[
|
||||||
idData
|
idData
|
||||||
? {required: false}
|
? { required: false }
|
||||||
: {required: true, message: "Please input password name!"},
|
: { required: true, message: "Please input password name!" },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Input/>
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
{!idData && (
|
{!idData && (
|
||||||
|
@ -251,11 +353,11 @@ export const PartnerComponent = observer((props) => {
|
||||||
label="Owner"
|
label="Owner"
|
||||||
rules={[
|
rules={[
|
||||||
idData
|
idData
|
||||||
? {required: false}
|
? { required: false }
|
||||||
: {required: true, message: "Please input password owner!"},
|
: { required: true, message: "Please input password owner!" },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Input/>
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
{((idData && isChangePassword) || !idData) && (
|
{((idData && isChangePassword) || !idData) && (
|
||||||
|
@ -264,14 +366,14 @@ export const PartnerComponent = observer((props) => {
|
||||||
label="Password Account"
|
label="Password Account"
|
||||||
rules={[
|
rules={[
|
||||||
idData
|
idData
|
||||||
? {required: false}
|
? { required: false }
|
||||||
: {
|
: {
|
||||||
required: true,
|
required: true,
|
||||||
message: "Please input password account!",
|
message: "Please input password account!",
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Input/>
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
{!idData && (
|
{!idData && (
|
||||||
|
@ -280,11 +382,14 @@ export const PartnerComponent = observer((props) => {
|
||||||
label="Phone Number"
|
label="Phone Number"
|
||||||
rules={[
|
rules={[
|
||||||
idData
|
idData
|
||||||
? {required: false}
|
? { required: false }
|
||||||
: {required: true, message: "Please input password phone number!"},
|
: {
|
||||||
|
required: true,
|
||||||
|
message: "Please input password phone number!",
|
||||||
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Input/>
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
{!isChangePassword && (
|
{!isChangePassword && (
|
||||||
|
@ -294,25 +399,25 @@ export const PartnerComponent = observer((props) => {
|
||||||
label="Npwp"
|
label="Npwp"
|
||||||
rules={[
|
rules={[
|
||||||
idData
|
idData
|
||||||
? {required: false}
|
? { required: false }
|
||||||
: {required: true, message: "Please input npwp!"},
|
: { required: true, message: "Please input npwp!" },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Input/>
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="address"
|
name="address"
|
||||||
label="Address"
|
label="Address"
|
||||||
rules={[
|
rules={[
|
||||||
idData
|
idData
|
||||||
? {required: false}
|
? { required: false }
|
||||||
: {
|
: {
|
||||||
required: true,
|
required: true,
|
||||||
message: "Please input address!",
|
message: "Please input address!",
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Input/>
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -1,28 +1,42 @@
|
||||||
import React, {useContext, useState} from "react";
|
import React, { useContext, useState } from "react";
|
||||||
import {Button, Col, Form, Input, message, Modal, Row, Select, Table, Tag, Typography} from "antd";
|
import {
|
||||||
import {observer} from "mobx-react-lite";
|
Button,
|
||||||
import {ExclamationCircleOutlined} from "@ant-design/icons";
|
Col,
|
||||||
import {useHistory} from "react-router-dom";
|
Form,
|
||||||
import {capitalize} from "lodash";
|
Input,
|
||||||
import {useStore} from "../utils/useStore";
|
message,
|
||||||
import {LINKS} from "../routes/app";
|
Modal,
|
||||||
import {ModalLoaderContext} from "../utils/modal";
|
Row,
|
||||||
|
Select,
|
||||||
|
Table,
|
||||||
|
Divider,
|
||||||
|
Tag,
|
||||||
|
Typography,
|
||||||
|
List,
|
||||||
|
} from "antd";
|
||||||
|
import { observer } from "mobx-react-lite";
|
||||||
|
import { ExclamationCircleOutlined } from "@ant-design/icons";
|
||||||
|
import { useHistory } from "react-router-dom";
|
||||||
|
import { capitalize } from "lodash";
|
||||||
|
import { useStore } from "../utils/useStore";
|
||||||
|
import { LINKS } from "../routes/app";
|
||||||
|
import { ModalLoaderContext } from "../utils/modal";
|
||||||
|
|
||||||
const {Title, Text} = Typography;
|
const { Title, Text } = Typography;
|
||||||
|
|
||||||
export const ProductComponent = observer((props) => {
|
export const ProductComponent = observer((props) => {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const {Option} = Select;
|
const { Option } = Select;
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const [idData, setIdData] = useState('');
|
const [idData, setIdData] = useState("");
|
||||||
const [filterSupplier, setFilterSupplier] = useState(null);
|
const [filterSupplier, setFilterSupplier] = useState(null);
|
||||||
const [filterCategories, setFilterCategories] = useState(null);
|
const [filterCategories, setFilterCategories] = useState(null);
|
||||||
const [filterSubCategories, setFilterSubCategories] = useState(null);
|
const [filterSubCategories, setFilterSubCategories] = useState(null);
|
||||||
const modalLoader = useContext(ModalLoaderContext);
|
const modalLoader = useContext(ModalLoaderContext);
|
||||||
|
|
||||||
const handleEditButton = (data) => {
|
const handleEditButton = (data) => {
|
||||||
console.log(data, "isi data")
|
console.log(data, "isi data");
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
name: data.name,
|
name: data.name,
|
||||||
price: data.price,
|
price: data.price,
|
||||||
|
@ -33,7 +47,7 @@ export const ProductComponent = observer((props) => {
|
||||||
});
|
});
|
||||||
store.product.visibleModalProduct = true;
|
store.product.visibleModalProduct = true;
|
||||||
setIdData(data.id);
|
setIdData(data.id);
|
||||||
}
|
};
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
|
@ -76,12 +90,12 @@ export const ProductComponent = observer((props) => {
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<Tag
|
<Tag
|
||||||
color={record?.status === "ACTIVE" ? "blue" : "#E3E8EE"}
|
color={record?.status === "ACTIVE" ? "blue" : "#E3E8EE"}
|
||||||
style={{color: "#4F566B"}}
|
style={{ color: "#4F566B" }}
|
||||||
>
|
>
|
||||||
{record?.status === "ACTIVE" ? " Tersedia" : "Tidak"}
|
{record?.status === "ACTIVE" ? " Tersedia" : "Tidak"}
|
||||||
</Tag>
|
</Tag>
|
||||||
),
|
),
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const deleteData = async (id) => {
|
const deleteData = async (id) => {
|
||||||
|
@ -99,7 +113,7 @@ export const ProductComponent = observer((props) => {
|
||||||
const handleDelete = (id) => {
|
const handleDelete = (id) => {
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: "Are you sure delete this record?",
|
title: "Are you sure delete this record?",
|
||||||
icon: <ExclamationCircleOutlined/>,
|
icon: <ExclamationCircleOutlined />,
|
||||||
okText: "Yes",
|
okText: "Yes",
|
||||||
okType: "primary",
|
okType: "primary",
|
||||||
cancelText: "Cancel",
|
cancelText: "Cancel",
|
||||||
|
@ -113,39 +127,39 @@ export const ProductComponent = observer((props) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
setIdData('')
|
setIdData("");
|
||||||
store.product.visibleModalProduct = false;
|
store.product.visibleModalProduct = false;
|
||||||
}
|
};
|
||||||
|
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
console.log(data, "isi data2")
|
console.log(data, "isi data2");
|
||||||
if (idData !== '') {
|
if (idData !== "") {
|
||||||
modalLoader.setLoading(true);
|
modalLoader.setLoading(true);
|
||||||
try {
|
try {
|
||||||
await store.product.update(idData, data)
|
await store.product.update(idData, data);
|
||||||
message.success("Success Update Data Member")
|
message.success("Success Update Data Member");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error("Failed Update Data Member")
|
message.error("Failed Update Data Member");
|
||||||
}
|
}
|
||||||
modalLoader.setLoading(false);
|
modalLoader.setLoading(false);
|
||||||
store.product.visibleModalProduct = false;
|
store.product.visibleModalProduct = false;
|
||||||
setIdData('');
|
setIdData("");
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
} else {
|
} else {
|
||||||
modalLoader.setLoading(true);
|
modalLoader.setLoading(true);
|
||||||
try {
|
try {
|
||||||
await store.product.create(data)
|
await store.product.create(data);
|
||||||
message.success("Success Add New Member")
|
message.success("Success Add New Member");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e, "apa errornya")
|
console.log(e, "apa errornya");
|
||||||
message.error("Failed Add Member")
|
message.error("Failed Add Member");
|
||||||
}
|
}
|
||||||
modalLoader.setLoading(false);
|
modalLoader.setLoading(false);
|
||||||
store.product.visibleModalProduct = false;
|
store.product.visibleModalProduct = false;
|
||||||
setIdData('');
|
setIdData("");
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const handleRemoveFilter = async () => {
|
const handleRemoveFilter = async () => {
|
||||||
store.product.filterSupplier = null;
|
store.product.filterSupplier = null;
|
||||||
|
@ -174,39 +188,132 @@ export const ProductComponent = observer((props) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const footerLayoutFilter = [
|
const footerLayoutFilter = [
|
||||||
<Button key={'remove'} onClick={handleRemoveFilter} style={{
|
<Button
|
||||||
backgroundColor: '#e74e5e', color: '#fff'
|
key={"remove"}
|
||||||
}}>Remove Filter</Button>,
|
onClick={handleRemoveFilter}
|
||||||
<Button key={'cancel'} onClick={handleCancelFilter}>Cancel</Button>,
|
style={{
|
||||||
<Button key={'submit'} onClick={handleSubmitFilter} style={{
|
backgroundColor: "#e74e5e",
|
||||||
backgroundColor: '#4e79e7', color: '#fff'
|
color: "#fff",
|
||||||
}}>Apply</Button>
|
}}
|
||||||
]
|
>
|
||||||
|
Remove Filter
|
||||||
|
</Button>,
|
||||||
|
<Button key={"cancel"} onClick={handleCancelFilter}>
|
||||||
|
Cancel
|
||||||
|
</Button>,
|
||||||
|
<Button
|
||||||
|
key={"submit"}
|
||||||
|
onClick={handleSubmitFilter}
|
||||||
|
style={{
|
||||||
|
backgroundColor: "#4e79e7",
|
||||||
|
color: "#fff",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Apply
|
||||||
|
</Button>,
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Table
|
{store.ui.mediaQuery.isDesktop && (
|
||||||
style={{textAlign: "center"}}
|
<Table
|
||||||
columns={columns}
|
style={{
|
||||||
dataSource={store.product.data}
|
textAlign: "center",
|
||||||
bordered
|
width: store.ui.mediaQuery.isMobile ? 250 : "",
|
||||||
pagination={{
|
}}
|
||||||
pageSize: store.product.pageSize,
|
columns={columns}
|
||||||
total: store.product.total_data,
|
dataSource={store.product.data}
|
||||||
current: store.product.page + 1,
|
bordered
|
||||||
showSizeChanger: true,
|
pagination={{
|
||||||
simple: false
|
pageSize: store.product.pageSize,
|
||||||
}}
|
total: store.product.total_data,
|
||||||
onChange={async (page) => {
|
current: store.product.page + 1,
|
||||||
let pageNumber = page.current;
|
showSizeChanger: true,
|
||||||
store.product.pageSize = page.pageSize;
|
simple: false,
|
||||||
store.product.page = pageNumber - 1;
|
}}
|
||||||
modalLoader.setLoading(true);
|
onChange={async (page) => {
|
||||||
await store.product.getData();
|
let pageNumber = page.current;
|
||||||
modalLoader.setLoading(false);
|
store.product.pageSize = page.pageSize;
|
||||||
}}
|
store.product.page = pageNumber - 1;
|
||||||
/>
|
modalLoader.setLoading(true);
|
||||||
|
await store.product.getData();
|
||||||
|
modalLoader.setLoading(false);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{store.ui.mediaQuery.isMobile && (
|
||||||
|
<List
|
||||||
|
itemLayout="horizontal"
|
||||||
|
position={"top"}
|
||||||
|
pagination={{
|
||||||
|
onChange: async (page) => {
|
||||||
|
store.product.pageSize = page.pageSize;
|
||||||
|
store.product.page = page.current;
|
||||||
|
modalLoader.setLoading(true);
|
||||||
|
await store.product.getData();
|
||||||
|
modalLoader.setLoading(false);
|
||||||
|
},
|
||||||
|
pageSize: store.product.pageSize,
|
||||||
|
total: store.product.total_data,
|
||||||
|
current: store.product.page,
|
||||||
|
style: { marginBottom: "1rem", marginRight: "1rem" },
|
||||||
|
}}
|
||||||
|
dataSource={store.product.data}
|
||||||
|
style={{ padding: 0 }}
|
||||||
|
renderItem={(item) => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<List.Item
|
||||||
|
key={item.id}
|
||||||
|
style={{
|
||||||
|
backgroundColor: "#ffffff",
|
||||||
|
paddingTop: 0,
|
||||||
|
paddingBottom: 0,
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<List.Item.Meta
|
||||||
|
className={["cariparkir-container"].join(" ")}
|
||||||
|
title={item.code}
|
||||||
|
description={
|
||||||
|
<div style={{}}>
|
||||||
|
<p>
|
||||||
|
<small>Nama Produk : {item.name}</small> <br />
|
||||||
|
<small>Harga Beli : {item.currentPrice.price}</small>
|
||||||
|
<br />
|
||||||
|
<small>
|
||||||
|
Harga Jual : {item.currentPrice.mark_up_price}
|
||||||
|
</small>
|
||||||
|
</p>
|
||||||
|
<p></p>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<div style={{ marginRight: 16 }}>
|
||||||
|
<p
|
||||||
|
style={{
|
||||||
|
fontSize: 9,
|
||||||
|
margin: 0,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Tag
|
||||||
|
color={item?.status === "ACTIVE" ? "blue" : "#E3E8EE"}
|
||||||
|
style={{ color: "#4F566B" }}
|
||||||
|
>
|
||||||
|
{item?.status === "ACTIVE" ? " Tersedia" : "Tidak"}
|
||||||
|
</Tag>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</List.Item>
|
||||||
|
<Divider plain style={{ margin: 0 }} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Modal
|
<Modal
|
||||||
visible={store.product.visibleModalProduct}
|
visible={store.product.visibleModalProduct}
|
||||||
title={idData ? "Edit Product" : "Create a new Product"}
|
title={idData ? "Edit Product" : "Create a new Product"}
|
||||||
|
@ -220,7 +327,7 @@ export const ProductComponent = observer((props) => {
|
||||||
form
|
form
|
||||||
.validateFields()
|
.validateFields()
|
||||||
.then((values) => {
|
.then((values) => {
|
||||||
console.log(values, "isi form")
|
console.log(values, "isi form");
|
||||||
handleSubmit(values);
|
handleSubmit(values);
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
})
|
})
|
||||||
|
@ -229,42 +336,39 @@ export const ProductComponent = observer((props) => {
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Form
|
<Form form={form} layout="vertical">
|
||||||
form={form}
|
|
||||||
layout="vertical"
|
|
||||||
>
|
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="name"
|
name="name"
|
||||||
label="Name"
|
label="Name"
|
||||||
rules={[{required: true, message: "Please input name!"}]}
|
rules={[{ required: true, message: "Please input name!" }]}
|
||||||
>
|
>
|
||||||
<Input/>
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="price"
|
name="price"
|
||||||
label="Price"
|
label="Price"
|
||||||
rules={[{required: true, message: "Please input price!"}]}
|
rules={[{ required: true, message: "Please input price!" }]}
|
||||||
>
|
>
|
||||||
<Input/>
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="markUpPrice"
|
name="markUpPrice"
|
||||||
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!" }]}
|
||||||
>
|
>
|
||||||
<Input/>
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="code"
|
name="code"
|
||||||
label="Code"
|
label="Code"
|
||||||
rules={[{required: true, message: "Please input code!"}]}
|
rules={[{ required: true, message: "Please input code!" }]}
|
||||||
>
|
>
|
||||||
<Input/>
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="status"
|
name="status"
|
||||||
label="Status"
|
label="Status"
|
||||||
rules={[{required: true, message: "Please select Status!"}]}
|
rules={[{ required: true, message: "Please select Status!" }]}
|
||||||
>
|
>
|
||||||
<Select placeholder="Select Sub Category" allowClear>
|
<Select placeholder="Select Sub Category" allowClear>
|
||||||
<Option value="ACTIVE">ACTIVE</Option>
|
<Option value="ACTIVE">ACTIVE</Option>
|
||||||
|
@ -274,7 +378,9 @@ export const ProductComponent = observer((props) => {
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="subCategoriesId"
|
name="subCategoriesId"
|
||||||
label="Sub categories"
|
label="Sub categories"
|
||||||
rules={[{required: true, message: "Please select sub categories!"}]}
|
rules={[
|
||||||
|
{ required: true, message: "Please select sub categories!" },
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<Select placeholder="Select Sub Category" allowClear>
|
<Select placeholder="Select Sub Category" allowClear>
|
||||||
{store.product.dataSubCategories.map((item) => (
|
{store.product.dataSubCategories.map((item) => (
|
||||||
|
@ -294,14 +400,16 @@ export const ProductComponent = observer((props) => {
|
||||||
>
|
>
|
||||||
<Row>
|
<Row>
|
||||||
<Col span={24}>
|
<Col span={24}>
|
||||||
<Title level={5} type={"secondary"} strong>Filter Supplier</Title>
|
<Title level={5} type={"secondary"} strong>
|
||||||
|
Filter Supplier
|
||||||
|
</Title>
|
||||||
<Select
|
<Select
|
||||||
mode={"multiple"}
|
mode={"multiple"}
|
||||||
placeholder="Choose Supplier"
|
placeholder="Choose Supplier"
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
setFilterSupplier(val);
|
setFilterSupplier(val);
|
||||||
}}
|
}}
|
||||||
style={{marginBottom: "20px", width: "100%"}}
|
style={{ marginBottom: "20px", width: "100%" }}
|
||||||
>
|
>
|
||||||
{store.supplier.data.map((item) => (
|
{store.supplier.data.map((item) => (
|
||||||
<Option value={item.id} key={item.id}>
|
<Option value={item.id} key={item.id}>
|
||||||
|
@ -311,7 +419,9 @@ export const ProductComponent = observer((props) => {
|
||||||
</Select>
|
</Select>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={24}>
|
<Col span={24}>
|
||||||
<Title level={5} type={"secondary"} strong>Filter Categories</Title>
|
<Title level={5} type={"secondary"} strong>
|
||||||
|
Filter Categories
|
||||||
|
</Title>
|
||||||
<Select
|
<Select
|
||||||
mode={"multiple"}
|
mode={"multiple"}
|
||||||
placeholder="Choose Category"
|
placeholder="Choose Category"
|
||||||
|
@ -320,7 +430,7 @@ export const ProductComponent = observer((props) => {
|
||||||
store.product.filterByCategory = val;
|
store.product.filterByCategory = val;
|
||||||
await store.product.getDataSubCategories();
|
await store.product.getDataSubCategories();
|
||||||
}}
|
}}
|
||||||
style={{marginBottom: "20px", width: "100%"}}
|
style={{ marginBottom: "20px", width: "100%" }}
|
||||||
>
|
>
|
||||||
{store.category.data.map((item) => (
|
{store.category.data.map((item) => (
|
||||||
<Option value={item.id} key={item.id}>
|
<Option value={item.id} key={item.id}>
|
||||||
|
@ -330,14 +440,16 @@ export const ProductComponent = observer((props) => {
|
||||||
</Select>
|
</Select>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={24}>
|
<Col span={24}>
|
||||||
<Title level={5} type={"secondary"} strong>Filter Sub-Categories</Title>
|
<Title level={5} type={"secondary"} strong>
|
||||||
|
Filter Sub-Categories
|
||||||
|
</Title>
|
||||||
<Select
|
<Select
|
||||||
mode={"multiple"}
|
mode={"multiple"}
|
||||||
placeholder="Choose Sub-Category"
|
placeholder="Choose Sub-Category"
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
setFilterSubCategories(val);
|
setFilterSubCategories(val);
|
||||||
}}
|
}}
|
||||||
style={{marginBottom: "20px", width: "100%"}}
|
style={{ marginBottom: "20px", width: "100%" }}
|
||||||
>
|
>
|
||||||
{store.product.dataSubCategories.map((item) => (
|
{store.product.dataSubCategories.map((item) => (
|
||||||
<Option value={item.id} key={item.id}>
|
<Option value={item.id} key={item.id}>
|
||||||
|
|
|
@ -1,14 +1,26 @@
|
||||||
import React, {useContext, useState} from "react";
|
import React, { useContext, useState } from "react";
|
||||||
import {Button, Form, Input, message, Modal, Select, Space, Table,} from "antd";
|
import {
|
||||||
import {observer} from "mobx-react-lite";
|
Button,
|
||||||
import {useHistory} from "react-router-dom";
|
Form,
|
||||||
import {useStore} from "../utils/useStore";
|
Input,
|
||||||
import {ModalLoaderContext} from "../utils/modal";
|
message,
|
||||||
|
Modal,
|
||||||
|
Select,
|
||||||
|
Space,
|
||||||
|
Table,
|
||||||
|
List,
|
||||||
|
Tag,
|
||||||
|
Divider,
|
||||||
|
} from "antd";
|
||||||
|
import { observer } from "mobx-react-lite";
|
||||||
|
import { useHistory } from "react-router-dom";
|
||||||
|
import { useStore } from "../utils/useStore";
|
||||||
|
import { ModalLoaderContext } from "../utils/modal";
|
||||||
|
|
||||||
export const SubcategoryComponent = observer((props) => {
|
export const SubcategoryComponent = observer((props) => {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const {Option} = Select;
|
const { Option } = Select;
|
||||||
const [idData, setIdData] = useState("");
|
const [idData, setIdData] = useState("");
|
||||||
const modalLoader = useContext(ModalLoaderContext);
|
const modalLoader = useContext(ModalLoaderContext);
|
||||||
|
|
||||||
|
@ -94,28 +106,96 @@ export const SubcategoryComponent = observer((props) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Table
|
{store.ui.mediaQuery.isDesktop && (
|
||||||
style={{textAlign: "center"}}
|
<Table
|
||||||
columns={columns}
|
style={{ textAlign: "center" }}
|
||||||
dataSource={store.subcategory.data}
|
columns={columns}
|
||||||
bordered
|
dataSource={store.subcategory.data}
|
||||||
pagination={{
|
bordered
|
||||||
pageSize: store.subcategory.pageSize,
|
pagination={{
|
||||||
total: store.subcategory.total_data,
|
pageSize: store.subcategory.pageSize,
|
||||||
current: store.subcategory.page + 1,
|
total: store.subcategory.total_data,
|
||||||
showSizeChanger: true,
|
current: store.subcategory.page + 1,
|
||||||
simple: false,
|
showSizeChanger: true,
|
||||||
}}
|
simple: false,
|
||||||
onChange={async (page) => {
|
}}
|
||||||
let pageNumber = page.current;
|
onChange={async (page) => {
|
||||||
store.subcategory.pageSize = page.pageSize;
|
let pageNumber = page.current;
|
||||||
store.subcategory.page = pageNumber - 1;
|
store.subcategory.pageSize = page.pageSize;
|
||||||
modalLoader.setLoading(true);
|
store.subcategory.page = pageNumber - 1;
|
||||||
await getData();
|
modalLoader.setLoading(true);
|
||||||
modalLoader.setLoading(false);
|
await getData();
|
||||||
}}
|
modalLoader.setLoading(false);
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{store.ui.mediaQuery.isMobile && (
|
||||||
|
<List
|
||||||
|
itemLayout="horizontal"
|
||||||
|
position={"top"}
|
||||||
|
pagination={{
|
||||||
|
onChange: async (page) => {
|
||||||
|
store.subcategory.pageSize = page.pageSize;
|
||||||
|
store.subcategory.page = page.current;
|
||||||
|
modalLoader.setLoading(true);
|
||||||
|
await store.subcategory.getData();
|
||||||
|
modalLoader.setLoading(false);
|
||||||
|
},
|
||||||
|
pageSize: store.subcategory.pageSize,
|
||||||
|
total: store.subcategory.total_data,
|
||||||
|
current: store.subcategory.page,
|
||||||
|
style: { marginBottom: "1rem", marginRight: "1rem" },
|
||||||
|
}}
|
||||||
|
dataSource={store.subcategory.data}
|
||||||
|
style={{ padding: 0 }}
|
||||||
|
renderItem={(item) => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<List.Item
|
||||||
|
key={item.id}
|
||||||
|
style={{
|
||||||
|
backgroundColor: "#ffffff",
|
||||||
|
paddingTop: 0,
|
||||||
|
paddingBottom: 0,
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<List.Item.Meta
|
||||||
|
className={["cariparkir-container"].join(" ")}
|
||||||
|
title={item.code}
|
||||||
|
description={
|
||||||
|
<div style={{}}>
|
||||||
|
<p>
|
||||||
|
<small>Sub Category : {item.name}</small> <br />
|
||||||
|
<small>Category : {item.categoryName}</small>
|
||||||
|
<br />
|
||||||
|
</p>
|
||||||
|
<p></p>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<div style={{ marginRight: 16 }}>
|
||||||
|
<p
|
||||||
|
style={{
|
||||||
|
fontSize: 9,
|
||||||
|
margin: 0,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button onClick={() => handleEditButton(item)}>
|
||||||
|
Edit
|
||||||
|
</Button>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</List.Item>
|
||||||
|
<Divider plain style={{ margin: 0 }} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Modal
|
<Modal
|
||||||
visible={store.subcategory.visibleModalSubcategory}
|
visible={store.subcategory.visibleModalSubcategory}
|
||||||
title={idData ? "Edit Sub Category" : "Create a new sub category"}
|
title={idData ? "Edit Sub Category" : "Create a new sub category"}
|
||||||
|
@ -144,24 +224,24 @@ export const SubcategoryComponent = observer((props) => {
|
||||||
name="code"
|
name="code"
|
||||||
label="Code"
|
label="Code"
|
||||||
rules={[
|
rules={[
|
||||||
{required: true, message: "Please input code category!"},
|
{ required: true, message: "Please input code category!" },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Input/>
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="name"
|
name="name"
|
||||||
label="Name"
|
label="Name"
|
||||||
rules={[{required: true, message: "Please input name category!"}]}
|
rules={[{ required: true, message: "Please input name category!" }]}
|
||||||
>
|
>
|
||||||
<Input/>
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
{!idData && (
|
{!idData && (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="categoryId"
|
name="categoryId"
|
||||||
label="Categories"
|
label="Categories"
|
||||||
rules={[{required: true, message: "Please input category id!"}]}
|
rules={[{ required: true, message: "Please input category id!" }]}
|
||||||
>
|
>
|
||||||
<Select placeholder="Select Category" allowClear>
|
<Select placeholder="Select Category" allowClear>
|
||||||
{store.category.data.map((item) => (
|
{store.category.data.map((item) => (
|
||||||
|
|
|
@ -65,15 +65,26 @@ export const SupplierComponent = observer((props) => {
|
||||||
width: "5%",
|
width: "5%",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Saldo",
|
title: "Saldo di Supplier",
|
||||||
dataIndex: ["coa", "amount"],
|
dataIndex: ["coa", "amount"],
|
||||||
key: ["coa", "amount"],
|
key: ["coa", "amount"],
|
||||||
width: "20%",
|
width: "20%",
|
||||||
render: (text, record) =>
|
render: (text, record) =>
|
||||||
new Intl.NumberFormat("id-ID", {
|
new Intl.NumberFormat("id-ID", {
|
||||||
style: "currency",
|
style: "currency",
|
||||||
currency: "IDR",
|
currency: "IDR",
|
||||||
}).format(text)
|
}).format(text)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Saldo di System",
|
||||||
|
dataIndex: ["coa_undistribute", "amount"],
|
||||||
|
key: ["coa_undistribute", "amount"],
|
||||||
|
width: "20%",
|
||||||
|
render: (text, record) =>
|
||||||
|
new Intl.NumberFormat("id-ID", {
|
||||||
|
style: "currency",
|
||||||
|
currency: "IDR",
|
||||||
|
}).format(text)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Status",
|
title: "Status",
|
||||||
|
|
|
@ -145,7 +145,7 @@ export const DesktopLayout = observer(() => {
|
||||||
</Link>
|
</Link>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
<Menu.Item key="commision">
|
<Menu.Item key="commision">
|
||||||
<Link to={LINKS.COMMISION}>
|
<Link to={LINKS.COMMISSION}>
|
||||||
<HomeOutlined />
|
<HomeOutlined />
|
||||||
<span>Commision</span>
|
<span>Commision</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
|
@ -20,8 +20,10 @@ export const PaybackFromUser = observer(() => {
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
try {
|
try {
|
||||||
modalLoader.setLoading(true);
|
modalLoader.setLoading(true);
|
||||||
await store.payback.getDataUser();
|
await Promise.allSettled([
|
||||||
await store.authentication.getProfile();
|
store.payback.getDataUser(),
|
||||||
|
store.authentication.getProfile()
|
||||||
|
]);
|
||||||
modalLoader.setLoading(false);
|
modalLoader.setLoading(false);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
modalLoader.setLoading(false);
|
modalLoader.setLoading(false);
|
||||||
|
|
|
@ -1,37 +1,28 @@
|
||||||
import React, {useState, useEffect, useContext} from "react";
|
import React, {useContext, useState} from "react";
|
||||||
import {
|
import {Form, Input, message, Modal, Upload,} from "antd";
|
||||||
Button,
|
|
||||||
Form,
|
|
||||||
Image,
|
|
||||||
Input,
|
|
||||||
message,
|
|
||||||
Modal,
|
|
||||||
Upload,
|
|
||||||
} from "antd";
|
|
||||||
import {useStore} from "../../utils/useStore";
|
import {useStore} from "../../utils/useStore";
|
||||||
import {appConfig} from "../../config/app";
|
import {LoadingOutlined, PlusOutlined} from "@ant-design/icons";
|
||||||
import {LoadingOutlined, UploadOutlined} from "@ant-design/icons";
|
|
||||||
import {ModalLoaderContext} from "../../utils/modal";
|
import {ModalLoaderContext} from "../../utils/modal";
|
||||||
|
import {http} from "../../utils/http";
|
||||||
|
import {appConfig} from "../../config/app";
|
||||||
|
|
||||||
export const PaybackModal = ({visible, onCreate, onCancel, initialData}) => {
|
export const PaybackModal = ({visible, onCreate, onCancel, initialData}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
const [image, setImage] = useState("");
|
||||||
const [fileList, setFileList] = useState([]);
|
const [fileList, setFileList] = useState([]);
|
||||||
const [previewTitle, setPreviewTitle] = useState("");
|
|
||||||
const [previewImage, setPreviewImage] = useState("");
|
const [previewImage, setPreviewImage] = useState("");
|
||||||
const [fileUrl, setFileUrl] = useState("");
|
const [previewVisible, setPreviewVisible] = useState(false);
|
||||||
const firstIndexFileList = fileList[0];
|
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const modalLoader = useContext(ModalLoaderContext);
|
const modalLoader = useContext(ModalLoaderContext);
|
||||||
|
|
||||||
const beforeUpload = (file) => {
|
const beforeUpload = (file) => {
|
||||||
let isPdf, isLt2M;
|
let isLt2M;
|
||||||
let allowedFile = ["image/jpeg", "image/png", "application/pdf"];
|
let allowedFile = ["image/jpeg", "image/png"];
|
||||||
let isValid = allowedFile.includes(file.type);
|
let isValid = allowedFile.includes(file.type);
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
message.error("You can only upload PDF or Image file!");
|
message.error("You can only upload Image file!");
|
||||||
}
|
}
|
||||||
// return file.type === 'application/pdf' ? true : Upload.LIST_IGNORE;
|
|
||||||
isLt2M = file.size / 1024 / 1024 < 2;
|
isLt2M = file.size / 1024 / 1024 < 2;
|
||||||
if (!isLt2M) {
|
if (!isLt2M) {
|
||||||
message.error("File must smaller than 2MB!");
|
message.error("File must smaller than 2MB!");
|
||||||
|
@ -39,40 +30,31 @@ export const PaybackModal = ({visible, onCreate, onCancel, initialData}) => {
|
||||||
return isValid && isLt2M ? true : Upload.LIST_IGNORE;
|
return isValid && isLt2M ? true : Upload.LIST_IGNORE;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePreview = async (file) => {
|
const uploadHandler = async (args) => {
|
||||||
const fileUrl = appConfig.apiUrl + file.response.path;
|
const file = args.file;
|
||||||
setPreviewTitle(file.url?.substring(file.url?.lastIndexOf("/") + 1));
|
const res = await http.upload(file);
|
||||||
|
setImage(`${appConfig.apiUrl}/config/image/${res.body.filename}`);
|
||||||
|
setFileList([{
|
||||||
|
uid: '-1',
|
||||||
|
name: 'image',
|
||||||
|
status: 'done',
|
||||||
|
url: `${appConfig.apiUrl}/config/image/${res.body.filename}`,
|
||||||
|
}]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChange = ({fileList}) => {
|
const handleChange = (info) => {
|
||||||
setFileList(fileList);
|
if (info.file.status === 'uploading') {
|
||||||
if (fileList.length && fileList[0].status === "done") {
|
setLoading(true);
|
||||||
form.setFieldsValue({
|
return;
|
||||||
file_url: fileList[0].response.path,
|
|
||||||
});
|
|
||||||
console.log(fileList, "apaaaaaa");
|
|
||||||
setFileUrl(fileList[0].response.path);
|
|
||||||
setPreviewImage(fileList[0].response.path);
|
|
||||||
setPreviewTitle(fileList[0].name);
|
|
||||||
}
|
}
|
||||||
|
setLoading(false)
|
||||||
};
|
};
|
||||||
|
|
||||||
const uploadButton = (
|
const uploadButton = (
|
||||||
<div>
|
<div>
|
||||||
{loading ? (
|
{loading ? <LoadingOutlined/> : <PlusOutlined/>}
|
||||||
<LoadingOutlined/>
|
<div style={{marginTop: 8}}>Click to Upload</div>
|
||||||
) : (
|
</div>
|
||||||
<Button icon={<UploadOutlined/>}>Click to Upload</Button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
const previewUpload = (
|
|
||||||
<Image
|
|
||||||
className="w-full h-full"
|
|
||||||
preview={false}
|
|
||||||
src={!fileUrl ? null : `${appConfig.apiUrl}${fileUrl ?? ""}`}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
|
@ -95,101 +77,85 @@ export const PaybackModal = ({visible, onCreate, onCancel, initialData}) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible={visible}
|
visible={visible}
|
||||||
title={"Create a new Payback"}
|
title={"Create a new Payback"}
|
||||||
okText={"Create"}
|
okText={"Create"}
|
||||||
cancelText="Cancel"
|
cancelText="Cancel"
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
form.resetFields();
|
|
||||||
onCancel();
|
|
||||||
}}
|
|
||||||
onOk={() => {
|
|
||||||
form
|
|
||||||
.validateFields()
|
|
||||||
.then((values) => {
|
|
||||||
handleSubmit(values);
|
|
||||||
console.log(values);
|
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
})
|
onCancel();
|
||||||
.catch((info) => {
|
}}
|
||||||
console.log("Validate Failed:", info);
|
onOk={() => {
|
||||||
});
|
form
|
||||||
}}
|
.validateFields()
|
||||||
>
|
.then((values) => {
|
||||||
<Form
|
handleSubmit(values);
|
||||||
form={form}
|
console.log(values);
|
||||||
layout="vertical"
|
form.resetFields();
|
||||||
name="form_in_modal"
|
})
|
||||||
initialValues={initialData}
|
.catch((info) => {
|
||||||
|
console.log("Validate Failed:", info);
|
||||||
|
});
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Form.Item
|
<Form
|
||||||
name="destination"
|
form={form}
|
||||||
label="destination"
|
layout="vertical"
|
||||||
rules={[{required: true, message: "Please input Name!"}]}
|
name="form_in_modal"
|
||||||
initialValue={store.authentication.profileData.superior?.id}
|
initialValues={initialData}
|
||||||
>
|
>
|
||||||
<Input/>
|
<Form.Item
|
||||||
</Form.Item>
|
name="destination"
|
||||||
<Form.Item
|
label="destination"
|
||||||
label="Upload Picture"
|
rules={[{required: true, message: "Please input Name!"}]}
|
||||||
name="image_prove"
|
initialValue={store.authentication.profileData.superior?.id}
|
||||||
>
|
>
|
||||||
<div
|
<Input/>
|
||||||
style={{
|
</Form.Item>
|
||||||
display: "flex",
|
<Form.Item
|
||||||
justifyContent: "space-between",
|
label="Upload Picture"
|
||||||
alignItems: "center",
|
name="image_prove"
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<Upload
|
<Upload
|
||||||
name="image_prove"
|
listType="picture-card"
|
||||||
maxCount={1}
|
fileList={fileList}
|
||||||
className="avatar-uploader"
|
onPreview={(file) => {
|
||||||
// listType="picture-card"
|
setPreviewImage(file.url || file.filename);
|
||||||
action={appConfig.apiUrl + "/files"}
|
setPreviewVisible(file.url || file.filename);
|
||||||
fileList={fileList}
|
}}
|
||||||
beforeUpload={beforeUpload}
|
showUploadList={true}
|
||||||
onPreview={handlePreview}
|
onChange={handleChange}
|
||||||
onChange={handleChange}
|
beforeUpload={(file) => beforeUpload(file)}
|
||||||
|
customRequest={(args) => uploadHandler(args)}
|
||||||
|
onRemove={(file) => {
|
||||||
|
setImage('');
|
||||||
|
setLoading(false);
|
||||||
|
setFileList([]);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{!firstIndexFileList ? uploadButton : null}
|
|
||||||
|
{image === "" ? uploadButton : null}
|
||||||
</Upload>
|
</Upload>
|
||||||
<h5
|
<h5
|
||||||
style={{
|
style={{
|
||||||
marginTop: 12,
|
marginTop: 12,
|
||||||
color: "rgba(0, 0, 0, 0.45)",
|
color: "rgba(0, 0, 0, 0.45)",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Max size of file 2 mb
|
Max size of file 2 mb
|
||||||
</h5>
|
</h5>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
</Form.Item>
|
||||||
<h5>Preview</h5>
|
<Form.Item
|
||||||
<div>
|
name="amount"
|
||||||
<img
|
label="amount"
|
||||||
src={previewImage}
|
rules={[{required: true, message: "Please input Amount!"}]}
|
||||||
alt="preview"
|
>
|
||||||
style={{width: "100%"}}
|
<Input/>
|
||||||
/>
|
</Form.Item>
|
||||||
</div>
|
</Form>
|
||||||
<h5>{previewTitle}</h5>
|
</Modal>
|
||||||
<h5>
|
|
||||||
{previewUpload}
|
|
||||||
{previewTitle && <span>{`${previewTitle ?? ""}`}</span>}
|
|
||||||
</h5>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item
|
|
||||||
name="amount"
|
|
||||||
label="amount"
|
|
||||||
rules={[{required: true, message: "Please input Amount!"}]}
|
|
||||||
>
|
|
||||||
<Input/>
|
|
||||||
</Form.Item>
|
|
||||||
</Form>
|
|
||||||
</Modal>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,7 +63,7 @@ export const Product = observer(() => {
|
||||||
</Button>
|
</Button>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<div style={{display: 'flex', justifyContent: 'flex-end'}}>
|
<div style={{display: store.ui.mediaQuery.isMobile? "" :'flex',justifyContent: 'flex-end',textAlign: "right"}}>
|
||||||
<Search
|
<Search
|
||||||
placeholder="input search text"
|
placeholder="input search text"
|
||||||
style={{
|
style={{
|
||||||
|
|
|
@ -50,13 +50,16 @@ export const http = {
|
||||||
return req;
|
return req;
|
||||||
},
|
},
|
||||||
upload: (file) => {
|
upload: (file) => {
|
||||||
const request = superagent
|
let req = superagent
|
||||||
.post(appConfig.apiUrl + '/files')
|
.post(appConfig.apiUrl + '/config/upload-files')
|
||||||
.attach('file', file)
|
.attach('file', file)
|
||||||
.use(authIntercept)
|
.use(authIntercept)
|
||||||
.use(attachSuperagentLogger);
|
.use(attachSuperagentLogger);
|
||||||
|
if (TokenUtil.accessToken) {
|
||||||
|
req = req.set('Authorization', 'Bearer ' + TokenUtil.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
return request;
|
return req;
|
||||||
},
|
},
|
||||||
uploadAntd: (args) => {
|
uploadAntd: (args) => {
|
||||||
const file = args.file;
|
const file = args.file;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user