Browse Source

update method request post to get in getDataProyekByCustomer

pull/2/head
wahyuun 1 year ago
parent
commit
b5a369f9fa
  1. 4
      src/const/ApiConst.js
  2. 51
      src/views/SimproV2/CreatedProyek/index.js

4
src/const/ApiConst.js

@ -364,7 +364,9 @@ export const PROYEK_ADD = `${BASE_SIMPRO_LUMEN}/project/add`;
export const PROYEK_LIST = `${BASE_SIMPRO_LUMEN}/project/list`;
export const PROYEK_SEARCH = `${BASE_SIMPRO_LUMEN}/project/search`;
export const PROYEK_SEARCH_DETAIL = `${BASE_SIMPRO_LUMEN}/project/search`;
export const PROYEK_SEARCH_BY_USER = `${BASE_SIMPRO_LUMEN}/project-by-customer`;
// export const PROYEK_SEARCH_BY_USER = (id) => {
// return `${BASE_SIMPRO_LUMEN}/project-by-customer/${id}`;
// };
export const PROYEK_GET_ID = (id) => {
return `${BASE_SIMPRO_LUMEN}/project/edit/${id}`;
};

51
src/views/SimproV2/CreatedProyek/index.js

@ -321,61 +321,14 @@ const CreatedProyek = ({ params, ...props }) => {
};
const getDataProyekByCustomer = async () => {
let start = 0;
if (currentPage !== 1 && currentPage > 1) {
start = currentPage * rowsPerPage - rowsPerPage;
}
const payload = {
columns: [
{
name: "nama",
logic_operator: "ilike",
value: search,
operator: "AND",
},
],
select: [
"id",
"nama",
"rencana_biaya",
"type_proyek_id",
"currency_symbol",
"mulai_proyek",
"akhir_proyek",
],
joins: [
{
name: "m_users",
column_join: "user_id",
column_results: ["name", "username"],
},
{
name: "m_proyek",
column_join: "proyek_id",
column_results: ["type_proyek_id"],
},
],
orders: { columns: ["id"], ascending: false },
paging: { start: start, length: rowsPerPage },
user_id: { user_id: user_id }
};
if (parseInt(role_id) !== 1) {
payload["columns"] = [
{ name: "id", logic_operator: "=", value: proyek_id, operator: "AND" },
];
}
const url = `${BASE_OSPRO}/api/project-by-customer/${user_id}`;
const result = await axios
.post(PROYEK_SEARCH_BY_USER, payload, HEADER)
.get(url, HEADER)
.then((res) => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || [];
setDatatable(dataRes);
setTotalPage(result.data.totalRecord);
setLoading(false);

Loading…
Cancel
Save