-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3a3a4e
commit b5583a0
Showing
6 changed files
with
400 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/Pages/AppStack/AdminStack/Profile/ChangePwdProfile.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { useFormik } from 'formik'; | ||
import React from 'react' | ||
import MyProfileYup from '../../../../Validation/MyProfile/MyProfileYup'; | ||
import Toaster from '../../../../Utils/Toaster/Toaster'; | ||
import MyProfileService from '../../../../Services/MyProfile/MyProfileService'; | ||
|
||
export default function ChangePwdProfile({ userId , loading, userValues, fetchEmployeeDetails, setLoading }) { | ||
const { setValues, values, handleChange, handleSubmit, errors, touched } = useFormik({ | ||
initialValues: { | ||
NewPassword: '', | ||
ConfirmPassword: '', | ||
}, | ||
validationSchema: MyProfileYup.changePassword, | ||
onSubmit: async (values) => { | ||
setLoading(true); | ||
Toaster.loadingToast('Updating Password...'); | ||
try { | ||
const result = await MyProfileService.changePasswordWithoutCheck(userId, values); | ||
if (result.data.Code === 200) { | ||
Toaster.justToast('success', result.data.Message, () => { | ||
// navigate('/app/admin/customers'); | ||
}); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
if (!error.response.data.Status) { | ||
Toaster.justToast('error', error.response.data.Data.error, () => { | ||
|
||
}); | ||
} | ||
// Handle error response | ||
} finally { | ||
setLoading(false); | ||
Toaster.dismissLoadingToast(); | ||
console.log('values:', values); | ||
} | ||
} | ||
}) | ||
return ( | ||
<> | ||
<div className="col-12 mb-5"> | ||
<div className="card p-4"> | ||
<h3 className='h5'>Change Password</h3> | ||
<form className='needs-validation' noValidate onSubmit={handleSubmit}> | ||
<div className="row row-gap-4"> | ||
<div className="col-md-12"> | ||
<input | ||
type="password" | ||
className={`form-control ${errors.NewPassword && touched.NewPassword ? 'is-invalid' : ''}`} | ||
placeholder="Enter New Password" | ||
name="NewPassword" | ||
value={values.NewPassword} | ||
onChange={handleChange} | ||
/> | ||
<div className="invalid-feedback"> | ||
{errors.NewPassword} | ||
</div> | ||
</div> | ||
<div className="col-md-12"> | ||
<input | ||
type="password" | ||
className={`form-control ${errors.ConfirmPassword && touched.ConfirmPassword ? 'is-invalid' : ''}`} | ||
placeholder="Enter Confirm Password" | ||
name="ConfirmPassword" | ||
value={values.ConfirmPassword} | ||
onChange={handleChange} | ||
/> | ||
<div className="invalid-feedback"> | ||
{errors.ConfirmPassword} | ||
</div> | ||
</div> | ||
<div className="col-12 text-end"> | ||
<button disabled={loading} className='btn btn-primary'>Change Password</button> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</> | ||
) | ||
} |
Oops, something went wrong.