feat: add number format

This commit is contained in:
rarsyansyahr 2021-12-17 13:30:35 +07:00
parent 8c9a3b05de
commit b1317d141c
4 changed files with 63 additions and 46 deletions

View File

@ -286,7 +286,19 @@ export const PartnerComponent = observer((props) => {
<Input />
</Form.Item>
)}
{!idData && (
<Form.Item
name="phone_number"
label="Phone Number"
rules={[
idData
? { required: false }
: { required: true, message: "Please input password phone number!" },
]}
>
<Input />
</Form.Item>
)}
{!isChangePassword && (
<>
<Form.Item

View File

@ -66,10 +66,12 @@ export const SupplierComponent = observer((props) => {
key: ["coa", "amount"],
width: "20%",
render: (text, record) =>
new Intl.NumberFormat("id-ID", {
text
? new Intl.NumberFormat("id-ID", {
style: "currency",
currency: "IDR",
}).format(text),
}).format(text)
: "-",
},
{
title: "Status",

View File

@ -43,10 +43,11 @@ export const Membership = observer(() => {
const init = async () => {
try {
setIsLoading(true);
const isAdmin = store.authentication.userData.role === "Admin";
await getData();
store.role.getData();
if (store.authentication.userData.role === "Admin")
await store.supplier.getData();
await store.role.getData(isAdmin);
if (isAdmin) await store.supplier.getData();
setIsLoading(false);
} catch (e) {
setIsLoading(false);

View File

@ -5,18 +5,22 @@ export class Role {
page = null;
pageSize = null;
data = [];
total_data = 0
total_data = 0;
constructor(ctx) {
this.ctx = ctx;
makeAutoObservable(this);
}
async getData() {
async getData(isForMembership = false) {
try {
const response = await http.get(`/config/roles?page=${this.page}&pageSize=${this.pageSize}`);
this.data = response.body.data ?? []
this.total_data = response.body.total_data ?? 0
const response = await http.get(
`/config/roles${isForMembership ? "/for-membership" : ""}?page=${
this.page
}&pageSize=${this.pageSize}`
);
this.data = response.body.data ?? [];
this.total_data = response.body.total_data ?? 0;
} catch (e) {
console.error(e);
}
@ -24,7 +28,7 @@ export class Role {
async create(data) {
try {
return await http.post('/users').send(data)
return await http.post("/users").send(data);
} catch (e) {
console.error(e);
}
@ -32,7 +36,7 @@ export class Role {
async update(id, data) {
try {
return await http.put('/users/' + id).send(data);
return await http.put("/users/" + id).send(data);
} catch (e) {
console.error(e);
}
@ -40,11 +44,9 @@ export class Role {
async delete(id) {
try {
return await http.del('/users/' + id);
return await http.del("/users/" + id);
} catch (e) {
console.error(e);
}
}
}