Commit 38aa7fd8 authored by PDuarte's avatar PDuarte

improvemens

parent 6ee4cc5f
SKIP_PREFLIGHT_CHECK=true
REACT_APP_BASENAME= "/cms/"
REACT_APP_API2="http://192.168.99.100:8001/cms"
REACT_APP_API="http://134.209.18.22/cmsapi"
REACT_APP_BASENAME=/cms
REACT_APP_API="http://192.168.99.100:8001/cms"
REACT_APP_API1="http://134.209.18.22/cmsapi"
SKIP_PREFLIGHT_CHECK=true
REACT_APP_BASENAME= "/cms/"
REACT_APP_API2="http://192.168.99.100:8001/cms"
REACT_APP_API="http://134.209.18.22/cmsapi"
......@@ -92,7 +92,7 @@
},
"scripts": {
"start": "react-app-rewired start",
"build": "env-cmd -f .env.production react-app-rewired build",
"build": "env-cmd -f .env.production.local react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-app-rewired eject",
"lint": "eslint src/**/*.js src/**/*.jsx",
......
......@@ -14,7 +14,7 @@ import calendar from '@src/views/apps/calendar/store/reducer'
import ecommerce from '@src/views/apps/ecommerce/store/reducer'
import dataTables from '@src/views/tables/data-tables/store/reducer'
import Settings from '@src/views/settings/store/reducer'
import settings from '@src/views/settings/store/reducer'
const rootReducer = combineReducers({
auth,
......@@ -28,7 +28,7 @@ const rootReducer = combineReducers({
calendar,
ecommerce,
dataTables,
Settings
settings
})
export default rootReducer
......@@ -17,7 +17,7 @@ import { Card, CardHeader, CardTitle, Input, Label, Row, Col } from 'reactstrap'
const DataTableServerSide = () => {
// ** Store Vars
const dispatch = useDispatch()
const store = useSelector(state => state.Settings)
const store = useSelector(state => state.settings)
// ** States
const [currentPage, setCurrentPage] = useState(1)
......
......@@ -259,7 +259,7 @@ export const serverSideColumns = [
<Link
to={`/settings/projects/edit/${row.id}`}
className='user-name text-truncate mb-0'
onClick={() => store.dispatch(getProject(row.id))}
// onClick={() => store.dispatch(getProject(row.id))}
>
<span className='font-weight-bold'>{row.app_name}</span>
</Link>
......
......@@ -3,12 +3,8 @@ import { useParams, Link } from 'react-router-dom'
// ** Store & Actions
import { getProject, updateProject } from '../../store/actions'
import { store } from '@store/storeConfig/store'
import { useSelector, useDispatch } from 'react-redux'
import { useForm } from 'react-hook-form'
import classnames from 'classnames'
// ** Utils
import { isObjEmpty } from '@utils'
......@@ -16,52 +12,44 @@ import { isObjEmpty } from '@utils'
import { Lock, Edit, Trash2 } from 'react-feather'
import {Media, Button, Label, Form, FormGroup, Input, Table, CustomInput, Card, CardBody, Row, Col, Nav, NavItem, NavLink, TabContent, TabPane, Alert } from 'reactstrap'
import { isEmptyObject } from 'jquery'
import ProjectCard from './projectCard'
import ProjectPlatform from './plataform'
import { useForm } from 'react-hook-form'
import classnames from 'classnames'
const ProjectsEdit = () => {
// ** States & Vars
const [activeTab, setActiveTab] = useState('1'),
storeSettings = useSelector(state => state.Settings),
[ProjectData, setProjectData] = useState(null),
const store = useSelector(state => state.settings),
[dataProject, setProjectData] = useState(null),
{ register, errors, handleSubmit } = useForm(),
dispatch = useDispatch(),
{ id } = useParams()
// ** Function to toggle tabs
const toggle = tab => setActiveTab(tab)
// ** Vars
const { register, errors, handleSubmit } = useForm()
// ** Function to handle form submit
const onSubmit = values => {
if (isObjEmpty(errors)) {
dispatch(
updateProject({
id: values.id,
app_name: values.app_name,
customer_name: values.customer_name
})
)
}
}
// ** Function to get user on mount
useEffect(() => {
console.log('eff')
console.log(storeSettings.selectedProject)
// if (storeSettings.selectedProject === null && storeSettings.selectedProject !== undefined)
store.dispatch(getProject(parseInt(id)))
// console.log('eff')
// console.log(store.selectedProject)
dispatch(getProject(id))
}, [dispatch])
return storeSettings.selectedProject !== null && storeSettings.selectedProject !== undefined ? (
// ** Update user image on mount or change
useEffect(() => {
if (store.selectedProject !== null || (store.selectedProject !== null && dataProject !== null && store.selectedProject.id !== dataProject.id)) {
return setProjectData(store.selectedProject)
}
}, [store.selectedProject])
return store.selectedProject !== null && store.selectedProject !== undefined ? (
<Row>
<Col sm='12'>
<Form onSubmit={handleSubmit(onSubmit)}>
<Form
// onSubmit={handleSubmit(onSubmit)}
>
<Row>
<Col md='4' sm='12'>
<FormGroup>
......@@ -72,7 +60,7 @@ const ProjectsEdit = () => {
name='id'
id='id'
innerRef={register({ required: true })}
placeholder=''
placeholder='id'
defaultValue={id}
/>
</FormGroup>
......@@ -86,7 +74,7 @@ const ProjectsEdit = () => {
id='app_name'
innerRef={register({ required: true })}
placeholder='Project Name'
defaultValue={storeSettings.selectedProject && storeSettings.selectedProject.data.app_name}
defaultValue={dataProject && dataProject.app_name}
className={classnames({ 'is-invalid': errors['app_name'] })}
/>
</FormGroup>
......@@ -100,7 +88,7 @@ const ProjectsEdit = () => {
id='customer_name'
innerRef={register({ required: true })}
placeholder='Client Name'
defaultValue={storeSettings.selectedProject && storeSettings.selectedProject.data.customer_name}
defaultValue={dataProject && dataProject.customer_name}
className={classnames({ 'is-invalid': errors['customer_name'] })}
/>
</FormGroup>
......@@ -172,6 +160,7 @@ const ProjectsEdit = () => {
</tbody>
</Table>
</div>
{/* <ProjectPlatform /> */}
</Col>
<Col className='d-flex flex-sm-row flex-column mt-2' sm='12'>
<Button.Ripple className='mb-1 mb-sm-0 mr-0 mr-sm-1' type='submit' color='primary'>
......@@ -180,11 +169,12 @@ const ProjectsEdit = () => {
<Button.Ripple color='secondary' outline>
Reset
</Button.Ripple>
{storeSettings.saveSucces ? 'sim' : 'nao'}
{storeSettings.errorMsg}
</Col>
</Row>
</Form>
{/* <ProjectCard selectedProject={dataProject} /> */}
{/* {saveSucces ? 'sim' : 'nao'}
{errorMsg} */}
</Col>
</Row>
) : (
......@@ -192,7 +182,6 @@ const ProjectsEdit = () => {
<h4 className='alert-heading'>Project not found</h4>
<div className='alert-body'>
User with id: {id} doesn't exist. Check list of all Projects: <Link to='/settings/projects'>Projects List</Link>
{store.Settings}
</div>
</Alert>
)
......
import {Media, Button, Label, Form, FormGroup, Input, Table, CustomInput, Card, CardBody, Row, Col, Nav, NavItem, NavLink, TabContent, TabPane, Alert } from 'reactstrap'
// ** Styles
import '@styles/react/apps/app-users.scss'
const ProjectPlatform = () => {
return (
<div clssName='permissions border mt-1'>
<h6 className='py-1 mx-1 mb-0 font-medium-2'>
<Lock size={18} className='mr-25' />
<span className='align-middle'>Platforms</span>
</h6>
<Table borderless striped responsive>
<thead className='thead-light'>
<tr>
<th>Platforms</th>
<th>Active</th>
</tr>
</thead>
<tbody>
<tr>
<td>IOS</td>
<td>
<CustomInput type='checkbox' id='admin-1' label='' defaultChecked />
</td>
</tr>
<tr>
<td>Android</td>
<td>
<CustomInput type='checkbox' id='staff-1' label='' />
</td>
</tr>
<tr>
<td>Android Tv</td>
<td>
<CustomInput type='checkbox' id='author-1' label='' defaultChecked />
</td>
</tr>
<tr>
<td>Roku</td>
<td>
<CustomInput type='checkbox' id='contributor-1' label='' />
</td>
</tr>
<tr>
<td>STV</td>
<td>
<CustomInput type='checkbox' id='user-1' label='' />
</td>
</tr>
</tbody>
</Table>
</div>
)
}
export default ProjectPlatform
// ** React Imports
import { useState, useEffect, Fragment } from 'react'
import {Media, Button, Label, Form, FormGroup, Input, Table, CustomInput, Card, CardBody, Row, Col, Nav, NavItem, NavLink, TabContent, TabPane, Alert } from 'reactstrap'
import { isEmptyObject } from 'jquery'
// ** Store & Actions
import { updateProject } from '../../store/actions'
import { useForm } from 'react-hook-form'
import classnames from 'classnames'
// ** Function to handle form submit
const onSubmit = values => {
// if (isObjEmpty(errors)) {
// dispatch(
// updateProject({
// id: values.id,
// app_name: values.app_name,
// customer_name: values.customer_name
// })
// )
// }
}
const ProjectCard = ({ selectedProject }) => {
const [dataProject, setProjectData] = useState(null)
// const { register, errors, handleSubmit } = useForm()
// const [dataProject, setProjectData] = useState(null)
// // ** Update user image on mount or change
// useEffect(() => {
// if (selectedProject !== null || (selectedProject !== null && dataProject !== null && selectedProject.id !== dataProject.id)) {
// return setProjectData(selectedProject)
// }
// }, [selectedProject])
useEffect(() => {
if (selectedProject !== null || (selectedProject !== null && dataProject !== null && selectedProject.id !== dataProject.id)) {
return setProjectData(selectedProject)
}
}, [selectedProject])
return (
<Fragment>
<Form
// onSubmit={handleSubmit(onSubmit)}
>
<Row>
<Col md='4' sm='12'>
<FormGroup>
<Label for='email'>ID</Label>
<Input
readOnly={true}
type='text'
name='id'
id='id'
// innerRef={register({ required: true })}
placeholder='id'
defaultValue='1'
/>
</FormGroup>
</Col>
<Col md='4' sm='12'>
<FormGroup>
<Label for='app_name'>Project Name</Label>
<Input
type='text'
name='app_name'
id='app_name'
// innerRef={register({ required: true })}
placeholder='Project Name'
defaultValue={dataProject && dataProject.app_name}
// className={classnames({ 'is-invalid': errors['app_name'] })}
/>
</FormGroup>
</Col>
<Col md='4' sm='12'>
<FormGroup>
<Label for='customer_name'>Client Name</Label>
<Input
type='text'
name='customer_name'
id='customer_name'
// innerRef={register({ required: true })}
placeholder='Client Name'
defaultValue={dataProject && dataProject.customer_name}
// className={classnames({ 'is-invalid': errors['customer_name'] })}
/>
</FormGroup>
</Col>
{/* <Col md='4' sm='12'>
<FormGroup>
<Label for='email'>Email</Label>
<Input disabled='disabled' type='text' id='email' placeholder='Email' defaultValue={ProjectData && ProjectData.email} />
</FormGroup>
</Col> */}
{/* <Col md='4' sm='12'>
<FormGroup>
<Label for='status'>Status</Label>
<Input type='select' name='status' id='status' defaultValue={ProjectData && ProjectData.status}>
<option value='pending'>Pending</option>
<option value='active'>Active</option>
<option value='inactive'>Inactive</option>
</Input>
</FormGroup>
</Col> */}
<Col sm='6'>
<div className='permissions border mt-1'>
<h6 className='py-1 mx-1 mb-0 font-medium-2'>
<Lock size={18} className='mr-25' />
<span className='align-middle'>Platforms</span>
</h6>
<Table borderless striped responsive>
<thead className='thead-light'>
<tr>
<th>Platforms</th>
<th>Active</th>
</tr>
</thead>
<tbody>
<tr>
<td>IOS</td>
<td>
<CustomInput type='checkbox' id='admin-1' label='' defaultChecked />
</td>
</tr>
<tr>
<td>Android</td>
<td>
<CustomInput type='checkbox' id='staff-1' label='' />
</td>
</tr>
<tr>
<td>Android Tv</td>
<td>
<CustomInput type='checkbox' id='author-1' label='' defaultChecked />
</td>
</tr>
<tr>
<td>Roku</td>
<td>
<CustomInput type='checkbox' id='contributor-1' label='' />
</td>
</tr>
<tr>
<td>STV</td>
<td>
<CustomInput type='checkbox' id='user-1' label='' />
</td>
</tr>
</tbody>
</Table>
</div>
</Col>
<Col className='d-flex flex-sm-row flex-column mt-2' sm='12'>
<Button.Ripple className='mb-1 mb-sm-0 mr-0 mr-sm-1' type='submit' color='primary'>
Save Changes
</Button.Ripple>
<Button.Ripple color='secondary' outline>
Reset
</Button.Ripple>
</Col>
</Row>
</Form>
</Fragment>
)
}
export default ProjectCard
\ No newline at end of file
......@@ -20,7 +20,6 @@ export const getData = params => {
export const setSaveSatus = params => {
return async dispatch => {
dispatch({
type: 'SAVE_STATUS',
status: params
......@@ -49,7 +48,6 @@ export const getData_projects = params => {
allData: response.data.allData,
// dataProjects: response.data.invoices,
totalPages: response.data.total,
selectedProject: null,
params: response.data.params
})
})
......@@ -66,7 +64,7 @@ export const getProject = id => {
// console.log(response)
dispatch({
type: 'GET_PROJECT',
selectedProject: response.data
data: response.data.data
})
})
.catch(err => console.log(err))
......
......@@ -20,7 +20,7 @@ const initialState = {
selectedPlatform: null
}
const Settings = (state = initialState, action) => {
const settings = (state = initialState, action) => {
switch (action.type) {
case 'GET_DATA':
return {
......@@ -50,12 +50,14 @@ const Settings = (state = initialState, action) => {
allDataProjects: action.allData,
dataProjects: action.data,
totalProjects: action.totalPages,
selectedProject: null,
paramsProjects: action.params
}
case 'GET_PROJECT':
return { ...state,
selectedProject : action.selectedProject
selectedProject : action.data
}
case 'UPDATE_PROJECT':
......@@ -74,4 +76,4 @@ const Settings = (state = initialState, action) => {
}
}
export default Settings
export default settings
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment