Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 01a135c929 |
@@ -45,10 +45,10 @@ export default function Login() {
|
||||
// if (email === "support@mermsemr.com") {
|
||||
if (loginResult.data.status > 0 && loginResult.data.session_token !='') { // just for a start
|
||||
localStorage.setItem("email", `${email}`);
|
||||
localStorage.setItem("member_id", `${JSON.stringify(loginResult.data.member_id)}`);
|
||||
localStorage.setItem("member_uuid", `${JSON.stringify(loginResult.data.member_uuid)}`);
|
||||
localStorage.setItem("session_token", `${loginResult.data.session_token}`);
|
||||
localStorage.setItem("status", `${JSON.stringify(loginResult.data.status)}`);
|
||||
localStorage.setItem("member_id", loginResult.data.member_id);
|
||||
localStorage.setItem("member_uuid", loginResult.data.member_uuid);
|
||||
localStorage.setItem("session_token", loginResult.data.session_token);
|
||||
localStorage.setItem("status", loginResult.data.status);
|
||||
localStorage.setItem("profile", `${JSON.stringify(loginResult.data.profile)}`);
|
||||
setLoginLoading(true);
|
||||
// userApi.getUserReminders(); //testing
|
||||
|
||||
@@ -9,6 +9,7 @@ export default function InputCom({
|
||||
iconName,
|
||||
inputHandler,
|
||||
value,
|
||||
maxLength
|
||||
}) {
|
||||
return (
|
||||
<div className="input-com">
|
||||
@@ -28,6 +29,8 @@ export default function InputCom({
|
||||
className="input-field placeholder:text-base text-bese px-6 text-dark-gray dark:text-white w-full h-full bg-[#FAFAFA] dark:bg-[#11131F] focus:ring-0 focus:outline-none"
|
||||
type={type}
|
||||
id={name}
|
||||
name={name}
|
||||
maxLength={maxLength}
|
||||
/>
|
||||
{iconName && (
|
||||
<div className="absolute right-6 bottom-[19px] z-10">
|
||||
|
||||
@@ -1,10 +1,104 @@
|
||||
import React from 'react'
|
||||
import React, {useState, useEffect} from 'react'
|
||||
import Layout from '../Partials/Layout'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Link, useNavigate } from 'react-router-dom'
|
||||
|
||||
// import { toast } from 'react-toastify';
|
||||
|
||||
import InputCom from "../Helpers/Inputs/InputCom";
|
||||
|
||||
import Calendar from 'react-calendar';
|
||||
import 'react-calendar/dist/Calendar.css';
|
||||
|
||||
import usersService from "../../services/UsersService";
|
||||
|
||||
|
||||
export default function AddEditReminder({ className }) {
|
||||
let navigate = useNavigate()
|
||||
const api = new usersService();
|
||||
|
||||
const [startDate, setStartDate] = useState(new Date());
|
||||
const [endDate, setEndDate] = useState(new Date());
|
||||
|
||||
const [mode, setMode] = useState([]) // for setting mode option display, content is updated when page loads
|
||||
|
||||
const [category, setCategory] = useState([]) // for setting category option display, content is updated when page loads
|
||||
|
||||
const [success, setSuccess] = useState(false)
|
||||
const [message, setMessage]=useState({
|
||||
status: false,
|
||||
message: ''
|
||||
})
|
||||
|
||||
|
||||
const [reminder, setReminder]=useState({
|
||||
'member_id': localStorage.getItem('member_id'),
|
||||
description: '',
|
||||
note: '',
|
||||
category: '',
|
||||
mode: '',
|
||||
'start_date': startDate,
|
||||
'end_date': endDate
|
||||
})
|
||||
|
||||
const onReminderInputChange = ({target:{name,value}}) => { //function to run when user changes any input on the add reminder page
|
||||
setReminder(prev=>(
|
||||
{...prev, [name]:value}
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
const getUserMode = async () => {
|
||||
try {
|
||||
const res = await api.getUserModeCategory('remmode');
|
||||
setMode(res.data);
|
||||
} catch (error) {
|
||||
console.log("Error getting mode");
|
||||
}
|
||||
};
|
||||
|
||||
const getUserCategory = async () => {
|
||||
try {
|
||||
const res = await api.getUserModeCategory('remcategory');
|
||||
setCategory(res.data);
|
||||
} catch (error) {
|
||||
console.log("Error getting user category");
|
||||
}
|
||||
};
|
||||
|
||||
const handleAddReminder = async () => { // function to add reminder, after all test cases are met
|
||||
// toast('Reminder Added')
|
||||
setSuccess(true)
|
||||
setMessage({status: true, message: ''})
|
||||
let {description, note, category, mode} = reminder
|
||||
//CHECKING IF AN EMPTY FIELD WAS PASSED
|
||||
if(!description || !note || !category || !mode){
|
||||
setSuccess(false)
|
||||
setMessage({status: false, message: 'All fields must be filled'})
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await api.addReminder(reminder);
|
||||
if(res && res.status == 200){
|
||||
setSuccess(false)
|
||||
setMessage({status: true, message: 'Reminder added successfully'})
|
||||
setTimeout(()=>{
|
||||
navigate('/reminders', {replace: true})
|
||||
}, 2000)
|
||||
return
|
||||
}
|
||||
setSuccess(false)
|
||||
setMessage({status: false, message: 'Opps cannot add reminder, try again'})
|
||||
} catch (error) {
|
||||
setSuccess(false)
|
||||
setMessage({status: false, message: 'An error occurred'})
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getUserMode();
|
||||
getUserCategory()
|
||||
}, []);
|
||||
return (
|
||||
<>
|
||||
<Layout>
|
||||
@@ -16,7 +110,6 @@ export default function AddEditReminder({ className }) {
|
||||
className || ""
|
||||
}`}
|
||||
>
|
||||
|
||||
<div className="fields w-full">
|
||||
{/*description */}
|
||||
<div className="field w-full mb-6">
|
||||
@@ -25,50 +118,80 @@ export default function AddEditReminder({ className }) {
|
||||
type="text"
|
||||
name="description"
|
||||
placeholder="Describe the Reminder"
|
||||
value={''}
|
||||
value={reminder.description}
|
||||
inputHandler={onReminderInputChange}
|
||||
maxLength={10}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* first name and last name */}
|
||||
<div className="xl:flex xl:space-x-7 mb-6">
|
||||
<div className="field w-full mb-6 xl:mb-0">
|
||||
<InputCom
|
||||
{/* <InputCom
|
||||
label="Reminder Type"
|
||||
type="text"
|
||||
name="remType"
|
||||
placeholder="Drop down of Category"
|
||||
value={''}
|
||||
/>
|
||||
/> */}
|
||||
<label className="input-label text-dark-gray dark:text-white text-xl font-bold block mb-2.5">Reminder Type</label>
|
||||
<select name='category' className='bg-white dark:bg-dark-white text-gray-700 w-full py-5 cursor-pointer focus:outline-none focus:border-none' onChange={onReminderInputChange}>
|
||||
<option className='' value="">Select category</option>
|
||||
{category.length > 0 &&
|
||||
<>
|
||||
{category.map((option, index)=>(
|
||||
<option key={index} className='' value={option.category}>{option.category}</option>
|
||||
))
|
||||
}
|
||||
</>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div className="field w-full">
|
||||
<InputCom
|
||||
{/* <InputCom
|
||||
label="Mode"
|
||||
type="text"
|
||||
name="remMode"
|
||||
placeholder="Drop down of Modes"
|
||||
value={''}
|
||||
/>
|
||||
/> */}
|
||||
<label className="input-label text-dark-gray dark:text-white text-xl font-bold block mb-2.5">Mode</label>
|
||||
<select name='mode' className='bg-white dark:bg-dark-white text-gray-700 w-full py-5 cursor-pointer focus:outline-none focus:border-none' onChange={onReminderInputChange}>
|
||||
<option className='' value="">Select mode</option>
|
||||
{category.length > 0 &&
|
||||
<>
|
||||
{mode.map((option, index)=>(
|
||||
<option key={index} className='' value={option.mode}>{option.mode}</option>
|
||||
))
|
||||
}
|
||||
</>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="xl:flex xl:space-x-7 mb-6">
|
||||
<div className="field w-full mb-6 xl:mb-0">
|
||||
<InputCom
|
||||
{/* <InputCom
|
||||
label="Start Date"
|
||||
type="text"
|
||||
name="startDate"
|
||||
placeholder="10-10-2021"
|
||||
value={''}
|
||||
/>
|
||||
/> */}
|
||||
<label className="input-label text-dark-gray dark:text-white text-xl font-bold block mb-2.5">Start Date</label>
|
||||
<Calendar onChange={setStartDate} value={startDate} calendarType="US" />
|
||||
</div>
|
||||
<div className="field w-full">
|
||||
<InputCom
|
||||
{/* <InputCom
|
||||
label="End Date"
|
||||
type="text"
|
||||
name="endDate"
|
||||
placeholder="10-20-2034"
|
||||
value={''}
|
||||
/>
|
||||
/> */}
|
||||
<label className="input-label text-dark-gray dark:text-white text-xl font-bold block mb-2.5">End Date</label>
|
||||
<Calendar onChange={setEndDate} value={endDate} calendarType="US" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -78,16 +201,18 @@ export default function AddEditReminder({ className }) {
|
||||
<div className="input-field mt-2">
|
||||
<div className="input-wrapper w-full ">
|
||||
<textarea
|
||||
value={''}
|
||||
name='note'
|
||||
value={reminder.note}
|
||||
placeholder="provide a detailed description of your item."
|
||||
rows="7"
|
||||
className="w-full h-full px-7 py-4 border border-light-purple dark:border-[#5356fb29] rounded-[20px] text-dark-gray dark:text-white bg-[#FAFAFA] dark:bg-[#11131F] focus:ring-0 focus:outline-none"
|
||||
onChange={onReminderInputChange}
|
||||
maxLength={250}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p className={`text-center ${message.status ? 'text-[rgb(0,128,0)]':'text-[rgb(255,0,0)]'}`}>{message.message}</p>
|
||||
</div>
|
||||
{/* border line */}
|
||||
<div className="w-full h-[120px] border-t border-light-purple dark:border-[#5356fb29] flex justify-end items-center">
|
||||
@@ -101,13 +226,24 @@ export default function AddEditReminder({ className }) {
|
||||
Cancel
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="w-[152px] h-[46px] flex justify-center items-center btn-gradient text-base rounded-full text-white"
|
||||
>
|
||||
Upadate
|
||||
</button>
|
||||
{
|
||||
success ?
|
||||
<div role="status">
|
||||
<svg aria-hidden="true" className="w-8 h-8 mr-2 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
|
||||
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
|
||||
</svg>
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
:
|
||||
<button
|
||||
type="button"
|
||||
className="w-[152px] h-[46px] flex justify-center items-center btn-gradient text-base rounded-full text-white"
|
||||
onClick={handleAddReminder}
|
||||
>
|
||||
Upadate
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -10,6 +10,11 @@ class usersService {
|
||||
return this.postAuxEnd("/login", reqData);
|
||||
}
|
||||
|
||||
//END POINT TO ADD REMINDER
|
||||
addReminder(reqData){
|
||||
return this.postAuxEnd("/editreminder", reqData);
|
||||
}
|
||||
|
||||
getUserReminders(){
|
||||
var reqData = {
|
||||
member_id: localStorage.getItem("member_id")
|
||||
@@ -17,6 +22,7 @@ class usersService {
|
||||
return this.getAuxEnd("/reminders", reqData);
|
||||
}
|
||||
|
||||
|
||||
getUserLoginHistory(){
|
||||
var reqData = {
|
||||
member_id: localStorage.getItem("member_id")
|
||||
@@ -24,6 +30,14 @@ class usersService {
|
||||
return this.getAuxEnd("/loginhx", reqData);
|
||||
}
|
||||
|
||||
//END POINT TO POPULATE MODE AND CATEGORY ON ADD REMINDER PAGED
|
||||
getUserModeCategory(path){
|
||||
var reqData = {
|
||||
member_id: localStorage.getItem("member_id")
|
||||
};
|
||||
return this.getAuxEnd(`/${path}`, reqData);
|
||||
}
|
||||
|
||||
//---------------------------------------- -----
|
||||
//---------------------------------------- -----
|
||||
// Unified call below
|
||||
|
||||
Reference in New Issue
Block a user