Commit e79c85e0 authored by PDuarte's avatar PDuarte

saving alerts

parent 1f58b375
......@@ -2,11 +2,14 @@
import { useState, useEffect, Fragment } from 'react'
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 { Lock, Edit, Trash2 } from 'react-feather'
import { Bell, Check, X, AlertTriangle, Info } from 'react-feather'
// ** Store & Actions
import { updateProject } from '../../store/actions'
......@@ -16,12 +19,52 @@ import classnames from 'classnames'
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 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),
{ register, errors, handleSubmit } = useForm(),
dispatch = useDispatch(),
notifySuccessProgress = () => toast.success(<SuccessProgressToast />),
onSubmit = values => {
if (isObjEmpty(errors)) {
notifySuccessProgress()
// handleError()
dispatch(
updateProject({
id: values.id,
......@@ -32,6 +75,7 @@ const ProjectCard = ({ selectedProject }) => {
}
}
useEffect(() => {
if (selectedProject !== null || (selectedProject !== null && dataProject !== null && selectedProject.id !== dataProject.id)) {
return setProjectData(selectedProject)
......@@ -80,7 +124,7 @@ return (
type='text'
name='customer_name'
id='customer_name'
// innerRef={register({ required: true })}
innerRef={register({ required: true })}
placeholder='Client Name'
defaultValue={dataProject && dataProject.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