Commit e79c85e0 authored by PDuarte's avatar PDuarte

saving alerts

parent 1f58b375
...@@ -2,11 +2,14 @@ ...@@ -2,11 +2,14 @@
import { useState, useEffect, Fragment } from 'react' import { useState, useEffect, Fragment } from 'react'
import { useDispatch } from 'react-redux' import { useDispatch } from 'react-redux'
import { toast } from 'react-toastify'
import Avatar from '@components/avatar'
import {Media, Button, Label, Form, FormGroup, Input, Table, CustomInput, Card, CardBody, Row, Col, Nav, NavItem, NavLink, TabContent, TabPane, Alert } from 'reactstrap' import {Media, Button, Label, Form, FormGroup, Input, Table, CustomInput, Card, CardBody, Row, Col, Nav, NavItem, NavLink, TabContent, TabPane, Alert, CardHeader, CardTitle, CardText } from 'reactstrap'
import { isObjEmpty } from '@utils' import { isObjEmpty } from '@utils'
import { Lock, Edit, Trash2 } from 'react-feather' import { Bell, Check, X, AlertTriangle, Info } from 'react-feather'
// ** Store & Actions // ** Store & Actions
import { updateProject } from '../../store/actions' import { updateProject } from '../../store/actions'
...@@ -16,12 +19,52 @@ import classnames from 'classnames' ...@@ -16,12 +19,52 @@ import classnames from 'classnames'
import ProjectPlatform from './plataform' import ProjectPlatform from './plataform'
import Swal from 'sweetalert2'
import withReactContent from 'sweetalert2-react-content'
const SuccessProgressToast = () => (
<Fragment>
<div className='toastify-header'>
<div className='title-wrapper'>
<Avatar size='sm' color='success' icon={<Check size={12} />} />
<h6 className='toast-title'>Saving Project !</h6>
</div>
<small className='text-muted'>now</small>
</div>
<div className='toastify-body'>
<span role='img' aria-label='toast-text'>
👋 Good job.
</span>
</div>
</Fragment>
)
const ProjectCard = ({ selectedProject }) => { const ProjectCard = ({ selectedProject }) => {
const MySwal = withReactContent(Swal)
const handleError = () => {
return MySwal.fire({
title: 'Error!',
text: ' You clicked the button!',
icon: 'error',
customClass: {
confirmButton: 'btn btn-primary'
},
buttonsStyling: false
})
}
const [dataProject, setProjectData] = useState(null), const [dataProject, setProjectData] = useState(null),
{ register, errors, handleSubmit } = useForm(), { register, errors, handleSubmit } = useForm(),
dispatch = useDispatch(), dispatch = useDispatch(),
notifySuccessProgress = () => toast.success(<SuccessProgressToast />),
onSubmit = values => { onSubmit = values => {
if (isObjEmpty(errors)) { if (isObjEmpty(errors)) {
notifySuccessProgress()
// handleError()
dispatch( dispatch(
updateProject({ updateProject({
id: values.id, id: values.id,
...@@ -32,6 +75,7 @@ const ProjectCard = ({ selectedProject }) => { ...@@ -32,6 +75,7 @@ const ProjectCard = ({ selectedProject }) => {
} }
} }
useEffect(() => { useEffect(() => {
if (selectedProject !== null || (selectedProject !== null && dataProject !== null && selectedProject.id !== dataProject.id)) { if (selectedProject !== null || (selectedProject !== null && dataProject !== null && selectedProject.id !== dataProject.id)) {
return setProjectData(selectedProject) return setProjectData(selectedProject)
...@@ -80,7 +124,7 @@ return ( ...@@ -80,7 +124,7 @@ return (
type='text' type='text'
name='customer_name' name='customer_name'
id='customer_name' id='customer_name'
// innerRef={register({ required: true })} innerRef={register({ required: true })}
placeholder='Client Name' placeholder='Client Name'
defaultValue={dataProject && dataProject.customer_name} defaultValue={dataProject && dataProject.customer_name}
className={classnames({ 'is-invalid': errors['customer_name'] })} className={classnames({ 'is-invalid': errors['customer_name'] })}
......
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