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 /> <Input />
</Form.Item> </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 && ( {!isChangePassword && (
<> <>
<Form.Item <Form.Item

View File

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

View File

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

View File

@ -1,50 +1,52 @@
import {makeAutoObservable} from "mobx"; import { makeAutoObservable } from "mobx";
import {http} from "../utils/http"; import { http } from "../utils/http";
export class Role { export class Role {
page = null; page = null;
pageSize = null; pageSize = null;
data = []; data = [];
total_data = 0 total_data = 0;
constructor(ctx) { constructor(ctx) {
this.ctx = ctx; this.ctx = ctx;
makeAutoObservable(this); makeAutoObservable(this);
} }
async getData() { async getData(isForMembership = false) {
try { try {
const response = await http.get(`/config/roles?page=${this.page}&pageSize=${this.pageSize}`); const response = await http.get(
this.data = response.body.data ?? [] `/config/roles${isForMembership ? "/for-membership" : ""}?page=${
this.total_data = response.body.total_data ?? 0 this.page
} catch (e) { }&pageSize=${this.pageSize}`
console.error(e); );
} this.data = response.body.data ?? [];
this.total_data = response.body.total_data ?? 0;
} catch (e) {
console.error(e);
} }
}
async create(data) { async create(data) {
try { try {
return await http.post('/users').send(data) return await http.post("/users").send(data);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
}
} }
}
async update(id, data) { async update(id, data) {
try { try {
return await http.put('/users/' + id).send(data); return await http.put("/users/" + id).send(data);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
}
} }
}
async delete(id) { async delete(id) {
try { try {
return await http.del('/users/' + id); return await http.del("/users/" + id);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
}
} }
}
} }