Commit 330411df authored by PDuarte's avatar PDuarte

platforms adding

parent 7d8b3476
...@@ -32,6 +32,11 @@ const SettingsRoutes = [ ...@@ -32,6 +32,11 @@ const SettingsRoutes = [
component: lazy(() => import('../../views/settings/platforms')), component: lazy(() => import('../../views/settings/platforms')),
exact: true exact: true
}, },
{
path: '/settings/platforms/add',
component: lazy(() => import('../../views/settings/platforms/add')),
exact: true
},
{ {
path: '/settings/locations', path: '/settings/locations',
component: lazy(() => import('../../views/settings/locations')), component: lazy(() => import('../../views/settings/locations')),
......
...@@ -3,7 +3,7 @@ import { Fragment } from 'react' ...@@ -3,7 +3,7 @@ import { Fragment } from 'react'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
// ** Store & Actions // ** Store & Actions
import { addProject } from '../../store/actions' import { addPlatform } from '../../store/actions'
import { useDispatch } from 'react-redux' import { useDispatch } from 'react-redux'
// ** Custom Components // ** Custom Components
...@@ -11,11 +11,10 @@ import Breadcrumbs from '@components/breadcrumbs' ...@@ -11,11 +11,10 @@ import Breadcrumbs from '@components/breadcrumbs'
// ** Third Party Components // ** Third Party Components
import { Row, Col } from 'reactstrap' import { Row, Col } from 'reactstrap'
import { isObjEmpty } from '@utils'
// ** Tables // ** Tables
import ProjectCard from '../edit/projectCard' import ElementCard from '../card'
// ** Styles // ** Styles
import '@styles/react/libs/tables/react-dataTable-component.scss' import '@styles/react/libs/tables/react-dataTable-component.scss'
...@@ -23,10 +22,9 @@ const Tables = () => { ...@@ -23,10 +22,9 @@ const Tables = () => {
const dispatch = useDispatch() const dispatch = useDispatch()
const onSubmitHandler = values => { const onSubmitHandler = values => {
dispatch( dispatch(
addProject({ addPlatform({
id: values.id, id: values.id,
app_name: values.app_name, name: values.name
customer_name: values.customer_name
}) })
) )
...@@ -34,23 +32,22 @@ const Tables = () => { ...@@ -34,23 +32,22 @@ const Tables = () => {
return ( return (
<Fragment> <Fragment>
<Breadcrumbs breadCrumbTitle='Settings' breadCrumbParent='Settings' breadCrumbActive='Projects' /> <Breadcrumbs breadCrumbTitle='Settings' breadCrumbParent='Settings' breadCrumbActive='Platforms' />
<Row> <Row>
<Col sm='12'> <Col sm='12'>
<Link to="/settings/projects">Back to Projects</Link> <Link to="/settings/platforms">Back to Platforms</Link>
</Col> </Col>
</Row> </Row>
<Row> <Row>
<Col sm='12'> <Col sm='12'>
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<h4 class="card-title">New Project</h4> <h4 class="card-title">New Platform</h4>
</div> </div>
<div class="card-body"> <div class="card-body">
<ProjectCard selectedProject={{ <ElementCard selectedProject={{
id: '<generate>', id: '<generate>',
app_name: '', name: ''
customer_name: ''
}} }}
onSubmitHandler={onSubmitHandler} onSubmitHandler={onSubmitHandler}
/> />
......
...@@ -12,13 +12,11 @@ import { Bell, Check, X, AlertTriangle, Info } from 'react-feather' ...@@ -12,13 +12,11 @@ import { Bell, Check, X, AlertTriangle, Info } from 'react-feather'
// ** Store & Actions // ** Store & Actions
import { updateProject, resetResults, getProject } from '../../store/actions' import { updateProject, resetResults, getPlatform } from '../../store/actions'
import { useForm } from 'react-hook-form' import { useForm } from 'react-hook-form'
import classnames from 'classnames' import classnames from 'classnames'
import ProjectPlatform from './plataform'
import Swal from 'sweetalert2' import Swal from 'sweetalert2'
import withReactContent from 'sweetalert2-react-content' import withReactContent from 'sweetalert2-react-content'
...@@ -41,8 +39,9 @@ const SuccessProgressToast = () => ( ...@@ -41,8 +39,9 @@ const SuccessProgressToast = () => (
) )
const ProjectCard = ({ selectedProject, onSubmitHandler }) => { const ElementCard = ({ selectedProject, onSubmitHandler }) => {
const store = useSelector(state => state.projectsettings) const store = useSelector(state => state.projectsettings)
const [PlatformName, setPlatformName] = useState('Web')
const MySwal = withReactContent(Swal) const MySwal = withReactContent(Swal)
...@@ -65,14 +64,10 @@ const handleError = (text) => { ...@@ -65,14 +64,10 @@ const handleError = (text) => {
notifySuccessProgress = () => toast.success(<SuccessProgressToast />), notifySuccessProgress = () => toast.success(<SuccessProgressToast />),
onSubmit = values => { onSubmit = values => {
if (isObjEmpty(errors)) { if (isObjEmpty(errors)) {
// dispatch( onSubmitHandler({
// updateProject({ id: null,
// id: values.id, name :PlatformName
// app_name: values.app_name, })
// customer_name: values.customer_name
// })
// )
onSubmitHandler(values)
} }
} }
...@@ -118,7 +113,7 @@ return ( ...@@ -118,7 +113,7 @@ return (
/> />
</FormGroup> </FormGroup>
</Col> </Col>
<Col md='4' sm='12'> {/* <Col md='4' sm='12'>
<FormGroup> <FormGroup>
<Label for='app_name'>Project Name</Label> <Label for='app_name'>Project Name</Label>
<Input <Input
...@@ -131,8 +126,8 @@ return ( ...@@ -131,8 +126,8 @@ return (
className={classnames({ 'is-invalid': errors['app_name'] })} className={classnames({ 'is-invalid': errors['app_name'] })}
/> />
</FormGroup> </FormGroup>
</Col> </Col> */}
<Col md='4' sm='12'> {/* <Col md='4' sm='12'>
<FormGroup> <FormGroup>
<Label for='customer_name'>Client Name</Label> <Label for='customer_name'>Client Name</Label>
<Input <Input
...@@ -145,32 +140,32 @@ return ( ...@@ -145,32 +140,32 @@ return (
className={classnames({ 'is-invalid': errors['customer_name'] })} className={classnames({ 'is-invalid': errors['customer_name'] })}
/> />
</FormGroup> </FormGroup>
</Col> </Col> */}
{/* <Col md='4' sm='12'> {/* <Col md='4' sm='12'>
<FormGroup> <FormGroup>
<Label for='email'>Email</Label> <Label for='email'>Email</Label>
<Input disabled='disabled' type='text' id='email' placeholder='Email' defaultValue={ProjectData && ProjectData.email} /> <Input disabled='disabled' type='text' id='email' placeholder='Email' defaultValue={ProjectData && ProjectData.email} />
</FormGroup> </FormGroup>
</Col> */} </Col> */}
{/* <Col md='4' sm='12'> <Col md='4' sm='12'>
<FormGroup> <FormGroup>
<Label for='status'>Status</Label> <Label for='name'>Name</Label>
<Input type='select' name='status' id='status' defaultValue={ProjectData && ProjectData.status}> <Input type='select' name='name' id='name' defaultValue={dataProject && dataProject.name} onChange={e => setPlatformName(e.target.value)}>
<option value='pending'>Pending</option> <option value='Web'>Web</option>
<option value='active'>Active</option> <option value='iOS Phone'>iOS Phone</option>
<option value='inactive'>Inactive</option> <option value='iOS Tablet'>iOS Tablet</option>
<option value='Android Phone'>Android Phone</option>
<option value='Android Tablet'>Android Tablet</option>
</Input> </Input>
</FormGroup> </FormGroup>
</Col> */}
<Col sm='6'>
<ProjectPlatform />
</Col> </Col>
<Col className='d-flex flex-sm-row flex-column mt-2' sm='12'> <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'> <Button.Ripple className='mb-1 mb-sm-0 mr-0 mr-sm-1' type='submit' color='primary'>
Save Changes Save Changes
</Button.Ripple> </Button.Ripple>
{/* <Button.Ripple color='secondary' outline onClick={() => dispatch(getProject(selectedProject.id))} > {/* <Button.Ripple color='secondary' outline onClick={() => dispatch(getPlatform(selectedProject.id))} >
Reset Reset
</Button.Ripple> */} </Button.Ripple> */}
</Col> </Col>
...@@ -181,4 +176,4 @@ return ( ...@@ -181,4 +176,4 @@ return (
} }
export default ProjectCard export default ElementCard
\ No newline at end of file \ No newline at end of file
...@@ -16,17 +16,17 @@ import '@styles/react/libs/tables/react-dataTable-component.scss' ...@@ -16,17 +16,17 @@ import '@styles/react/libs/tables/react-dataTable-component.scss'
const Tables = () => { const Tables = () => {
return ( return (
<Fragment> <Fragment>
<Breadcrumbs breadCrumbTitle='Settings' breadCrumbParent='Settings' breadCrumbActive='Projects' /> <Breadcrumbs breadCrumbTitle='Settings' breadCrumbParent='Settings' breadCrumbActive='Platforms' />
<Row> <Row>
<Col sm='12'> <Col sm='12'>
<Link to="/settings/projects">Back to Projects</Link> <Link to="/settings/platforms">Back to Platforms</Link>
</Col> </Col>
</Row> </Row>
<Row> <Row>
<Col sm='12'> <Col sm='12'>
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<h4 class="card-title">Project</h4> <h4 class="card-title">Platform</h4>
</div> </div>
<div class="card-body"> <div class="card-body">
<ProjectsEdit /> <ProjectsEdit />
......
...@@ -8,7 +8,7 @@ import { useSelector, useDispatch } from 'react-redux' ...@@ -8,7 +8,7 @@ import { useSelector, useDispatch } from 'react-redux'
import { Alert } from 'reactstrap' import { Alert } from 'reactstrap'
import ProjectCard from './projectCard' import ElementCard from '../card'
const ProjectsEdit = () => { const ProjectsEdit = () => {
// ** States & Vars // ** States & Vars
...@@ -43,7 +43,7 @@ const ProjectsEdit = () => { ...@@ -43,7 +43,7 @@ const ProjectsEdit = () => {
return store.selectedProject !== null && store.selectedProject !== undefined ? ( return store.selectedProject !== null && store.selectedProject !== undefined ? (
<ProjectCard <ElementCard
selectedProject={store.selectedProject} selectedProject={store.selectedProject}
onSubmitHandler={onSubmitHandler} onSubmitHandler={onSubmitHandler}
/> />
......
...@@ -15,7 +15,7 @@ import '@styles/react/libs/tables/react-dataTable-component.scss' ...@@ -15,7 +15,7 @@ import '@styles/react/libs/tables/react-dataTable-component.scss'
const Tables = () => { const Tables = () => {
return ( return (
<Fragment> <Fragment>
<Breadcrumbs breadCrumbTitle='Settings' breadCrumbParent='Settings' breadCrumbActive='Projects' /> <Breadcrumbs breadCrumbTitle='Settings' breadCrumbParent='Settings' breadCrumbActive='Platforms' />
<Row> <Row>
<Col sm='12'> <Col sm='12'>
<DataTable /> <DataTable />
......
...@@ -15,6 +15,7 @@ const DataTable = () => { ...@@ -15,6 +15,7 @@ const DataTable = () => {
return ( return (
<DataTableServerSide <DataTableServerSide
cardTitle='Platforms'
allData={store.allDataPlatforms} allData={store.allDataPlatforms}
getData={getData_platforms} getData={getData_platforms}
serverSideColumns={serverSideColumns} serverSideColumns={serverSideColumns}
......
...@@ -15,6 +15,7 @@ const DataTable = () => { ...@@ -15,6 +15,7 @@ const DataTable = () => {
return ( return (
<DataTableServerSide <DataTableServerSide
cardTitle='Projects'
allData={store.allDataProjects} allData={store.allDataProjects}
getData={getData_projects} getData={getData_projects}
serverSideColumns={serverSideColumns} serverSideColumns={serverSideColumns}
......
import axios from 'axios' import axios from 'axios'
import { platform } from 'chart.js'
// ** Get table Data ///api/datatables/data // ** Get table Data ///api/datatables/data
...@@ -140,7 +141,7 @@ export const addProject = project => { ...@@ -140,7 +141,7 @@ export const addProject = project => {
// ** Get table Data platforms // ** Get table Data platforms
export const getData_platforms = params => { export const getData_platforms = params => {
return async dispatch => { return async dispatch => {
await axios.get(`${process.env.REACT_APP_API}/api/platforms`, params await axios.get(`${process.env.REACT_APP_API}/api/platforms`, {params}
).then(response => { ).then(response => {
dispatch({ dispatch({
type: 'GET_DATA_PLATFORMS', type: 'GET_DATA_PLATFORMS',
...@@ -152,3 +153,23 @@ export const getData_platforms = params => { ...@@ -152,3 +153,23 @@ export const getData_platforms = params => {
}) })
} }
} }
export const addPlatform = platform => {
return (dispatch, getState) => {
axios
.post(`${process.env.REACT_APP_API}/api/platforms`, platform)
.then(response => {
dispatch({
type: 'ADD_PLATFORM',
platform
})
})
.then(() => {
dispatch(setSaveSatus(true))
})
.catch(err => {
dispatch(setErrorMsg(err.response.data.message))
console.log(err.response.data)
})
}
}
...@@ -78,6 +78,11 @@ const settings = (state = initialState, action) => { ...@@ -78,6 +78,11 @@ const settings = (state = initialState, action) => {
totalPlatforms: action.totalPages, totalPlatforms: action.totalPages,
paramsPlatforms: action.params paramsPlatforms: action.params
} }
case 'ADD_PLATFORM':
return { ...state }
default: default:
return state return state
} }
......
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