change
This commit is contained in:
parent
d21eb2dc5b
commit
e89beffbce
@ -6,7 +6,7 @@ const AppFooter = () => {
|
|||||||
<CFooter>
|
<CFooter>
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<span className="ms-1">{new Date().getFullYear()} © Sales Champions.</span>
|
<span className="ms-1">{new Date().getFullYear()} ©CMP.</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</CFooter>
|
</CFooter>
|
||||||
|
@ -32,7 +32,7 @@ const AppHeader = () => {
|
|||||||
<CIcon icon={cilMenu} size="lg" />
|
<CIcon icon={cilMenu} size="lg" />
|
||||||
</CHeaderToggler>
|
</CHeaderToggler>
|
||||||
<CHeaderBrand className="mx-auto d-md-none" to="/">
|
<CHeaderBrand className="mx-auto d-md-none" to="/">
|
||||||
<h2>Sales Champions</h2>
|
<h1>CMP</h1>
|
||||||
</CHeaderBrand>
|
</CHeaderBrand>
|
||||||
<CHeaderNav className="d-none d-md-flex me-auto">
|
<CHeaderNav className="d-none d-md-flex me-auto">
|
||||||
<CNavItem>
|
<CNavItem>
|
||||||
|
@ -31,7 +31,7 @@ const AppSidebar = () => {
|
|||||||
>
|
>
|
||||||
<CSidebarBrand className="d-none bg-info d-md-flex" to="/">
|
<CSidebarBrand className="d-none bg-info d-md-flex" to="/">
|
||||||
{/* <CIcon className="sidebar-brand-full" icon={logoNegative} height={35} /> */}
|
{/* <CIcon className="sidebar-brand-full" icon={logoNegative} height={35} /> */}
|
||||||
<h3>Sales Champions</h3>
|
<h1>CMP</h1>
|
||||||
{/* <CIcon className="sidebar-brand-narrow" height={35} /> */}
|
{/* <CIcon className="sidebar-brand-narrow" height={35} /> */}
|
||||||
<CIcon className="sidebar-brand-narrow" icon={sygnet} height={35} />
|
<CIcon className="sidebar-brand-narrow" icon={sygnet} height={35} />
|
||||||
</CSidebarBrand>
|
</CSidebarBrand>
|
||||||
|
@ -11,8 +11,8 @@ import store from './store'
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
const setupAxios = () => {
|
const setupAxios = () => {
|
||||||
axios.defaults.baseURL = 'https://cms-api-dashboard.herokuapp.com/';
|
// axios.defaults.baseURL = 'https://cms-api-dashboard.herokuapp.com/';
|
||||||
//axios.defaults.baseURL = 'http://localhost:5000'
|
axios.defaults.baseURL = 'http://localhost:5000'
|
||||||
axios.defaults.headers = {
|
axios.defaults.headers = {
|
||||||
'Cache-Control': 'no-cache,no-store',
|
'Cache-Control': 'no-cache,no-store',
|
||||||
'Pragma': 'no-cache',
|
'Pragma': 'no-cache',
|
||||||
|
@ -43,8 +43,8 @@ const AddBanner = () => {
|
|||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!(title && subTitle && image && section && subSection && startDate && endDate)) {
|
if (!(title && subTitle && image && section && subSection && startDate && endDate)) {
|
||||||
alert("Please fill All required field ");
|
return swal('Error!', 'All fields are required', 'error')
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const myForm = new FormData();
|
const myForm = new FormData();
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ const AddBanner = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert(error)
|
swal('Error!', error, 'error')
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,8 +59,8 @@ const EditBanner = () => {
|
|||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!(title && subTitle && image && section && subSection && startDate && endDate)) {
|
if (!(title && subTitle && image && section && subSection && startDate && endDate)) {
|
||||||
alert("Please fill All required field ");
|
return swal('Error!', 'All fields are required', 'error')
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const myForm = new FormData();
|
const myForm = new FormData();
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ const EditBanner = () => {
|
|||||||
history.goBack();
|
history.goBack();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert(error)
|
swal('Error!', error, 'error')
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
// console.log(image)
|
// console.log(image)
|
||||||
|
@ -69,7 +69,8 @@ const EditCms = () => {
|
|||||||
history.goBack()
|
history.goBack()
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert(error)
|
swal('Error!', error, 'error')
|
||||||
|
|
||||||
changeState({ loading: false });
|
changeState({ loading: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,8 +32,8 @@ const AddProduct = () => {
|
|||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!(name && image)) {
|
if (!(name && image)) {
|
||||||
alert("Please fill All required field ");
|
return swal('Error!', 'All fields are required', 'error')
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const myForm = new FormData();
|
const myForm = new FormData();
|
||||||
|
|
||||||
@ -60,7 +60,8 @@ const AddProduct = () => {
|
|||||||
history.goBack();
|
history.goBack();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert("something went wrong")
|
swal('Error!', "something went wrong", 'error')
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ const AddProduct = () => {
|
|||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!(name && image)) {
|
if (!(name && image)) {
|
||||||
alert("Please fill All required field ");
|
return swal('Error!', 'All fields are required', 'error')
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const myForm = new FormData();
|
const myForm = new FormData();
|
||||||
|
|
||||||
@ -72,7 +72,8 @@ const AddProduct = () => {
|
|||||||
history.goBack();
|
history.goBack();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert("something went wrong")
|
swal('Error!', "something went wrong", 'error')
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,8 +75,8 @@ const Add_Business = () => {
|
|||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!(state.name && state.phone && state.email && state.Bname && state.Sname && state.country && state.city && state.description
|
if (!(state.name && state.phone && state.email && state.Bname && state.Sname && state.country && state.city && state.description
|
||||||
&& state.category && state.status && image)) {
|
&& state.category && state.status && image)) {
|
||||||
alert("Please fill All required field ");
|
return swal('Error!', 'All fields are required', 'error')
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const myForm = new FormData();
|
const myForm = new FormData();
|
||||||
@ -122,7 +122,8 @@ const Add_Business = () => {
|
|||||||
history.goBack()
|
history.goBack()
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert(error)
|
swal('Error!', error, 'error')
|
||||||
|
|
||||||
changeState({ loading: false });
|
changeState({ loading: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,8 +96,8 @@ const EditBisuness = () => {
|
|||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!(state.name && state.phone && state.email && state.Building_Name && state.Street_Name && state.country && state.city && state.description
|
if (!(state.name && state.phone && state.email && state.Building_Name && state.Street_Name && state.country && state.city && state.description
|
||||||
&& state.category && state.status && image)) {
|
&& state.category && state.status && image)) {
|
||||||
alert("Please fill All required field ");
|
return swal('Error!', 'All fields are required', 'error')
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const myForm = new FormData();
|
const myForm = new FormData();
|
||||||
myForm.set('name', state.name)
|
myForm.set('name', state.name)
|
||||||
@ -138,7 +138,8 @@ const EditBisuness = () => {
|
|||||||
history.goBack()
|
history.goBack()
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert(error)
|
swal('Error!', error, 'error')
|
||||||
|
|
||||||
changeState({ loading: false });
|
changeState({ loading: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ const AddEvent = () => {
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!(title && description && image && location && time && date)) {
|
if (!(title && description && image && location && time && date)) {
|
||||||
alert("Please fill All required field ");
|
return swal('Error!', 'All fields are required', 'error')
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const myForm = new FormData();
|
const myForm = new FormData();
|
||||||
|
|
||||||
@ -64,7 +64,8 @@ const AddEvent = () => {
|
|||||||
history.goBack();
|
history.goBack();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert("Something went Wrong")
|
swal('Error!', 'Something went Wrong', 'error')
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +53,8 @@ const EditEvent = () => {
|
|||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!(title && description && image && location && time && date)) {
|
if (!(title && description && image && location && time && date)) {
|
||||||
alert("Please fill All required field ");
|
return swal('Error!', 'All fields are required', 'error')
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const myForm = new FormData();
|
const myForm = new FormData();
|
||||||
|
|
||||||
@ -84,7 +84,8 @@ const EditEvent = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert("Something went Wrong")
|
swal('Error!', 'Something went Wrong', 'error')
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ const AddFaqs = () => {
|
|||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!(topic && description)) {
|
if (!(topic && description)) {
|
||||||
alert("Please fill All required field ");
|
return swal('Error!', 'All fields are required', 'error')
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const myForm = new FormData();
|
const myForm = new FormData();
|
||||||
|
|
||||||
@ -58,7 +58,8 @@ const AddFaqs = () => {
|
|||||||
history.goBack();
|
history.goBack();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert(error)
|
swal('Error!', error, 'error')
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +42,8 @@ const EditFaqs = () => {
|
|||||||
}, [id]);
|
}, [id]);
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!(topic && description)) {
|
if (!(topic && description)) {
|
||||||
alert("Please fill All required field ");
|
return swal('Error!', 'All fields are required', 'error')
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const myForm = new FormData();
|
const myForm = new FormData();
|
||||||
|
|
||||||
@ -69,7 +69,8 @@ const EditFaqs = () => {
|
|||||||
history.goBack();
|
history.goBack();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert(error)
|
swal('Error!', error, 'error')
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ const AddNews = () => {
|
|||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!(title && description && image)) {
|
if (!(title && description && image)) {
|
||||||
alert("Please fill All required field ");
|
return swal('Error!', 'All fields are required', 'error')
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const myForm = new FormData();
|
const myForm = new FormData();
|
||||||
|
|
||||||
@ -58,7 +58,8 @@ const AddNews = () => {
|
|||||||
history.goBack();
|
history.goBack();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert(error)
|
swal('Error!', error, 'error')
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ const EditNews = () => {
|
|||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!(title && description && image)) {
|
if (!(title && description && image)) {
|
||||||
alert("Please fill All required field ");
|
return swal('Error!', 'All fields are required', 'error')
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const myForm = new FormData();
|
const myForm = new FormData();
|
||||||
|
|
||||||
@ -73,7 +73,8 @@ const EditNews = () => {
|
|||||||
history.goBack();
|
history.goBack();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert(error)
|
swal('Error!', error, 'error')
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,8 +63,8 @@ const AddOffer = () => {
|
|||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!(title && description && image && location && sendBisunessName)) {
|
if (!(title && description && image && location && sendBisunessName)) {
|
||||||
alert("Please fill All required field ");
|
return swal('Error!', 'All fields are required', 'error')
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const myForm = new FormData();
|
const myForm = new FormData();
|
||||||
|
|
||||||
@ -93,7 +93,8 @@ const AddOffer = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert("something Went Wrong")
|
swal('Error!', 'something Went Wrong', 'error')
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ const EditOffer = () => {
|
|||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!(title && description && image && location && sendBisunessName)) {
|
if (!(title && description && image && location && sendBisunessName)) {
|
||||||
alert("Please fill All required field ");
|
return swal('Error!', 'All fields are required', 'error')
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const myForm = new FormData();
|
const myForm = new FormData();
|
||||||
|
|
||||||
@ -101,7 +101,8 @@ const EditOffer = () => {
|
|||||||
history.goBack();
|
history.goBack();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert("something Went Wrong")
|
swal('Error!', 'something Went Wrong', 'error')
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,8 +67,8 @@ const AddRequirement = () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
if (!(title && description && areaOfInterest && allimage[0])) {
|
if (!(title && description && areaOfInterest && allimage[0])) {
|
||||||
alert("please fill all fields")
|
return swal('Error!', 'All fields are required', 'error')
|
||||||
return
|
|
||||||
}
|
}
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
@ -89,7 +89,8 @@ const AddRequirement = () => {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
alert(error)
|
swal('Error!', error, 'error')
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,8 +82,8 @@ const EditRequirement = () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
if (!(title && description && areaOfInterest && allimage[0])) {
|
if (!(title && description && areaOfInterest && allimage[0])) {
|
||||||
alert("please fill all fields")
|
return swal('Error!', 'All fields are required', 'error')
|
||||||
return
|
|
||||||
}
|
}
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
@ -104,7 +104,8 @@ const EditRequirement = () => {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
alert(error)
|
swal('Error!', error, 'error')
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
import {
|
import {
|
||||||
CButton,
|
CButton,
|
||||||
@ -22,20 +22,80 @@ import { useHistory } from 'react-router-dom'
|
|||||||
|
|
||||||
const Login = () => {
|
const Login = () => {
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [validForm, setValidForm] = useState(false)
|
||||||
const [auth, setAuth] = useState({
|
const [auth, setAuth] = useState({
|
||||||
email: "",
|
email: "",
|
||||||
password: ""
|
password: ""
|
||||||
});
|
});
|
||||||
const history = useHistory();
|
const [errors, setErrors] = useState({
|
||||||
|
emailError: '',
|
||||||
|
passwordError: '',
|
||||||
|
|
||||||
const handleChange = (e) => (event) => {
|
})
|
||||||
setAuth({ ...auth, [e]: event.target.value });
|
const validEmailRegex = RegExp(
|
||||||
};
|
/^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i,
|
||||||
|
)
|
||||||
|
const validPasswordRegex = RegExp(/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[^\w\s]).{7,}$/)
|
||||||
|
const history = useHistory();
|
||||||
|
// const handleChange = (e) => (event) => {
|
||||||
|
|
||||||
|
// setAuth({ ...auth, [e]: event.target.value });
|
||||||
|
// };
|
||||||
|
const validateForm = () => {
|
||||||
|
let valid = true
|
||||||
|
Object.values(errors).forEach((val) => {
|
||||||
|
if (val.length > 0) {
|
||||||
|
valid = false
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Object.values(auth).forEach((val) => {
|
||||||
|
if (val.length <= 0) {
|
||||||
|
valid = false
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return valid
|
||||||
|
}
|
||||||
|
|
||||||
|
//cheking email and password
|
||||||
|
useEffect(() => {
|
||||||
|
if (validateForm()) {
|
||||||
|
setValidForm(true)
|
||||||
|
} else {
|
||||||
|
setValidForm(false)
|
||||||
|
}
|
||||||
|
}, [errors])
|
||||||
|
const handleChange = (e) => {
|
||||||
|
const { name, value } = e.target
|
||||||
|
|
||||||
|
switch (name) {
|
||||||
|
case 'email':
|
||||||
|
setErrors({
|
||||||
|
...errors,
|
||||||
|
emailError: validEmailRegex.test(value) ? '' : 'Email is not valid!',
|
||||||
|
})
|
||||||
|
|
||||||
|
break
|
||||||
|
case 'password':
|
||||||
|
setErrors((errors) => ({
|
||||||
|
...errors,
|
||||||
|
passwordError: validPasswordRegex.test(value)
|
||||||
|
? ''
|
||||||
|
: 'Password Shoud Be 8 Characters Long, Atleast One Uppercase, Atleast One Lowercase,Atleast One Digit, Atleast One Special Character',
|
||||||
|
}))
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
setAuth({ ...auth, [name]: value })
|
||||||
|
}
|
||||||
|
|
||||||
const Login = async () => {
|
const Login = async () => {
|
||||||
if (!(auth.email && auth.password)) {
|
if (!(auth.email && auth.password)) {
|
||||||
alert("please filled both fields")
|
|
||||||
return
|
return swal('Error!', 'All fields are required', 'error')
|
||||||
}
|
}
|
||||||
setLoading({ loading: true })
|
setLoading({ loading: true })
|
||||||
try {
|
try {
|
||||||
@ -55,7 +115,7 @@ const Login = () => {
|
|||||||
window.location.reload()
|
window.location.reload()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
alert("please try with admin credential!!")
|
swal('Error!', 'please try with admin credential!!', 'error')
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,12 +124,14 @@ const Login = () => {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
alert("Invalid Credential");
|
|
||||||
|
swal('Error!', 'Invalid Credentials', 'error')
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
alert("Invalid Credentials");
|
|
||||||
|
swal('Error!', 'Invalid Credentials', 'error')
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,27 +146,34 @@ const Login = () => {
|
|||||||
<CCardBody>
|
<CCardBody>
|
||||||
<CForm>
|
<CForm>
|
||||||
<h1>Login</h1>
|
<h1>Login</h1>
|
||||||
<p className="text-medium-emphasis">Sign In to Your Sales Champions Dashboard Account.</p>
|
<p className="text-medium-emphasis">Sign In to Your CMP Dashboard Account.</p>
|
||||||
<CInputGroup className="mb-3">
|
<CInputGroup className="mb-3">
|
||||||
<CInputGroupText>
|
<CInputGroupText>
|
||||||
<CIcon icon={cilUser} />
|
<CIcon icon={cilUser} />
|
||||||
</CInputGroupText>
|
</CInputGroupText>
|
||||||
<CFormInput placeholder="Email" onChange={handleChange("email")} autoComplete="email" />
|
<CFormInput type="email" placeholder="Email" onChange={handleChange} value={auth.email} name="email" autoComplete="email" />
|
||||||
</CInputGroup>
|
</CInputGroup>
|
||||||
|
{errors.emailError && (
|
||||||
|
<p className="text-center py-2 text-danger">{errors.emailError}</p>
|
||||||
|
)}
|
||||||
<CInputGroup className="mb-4">
|
<CInputGroup className="mb-4">
|
||||||
<CInputGroupText>
|
<CInputGroupText>
|
||||||
<CIcon icon={cilLockLocked} />
|
<CIcon icon={cilLockLocked} />
|
||||||
</CInputGroupText>
|
</CInputGroupText>
|
||||||
<CFormInput
|
<CFormInput
|
||||||
type="password"
|
type="password"
|
||||||
onChange={handleChange("password")}
|
name="password"
|
||||||
|
value={auth.password}
|
||||||
|
onChange={handleChange}
|
||||||
placeholder="Password"
|
placeholder="Password"
|
||||||
autoComplete="current-password"
|
autoComplete="current-password"
|
||||||
/>
|
/>
|
||||||
</CInputGroup>
|
</CInputGroup>
|
||||||
|
|
||||||
|
{errors.passwordError && (
|
||||||
<CButton color="primary" className="px-4" onClick={Login}>
|
<p className="text-center py-2 text-danger">{errors.passwordError}</p>
|
||||||
|
)}
|
||||||
|
<CButton color="primary" className="px-4" disabled={!validForm} onClick={Login}>
|
||||||
<ClipLoader loading={loading} size={18} />
|
<ClipLoader loading={loading} size={18} />
|
||||||
{!loading && "Login"}
|
{!loading && "Login"}
|
||||||
|
|
||||||
|
@ -20,27 +20,77 @@ import Swal from 'sweetalert2'
|
|||||||
import { useHistory } from 'react-router-dom'
|
import { useHistory } from 'react-router-dom'
|
||||||
|
|
||||||
const Register = () => {
|
const Register = () => {
|
||||||
const [oldPassword, setOldPassword] = useState();
|
|
||||||
const [newPassword, setNewPassword] = useState();
|
|
||||||
const [confirmPassword, setConfirmPassword] = useState();
|
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
const [user, setUser] = useState({
|
||||||
|
oldPassword: '',
|
||||||
|
newPassword: '',
|
||||||
|
confirmPassword: '',
|
||||||
|
})
|
||||||
|
const [errors, setErrors] = useState({
|
||||||
|
confirmPasswordError: '',
|
||||||
|
newPasswordError: '',
|
||||||
|
oldPasswordError: '',
|
||||||
|
|
||||||
|
})
|
||||||
|
const validEmailRegex = RegExp(
|
||||||
|
/^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i,
|
||||||
|
)
|
||||||
|
const validPasswordRegex = RegExp(/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[^\w\s]).{7,}$/)
|
||||||
|
const handleChange = (e) => {
|
||||||
|
const { name, value } = e.target
|
||||||
|
|
||||||
|
switch (name) {
|
||||||
|
case 'oldPassword':
|
||||||
|
setErrors({
|
||||||
|
...errors,
|
||||||
|
oldPasswordError: validPasswordRegex.test(value)
|
||||||
|
? ''
|
||||||
|
: 'Password Shoud Be 8 Characters Long, Atleast One Uppercase, Atleast One Lowercase,Atleast One Digit, Atleast One Special Character',
|
||||||
|
})
|
||||||
|
|
||||||
|
break
|
||||||
|
case 'newPassword':
|
||||||
|
setErrors({
|
||||||
|
...errors,
|
||||||
|
newPasswordError: validPasswordRegex.test(value)
|
||||||
|
? ''
|
||||||
|
: 'Password Shoud Be 8 Characters Long, Atleast One Uppercase, Atleast One Lowercase,Atleast One Digit, Atleast One Special Character',
|
||||||
|
})
|
||||||
|
|
||||||
|
break
|
||||||
|
case 'confirmPassword':
|
||||||
|
setErrors((errors) => ({
|
||||||
|
...errors,
|
||||||
|
confirmPasswordError: validPasswordRegex.test(value)
|
||||||
|
? ''
|
||||||
|
: 'Password Shoud Be 8 Characters Long, Atleast One Uppercase, Atleast One Lowercase,Atleast One Digit, Atleast One Special Character',
|
||||||
|
}))
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
setUser({ ...user, [name]: value })
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!(oldPassword && newPassword && confirmPassword)) {
|
if (!(user.oldPassword && user.newPassword && user.confirmPassword)) {
|
||||||
alert("Please fill All required field ");
|
|
||||||
return;
|
return swal('Error!', 'All fields are required', 'error')
|
||||||
|
}
|
||||||
|
if (!(user.newPassword.length >= 8)) {
|
||||||
|
|
||||||
|
return swal('Error!', 'All fields are required', 'error');
|
||||||
}
|
}
|
||||||
const token = localStorage.getItem("authToken")
|
const token = localStorage.getItem("authToken")
|
||||||
setLoading({ loading: true })
|
setLoading({ loading: true })
|
||||||
if (newPassword == confirmPassword) {
|
if (user.newPassword == user.confirmPassword) {
|
||||||
let res = await axios.put('/api/v1/user/password/update',
|
let res = await axios.put('/api/v1/user/password/update',
|
||||||
{
|
{
|
||||||
oldPassword
|
...user
|
||||||
, newPassword,
|
|
||||||
confirmPassword
|
|
||||||
}, {
|
}, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
@ -63,7 +113,7 @@ const Register = () => {
|
|||||||
}
|
}
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
} else {
|
} else {
|
||||||
alert('new password and confirm password are not matched')
|
swal('Error!', 'New Password And Confirm Password is Not Match !', 'error')
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,29 +133,51 @@ const Register = () => {
|
|||||||
<CInputGroupText>
|
<CInputGroupText>
|
||||||
<CIcon icon={cilLockLocked} />
|
<CIcon icon={cilLockLocked} />
|
||||||
</CInputGroupText>
|
</CInputGroupText>
|
||||||
<CFormInput placeholder="Old Password" type="password" onChange={(e) => setOldPassword(e.target.value)} />
|
<CFormInput placeholder="Old Password" type="password" value={user.oldPassword}
|
||||||
|
onChange={handleChange}
|
||||||
|
autoComplete="current-password"
|
||||||
|
name="oldPassword" />
|
||||||
</CInputGroup>
|
</CInputGroup>
|
||||||
|
{errors.oldPasswordError && (
|
||||||
|
<p className="text-center py-2 text-danger">{errors.oldPasswordError}</p>
|
||||||
|
)}
|
||||||
|
|
||||||
<CInputGroup className="mb-3">
|
<CInputGroup className="mb-3">
|
||||||
<CInputGroupText>
|
<CInputGroupText>
|
||||||
<CIcon icon={cilLockLocked} />
|
<CIcon icon={cilLockLocked} />
|
||||||
</CInputGroupText>
|
</CInputGroupText>
|
||||||
<CFormInput
|
<CFormInput
|
||||||
type="password"
|
type="password"
|
||||||
placeholder="Password"
|
placeholder=" New Password"
|
||||||
|
|
||||||
|
value={user.newPassword}
|
||||||
|
onChange={handleChange}
|
||||||
|
name="newPassword"
|
||||||
|
|
||||||
onChange={(e) => setNewPassword(e.target.value)}
|
|
||||||
/>
|
/>
|
||||||
</CInputGroup>
|
</CInputGroup>
|
||||||
|
{errors.newPasswordError && (
|
||||||
|
<p className="text-center py-2 text-danger">{errors.newPasswordError}</p>
|
||||||
|
)}
|
||||||
<CInputGroup className="mb-4">
|
<CInputGroup className="mb-4">
|
||||||
<CInputGroupText>
|
<CInputGroupText>
|
||||||
<CIcon icon={cilLockLocked} />
|
<CIcon icon={cilLockLocked} />
|
||||||
</CInputGroupText>
|
</CInputGroupText>
|
||||||
|
{errors.passwordError && (
|
||||||
|
<p className="text-center py-2 text-danger">{errors.passwordError}</p>
|
||||||
|
)}
|
||||||
<CFormInput
|
<CFormInput
|
||||||
type="password"
|
type="password"
|
||||||
placeholder="Confirm password"
|
|
||||||
onChange={(e) => setConfirmPassword(e.target.value)}
|
placeholder="Confirm password "
|
||||||
|
value={user.confirmPassword}
|
||||||
|
onChange={handleChange}
|
||||||
|
name="confirmPassword"
|
||||||
/>
|
/>
|
||||||
</CInputGroup>
|
</CInputGroup>
|
||||||
|
{errors.confirmPasswordError && (
|
||||||
|
<p className="text-center py-2 text-danger">{errors.confirmPasswordError}</p>
|
||||||
|
)}
|
||||||
<div className="d-grid">
|
<div className="d-grid">
|
||||||
<CButton color="success" onClick={handleSubmit}>
|
<CButton color="success" onClick={handleSubmit}>
|
||||||
<ClipLoader loading={loading} size={18} />
|
<ClipLoader loading={loading} size={18} />
|
||||||
|
Loading…
Reference in New Issue
Block a user