Browse Source

filter by company_id

pull/1/head
farhantock 1 year ago
parent
commit
49d46d394e
  1. 1
      src/views/SimproV2/ChecklistK3/index.js
  2. 3
      src/views/SimproV2/CreatedProyek/AsignCustProject.js
  3. 29
      src/views/SimproV2/CreatedProyek/AsignHrProject.js
  4. 5
      src/views/SimproV2/CreatedProyek/DialogAssignCust.js
  5. 21
      src/views/SimproV2/CreatedProyek/DialogFormProyek.js
  6. 86
      src/views/SimproV2/CreatedProyek/index.js

1
src/views/SimproV2/ChecklistK3/index.js

@ -285,6 +285,7 @@ const ChecklistK3 = ({ params }) => {
dataEdit={dataEdit}
clickOpenModal={clickOpenModal}
dataParent={allDataMenu}
company_id={company_id}
/>
<Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>

3
src/views/SimproV2/CreatedProyek/AsignCustProject.js

@ -13,7 +13,7 @@ import { NotificationContainer, NotificationManager } from 'react-notifications'
import SweetAlert from 'react-bootstrap-sweetalert';
import FormAsignCust from './DialogAssignCust';
const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName }) => {
const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, company_id }) => {
const token = localStorage.getItem("token")
const HEADER = {
headers: {
@ -200,6 +200,7 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy
closeDialog={handleCloseDialogFormTools}
toggleDialog={toogleDialogFormTools}
idTask={idTask}
company_id={company_id}
/>
</>
)

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

@ -4,14 +4,14 @@ import { Button, Form } from 'reactstrap';
import { Table, Tooltip, Spin } from 'antd';
import 'antd/dist/antd.css';
import moment from 'moment';
import { API_ADW, TOKEN_ADW, ASSIGN_HR_PROJECT_SEARCH, ASSIGN_HR_PROJECT_DELETE, USER_LIST, PROJECT_ROLE_SEARCH, ASSIGN_HR_PROJECT_ADD, ASSIGN_HR_PROJECT_EDIT } from '../../../const/ApiConst';
import { USER_SEARCH, ASSIGN_HR_PROJECT_SEARCH, ASSIGN_HR_PROJECT_DELETE, PROJECT_ROLE_SEARCH, ASSIGN_HR_PROJECT_ADD, ASSIGN_HR_PROJECT_EDIT } from '../../../const/ApiConst';
import axios from "../../../const/interceptorApi"
import { NotificationContainer, NotificationManager } from 'react-notifications';
import SweetAlert from 'react-bootstrap-sweetalert';
import FormAsignHr from './FormAsignHr';
import { formatThousand } from '../../../const/CustomFunc';
const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsResource, proyekName }) => {
const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, company_id, proyekName }) => {
const token = localStorage.getItem("token")
const HEADER = {
headers: {
@ -81,14 +81,29 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR
}
const getDataUser = async () => {
const HEADER_ADW = {
headers: {
"Authorization": `${TOKEN_ADW}`
const payload = {
"select": [
"id",
"name",
"role_id"
],
"paging": {
"start": 0,
"length": -1
},
"columns": [
{ "name": "company_id", "logic_operator": "=", "value": company_id },
],
"orders": {
"columns": [
"id"
],
"ascending": false
}
}
const result = await axios
// .get(`${API_ADW}employees`, HEADER_ADW)
.get(USER_LIST, HEADER)
.post(USER_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.data.length != 0) {

5
src/views/SimproV2/CreatedProyek/DialogAssignCust.js

@ -12,7 +12,7 @@ import 'antd/dist/antd.css';
import { NotificationManager } from 'react-notifications';
const role_id = localStorage.getItem('role_id');
const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask }) => {
const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask, company_id }) => {
const token = localStorage.getItem("token")
const HEADER = {
headers: {
@ -51,7 +51,8 @@ const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask }) =>
"length": -1
},
"columns": [
{ "name": "role_id", "logic_operator": "=", "value": 44 }
{ "name": "role_id", "logic_operator": "=", "value": 44 },
{ "name": "company_id", "logic_operator": "=", "value": company_id },
],
"orders": {
"columns": [

21
src/views/SimproV2/CreatedProyek/DialogFormProyek.js

@ -1,7 +1,7 @@
import React, { useEffect, useState, useMemo } from "react";
import { Modal, ModalHeader, ModalBody, ModalFooter } from "reactstrap";
import { Button, Form, FormGroup, Label, Input, Col, Row } from "reactstrap";
import { DatePicker, Tooltip, Select, Divider } from "antd";
import { DatePicker, Tooltip, Select, Divider, Spin } from "antd";
import axios from "../../../const/interceptorApi";
import moment from "moment";
import { CKEditor } from '@ckeditor/ckeditor5-react';
@ -88,8 +88,9 @@ const DialogFormProyek = ({
const [lastIdxRisks, setLastIdxRisks] = useState(0);
const [lastIdxMilestones, setLastIdxMilestones] = useState(0);
const [lastIdxApproval, setLastIdxApproval] = useState(0);
const [loading, setLoading] = useState(true);
const handleGetdataIdproyek = async (id) => {
setLoading(true)
const result = await axios
.get(`${PROYEK_GET_ID(id)}`, HEADER)
.then((res) => res)
@ -122,6 +123,7 @@ const DialogFormProyek = ({
setCurrencyCode(val.currency_code);
setCurrencySymbol(val.currency_symbol);
setCurrencyName(val.currency_name);
setLoading(false)
} else {
NotificationManager.error(`Data proyek gagal di edit`, `Failed!!`);
}
@ -457,8 +459,7 @@ const DialogFormProyek = ({
const handleInputChangeParticipants = (e, index) => {
const { name, value } = e.target;
const existingParticipant = participants.find((participant) => participant.tittle === "PM");
if(value.toLowerCase() === "pm" && name === "tittle" && existingParticipant)
{
if (value.toLowerCase() === "pm" && name === "tittle" && existingParticipant) {
alert('PM is already exist!');
setParticipants((prevParticipants) =>
prevParticipants.map((participant, i) => {
@ -1166,7 +1167,7 @@ const DialogFormProyek = ({
}
const RenderChecklist = () => {
if (checklist.length > 0) {
if (checklist?.length > 0) {
return checklist.map((item, index) => {
return (
<Row key={index} style={{ marginBottom: 10 }}>
@ -1280,7 +1281,7 @@ const DialogFormProyek = ({
};
const RenderRisk = () => {
if (potentialRisks.length > 0) {
if (potentialRisks?.length > 0) {
return potentialRisks.map((item, index) => {
return (
<Row key={index} style={{ marginBottom: 10 }}>
@ -1348,7 +1349,7 @@ const DialogFormProyek = ({
};
const RenderParticipants = () => {
if (participants.length > 0) {
if (participants?.length > 0) {
return participants.map((item, index) => {
return (
<Row key={index} style={{ marginBottom: 10 }}>
@ -1516,7 +1517,11 @@ const DialogFormProyek = ({
: "Add Project"
: "Project Charter"}
</ModalHeader>
<ModalBody>{ RenderFormProject() }</ModalBody>
<ModalBody>
<Spin tip="Loading..." spinning={loading}>
{RenderFormProject()}
</Spin>
</ModalBody>
<ModalFooter>
{step === 1 ? (
<>

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

@ -23,31 +23,23 @@ import {
} from "antd";
import {
PROJECT_APPROVAL_ADD,
PROJECT_APPROVAL_EDIT,
PROJECT_PARTICIPANT_ADD,
PROJECT_CHECKLIST_ADD,
PROJECT_ISSUE_ADD,
PROJECT_RISK_ADD,
PROJECT_PARTICIPANT_EDIT,
PROJECT_MILESTONE_ADD,
PROJECT_MILESTONE_EDIT,
PROJECT_PARTICIPANT_DELETE_BY_PROYEK,
PROJECT_MILESTONE_DELETE_BY_PROYEK,
PROJECT_APPROVAL_DELETE_BY_PROYEK,
USER_LIST,
TYPE_PROYEK,
USER_SEARCH,
PROJECT_TYPE_SEARCH,
PROYEK_ADD,
PROYEK_SEARCH,
PROYEK_SEARCH_BY_USER,
PROYEK_EDIT,
ASSIGN_HR_PROJECT_SEARCH,
PROJECT_CHECKLIST_SEARCH,
PROYEK_DELETE,
TOOLS_RESOURCE_SEARCH,
MATERIAL_RESOURCE_SEARCH,
USER_SEARCH,
PROJECT_CHARTER_SEARCH,
HIERARCHY_FTTH_SEARCH,
PROJECT_ISSUE_SEARCH,
PROJECT_RISK_SEARCH,
PROJECT_CHECKLIST_DELETE_BY_PROYEK,
@ -61,18 +53,15 @@ import {
PROJECT_APPROVAL_SEARCH,
CHECKLIST_K3_LIST,
VERSION_GANTT_SEARCH,
PHASE_PROYEK,
DIVISI_LIST,
PROJECT_PHASE_SEARCH,
DIVISI_SEARCH,
BASE_OSPRO,
IMAGE_UPLOAD,
IMAGE_GET_BY_ID,
IMAGE_DELETE,
} from "../../../const/ApiConst";
import {
formatNumber,
formatRupiah,
formatThousand,
renderFormatRupiah,
formatThousand
} from "../../../const/CustomFunc";
import moment from "moment";
// import DialogFormResource from './DialogFormResource';
@ -96,7 +85,7 @@ const url = "";
const format = "DD-MM-YYYY";
const CreatedProyek = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '';
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0;
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
@ -109,6 +98,7 @@ const CreatedProyek = ({ params, ...props }) => {
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
}
const history = useHistory();
const HEADER = {
@ -234,8 +224,17 @@ const CreatedProyek = ({ params, ...props }) => {
};
const handleGetTipeProject = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"columns": [
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
],
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.get(TYPE_PROYEK, HEADER)
.post(PROJECT_TYPE_SEARCH, payload, HEADER)
.then((res) => res)
.catch((err) => err.response);
if (result && result.data && result.data.code === 200) {
@ -245,8 +244,17 @@ const CreatedProyek = ({ params, ...props }) => {
};
const handleGetPhaseProject = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"columns": [
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
],
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.get(PHASE_PROYEK, HEADER)
.post(PROJECT_PHASE_SEARCH, payload, HEADER)
.then((res) => res)
.catch((err) => err.response);
if (result && result.data && result.data.code === 200) {
@ -255,8 +263,17 @@ const CreatedProyek = ({ params, ...props }) => {
};
const handleGetDivisions = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"columns": [
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
],
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.get(DIVISI_LIST, HEADER)
.post(DIVISI_SEARCH, payload, HEADER)
.then((res) => res)
.catch((err) => err.response);
if (result && result.data && result.data.code === 200) {
@ -266,9 +283,18 @@ const CreatedProyek = ({ params, ...props }) => {
}
};
const handleGetDataPm = async (text) => {
const handleGetDataPm = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"columns": [
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
],
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.get(USER_LIST, HEADER)
.post(USER_SEARCH, payload, HEADER)
.then((res) => res)
.catch((err) => err.response);
if (result && result.data && result.data.code === 200) {
@ -304,6 +330,7 @@ const CreatedProyek = ({ params, ...props }) => {
};
const getDataProyek = async () => {
setLoading(true);
let start = 0;
let hierarchy = [];
hierarchy.push(JSON.parse(localStorage.getItem("hierarchy")));
@ -468,10 +495,6 @@ const CreatedProyek = ({ params, ...props }) => {
}
};
const handleOpenDialog = (id) => {
setOpenDialog(true);
setidTask(id);
};
const handleOpenDialogProyek = async (id) => {
setOpenDialogProyek(true);
@ -531,12 +554,6 @@ const CreatedProyek = ({ params, ...props }) => {
setOpenDialogAssignK3(true);
};
const handleOpenDialogTools = (data) => {
setOpenDialogTools(true);
setidTask(data.id);
setProyekName(data.nama);
setUserProyek(data.user_proyeks);
};
const handleOpenDialogViewDetail = async (data) => {
setLoading(true);
@ -1132,6 +1149,7 @@ const CreatedProyek = ({ params, ...props }) => {
};
const editProyek = async (data) => {
setLoading(true)
const { checklist, issue, potentialRisks, participants, milestones, approval } = data.projectCharter;
const imageObject = data.imageStructureOrg;
@ -1852,6 +1870,7 @@ const CreatedProyek = ({ params, ...props }) => {
handleClose={handleCloseDialogAsignHr}
idTask={idTask}
proyekName={proyekName}
company_id={company_id}
/>
),
[openDialogAsignHR]
@ -1867,6 +1886,7 @@ const CreatedProyek = ({ params, ...props }) => {
handleClose={handleCloseDialogAsignCust}
idTask={idTask}
proyekName={proyekName}
company_id={company_id}
/>
),
[openDialogAsignCust]

Loading…
Cancel
Save