Browse Source

Merge pull request 'Dev-Farhan' (#7) from Dev-Farhan into staging

Reviewed-on: ibnu/generic-ospro-frontend#7
pull/1/head
farhantock 10 months ago
parent
commit
d5a4e9e815
  1. 1
      src/views/Master/MasterRoles/DialogForm.js
  2. 61
      src/views/Master/MasterRoles/index.js
  3. 40
      src/views/Master/ProjectPhase/index.js
  4. 18
      src/views/Master/RoleProject/index.js
  5. 10
      src/views/Pages/Login/Login.js
  6. 35
      src/views/SimproV2/Divisi/index.js
  7. 6
      src/views/SimproV2/Gantt/index.js
  8. 42
      src/views/SimproV2/ProjectType/index.js
  9. 45
      src/views/SimproV2/ResourceWorker/index.js
  10. 36
      src/views/SimproV2/Satuan/index.js

1
src/views/Master/MasterRoles/DialogForm.js

@ -37,7 +37,6 @@ class DialogForm extends Component {
this.props.showDialog(this.showDialog);
this.getAllMenu();
}
async componentDidUpdate() {
if (this.state.isParentClick === true) {
if (this.props.typeDialog === "Edit") {

61
src/views/Master/MasterRoles/index.js

@ -11,28 +11,33 @@ import { Pagination, Tooltip, Table } from 'antd';
import { ROLE_ADD, ROLE_SEARCH, ROLE_EDIT, ROLE_DELETE, ROLEMENU_ADD, ROLEMENU_SEARCH, ROLEMENU_DELETE_ROLE } from '../../../const/ApiConst.js';
import { withTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token');
const company_id = window.localStorage.getItem('company_id');
const role_name = window.localStorage.getItem('role_name');
const BASE_URL = "http://siopas.co.id/custom-php/api/geohr/";
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const momentFormat = 'HH:mm';
const LENGTH_DATA = 10
class index extends Component {
constructor(props) {
let role_id = '', user_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
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;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
company_id = props.location.state.company_id;
role_name = props.location.state.role_name;
} else {
token = window.localStorage.getItem('token');
role_name = window.localStorage.getItem('role_name');
company_id = window.localStorage.getItem('company_id');
}
super(props)
this.config = {
headers: {
Authorization: `Bearer ${token}`,
"Content-type": "application/json"
}
};
this.state = {
alertDelete: false,
alertNotDelete: false,
@ -58,9 +63,9 @@ class index extends Component {
tooltipTambah: false,
totalPage: 0,
typeDialog: 'Save',
company_id: company_id
company_id: company_id,
role_name: role_name
}
this.columns = [
{
title: this.props.t('action'),
@ -117,7 +122,7 @@ class index extends Component {
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if (role_name !== "Super Admin") {
if (this.state.role_name !== "Super Admin") {
formData.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" },
)
@ -127,7 +132,7 @@ class index extends Component {
)
}
const result = await axios
.post(ROLE_SEARCH, formData, config)
.post(ROLE_SEARCH, formData, this.config)
.then(res => res)
.catch((error) => error.response);
@ -172,7 +177,7 @@ class index extends Component {
const { idDelete } = this.state
const url = ROLE_DELETE(idDelete)
const result = await axios.delete(url, config)
const result = await axios.delete(url, this.config)
.then(res => res)
.catch((error) => error.response);
@ -193,10 +198,10 @@ class index extends Component {
name: data.name,
description: data.description,
default_page: data.selectedMenu,
company_id: company_id
company_id: this.company_id
}
const result = await axios.post(ROLE_ADD, formData, config)
const result = await axios.post(ROLE_ADD, formData, this.config)
.then(res => res)
.catch((error) => error.response);
@ -216,7 +221,7 @@ class index extends Component {
default_page: data.selectedMenu
}
const url = ROLE_EDIT(data.id)
const result = await axios.put(url, formData, config)
const result = await axios.put(url, formData, this.config)
.then(res => res)
.catch((error) => error.response);
@ -285,7 +290,7 @@ class index extends Component {
}
const result = await axios
.post(ROLEMENU_SEARCH, formData, config)
.post(ROLEMENU_SEARCH, formData, this.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
@ -309,7 +314,7 @@ class index extends Component {
menu_id: val.menu_id,
role_id: val.roles_id
}
promises.push(axios.post(ROLEMENU_ADD, formData, config)
promises.push(axios.post(ROLEMENU_ADD, formData, this.config)
.then(res => result.push(res)))
}
})
@ -329,7 +334,7 @@ class index extends Component {
deleteCurrentRoleMenu = async (id) => {
let urlDel = ROLEMENU_DELETE_ROLE(id)
const result = await axios.delete(urlDel, config)
const result = await axios.delete(urlDel, this.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
@ -352,7 +357,7 @@ class index extends Component {
}
const result = await axios
.post(ROLE_SEARCH, formData, config)
.post(ROLE_SEARCH, formData, this.config)
.then(res => res)
.catch((error) => error.response);

40
src/views/Master/ProjectPhase/index.js

@ -9,27 +9,27 @@ import { NotificationContainer, NotificationManager } from 'react-notifications'
import { PROJECT_PHASE_ADD, PROJECT_PHASE_EDIT, PROJECT_PHASE_DELETE, PROJECT_PHASE_SEARCH, PROJECT_PHASE_LIST, BASE_OSPRO } from '../../../const/ApiConst';
import { Pagination, Button, Tooltip, Table } from 'antd';
import { useTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token');
const company_id = window.localStorage.getItem('company_id');
const role_name = window.localStorage.getItem('role_name');
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
}
};
const ProjectPhase = ({ params }) => {
const token = localStorage.getItem("token")
const company_id = localStorage.getItem("company_id")
/*const HEADER = {
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"Access-Control-Allow-Origin": "*",
"Authorization": `Bearer ${token}`
const ProjectPhase = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
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;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
role_name = props.location.state.role_name;
} else {
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
}
}*/
console.log('company_id', company_id);
const HEADER = {
headers: {
"Content-Type": "application/json",
@ -257,7 +257,7 @@ const ProjectPhase = ({ params }) => {
const onConfirmDelete = async () => {
let url = PROJECT_PHASE_DELETE(idDelete);
const result = await axios.delete(url, config)
const result = await axios.delete(url, HEADER)
.then(res => res)
.catch((error) => error.response);

18
src/views/Master/RoleProject/index.js

@ -35,6 +35,19 @@ const LENGTH_DATA = 10
class index extends Component {
constructor(props) {
let role_id = '', user_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
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;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
company_id = props.location.state.company_id;
role_name = props.location.state.role_name;
} else {
token = window.localStorage.getItem('token');
role_name = window.localStorage.getItem('role_name');
company_id = window.localStorage.getItem('company_id');
}
super(props)
this.state = {
alertDelete: false,
@ -61,7 +74,8 @@ class index extends Component {
tooltipTambah: false,
totalPage: 0,
typeDialog: 'Save',
company_id
company_id: company_id,
role_name: role_name
}
this.columns = [
{
@ -115,7 +129,7 @@ class index extends Component {
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if (role_name !== "Super Admin") {
if (this.state.role_name !== "Super Admin") {
formData.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" },
)

10
src/views/Pages/Login/Login.js

@ -133,7 +133,7 @@ class Login extends Component {
}
}
getDataMenu = async (token, role_id, user_id) => {
getDataMenu = async (token, role_id, user_id, company_id, role_name) => {
const config = {
headers:
{
@ -159,14 +159,14 @@ class Login extends Component {
else {
this.props.history.push({
pathname: "/dashboard",
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true }
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name }
});
}
if (this.state.defaultPage) {
if (role_id === 44) {
this.props.history.push({
pathname: this.state.defaultPage,
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true }
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name }
});
} else {
this.props.history.push(this.state.defaultPage);
@ -177,7 +177,7 @@ class Login extends Component {
else {
this.props.history.push({
pathname: "/dashboard",
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true }
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name }
});
}
} else {
@ -222,7 +222,7 @@ class Login extends Component {
if (doLogin && doLogin.data && doLogin.data.code === 200) {
const { access_token, data_user } = doLogin.data.data
this.getDataRole(access_token, data_user.role_id)
this.getDataMenu(access_token, data_user.role_id, data_user.id)
this.getDataMenu(access_token, data_user.role_id, data_user.id, data_user.company_id, data_user.role.name)
window.localStorage.setItem('isLogin', true);
window.localStorage.setItem('token', access_token);
window.localStorage.setItem('user_id', data_user.id);

35
src/views/SimproV2/Divisi/index.js

@ -9,20 +9,6 @@ import { NotificationContainer, NotificationManager } from 'react-notifications'
import { Pagination, Button, Tooltip } from 'antd';
import { useTranslation } from 'react-i18next';
const url = "";
const proyek_id = localStorage.getItem('proyek_id');
const role_id = localStorage.getItem('role_id');
const company_id = localStorage.getItem("company_id")
const role_name = window.localStorage.getItem('role_name');
const format = "DD-MM-YYYY";
const token = window.localStorage.getItem('token');
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const column = [
{ name: "Nama" },
@ -30,8 +16,23 @@ const column = [
{ name: "Color" },
]
const ProjectType = ({ params }) => {
const token = localStorage.getItem("token")
const ProjectType = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
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;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
role_name = props.location.state.role_name;
} else {
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
}
const HEADER = {
headers: {
"Content-Type": "application/json",
@ -256,7 +257,7 @@ const ProjectType = ({ params }) => {
const onConfirmDelete = async () => {
let url = DIVISI_DELETE(idDelete);
const result = await axios.delete(url, config)
const result = await axios.delete(url, HEADER)
.then(res => res)
.catch((error) => error.response);

6
src/views/SimproV2/Gantt/index.js

@ -15,7 +15,7 @@ import GanttFrame from "./GanttFrame";
let roCount = 0;
const Gantt = (props) => {
let role_id = '', userId='',isLogin='',token='';
let role_id = '', userId = '', isLogin = '', token = '';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
userId = props.location.state.user_id;
@ -56,7 +56,7 @@ const Gantt = (props) => {
cekPermission();
}, [listUserGant]);
useEffect(() => {}, [ro]);
useEffect(() => { }, [ro]);
const getDataUserGantt = async () => {
const payload = {
@ -94,7 +94,7 @@ const Gantt = (props) => {
};
const cekPermission = () => {
let check = listUserGant.includes(userId);
let check = listUserGant.includes(parseInt(userId));
if (check) {
setRo(0);
} else {

42
src/views/SimproV2/ProjectType/index.js

@ -11,28 +11,24 @@ import { NotificationContainer, NotificationManager } from 'react-notifications'
import { PROJECT_TYPE_ADD, PROJECT_TYPE_EDIT, PROJECT_TYPE_DELETE, PROJECT_TYPE_SEARCH } from '../../../const/ApiConst';
import { Pagination, Button, Tooltip, Table } from 'antd';
import { useTranslation } from 'react-i18next';
const url = "";
const proyek_id = localStorage.getItem('proyek_id');
const role_id = localStorage.getItem('role_id');
const format = "DD-MM-YYYY";
const token = window.localStorage.getItem('token');
const company_id = window.localStorage.getItem('company_id');
const role_name = window.localStorage.getItem('role_name');
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const column = [
{ name: "Nama" },
{ name: "Deskripsi" },
]
const ProjectType = ({ params }) => {
const token = localStorage.getItem("token")
const ProjectType = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
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;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
role_name = props.location.state.role_name;
} else {
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
}
const HEADER = {
headers: {
"Content-Type": "application/json",
@ -106,7 +102,7 @@ const ProjectType = ({ params }) => {
)
}
const result = await axios
.post(PROJECT_TYPE_SEARCH, payload, config, HEADER)
.post(PROJECT_TYPE_SEARCH, payload, HEADER, HEADER)
.then(res => res)
.catch((error) => error.response);
@ -263,7 +259,7 @@ const ProjectType = ({ params }) => {
const onConfirmDelete = async () => {
let url = PROJECT_TYPE_DELETE(idDelete);
const result = await axios.delete(url, config)
const result = await axios.delete(url, HEADER)
.then(res => res)
.catch((error) => error.response);

45
src/views/SimproV2/ResourceWorker/index.js

@ -13,24 +13,25 @@ import {
PROYEK_SEARCH, USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH, USER_SHIFT_ADD, USER_SYNC
} from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next';
const url = "";
const proyek_id = localStorage.getItem('proyek_id');
const role_id = localStorage.getItem('role_id');
const format = "DD-MM-YYYY";
const token = window.localStorage.getItem('token');
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const role_name = window.localStorage.getItem('role_name');
const company_id = window.localStorage.getItem('company_id');
const ResourceWorker = ({ params }) => {
const token = localStorage.getItem("token")
const company_id = localStorage.getItem("company_id")
const ResourceWorker = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
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;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
role_name = props.location.state.role_name;
} else {
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
}
const HEADER = {
headers: {
"Content-Type": "application/json",
@ -90,7 +91,7 @@ const ResourceWorker = ({ params }) => {
}
const result = await axios
.post(ROLE_SEARCH, formData, config)
.post(ROLE_SEARCH, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
@ -106,7 +107,7 @@ const ResourceWorker = ({ params }) => {
}
const result = await axios
.post(DIVISI_SEARCH, formData, config)
.post(DIVISI_SEARCH, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
@ -215,7 +216,7 @@ const ResourceWorker = ({ params }) => {
}
const result = await axios
.post(USER_SEARCH, payload, config)
.post(USER_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
@ -468,7 +469,7 @@ const ResourceWorker = ({ params }) => {
const onConfirmDelete = async () => {
let url = USER_DELETE(idDelete);
const result = await axios.delete(url, config)
const result = await axios.delete(url, HEADER)
.then(res => res)
.catch((error) => error.response);

36
src/views/SimproV2/Satuan/index.js

@ -9,20 +9,24 @@ import { Pagination, Button, Tooltip } from 'antd';
import { SATUAN_ADD, SATUAN_EDIT, SATUAN_DELETE, SATUAN_SEARCH } from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token');
const company_id = window.localStorage.getItem('company_id');
const role_name = window.localStorage.getItem('role_name');
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const Satuan = ({ params }) => {
const token = localStorage.getItem("token")
const company_id = localStorage.getItem("company_id")
const Satuan = ({ params, ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, role_name = '';
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;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
role_name = props.location.state.role_name;
} else {
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
company_id = localStorage.getItem('company_id');
role_name = localStorage.getItem('role_name');
}
const HEADER = {
headers: {
"Content-Type": "application/json",
@ -101,7 +105,7 @@ const Satuan = ({ params }) => {
const result = await axios
.post(SATUAN_SEARCH, payload, config)
.post(SATUAN_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
@ -132,7 +136,7 @@ const Satuan = ({ params }) => {
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(SATUAN_SEARCH, payload, config)
.post(SATUAN_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
@ -218,7 +222,7 @@ const Satuan = ({ params }) => {
const onConfirmDelete = async () => {
let url = SATUAN_DELETE(idDelete);
const result = await axios.delete(url, config)
const result = await axios.delete(url, HEADER)
.then(res => res)
.catch((error) => error.response);

Loading…
Cancel
Save