Commit 330411df authored by PDuarte's avatar PDuarte

platforms adding

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