diff --git a/src/components/Calendar/CalendarTable.jsx b/src/components/Calendar/CalendarTable.jsx
index d2c4552..6e77c7a 100755
--- a/src/components/Calendar/CalendarTable.jsx
+++ b/src/components/Calendar/CalendarTable.jsx
@@ -1,16 +1,45 @@
-import React, { useState } from "react";
+import React, { useState, useEffect } from "react";
import dataImage1 from "../../assets/images/data-table-user-1.png";
import dataImage2 from "../../assets/images/data-table-user-2.png";
import dataImage3 from "../../assets/images/data-table-user-3.png";
import dataImage4 from "../../assets/images/data-table-user-4.png";
import SelectBox from "../Helpers/SelectBox";
+
+import usersService from "../../services/UsersService"; // API SERVICE
+import localImgLoad from "../../lib/localImgLoad"; // img loader
+
+
import Calendar from 'react-calendar';
import 'react-calendar/dist/Calendar.css';
export default function CalendarTable({ className }) {
+ const [isLoading, setIsLoading] = useState(true) // for determining when a page is awating request call
+
const filterCategories = ["All Categories", "Explore", "Featured"];
const [selectedCategory, setCategory] = useState(filterCategories[0]);
- const [value, onChange] = useState(new Date());
+
+ const [value, onChange] = useState(new Date()); // value of calendar date and onchange handler for calendar
+ const [remDate, setRemDate] = useState([]) // for holding dates on reminders to display on calendar
+
+ const reminderApi = new usersService(); // instantiating the API SERVICE
+
+ const getUserReminders = async () => {
+ try {
+ const res = await reminderApi.getUserReminders();
+ if(res.status == 200 && res.data.status > 0){
+ setRemDate(res.data.reminders)
+ setIsLoading(false)
+ return
+ }
+ setIsLoading(false)
+ }catch(error) {
+ setIsLoading(false)
+ }
+ };
+
+ useEffect(() => {
+ getUserReminders();
+ }, []);
return (
-
+
+ {
+ isLoading ?
+
+ :
+
{
+ const reminder = []
+ remDate.map((x) => {
+ // console.log(new Date(date).toDateString() == new Date(x.start_date).toDateString())
+ if(date.toDateString() == new Date(x.start_date.split(' ')[0]).toDateString()){
+ if(reminder.length < 1) {
+ reminder.push([x])
+ }else{
+ for(let i=0; i {
+ if(rem){
+ return
+ }
+ }) : "";
+ }}
+
+ />
+ }
+
);
+}
+
+const ReminderThumbnail = ({reminders}) => {
+ return (
+
+ {reminders.map((reminder, index) => (
+
+
+

+
+
+
+ {reminder.description?.substring(0, 20)+ ' ...'}
+
+
+
+ Added
+ {reminder.start_date.split(' ')[0]}
+
+
+
+
+ ))}
+
+
+ )
}
\ No newline at end of file
diff --git a/src/components/Reminders/ReminderTable.jsx b/src/components/Reminders/ReminderTable.jsx
index aa2aaaf..c7093de 100755
--- a/src/components/Reminders/ReminderTable.jsx
+++ b/src/components/Reminders/ReminderTable.jsx
@@ -90,7 +90,7 @@ export default function ReminderTable({ className }) {
Reminder |
. |
-
+
>
{
@@ -99,7 +99,7 @@ export default function ReminderTable({ className }) {
userReminders[0].reminders.map((reminder, index) => (
<>
{/* */}
-
+
@@ -149,7 +149,7 @@ export default function ReminderTable({ className }) {
Edit
|
- {/*
*/}
+
>
))
)
@@ -159,7 +159,7 @@ export default function ReminderTable({ className }) {
return (
<>
{/* */}
-
+
@@ -212,7 +212,7 @@ export default function ReminderTable({ className }) {
Edit
|
- {/*
*/}
+
>
)
}
diff --git a/src/components/Settings/Tabs/ChangePasswordTab.jsx b/src/components/Settings/Tabs/ChangePasswordTab.jsx
index a078646..16ef472 100755
--- a/src/components/Settings/Tabs/ChangePasswordTab.jsx
+++ b/src/components/Settings/Tabs/ChangePasswordTab.jsx
@@ -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 (
@@ -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}
/>
+ {validation &&
{validation}
}
diff --git a/src/services/UsersService.js b/src/services/UsersService.js
index f3c0acf..5ce3c2d 100644
--- a/src/services/UsersService.js
+++ b/src/services/UsersService.js
@@ -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);