Compare commits

...

13 Commits

7 changed files with 283 additions and 110 deletions
+4 -1
View File
@@ -14,4 +14,7 @@ REACT_APP_USERS_ENDPOINT="https://devapi.mermsemr.com/en/desktop/api/v2/myfituse
REACT_APP_SESSION_EXPIRE_MINUTES=15
REACT_APP_TRACKING="Tracking"
REACT_APP_RESOURCES="Resources"
REACT_APP_RESOURCES="Resources"
REACT_APP_HISTORY="History"
REACT_APP_TRACKING_SHOW=1
+20
View File
@@ -0,0 +1,20 @@
SKIP_PREFLIGHT_CHECK=true
REACT_APP_FACEBOOK="https://www.facebook.com/profile.php?id=100066498622246"
REACT_APP_TWITTER="https://twitter.com/fluxtra"
REACT_APP_APPSITE=" https://myfitapp.mermsemr.com"
#REACT_APP_APPSITE="http://localhost:7012"
REACT_APP_AUX_ENDPOINT="https://devapi.mermsemr.com/en/desktop/api/v2/myfit"
REACT_APP_USERS_ENDPOINT="https://devapi.mermsemr.com/en/desktop/api/v2/myfituser"
# REACT_APP_PASSWORD_ENDPOINT="https://devapi.mermsemr.com/en/desktop/api/v2/myfituser/resetpass"
REACT_APP_SESSION_EXPIRE_MINUTES=15
REACT_APP_TRACKING="Tracking"
REACT_APP_RESOURCES="Resources"
REACT_APP_HISTORY="History"
REACT_APP_TRACKING_SHOW=1
+20
View File
@@ -0,0 +1,20 @@
SKIP_PREFLIGHT_CHECK=true
REACT_APP_FACEBOOK="https://www.facebook.com/profile.php?id=100066498622246"
REACT_APP_TWITTER="https://twitter.com/fluxtra"
REACT_APP_APPSITE=" https://myfitapp.mermsemr.com"
#REACT_APP_APPSITE="http://localhost:7012"
REACT_APP_AUX_ENDPOINT="https://devapi.mermsemr.com/en/desktop/api/v2/myfit"
REACT_APP_USERS_ENDPOINT="https://devapi.mermsemr.com/en/desktop/api/v2/myfituser"
# REACT_APP_PASSWORD_ENDPOINT="https://devapi.mermsemr.com/en/desktop/api/v2/myfituser/resetpass"
REACT_APP_SESSION_EXPIRE_MINUTES=15
REACT_APP_TRACKING="Tracking"
REACT_APP_RESOURCES="Resources"
REACT_APP_HISTORY="History"
REACT_APP_TRACKING_SHOW=0
+118 -107
View File
@@ -82,127 +82,138 @@ export default function ReminderTable({ className }) {
<div className="relative w-full overflow-x-auto sm:rounded-lg">
<table className="w-full text-sm text-left text-gray-500 dark:text-gray-400">
<tbody>
<tr className="text-base text-thin-light-gray whitespace-nowrap border-b dark:border-[#5356fb29] default-border-bottom ">
<td className="py-4">Item</td>
<td className="py-4 text-center">Start</td>
<td className="py-4 text-center">End</td>
<td className="py-4 text-center">Reminder</td>
<td className="py-4 text-right">.</td>
</tr>
<>
<tr className="text-base text-thin-light-gray whitespace-nowrap border-b dark:border-[#5356fb29] default-border-bottom">
<td className="py-4">Item</td>
<td className="py-4 text-center">Start</td>
<td className="py-4 text-center">End</td>
<td className="py-4 text-center">Reminder</td>
<td className="py-4 text-right">.</td>
</tr>
<tr class="spacer"></tr>
</>
{
userReminders[0].reminders.length > 0 && (
selectedCategory == "All category" ? (
userReminders[0].reminders.map((reminder, index) => (
<tr key={index} className="bg-white dark:bg-dark-white border-b dark:border-[#5356fb29] hover:bg-gray-50">
<td className=" py-4">
<div className="flex space-x-2 items-center">
<div className="w-[60px] h-[60px] rounded-full overflow-hidden flex justify-center items-center">
<img
src={(reminder.category == null || reminder.category == '')? dataImage1: localImgLoad(`images/${reminder.category}.png`)}
alt="data"
className="w-full h-full"
/>
</div>
<div className="flex flex-col">
<h1 className="font-bold text-xl text-dark-gray dark:text-white whitespace-nowrap">
{reminder.description.substring(0, 30)+ ' ...'}
</h1>
<span className="text-sm text-thin-light-gray">
Added <span className="text-purple">
{/* {new Date(reminder.added).toLocaleString().replace(/-/g, '/')} */}
{reminder.added.split(' ')[0]}
<>
{/* <tr key={index} className="bg-white dark:bg-dark-white border border-light-purple dark:border-[#5356fb29] hover:bg-gray-50"> */}
<tr key={index} className="even:bg-slate-100 odd:bg-gray-50 dark:bg-dark-white dark:odd:bg-black hover:bg-light-purple transition-all duration-500">
<td className="py-4 px-2 rounded-l-full">
<div className="flex space-x-2 items-center">
<div className="w-[60px] h-[60px] rounded-full overflow-hidden flex justify-center items-center">
<img
src={(reminder.category == null || reminder.category == '')? dataImage1: localImgLoad(`images/${reminder.category}.png`)}
alt="data"
className="w-full h-full"
/>
</div>
<div className="flex flex-col">
<h1 className="font-bold text-xl text-dark-gray dark:text-white whitespace-nowrap">
{reminder.description.substring(0, 30)+ ' ...'}
</h1>
<span className="text-sm text-thin-light-gray dark:text-white">
Added <span className="text-purple dark:text-white">
{/* {new Date(reminder.added).toLocaleString().replace(/-/g, '/')} */}
{reminder.added.split(' ')[0]}
</span>
</span>
</div>
</div>
</td>
<td className="text-center py-4 px-2">
<div className="flex space-x-1 items-center justify-center">
<span className="text-base text-dark-gray dark:text-white font-medium whitespace-nowrap">
{/* {new Date(reminder.start_date).toLocaleString().replace(/-/g, '/')} */}
{reminder.start_date.split(' ')[0]}
</span>
</div>
</td>
<td className="text-center py-4 px-2">
<div className="flex space-x-1 items-center justify-center">
<span className="text-base text-dark-gray dark:text-white font-medium whitespace-nowrap">
{/* {new Date(reminder.end_date).toLocaleString().replace(/-/g, '/')} */}
{reminder.end_date.split(' ')[0]}
</span>
</div>
</td>
<td className="text-right py-4 px-2">
<span className="text-base text-thin-light-gray whitespace-nowrap">
{reminder.reminder}
</span>
</span>
</div>
</div>
</td>
<td className="text-center py-4 px-2">
<div className="flex space-x-1 items-center justify-center">
<span className="text-base text-dark-gray dark:text-white font-medium whitespace-nowrap">
{/* {new Date(reminder.start_date).toLocaleString().replace(/-/g, '/')} */}
{reminder.start_date.split(' ')[0]}
</span>
</div>
</td>
<td className="text-center py-4 px-2">
<div className="flex space-x-1 items-center justify-center">
<span className="text-base text-dark-gray dark:text-white font-medium whitespace-nowrap">
{/* {new Date(reminder.end_date).toLocaleString().replace(/-/g, '/')} */}
{reminder.end_date.split(' ')[0]}
</span>
</div>
</td>
<td className="text-right py-4 px-2">
<span className="text-base text-thin-light-gray whitespace-nowrap">
{reminder.reminder}
</span>
</td>
<td className="text-right py-4 px-2">
<Link to={`/add-reminder/${reminder.uuid}`} state={{reminder}} className="text-sm text-white btn-gradient px-2.5 py-1.5 rounded-full">Edit</Link>
</td>
</tr>
</td>
<td className="text-right py-4 px-2 rounded-r-full">
<Link to={`/add-reminder/${reminder.uuid}`} state={{reminder}} className="text-sm text-white btn-gradient px-2.5 py-1.5 rounded-full">Edit</Link>
</td>
</tr>
{/* <tr class="spacer"></tr> */}
</>
))
)
:
userReminders[0].reminders.map((reminder, index) => {
if(reminder.category == selectedCategory){
return (
<tr key={index} className="bg-white dark:bg-dark-white border-b dark:border-[#5356fb29] hover:bg-gray-50">
<td className=" py-4">
<div className="flex space-x-2 items-center">
<div className="w-[60px] h-[60px] rounded-full overflow-hidden flex justify-center items-center">
<img
src={(reminder.category == null || reminder.category == '')? dataImage1: localImgLoad(`images/${reminder.category}.png`)}
alt="data"
className="w-full h-full"
/>
</div>
<div className="flex flex-col">
<h1 className="font-bold text-xl text-dark-gray dark:text-white whitespace-nowrap">
{reminder.description.substring(0, 30)+ ' ...'}
</h1>
<span className="text-sm text-thin-light-gray">
Added <span className="text-purple">
{new Date(reminder.added).toLocaleString().replace(/-/g, '/')}
<>
{/* <tr key={index} className="bg-white dark:bg-dark-white border border-light-purple dark:border-[#5356fb29] hover:bg-gray-50"> */}
<tr key={index} className="even:bg-slate-100 odd:bg-gray-50 dark:bg-dark-white dark:odd:bg-black hover:bg-light-purple transition-all duration-500">
<td className="py-4 px-2 rounded-l-full">
<div className="flex space-x-2 items-center">
<div className="w-[60px] h-[60px] rounded-full overflow-hidden flex justify-center items-center">
<img
src={(reminder.category == null || reminder.category == '')? dataImage1: localImgLoad(`images/${reminder.category}.png`)}
alt="data"
className="w-full h-full"
/>
</div>
<div className="flex flex-col">
<h1 className="font-bold text-xl text-dark-gray dark:text-white whitespace-nowrap">
{reminder.description.substring(0, 30)+ ' ...'}
</h1>
<span className="text-sm text-thin-light-gray dark:text-white">
Added <span className="text-purple dark:text-white">
{new Date(reminder.added).toLocaleString().replace(/-/g, '/')}
</span>
</span>
</div>
</div>
</td>
<td className="text-center py-4 px-2">
<div className="flex space-x-1 items-center justify-center">
<span className="text-base text-dark-gray dark:text-white font-medium whitespace-nowrap">
{new Date(reminder.start_date).toLocaleString().replace(/-/g, '/')}
</span>
</div>
</td>
<td className="text-center py-4 px-2">
<div className="flex space-x-1 items-center justify-center">
<span className="text-base text-dark-gray dark:text-white font-medium whitespace-nowrap">
{new Date(reminder.end_date).toLocaleString().replace(/-/g, '/')}
</span>
</div>
</td>
<td className="text-right py-4 px-2">
<span className="text-base text-thin-light-gray whitespace-nowrap">
{reminder.reminder}
</span>
</span>
</div>
</div>
</td>
<td className="text-center py-4 px-2">
<div className="flex space-x-1 items-center justify-center">
<span className="text-base text-dark-gray dark:text-white font-medium whitespace-nowrap">
{new Date(reminder.start_date).toLocaleString().replace(/-/g, '/')}
</span>
</div>
</td>
<td className="text-center py-4 px-2">
<div className="flex space-x-1 items-center justify-center">
<span className="text-base text-dark-gray dark:text-white font-medium whitespace-nowrap">
{new Date(reminder.end_date).toLocaleString().replace(/-/g, '/')}
</span>
</div>
</td>
<td className="text-right py-4 px-2">
<span className="text-base text-thin-light-gray whitespace-nowrap">
{reminder.reminder}
</span>
</td>
<td className="text-right py-4 px-2">
{/* <button
type="button"
className="text-sm text-white bg-purple px-2.5 py-1.5 rounded-full"
>
Edit
</button> */}
<Link to={`/add-reminder/${reminder.uuid}`} state={{reminder}} className="text-sm text-white btn-gradient px-2.5 py-1.5 rounded-full">Edit</Link>
</td>
</td>
<td className="text-right py-4 px-2 rounded-r-full">
{/* <button
type="button"
className="text-sm text-white bg-purple px-2.5 py-1.5 rounded-full"
>
Edit
</button> */}
<Link to={`/add-reminder/${reminder.uuid}`} state={{reminder}} className="text-sm text-white btn-gradient px-2.5 py-1.5 rounded-full">Edit</Link>
</td>
</tr>
{/* <tr class="spacer"></tr> */}
</>
)
}
})
@@ -3,6 +3,8 @@
import React, { useState } from "react";
import Icons from "../../Helpers/Icons";
import PasswordSvg from "../PasswordSvg";
import { toast } from "react-toastify";
import usersService from "../../../services/UsersService";
export default function ChangePasswordTab() {
const [oldPass, setOldPass] = useState("hide-password");
@@ -38,6 +40,95 @@ export default function ChangePasswordTab() {
}
}
};
// Reset Password
const reset_profilePass = new usersService()
const [loading, setLoading] = useState(false)
const [validation, setValidation] = useState("")
// state for password values
const [passwordDetails, setPasswordDetails] = useState({
prev_pass: '',
new_pass: '',
confirm_pass: ''
})
// tracks password changes
const handlePasswordChange = ({target:{name, value}}) => {
setPasswordDetails(prev => ({...prev, [name]:value}))
}
const handleResetPassword = async(e) => {
setValidation("")
setLoading(true)
let resetPassword = {...passwordDetails}
let {prev_pass, new_pass, confirm_pass} = resetPassword
// Check empty fields
if(!prev_pass || !new_pass || !confirm_pass) {
setLoading(false)
setValidation("Please fill the empty fields")
return
}
// Checking to see the password has
if(!/^[A-Za-z]\w{6,14}$/.test(new_pass)) {
setLoading(false)
setValidation("it must be a more 7 alphanumeric characters")
return
}
// matching new passwords with confirm_password
if(new_pass != confirm_pass){
setLoading(false)
setValidation("new password does not match")
return
}
// matching new passwords with old passwords
if(prev_pass === new_pass){
setLoading(false)
setValidation("you can't use old passwords")
return
}
// assigning new values to resetPassword
resetPassword.member_id = localStorage.getItem("member_id")
resetPassword.session_token = localStorage.getItem("session_token")
resetPassword.member_uuid = localStorage.getItem("member_uuid")
// removed confirm password from the payload
delete resetPassword.confirm_pass
try {
const res = await reset_profilePass.resetProfilePassword(resetPassword)
console.log(res)
if(res.status != 200){
setLoading(false)
setValidation("An error occurred")
return
}
if(res.status == 200){
// if status is okay but can't success not granted
if(res.data.status < 0 ) {
setLoading(false)
setValidation("sorry, error updating password")
} else {
setLoading(false)
// setValidation("password updated successfully")
toast.success("password updated successfully")
// setPasswordDetails(prev => ({...prev, e.target.name: ''}))
}
}
} catch (error) {
setLoading(false)
setValidation("something went wrong, try again later")
}
}
return (
<div className="changePasswordTab w-full">
<div className="w-full flex xl:flex-row flex-col-reverse space-x-5 xl:items-center">
@@ -58,6 +149,9 @@ export default function ChangePasswordTab() {
className="input-field placeholder:text-base text-bese px-12 text-dark-gray dark:text-white w-full h-full bg-[#FAFAFA] dark:bg-[#11131F] focus:ring-0 focus:outline-none"
type="password"
id="old_password"
name='prev_pass'
value={passwordDetails.prev_pass}
onChange={handlePasswordChange}
/>
<div
className="absolute right-6 bottom-[17px] z-10 cursor-pointer"
@@ -83,6 +177,9 @@ export default function ChangePasswordTab() {
className="input-field placeholder:text-base text-bese px-12 text-dark-gray dark:text-white w-full h-full bg-[#FAFAFA] dark:bg-[#11131F] focus:ring-0 focus:outline-none"
type="password"
id="new_password"
name="new_pass"
value={passwordDetails.new_pass}
onChange={handlePasswordChange}
/>
<div
className="absolute right-6 bottom-[17px] z-10 cursor-pointer"
@@ -108,6 +205,9 @@ export default function ChangePasswordTab() {
className="input-field placeholder:text-base text-bese px-12 text-dark-gray dark:text-white w-full h-full bg-[#FAFAFA] dark:bg-[#11131F] focus:ring-0 focus:outline-none"
type="password"
id="confirm_password"
name="confirm_pass"
value={passwordDetails.confirm_pass}
onChange={handlePasswordChange}
/>
<div
className="absolute right-6 bottom-[17px] z-10 cursor-pointer"
@@ -117,6 +217,7 @@ export default function ChangePasswordTab() {
</div>
</div>
</div>
{validation && <p className={`my-5 text-center font-light italic text-sm subpixel-antialiased tracking-wide ${validation == 'Password updated' ? 'text-green-600' : 'text-red-500'} `}>{validation}</p>}
<div className="flex justify-center space-x-4 items-center">
<button
type="button"
@@ -127,9 +228,10 @@ export default function ChangePasswordTab() {
<button
type="button"
className="btn-gradient tracking-wide rounded-full w-[173px] h-[46px] flex justify-center items-center"
onClick={handleResetPassword}
>
<span className="font-thin text-18 tracking-wide antialiased text-white">
Change Password
{loading ? <div className="signup btn-loader"></div> : <span>Change Password</span>}
</span>
</button>
</div>
+7 -1
View File
@@ -365,9 +365,15 @@ input[type="number"] {
.trending-products .slick-list {
margin: 0 -16px;
}
.update-table table tr:last-child {
/* .update-table table tr:last-child {
border-bottom: none;
} */
.update-table table tr.spacer {
height: 10px;
}
/* TODO: =================================HomePage end================================ */
/* TODO: =================================my wallet end================================ */
.circle-count {
+11
View File
@@ -10,6 +10,10 @@ class usersService {
return this.postAuxEnd('/resetpass', reqData);
}
resetProfilePassword(reqData){
return this.postAuxEnd('/resetpass-profile', reqData);
}
logInUser(reqData) {
localStorage.setItem("session_token", ``);
return this.postAuxEnd("/login", reqData);
@@ -32,6 +36,13 @@ class usersService {
return this.getAuxEnd("/reminders", reqData);
}
getUserHomeStats(){
var reqData = {
member_id: localStorage.getItem("member_id")
};
return this.getAuxEnd("/home-stats", reqData);
}
getUserLoginHistory(){
var reqData = {
member_id: localStorage.getItem("member_id")