Browse Source

add endpoint project-by-customer

pull/2/head
wahyuun 1 year ago
parent
commit
b5e59d40db
  1. 1
      src/const/ApiConst.js
  2. 29
      src/views/SimproV2/CreatedProyek/index.js

1
src/const/ApiConst.js

@ -364,6 +364,7 @@ export const PROYEK_ADD = `${BASE_SIMPRO_LUMEN}/project/add`;
export const PROYEK_LIST = `${BASE_SIMPRO_LUMEN}/project/list`; export const PROYEK_LIST = `${BASE_SIMPRO_LUMEN}/project/list`;
export const PROYEK_SEARCH = `${BASE_SIMPRO_LUMEN}/project/search`; export const PROYEK_SEARCH = `${BASE_SIMPRO_LUMEN}/project/search`;
export const PROYEK_SEARCH_DETAIL = `${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_GET_ID = (id) => { export const PROYEK_GET_ID = (id) => {
return `${BASE_SIMPRO_LUMEN}/project/edit/${id}`; return `${BASE_SIMPRO_LUMEN}/project/edit/${id}`;
}; };

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

@ -35,6 +35,7 @@ import {
TYPE_PROYEK, TYPE_PROYEK,
PROYEK_ADD, PROYEK_ADD,
PROYEK_SEARCH, PROYEK_SEARCH,
PROYEK_SEARCH_BY_USER,
PROYEK_EDIT, PROYEK_EDIT,
PROYEK_DELETE, PROYEK_DELETE,
TOOLS_RESOURCE_SEARCH, TOOLS_RESOURCE_SEARCH,
@ -80,6 +81,7 @@ import { Link, useHistory } from "react-router-dom";
const url = ""; const url = "";
const proyek_id = localStorage.getItem("proyek_id"); const proyek_id = localStorage.getItem("proyek_id");
const role_id = localStorage.getItem("role_id"); const role_id = localStorage.getItem("role_id");
const user_id = localStorage.getItem("user_id");
const format = "DD-MM-YYYY"; const format = "DD-MM-YYYY";
const CreatedProyek = ({ params, ...props }) => { const CreatedProyek = ({ params, ...props }) => {
@ -247,16 +249,17 @@ const CreatedProyek = ({ params, ...props }) => {
joins: [ joins: [
{ {
name: "m_users", name: "m_users",
column_join: "pm_id", column_join: "user_id",
column_results: ["name", "username", "role_id"], column_results: ["name", "username"],
}, },
{ {
name: "m_type_proyek", name: "m_proyek",
column_join: "type_proyek_id", column_join: "proyek_id",
column_results: ["name", "description"], column_results: ["type_proyek_id"],
}, },
// { "name": "subproyeks.m_subproyek", "column_join": "parent_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual"] } // { "name": "subproyeks.m_subproyek", "column_join": "parent_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual"] }
], ],
user_id: { user_id: user_id },
orders: { columns: ["id"], ascending: false }, orders: { columns: ["id"], ascending: false },
paging: { start: start, length: rowsPerPage }, paging: { start: start, length: rowsPerPage },
}; };
@ -268,16 +271,16 @@ const CreatedProyek = ({ params, ...props }) => {
} }
const result = await axios const result = await axios
.post(PROYEK_SEARCH, payload, HEADER) .post(PROYEK_SEARCH_BY_USER, payload, HEADER)
// .then((res) => res) .then((res) => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || []; let dataRes = result.data.data || [];
const filteredData = dataRes.filter( // const filteredData = dataRes.filter(
(item) => item.join_first_role_id === parseInt(role_id) // (item) => item.join_first_role_id === parseInt(role_id)
); // );
setDatatable(filteredData); setDatatable(dataRes);
setTotalPage(result.data.totalRecord); setTotalPage(result.data.totalRecord);
} else { } else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed"); NotificationManager.error("Gagal Mengambil Data!!", "Failed");
@ -895,7 +898,7 @@ const CreatedProyek = ({ params, ...props }) => {
const data = resData.map((elt) => [ const data = resData.map((elt) => [
elt.nama, elt.nama,
`Rp. ${formatThousand(elt.rencana_biaya)}`, `Rp. ${formatThousand(elt.rencana_biaya)}`,
elt.join_second_name, elt.nama_type_proyek,
elt.join_first_name, elt.join_first_name,
`${moment(elt.mulai_proyek).format(format)} - ${moment( `${moment(elt.mulai_proyek).format(format)} - ${moment(
elt.akhir_proyek elt.akhir_proyek
@ -1162,7 +1165,7 @@ const CreatedProyek = ({ params, ...props }) => {
dataIndex: "color_progress", dataIndex: "color_progress",
key: "color_progress", key: "color_progress",
render: (text, record) => ( render: (text, record) => (
<>{record.join_second_name ? record.join_second_name : "-"}</> <>{record.nama_type_proyek ? record.nama_type_proyek : "-"}</>
), ),
}, },
{ {

Loading…
Cancel
Save